source: tol/tolbase/lib/toltk/tolinspe__wtree1.tcl @ cc64b09

1941-docker-image-to-testdevel
Last change on this file since cc64b09 was cc64b09, checked in by Pedro Gea <pgea@…>, 10 years ago

Refs #1933
Se revisan los binds respecto a wtree y su treectrl.
Se quitan los métodos específicos para la creación de columnas e inserción de nodos que quedaban en tolinspe.
Se añade un update del nodo de paquetes para que se actualice ante un "require".
Se revisan los métodos de botón derecho para que aparezcan sólo sobre los objetos seleccionados.
Se añade un método a wtree para gestionar el color de todas las columnas de un nodo.
Se añaden las columnas al root de wtree.

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

  • Property mode set to 100644
File size: 25.0 KB
Line 
1
2#/////////////////////////////////////////////////////////////////////////////
3proc ::TolInspector::InsertChild { args } {
4#
5# PURPOSE: Inserts a node in the corresponding wtree of the right panel.
6#
7# PARAMETERS:
8#   args[0] -> grammar
9#   args[1] -> name
10#   args[2] -> content
11#   args[3] -> path
12#   args[4] -> desc
13#   Si grammar == "Code"
14#    args[5] -> ¿es una variable?
15#   Si grammar == "Set" || "NameBlock"
16#    args[5] -> indexes of the set
17#    args[6] -> is file?
18#    args[7] -> has subset?
19#    args[8] -> subtype
20#
21#/////////////////////////////////////////////////////////////////////////////
22  variable wt_vars
23  variable wt_funcs
24
25  set grammar [lindex $args 0]
26  set name    [lindex $args 1]
27  set content [lindex $args 2]
28  set path    [lindex $args 3]
29  set desc    [lindex $args 4]
30
31  switch $grammar {
32    Code {
33      set isvar [lindex $args 5]
34      if { [string equal $isvar "1"] } {
35        InsertItem $wt_vars $grammar $name $content $path $desc {}
36      } else {
37        InsertItem $wt_funcs $grammar $name $content $path $desc {}
38      }
39    }
40    NameBlock -
41    Set {
42      #puts "HTItem, ref = '$ref' '$args'"
43      # args[5] is the index of the set object
44      # args[6] is the flag file
45      # args[8] is the subtype
46      InsertItem $wt_vars $grammar $name $content $path $desc [lindex $args 8]
47      # [lindex $args 5] [lindex $args 6] [lindex $args 8] $ref
48    }
49    default {
50      InsertItem $wt_vars $grammar $name $content $path $desc {}
51    }
52  }
53}
54
55#/////////////////////////////////////////////////////////////////////////////
56proc ::TolInspector::InsertItem {wt grammar name content path desc subtype} {
57#/////////////////////////////////////////////////////////////////////////////
58  variable wt_tree
59  variable arguments
60
61  #upvar \#0 ::TolTk::Images Images
62
63  set parent_grammar $arguments(parent_grammar) 
64 
65  #@ Si la llamada a InsertChild viene de SelectSet el argumento tolref
66  #@ no está definido y se crea a partir de parent_tolref
67  set tolref $arguments(tolref)
68  if { $tolref eq "" } {
69    set tolref $arguments(parent_tolref)
70    lappend tolref $arguments(index)
71  }
72 
73  if { $parent_grammar eq "NameBlock" } {
74    array set info_member [ FilterNameBlockMember $name ]
75    if { !$info_member(-show) } {
76      incr arguments(index)
77      return
78    }
79    set fcolor $info_member(-fcolor)
80  } else {
81    set fcolor "black"
82  }
83
84  set brief_cont [TrimContent $grammar $content]
85  set brief_desc [TrimContent DONTCARE $desc] 
86 
87  set data3 $brief_cont
88  if {$grammar eq "NameBlock"} {
89    #(pgea) se utiliza la informacon de instancia
90    #puts "Tol_ClassOfFromReference $tolref"
91    set classOf [Tol_ClassOfFromReference $tolref]
92    #puts "Tol_InstanceContentFromReference $tolref"
93    set insCont [Tol_InstanceContentFromReference $tolref]
94    if {$insCont ne ""} {
95      set data3 [TrimContent $grammar $insCont]
96    } elseif {$classOf ne ""} {
97      set data3 $classOf
98    }   
99  }
100 
101  #@ Se introduce toda la descripción de la clase.
102  if {$grammar eq "Anything"} {
103    if { [regexp {@[^ ]+} $name] } {
104      set data3 $content
105    }
106  }
107
108  #@ Se localiza el icono según la gramática
109  if {$grammar eq "Set" || $grammar eq "NameBlock"} {
110    if {$grammar eq "Set"} {
111      set icon_grammar [SubTypeImage $subtype]
112    } else {
113      set objAddress [tol::info address $tolref]
114      set icon_grammar [::ImageManager::getIconForInstance $objAddress]
115    }
116  } elseif { $grammar eq "Anything" } {
117    set anyType [ tol::info Anything $tolref ]
118    set icon_grammar [::Bitmap::get $anyType]
119  } else {
120    set icon_grammar [::Bitmap::get $grammar]
121  }
122 
123  #@ No se usa el método insert de wtree porque es más lento
124  #@ Crea y completa los datos de un nodo
125  set idx [$wt item create -button 1 -open 0 -parent root]
126  $wt item image $idx Name $icon_grammar
127  $wt item text $idx Index $arguments(index) Grammar $grammar \
128    Name $name Content $data3 Description $brief_desc Path $path Reference $tolref
129  if { $fcolor ne "black" } {
130    $wt item-color $idx $fcolor
131  }
132  incr arguments(index)
133}
134
135#/////////////////////////////////////////////////////////////////////////////
136proc ::TolInspector::ClearHiertables { } {
137#
138# PURPOSE:
139#
140#/////////////////////////////////////////////////////////////////////////////
141  variable w_tabset
142  variable wt_vars
143  variable wt_funcs
144  variable OnSelectItem
145
146  $wt_vars selection clear
147  $wt_vars item delete all
148  $wt_funcs selection clear
149  $wt_funcs item delete all
150 
151  $w_tabset itemconfigure Variables -text [mc Variables] -state normal
152  $w_tabset itemconfigure Functions -state normal
153
154  if { [string length $OnSelectItem] } {
155    $OnSelectItem
156  }
157}
158
159#/////////////////////////////////////////////////////////////////////////////
160proc ::TolInspector::OpenObject { node } {
161#
162# PURPOSE: Script called each time a node in wt_tree (left wtree) is opened.
163#
164# PARAMETERS:
165#   node : The id of the node opened
166#
167#/////////////////////////////////////////////////////////////////////////////
168  variable wt_tree
169  variable arguments
170 
171  #@ No es necesario llenar ni el nodo root (0) ni root-grammars (1)
172  if { $node == 0 } return
173  if { $node == 1 } return 
174
175  #@ Argumentos pasados por atributo
176  #@  + parent_node es usado por InsertSubset para saber dónde insertar
177  set arguments(parent_node) $node
178  set tolReference [$wt_tree item text $node Reference]
179 
180  if { [llength $tolReference] == 1 } {
181    #@ Aquí llegan los nodos raíz y las gramáticas
182    switch $tolReference {
183      Package InsertPackages
184      File    InsertFiles
185      Console InsertConsoleObj
186      default return
187    }
188  } elseif { [lindex $tolReference 0] == "Grammar" } {
189    return
190  } else {
191    Busy
192    #@ Argumentos pasados por atributo
193    #@  + parent_grammar es usado por InsertSubset para abrir o no un nodo
194    #@  + parent_tolref es usado por InsertSubset para determinar tolref
195    set arguments(parent_grammar) [$wt_tree item text $node Grammar]
196    set arguments(parent_tolref) $tolReference
197    ::tol::forallchild $tolReference ::TolInspector::InsertSubset
198    NotBusy
199  }
200}
201
202#/////////////////////////////////////////////////////////////////////////////
203proc ::TolInspector::InsertPackages {} {
204#
205# PURPOSE: Inserts a node in wt_tree (left ::wtree) for each TOL packages
206#
207#/////////////////////////////////////////////////////////////////////////////
208  variable wt_tree
209  #upvar \#0 ::TolTk::Images Images
210 
211  set order 1
212  foreach pkg [::tol::info packages] {
213    # takes an icon with the same name that the grammar     
214    set idnew [$wt_tree item create -parent "root-packages" -button yes -open 0 -tags "package-$order"]
215    $wt_tree item image $idnew Name [::Bitmap::get NameBlock]
216    $wt_tree item text $idnew Index $order Grammar "NameBlock" Name $pkg Reference "NameBlock $pkg"     
217    incr order
218  }
219}
220
221#/////////////////////////////////////////////////////////////////////////////
222proc ::TolInspector::InsertGrammars {} {
223#
224# PURPOSE: Inserts a node in wt_tree (left ::wtree) for each TOL grammar
225#
226#/////////////////////////////////////////////////////////////////////////////
227  variable wt_tree
228  #upvar \#0 ::TolTk::Images Images
229 
230  set id 1
231  foreach g [::tol::info grammars] {
232    # takes an icon with the same name that the grammar
233    set idnew [$wt_tree item create -parent "root-grammars" -button no -open 0 -tags "grammar-$id"]
234    $wt_tree item image $idnew Name [::Bitmap::get $g]
235    $wt_tree item text $idnew Index $id Grammar "Grammar" Name $g Reference "Grammar $g"
236    incr id
237  }
238}
239
240#/////////////////////////////////////////////////////////////////////////////
241proc ::TolInspector::InsertFiles { } {
242#
243# PURPOSE: Inserts a node in wt_tree (left treeview) for each Included file
244#
245#/////////////////////////////////////////////////////////////////////////////
246  variable wt_tree
247
248  set index 1
249  #set img [::Bitmap::get "File"]
250  foreach f [lreverse [::tol::info included]] {
251    set finfo   [::tol::info included $f]
252    set button  [lindex $finfo 3]
253    set subtype [lindex $finfo 4]
254    # tomar la imagen en funcion del subtype
255    set img [SubTypeImage $subtype]
256    # Tail del fichero. Podría hacerse configurable por el usuario
257    set label [file tail $f]
258    set idnew [$wt_tree item create -parent "root-files" -button $button -open 0 -tags "file-$index"]
259    $wt_tree item image $idnew Name $img
260    $wt_tree item text $idnew Index $index Grammar "File" Name $label Reference [list File $f]
261    incr index
262  }
263}
264
265#/////////////////////////////////////////////////////////////////////////////
266proc ::TolInspector::InsertConsoleObj { } {
267#
268# PURPOSE: Inserts a node in wt_tree (left treeview) for each Console object
269#
270#/////////////////////////////////////////////////////////////////////////////
271  variable wt_tree
272   
273  set index 1
274  foreach co [::tol::console stack list] {
275    set grammar [lindex $co 0]
276    if {$grammar eq "Set" || $grammar eq "NameBlock"} {
277      # SUBTYPE: icono en funcion de [lindex $co 7]
278      if {$grammar eq "Set"} {
279        set icon [SubTypeImage [lindex $co 7]]
280      } else  {
281        set objRef [ list "Console" $index ]
282        set objAddress [ tol::info address $objRef ]
283        set icon [ ::ImageManager::getIconForInstance $objAddress ]
284      }
285      set name [lindex $co 1]
286      set has_button [lindex $co 6]
287      if {$name eq ""} {
288        if {[set name [TrimContent DONTCARE [lindex $co 4]]] eq ""} {
289          set name " "
290        }
291      }
292      set idnew [$wt_tree item create -parent "root-console" -button $has_button -open 0 -tags "console-$index"]
293      $wt_tree item image $idnew Name $icon
294      $wt_tree item text $idnew Index $index Grammar $grammar Name $name Reference "Console $index"
295    }
296    incr index
297  }
298}
299
300#/////////////////////////////////////////////////////////////////////////////
301proc ::TolInspector::InsertSubset { args } {
302#
303# PURPOSE: Inserts a node in wt_tree (left treeview) for each child of a Set
304#
305# PARAMETERS:
306#   args[0] -> grammar
307#   args[1] -> name
308#   args[2] -> content
309#   args[3] -> path
310#   args[4] -> desc
311#   Si grammar == "Set"
312#    args[5] -> indexes of the set
313#    args[6] -> is file?
314#    args[7] -> has subset?
315#    args[8] -> subtype
316#
317#/////////////////////////////////////////////////////////////////////////////
318  variable wt_tree
319  variable arguments
320 
321  #@ para saber dónde insertar
322  set parent_node $arguments(parent_node)
323  ## para distinguir set de nameblocks
324  set parent_grammar $arguments(parent_grammar)
325  #@ para obtener el icono de las instancias
326  set parent_tolref $arguments(parent_tolref)
327 
328  catch {
329  #puts "InsertSubset, args=$args"
330  set grammar [lindex $args 0]
331  if {$grammar eq "Set" || $grammar eq "NameBlock"} {
332    #puts "InsertSubset, args=$args"
333    if { $parent_grammar eq "NameBlock" } {
334      array set info_member [ FilterNameBlockMember [ lindex $args 1 ] ]
335      if { !$info_member(-show) } {
336        return
337      }
338      set name $info_member(-name)
339      set fcolor $info_member(-fcolor)
340    } else {
341      set name [ lindex $args 1 ]
342      set fcolor "black"
343    }
344    set content [lindex $args 2]
345    # indices es el indice completo desde el Set root
346    set indices     [lindex $args 5]
347    set isfile  [lindex $args 6]
348    set has_button [lindex $args 7]
349    set subtype [lindex $args 8]
350    if {$grammar eq "Set"} {
351      set icon [SubTypeImage $subtype]
352    } else {
353      set objRef $parent_tolref
354      lappend objRef [ lindex $indices end ]
355      set objAddress [ tol::info address $objRef ]
356      set icon [ ::ImageManager::getIconForInstance $objAddress ]
357    }
358    # Tail por si es un fichero. Podría hacerse configurable por el usuario
359    set label [file tail $name]
360    #puts [list InsertSubset, indices {lindex $args 5} = $indices]
361   
362    set index [lindex $indices end]
363    set tolRefe [eval list [$wt_tree item text $parent_node Reference] $index]
364    if {$label eq ""} {
365      if {[set label [TrimContent DONTCARE [lindex $args 4]]] eq ""} {
366        set label " "
367      }
368    }
369
370    set idnew [$wt_tree item create -parent $parent_node -button $has_button -open 0]
371    $wt_tree item image $idnew Name $icon
372    $wt_tree item text $idnew Index $index Grammar $grammar Name $label Reference $tolRefe 
373    if { $fcolor ne "black" } {
374      $wt_tree item-color $idnew $fcolor
375    }
376  }
377  } msg
378}
379
380#/////////////////////////////////////////////////////////////////////////////
381proc ::TolInspector::SelectObject { } {
382#
383# PURPOSE: Script called each time a node in wt_tree (left wtree) is selected.
384#
385#/////////////////////////////////////////////////////////////////////////////
386  variable w_tabset
387  variable wt_tree
388  variable arguments
389 
390  set node [$wt_tree selection get 0]
391  if { ![string length $node] } return
392  if { $node == 0 } {
393    ClearHiertables
394    #@D $w_tabset itemconfigure Variables -state disabled
395    #@D $w_tabset itemconfigure Functions -state disabled   
396    return
397  }
398 
399  set tolReference [$wt_tree item text $node Reference]
400 
401  Busy
402  if { [llength $tolReference] == 1 } {
403    #@ Aquí llegan los nodos raíz y las gramáticas
404    #@ Argumentos pasados por atributo
405    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock 
406    set arguments(parent_grammar) ""
407    switch $tolReference {
408      Package SelectPackageRoot
409      File    SelectFileRoot
410      Console SelectConsoleRoot
411      default {
412        ClearHiertables
413        #@D $w_tabset itemconfigure Variables -state disabled
414        #@D $w_tabset itemconfigure Functions -state disabled
415      }
416    }
417  } elseif { [lindex $tolReference 0] == "Grammar" } {
418    #@ Argumentos pasados por atributo
419    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock
420    set arguments(parent_grammar) ""
421    SelectGrammar
422  } else {
423    #@ Argumentos pasados por atributo
424    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock
425    set arguments(parent_grammar) [$wt_tree item text $node Grammar]
426    SelectSet $tolReference
427  }
428  NotBusy
429}
430
431#/////////////////////////////////////////////////////////////////////////////
432proc ::TolInspector::SelectPackageRoot { } {
433#
434# PURPOSE: Script called each time 'Packages' node in wt_tree is
435#          selected. Gets information about each node that must be in
436#          packages, and inserts it in the right wtree.
437#
438#/////////////////////////////////////////////////////////////////////////////
439  variable w_tabset
440  variable arguments
441 
442  #@ Argumentos pasados por atributo
443  #@  + index es usado e incrementado por InsertItem
444  set arguments(index) 1
445
446  ClearHiertables
447  $w_tabset itemconfigure Variables -text [mc Packages] 
448  $w_tabset raise Variables 
449  #@D $w_tabset itemconfigure Functions -state disabled   
450 
451  foreach pkg [::tol::info packages] {
452    set pi [::tol::info var "NameBlock $pkg"]
453    #@ Argumentos pasados por atributo
454    #@  + tolref es usado por InsertItem   
455    set arguments(tolref) [list "NameBlock" $pkg]
456    InsertChild NameBlock $pkg [lindex $pi 2] [lindex $pi 3] [lindex $pi 4] \
457      $arguments(index) [lindex $pi 5] [lindex $pi 6] [lindex $pi 7]       
458  }
459}
460
461#/////////////////////////////////////////////////////////////////////////////
462proc ::TolInspector::SelectFileRoot { } {
463#
464# PURPOSE: Script called each time 'Included Files' node in wt_tree is
465#          selected. Gets information about each node that must be in
466#          included files, and inserts it in the right wtree.
467#
468#/////////////////////////////////////////////////////////////////////////////
469  variable w_tabset
470  variable arguments
471 
472  #@ Argumentos pasados por atributo
473  #@  + index es usado e incrementado por InsertItem
474  set arguments(index) 1
475
476  ClearHiertables
477  $w_tabset itemconfigure Variables -text [mc Files]
478  $w_tabset raise Variables
479  #@D $w_tabset itemconfigure Functions -state disabled
480 
481  foreach f [lreverse [::tol::info included]] {
482    # this catch is needed because info include could return files not really included
483    if { [catch { ::tol::info included $f } fi] } continue
484    #@ Argumentos pasados por atributo
485    #@  + tolref es usado por InsertItem
486    set arguments(tolref) [list "File" $f]
487    set label [file tail $f]
488    InsertChild Set $label [lindex $fi 0] [lindex $fi 2] [lindex $fi 1] \
489      $arguments(index) 1 [lindex $fi 3] [lindex $fi 4]       
490  }
491}
492
493#/////////////////////////////////////////////////////////////////////////////
494proc ::TolInspector::SelectConsoleRoot { } {
495#
496# PURPOSE: Script called each time 'Console Objects' node in wt_tree is
497#          selected. Gets information about each node that must be in console,
498#          and inserts it in the right wtree.
499#
500#/////////////////////////////////////////////////////////////////////////////
501  variable wt_tree
502  variable arguments
503 
504  #@ Argumentos pasados por atributo
505  #@  + index es usado e incrementado por InsertItem
506  set arguments(index) 1
507
508  ClearHiertables
509
510#(pgea) se quita la linea que oculta la columna del indice y que
511#(pgea) el procedimimento anterior ClearHiertables muestra
512#  $ht_vars column  configure Index -hide yes
513 
514  foreach co [::tol::console stack list] {
515    #puts "SelectConsoleRoot: co = $co"
516    set gra  [lindex $co 0]
517    set name [lindex $co 1]
518    set cont [lindex $co 2]
519    set path [lindex $co 3]
520    set desc [lindex $co 4]
521    #@ Argumentos pasados por atributo
522    #@  + tolref es usado por InsertItem
523    set arguments(tolref) [list Console $arguments(index)]
524    switch [lindex $co 0 ] {
525      Code {
526        InsertChild $gra $name $cont $path $desc 0
527      }
528      NameBlock -
529      Set {
530        #puts "switch: SelectConsoleRoot $gra"
531        InsertChild $gra $name $cont $path $desc \
532            $arguments(index) [lindex $co 5] [lindex $co 6] [lindex $co 7]
533      }
534      default {
535        InsertChild $gra $name $cont $path $desc
536      }
537    }
538  }
539  set arguments(tolref) ""
540}
541
542#/////////////////////////////////////////////////////////////////////////////
543proc ::TolInspector::SelectGrammar { } {
544#
545# PURPOSE: Script called each time a Grammar node in wt_tree is selected. Gets
546#          information about each var and function of this grammar, and
547#          inserts them in the right treeview.
548#
549#/////////////////////////////////////////////////////////////////////////////
550  variable w_tabset
551  variable wt_tree
552  variable OnSelectItem
553  variable arguments
554 
555  #@ Argumentos pasados por atributo
556  #@  + index es usado e incrementado por InsertItem 
557  set arguments(index) 1
558 
559  ClearHiertables
560 
561  set selAnchor [$wt_tree selection get 0]
562 
563  set grammar [$wt_tree item text $selAnchor Name ]
564  if { [string compare $grammar "Anything"] } {
565    #@ Por aquí si no es Anything
566    if { [string length $OnSelectItem] } {
567      $OnSelectItem [::tol::info grammars $grammar]
568    }
569    foreach var [::tol::info variables $grammar] {
570      if {[catch {
571        set vinfo [::tol::info variables [list $grammar $var]]
572        #@ Devuelve:
573        #@ Grammar Name Content Path Description [IsFile HasSubset ? Subtype?]
574      } msg]} {
575        Tol_HciWriter "<E>in ::TolInspector::SelectGrammar : $msg\n</E>"
576        continue
577      }
578      #@ Argumentos pasados por atributo
579      #@  + tolref es usado por InsertItem
580      set arguments(tolref) [list $grammar $var]
581      #@ InsertChild grammar name content path desc [Set|Nameblock: index isfile hassubset subtype] [Code: isvariable]
582      if { [string equal $grammar "Code"] } {
583        InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [lindex $vinfo 4] 1 
584      } elseif { $grammar eq "Set" || $grammar eq "NameBlock" } {
585        InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [lindex $vinfo 4] \
586          $arguments(index) [lindex $vinfo 5] [lindex $vinfo 6] [lindex $vinfo 7]
587      } else {
588        InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [lindex $vinfo 4]
589      } 
590    }
591  } else {
592    $w_tabset raise Functions 
593    #@D $w_tabset itemconfigure Variables -state disabled
594  }
595  foreach fun  [::tol::info functions $grammar] {
596    set finfo [::tol::info functions $grammar $fun]
597    #@ Argumentos pasados por atributo
598    #@  + tolref es usado por InsertItem   
599    set arguments(tolref) [list Code $fun]
600    InsertChild Code $fun [lindex $finfo 0] [lindex $finfo 1] [lindex $finfo 2] 0   
601  }
602}
603
604#/////////////////////////////////////////////////////////////////////////////
605proc ::TolInspector::SelectSet { tolReference } {
606#
607# PURPOSE: Script called each time a Set node in wt_tree is selected. Gets
608#          information about each child of this set, and inserts it in the
609#          right treeview.
610#
611#/////////////////////////////////////////////////////////////////////////////
612  variable var_id 1
613  variable fun_id 1
614  variable arguments
615 
616  ClearHiertables
617 
618  #@ Argumentos pasados por atributo
619  #@  + index es usado e incrementado por InsertItem
620  #@  + tolref indica a InsertItem que se ha de obtener desde parent_tolref
621  #@  + parent_tolref es usado por InsertItem para encontrar tolref 
622  set arguments(index) 1 
623  set arguments(tolref) ""
624  set arguments(parent_tolref) $tolReference
625  ::tol::forallchild $tolReference ::TolInspector::InsertChild
626}
627
628#/////////////////////////////////////////////////////////////////////////////
629proc ::TolInspector::CloseObject { node } {
630#
631# PURPOSE: Script called each time a node in wt_tree (left treeview) is closed.
632#
633# PARAMETERS:
634#   node : The id of the node closed
635#
636#/////////////////////////////////////////////////////////////////////////////
637  variable wt_tree
638 
639  #@ No es necesario vaciar ni el nodo root (0) ni root-grammars (1)
640  if { $node == 0 } return
641  if { $node == 1 } return
642  foreach it [$wt_tree item children $node] {
643    $wt_tree item delete $it
644  }   
645}
646
647#/////////////////////////////////////////////////////////////////////////////
648proc ::TolInspector::OpenVariable { node } {
649#
650# PURPOSE: Script called each time a node in wt_vars (right wtree) is opened.
651#
652# PARAMETERS:
653#   node : The id of the node opened
654#
655#/////////////////////////////////////////////////////////////////////////////
656  variable wt_tree
657  variable wt_vars
658
659  if { ![string length $node] } { return }
660 
661  set treeParent [$wt_tree selection get 0]
662  set treeParent_tolRef [$wt_tree item text $treeParent Reference]
663  if { [llength $treeParent_tolRef] < 1 } return
664  if { [lindex $treeParent_tolRef 0] eq "Grammar" } return 
665 
666  set treeNode -1
667
668  set grammar [$wt_vars item text $node Grammar]
669  if {$grammar eq "Set" || $grammar eq "NameBlock"} {
670    $wt_tree item expand $treeParent
671    #@ Se localiza el nodo seleccionado en el árbol (wt_tree)
672    set index [$wt_vars item text $node Index]   
673    foreach node_i [$wt_tree item children $treeParent] {
674      set index_i [$wt_tree item text $node_i Index]
675      if { [string equal $index $index_i] } {
676        set treeNode $node_i
677        break
678      }
679    }
680  } else {
681    return
682  }
683 
684  if { $treeNode != -1 } {
685    update
686    $wt_tree selection clear   
687    $wt_tree selection add $treeNode
688  }
689}
690
691#/////////////////////////////////////////////////////////////////////////////
692proc ::TolInspector::SelectItem { wt } {
693#
694# PURPOSE: Procedure that is executed when the user selects an element of
695#          the trees of variables or functions.
696#          First it take all the arguments necessary of the node of tree to
697#          execute the procedure stored in the variable OnSelectItem, and
698#          later executes it passing those arguments.
699#
700# PARAMETERS: path of wt_* (::wtree of variables or of functions)
701#
702#/////////////////////////////////////////////////////////////////////////////
703# variable w_text       ;# TODO: ????
704  variable OnSelectItem ;#Command to invoke on SelectItem in wt_*
705 
706  #@ entry era el 'selection anchor'
707  set entry [$wt selection get end] ;# id of entry selected
708
709  if { [string length $OnSelectItem] } {
710    # there are associated command
711    if { [string length $entry] } {
712      # almost one entry of wt_* selected
713      set name   [$wt item text $entry Name] ;# name of item     
714      set itemid [$wt item text $entry Index] ;# id of item       
715      set path   [$wt item text $entry Path] ;# path of file of item
716      set objRef [$wt item text $entry Reference] ;# info of item
717      set value  [$wt item text $entry Content]
718      if { [string equal \"\n\" $value] } {
719        # hasn't value       
720        set value {"\n"}
721      } else {
722        set value [string trim $value]
723      }
724      set desc [$wt item text $entry Description]
725      set grammar [$wt item text $entry Grammar]
726      set icon [$wt item image $entry Name]
727      #(pgea) lista de argumentos que recibe ::TolConsole::OnInfo
728      set args [list $icon $grammar $name $value $path $desc $objRef]
729    } else {
730      set args ""
731    }
732    eval "$OnSelectItem $args"
733  }
734  return
735}
Note: See TracBrowser for help on using the repository browser.