Changeset 0fce7d3 in tol


Ignore:
Timestamp:
Nov 17, 2016, 12:54:18 PM (10 years ago)
Author:
Pedro Gea <pgea@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
f861956
Parents:
88e6fd7
Message:

Refs #1933
Se revisa tolprj.
Se prescinden de algunos métodos auxiliares creados en tolprj para usar wtree/treectrl.

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7347 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tolbase/lib/toltk/tolprj.tcl

    r88e6fd7 r0fce7d3  
    4242
    4343#/////////////////////////////////////////////////////////////////////////////
    44 proc ::TolProject::NodeDef { } {
    45 #/////////////////////////////////////////////////////////////////////////////
    46   return [list \
    47     [list {image text} -label FileName] \
    48     [list text -label Description] \
    49     [list text -label Type] \
    50     [list text -label Exclude] \
    51     [list text -label ExcludeTOL]
    52   ]
    53 }
    54 
    55 #/////////////////////////////////////////////////////////////////////////////
    56 proc ::TolProject::Node {icon filename desc type exclude excludetol} {
    57 #/////////////////////////////////////////////////////////////////////////////
    58   return [list \
    59     [list $icon $filename] \
    60     [list $desc] \
    61     [list $type] \
    62     [list $exclude] \
    63     [list $excludetol] \
    64   ]
    65 }
    66 
    67 proc ::TolProject::NiFileName    { } { return 0 }
    68 proc ::TolProject::NiDescription { } { return 1 }
    69 proc ::TolProject::NiType        { } { return 2 }
    70 proc ::TolProject::NiExclude     { } { return 3 }
    71 proc ::TolProject::NiExcludeTOL  { } { return 4 }
    72 
    73 #/////////////////////////////////////////////////////////////////////////////
    7444proc ::TolProject::ComputeFullPath {this path} {
    7545#
    … …  
    322292  set tv [GetTreeview $this]
    323293  #@ Antes se usaba $data(nameFile) como FileName y $data(labelWindow) como label   
    324   $tv item text root [NiFileName] [file tail $data(labelWindow)]
     294  $tv item text root FileName [file tail $data(labelWindow)]
    325295}
    326296
    … …  
    436406  # treeview y scroll
    437407  ScrolledWindow $f.sw
    438   set data(treeview) [::wtree $f.sw.t -table 0 -filter no \
     408  set tv [::wtree $f.sw.t -table 0 -filter no \
    439409    -background white -showroot 1 -selectmode single -showheader 0 \
    440410    -highlightbackground gray75 -highlightcolor black \
    441411    -highlightthickness 0 -font $toltk_options(fonts,Label) \
    442     -columns [::TolProject::NodeDef] ]
    443   $data(treeview) item style set root [NiFileName] [$data(treeview) column cget [NiFileName] -itemstyle]
    444   $data(treeview) item style set root [NiDescription] [$data(treeview) column cget [NiDescription] -itemstyle]
    445   $data(treeview) item style set root [NiType] [$data(treeview) column cget [NiType] -itemstyle]
    446   $data(treeview) item style set root [NiExclude] [$data(treeview) column cget [NiExclude] -itemstyle]
    447   $data(treeview) item style set root [NiExcludeTOL] [$data(treeview) column cget [NiExcludeTOL] -itemstyle]
    448   $data(treeview) column configure "range 1 end" -visible no
    449   $data(treeview) column configure first -expand yes -weight 1
    450   $data(treeview) column configure all -itembackground ""       
    451   $data(treeview) notify bind $data(treeview) <Selection> "::TolProject::SelectProc $this"       
     412    -columns [list \
     413      [list {image text} -label FileName -tags FileName] \
     414      [list text -label Description -tags Description] \
     415      [list text -label Type -tags Type] \
     416      [list text -label Exclude -tags Exclude] \
     417      [list text -label ExcludeTOL -tags ExcludeTOL] \
     418    ] ]
     419  set data(treeview) $tv
     420  $tv item style set root FileName    [$tv column cget FileName -itemstyle]
     421  $tv item style set root Description [$tv column cget Description -itemstyle]
     422  $tv item style set root Type        [$tv column cget Type -itemstyle]
     423  $tv item style set root Exclude     [$tv column cget Exclude -itemstyle]
     424  $tv item style set root ExcludeTOL  [$tv column cget ExcludeTOL -itemstyle]
     425  $tv column configure "range 1 end" -visible no
     426  $tv column configure first -expand yes -weight 1
     427  $tv column configure all -itembackground ""       
     428  $tv notify bind $tv <Selection> "::TolProject::SelectProc $this"       
    452429 
    453430  $f.sw setwidget $f.sw.t
    … …  
    465442
    466443
    467   bind $data(treeview).frameTree.t <Control-KeyRelease> [list ::TolProject::OnControlKey $this %K %k]
    468 
    469   bind $data(treeview).frameTree.t <Button-1> "::focus $data(treeview)" 
     444  bind $tv.frameTree.t <Control-KeyRelease> [list ::TolProject::OnControlKey $this %K %k]
     445
     446  bind $tv.frameTree.t <Button-1> "::focus $tv" 
    470447 
    471   bind $data(treeview).frameTree.t <Button-3> +[list ::TolProject::PostVariable $this %X %Y]
    472  
    473   set prevBind [bind $data(treeview).frameTree.t <Double-1>]
     448  bind $tv.frameTree.t <Button-3> +[list ::TolProject::PostVariable $this %X %Y]
     449 
     450  set prevBind [bind $tv.frameTree.t <Double-1>]
    474451  set newBind "[lrange $prevBind 0 [expr [llength $prevBind]-3]] ; mdidoc disableglobalraise ; ::TolProject::OpenNodeIfTerminal $this ; break"
    475452  #@ mdidoc disableglobalraise y break parece que cumplen el mismo cometido
    476   bind $data(treeview).frameTree.t <Double-1> $newBind
    477  
    478   set prevBind [bind $data(treeview).frameTree.t <KeyPress-Return>]
     453  bind $tv.frameTree.t <Double-1> $newBind
     454 
     455  set prevBind [bind $tv.frameTree.t <KeyPress-Return>]
    479456  set newBind "[lrange $prevBind 0 [expr [llength $prevBind]-3]] ; ::TolProject::OpenNodeIfTerminal $this ; break"
    480   bind $data(treeview).frameTree.t <KeyPress-Return> $newBind   
    481 
    482   bind $data(treeview).frameTree.t <KeyPress-space>  +[list ::TolProject::NodeActiveAttributes $this]
    483   bind $data(treeview).frameTree.t <KeyPress-Delete> +[list ::TolProject::DeleteActiveNode     $this]
    484   bind $data(treeview).frameTree.t <KeyPress-F9>     "::TolProject::CompileActiveNode    $this ; break"
    485   bind $data(treeview).frameTree.t <KeyPress-F8>     "::TolProject::DecompileActiveNode  $this ; break" 
     457  bind $tv.frameTree.t <KeyPress-Return> $newBind   
     458
     459  bind $tv.frameTree.t <KeyPress-space>  +[list ::TolProject::NodeActiveAttributes $this]
     460  bind $tv.frameTree.t <KeyPress-Delete> +[list ::TolProject::DeleteActiveNode     $this]
     461  bind $tv.frameTree.t <KeyPress-F9>     "::TolProject::CompileActiveNode    $this ; break"
     462  bind $tv.frameTree.t <KeyPress-F8>     "::TolProject::DecompileActiveNode  $this ; break" 
    486463 
    487   set data(mainMenu) [menu $data(treeview).m -tearoff 0]
     464  set data(mainMenu) [menu $tv.m -tearoff 0]
    488465
    489466  bind $data(f) <Destroy> +[list ::TolProject::Destroy $this %W]
    … …  
    530507  $tv item delete all
    531508  set img [GetImageFromType ROOT]
    532   $tv item image root [NiFileName] $img
    533   $tv item text root [NiFileName] "" 
    534   $tv item text root [NiDescription] "Root node"
    535   $tv item text root [NiType] "ROOT"
    536   $tv item text root [NiExclude] 0
    537   $tv item text root [NiExcludeTOL] 0
     509  $tv item image root FileName $img
     510  $tv item text root FileName "" Description "Root node" \
     511    Type "ROOT" Exclude 0 ExcludeTOL 0
    538512  InitState $this new
    539513}
    … …  
    825799  set tv [GetTreeview $this]
    826800  # Guardar data del nodo actual
    827   set excludeTOL [$tv item text $index [NiExcludeTOL]]
     801  set excludeTOL [$tv item text $index ExcludeTOL]
    828802  if ![string equal $excludeTOL 1] {
    829803    if {[IsCompilable $this $index] } {
    830       set filename [$tv item text $index [NiFileName]]
     804      set filename [$tv item text $index FileName]
    831805      set item "Set $name.$data(num)"
    832806      set value "Include(\"$filename\");"
    … …  
    880854  set node [$tv selection get end] ;# anchor
    881855  if { $node eq "" } return
    882   set description [$tv item text $node [NiDescription]]
     856  set description [$tv item text $node Description]
    883857  $data(sb,desc) configure -text "$description"
    884858}
    … …  
    988962  set tv [GetTreeview $this]
    989963 
    990   set type [$tv item text $node [NiType]]
    991   set filename [$tv item text $node [NiFileName]]
     964  set type [$tv item text $node Type]
     965  set filename [$tv item text $node FileName]
    992966  switch $type {
    993967    TOL { ::Editor::Open \
    … …  
    10471021     
    10481022      set img [GetImageFromType $data(type)]                                       
    1049       set tv_row [::TolProject::Node $img $data(name) $data(desc) $data(type) $data(exclude) $data(excludeTOL)]
    1050       if {$prev eq "end"} {
    1051         set where end
    1052       } else {
    1053         set where next
    1054         set node $prev
    1055       }
    10561023      if { $data(type) eq "Fol" } {
    10571024        set hasbutton 1
    … …  
    10591026        set hasbutton 0
    10601027      }
    1061       #@ Tolcon_Trace "prev $prev node $node where $where"
    1062       $tv insert $tv_row -at $where -relative $node -button $hasbutton
     1028      Tolcon_Trace "prev $prev node $node"
     1029      if {$prev eq "end"} {
     1030        set idx [$tv item create -parent $node -button $hasbutton -open 0]
     1031      } else {
     1032        set idx [$tv item create -prevsibling $prev -button $hasbutton -open 0]
     1033      }
     1034      $tv item image $idx FileName $img
     1035      $tv item text $idx FileName $data(name) Description $data(desc) \
     1036        Type $data(type) Exclude $data(exclude) ExcludeTOL $data(excludeTOL)
    10631037      set data(isSaved) 0
    10641038    }
    … …  
    10921066  set excl_old $data(exclude)
    10931067  set exct_old $data(excludeTOL)
    1094   set title "[$tv item text $node [NiFileName]] [mc Attributes]"
     1068  set title "[$tv item text $node FileName] [mc Attributes]"
    10951069  DialogAttributes $this $tv $title
    10961070  # si no se ha pulsado cancelar
    … …  
    11011075        ![string equal $excl_old $data(exclude)] ||
    11021076        ![string equal $exct_old $data(excludeTOL)]} {
    1103       $tv item text root FileName $data(name) 
    1104       $tv item text root Description $data(desc)
    1105       $tv item text root Exclude $data(exclude)
    1106       $tv item text root ExcludeTOL $data(excludeTOL)                       
     1077      $tv item text $node FileName $data(name) Description $data(desc) \
     1078        Exclude $data(exclude) ExcludeTOL $data(excludeTOL)                       
    11071079      set data(isSaved) 0
    11081080    }
    … …  
    11321104
    11331105  set tv [GetTreeview $this]
    1134   set name [$tv item text $node [NiFileName]]
     1106  set name [$tv item text $node FileName]
    11351107  set answer [tk_messageBox -title [mc "Question"]\
    11361108            -parent $tv\
    … …  
    11651137  upvar \#0 ${this}::data data
    11661138  set tv [GetTreeview $this]
    1167   set exclude [$tv item text $node [NiExclude]]
     1139  set exclude [$tv item text $node Exclude]
    11681140  if ![string equal $exclude 1] { 
    11691141    if [IsCompilable $this $node] {
    11701142      #Tolcon_Trace "  Compilo $node"
    11711143      set data(compiling) 1
    1172       #@T set filename $aryData(FileName)
    1173       set filename [$tv item text $node [NiFileName]]     
     1144      set filename [$tv item text $node FileName]   
    11741145      ::TolConsole::Include \
    11751146        [::TolProject::ComputeFullPath $this $filename]
    … …  
    12491220#/////////////////////////////////////////////////////////////////////////////
    12501221  set tv [GetTreeview $this]
    1251   set exclude [$tv item text $node [NiExclude]]
     1222  set exclude [$tv item text $node Exclude]
    12521223  if ![string equal $exclude 1] {
    12531224    if [IsCompilable $this $node] {
    1254       set filename [$tv item text $node [NiFileName]]     
     1225      set filename [$tv item text $node FileName]   
    12551226      catch {::TolInspector::DecompileFile \
    12561227             [::TolProject::ComputeFullPath $this $filename]}
    … …  
    12941265  upvar \#0 ${this}::data data
    12951266  set tv [GetTreeview $this]
    1296   set data(name)       [$tv item text $index [NiFileName]]
    1297   set data(desc)       [$tv item text $index [NiDescription]]
    1298   set data(type)       [$tv item text $index [NiType]]
    1299   set data(exclude)    [$tv item text $index [NiExclude]]
    1300   set data(excludeTOL) [$tv item text $index [NiExcludeTOL]] ;#$aryData(ExcludeTOL)
     1267  set data(name)       [$tv item text $index FileName]
     1268  set data(desc)       [$tv item text $index Description]
     1269  set data(type)       [$tv item text $index Type]
     1270  set data(exclude)    [$tv item text $index Exclude]
     1271  set data(excludeTOL) [$tv item text $index ExcludeTOL]
    13011272}
    13021273
    … …  
    13371308  set terminal 0
    13381309  set tv [GetTreeview $this]
    1339   set type [$tv item text $node [NiType]]
     1310  set type [$tv item text $node Type]
    13401311  switch $type {
    13411312    Fol -
    … …  
    13621333  set compilable 0
    13631334  set tv [GetTreeview $this]
    1364   set type [$tv item text $node [NiType]]
     1335  set type [$tv item text $node Type]
    13651336  switch $type {
    13661337    Fol -
    … …  
    18281799}
    18291800
    1830 #@ Métodos (4) antes en ::BayesTreeview (bftrview.tcl)
     1801#/////////////////////////////////////////////////////////////////////////////
     1802# Métodos que estaban en ::BayesTreeview (bftrview.tcl)
     1803#/////////////////////////////////////////////////////////////////////////////
    18311804
    18321805#/////////////////////////////////////////////////////////////////////////////
    … …  
    18871860
    18881861  # Guardar data del nodo actual
    1889   #@T array set aryData [$tv entry cget $index -data]
    1890   #@T set columnNames [array names aryData]
    18911862  set columnNames [list FileName Description Type Exclude ExcludeTOL]
    18921863  foreach item $columnNames {
    1893     writeini $fd $key $item [$tv item text $index [Ni$item]]
    1894   }
    1895  
    1896   #@T writeini $fd $key Label [$tv entry cget $index -label]
    1897   writeini $fd $key Label [$tv item text $index [NiFileName]]
     1864    writeini $fd $key $item [$tv item text $index $item]
     1865  }
     1866 
     1867  writeini $fd $key Label [$tv item text $index FileName]
    18981868  # Guardar sus hijos
    1899   #@T writeini $fd $key Children [$tv entry children $index]
    19001869  writeini $fd $key Children [$tv item children $index]
    19011870
    … …  
    19201889#/////////////////////////////////////////////////////////////////////////////
    19211890  set key $index
    1922 
    1923   #@T if ![string equal $parent ""] {
    1924   #@T   set idx [$tv insert -at $parent end $index ]
    1925   #@T } else {
    1926   #@T   set idx root
    1927   #@T }
    1928   #@T # Configurar data del nodo actual
    1929   #@T foreach item [readini $fd $key] {
    1930   #@T   set value [readini $fd $key $item]
    1931   #@T   if {[lsearch -exact [$tv column names] $item] != -1} {
    1932   #@T     $tv entry configure $idx -data [list $item $value]   
    1933   #@T   }
    1934   #@T   if [string equal $item "Label"] {
    1935   #@T     $tv entry configure $idx -label $value
    1936   #@T   }
    1937   #@T   if {[string equal $item "Type"] && ![string equal $imgFromType ""]} {
    1938   #@T     if ![string equal [set img [$imgFromType $value]] ""] {
    1939   #@T       #@ $tv entry configure $idx -icons [list $img $img]
    1940   #@T       $tv item image $idx FileName $img
    1941   #@T     }
    1942   #@T   }
    1943   #@T }
    19441891  set image "" 
    19451892  set filename ""
    … …  
    19471894  set type ""
    19481895  set exclude 0
    1949   set excludeTOL 0 ;#@T!! puede que no lo tenga el prj
     1896  set excludeTOL 0 ;#@ puede que no lo tenga el prj
    19501897  foreach item [readini $fd $key] {
    19511898    set value [readini $fd $key $item]
    … …  
    19661913  }
    19671914  if ![string equal $parent ""] {
    1968     #@T se inserta un nodo
    1969     #@T set idx [$tv insert -at $parent end $index ]
    1970     set tv_row [::TolProject::Node $img $filename $description $type $exclude $excludeTOL]
     1915    #@ se inserta un nodo
    19711916    if { $type eq "Fol" } {
    19721917      set hasbutton 1
    … …  
    19741919      set hasbutton 0
    19751920    } 
    1976     set idx [$tv insert $tv_row -at end -relative $parent -button $hasbutton]
     1921    set idx [$tv item create -parent $parent -button $hasbutton -open 0]
     1922    $tv item image $idx FileName $img
     1923    $tv item text $idx FileName $filename Description $description \
     1924      Type $type Exclude $exclude ExcludeTOL $excludeTOL 
    19771925  } else {
    1978     #@T se actualiza root
    1979     $tv item image root [NiFileName] $img
    1980     $tv item text root [NiFileName] $filename
    1981     $tv item text root [NiDescription] $description
    1982     $tv item text root [NiType] $type
    1983     $tv item text root [NiExclude] $exclude
    1984     $tv item text root [NiExcludeTOL] $excludeTOL
     1926    #@ se actualiza root
     1927    $tv item image root FileName $img
     1928    $tv item text root FileName $filename Description $description \
     1929      Type $type Exclude $exclude ExcludeTOL $excludeTOL
    19851930    set idx root
    19861931  } 
Note: See TracChangeset for help on using the changeset viewer.