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

1941-docker-image-to-testdevel
Last change on this file since f738c05 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
RevLine 
[e0578ae]1
2#/////////////////////////////////////////////////////////////////////////////
[7a3f24e]3proc ::TolInspector::InsertChild { args } {
4#
[6207115]5# PURPOSE: Inserts a node in the corresponding wtree of the right panel.
[7a3f24e]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"
[6207115]14#    args[5] -> ¿es una variable?
[7a3f24e]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#/////////////////////////////////////////////////////////////////////////////
[6207115]22  variable wt_vars
23  variable wt_funcs
[7a3f24e]24
25  set grammar [lindex $args 0]
[6207115]26  set name    [lindex $args 1]
[7a3f24e]27  set content [lindex $args 2]
28  set path    [lindex $args 3]
[6207115]29  set desc    [lindex $args 4]
[7a3f24e]30
31  switch $grammar {
32    Code {
33      set isvar [lindex $args 5]
34      if { [string equal $isvar "1"] } {
[6207115]35        InsertItem $wt_vars $grammar $name $content $path $desc {}
[7a3f24e]36      } else {
[6207115]37        InsertItem $wt_funcs $grammar $name $content $path $desc {}
[7a3f24e]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
[6207115]46      InsertItem $wt_vars $grammar $name $content $path $desc [lindex $args 8]
47      # [lindex $args 5] [lindex $args 6] [lindex $args 8] $ref
[7a3f24e]48    }
49    default {
[6207115]50      InsertItem $wt_vars $grammar $name $content $path $desc {}
[7a3f24e]51    }
52  }
53}
54
55#/////////////////////////////////////////////////////////////////////////////
[6207115]56proc ::TolInspector::InsertItem {wt grammar name content path desc subtype} {
[7a3f24e]57#/////////////////////////////////////////////////////////////////////////////
[6207115]58  variable wt_tree
59  variable arguments
[7a3f24e]60
61  #upvar \#0 ::TolTk::Images Images
62
[6207115]63  set parent_grammar $arguments(parent_grammar) 
[0731938]64 
[6207115]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" } {
[7a3f24e]74    array set info_member [ FilterNameBlockMember $name ]
75    if { !$info_member(-show) } {
[6207115]76      incr arguments(index)
[7a3f24e]77      return
78    }
79    set fcolor $info_member(-fcolor)
80  } else {
81    set fcolor "black"
82  }
83
84  set brief_cont [TrimContent $grammar $content]
[e933fd6]85  set brief_desc [TrimContent DONTCARE $desc] 
86 
[6207115]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    }   
[7a3f24e]99  }
[e933fd6]100 
[cc64b09]101  #@ Se introduce toda la descripción de la clase.
[e933fd6]102  if {$grammar eq "Anything"} {
103    if { [regexp {@[^ ]+} $name] } {
104      set data3 $content
105    }
106  }
[7a3f24e]107
[6207115]108  #@ Se localiza el icono según la gramática
[7a3f24e]109  if {$grammar eq "Set" || $grammar eq "NameBlock"} {
110    if {$grammar eq "Set"} {
[6207115]111      set icon_grammar [SubTypeImage $subtype]
[7a3f24e]112    } else {
[6207115]113      set objAddress [tol::info address $tolref]
114      set icon_grammar [::ImageManager::getIconForInstance $objAddress]
[7a3f24e]115    }
116  } elseif { $grammar eq "Anything" } {
[6207115]117    set anyType [ tol::info Anything $tolref ]
118    set icon_grammar [::Bitmap::get $anyType]
[7a3f24e]119  } else {
[6207115]120    set icon_grammar [::Bitmap::get $grammar]
[7a3f24e]121  }
[6207115]122 
[ceea866]123  #@ No se usa el método insert de wtree porque es más lento
[cc64b09]124  #@ Crea y completa los datos de un nodo
125  set idx [$wt item create -button 1 -open 0 -parent root]
[ceea866]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
[cc64b09]129  if { $fcolor ne "black" } {
130    $wt item-color $idx $fcolor
131  }
[6207115]132  incr arguments(index)
[7a3f24e]133}
134
135#/////////////////////////////////////////////////////////////////////////////
136proc ::TolInspector::ClearHiertables { } {
137#
138# PURPOSE:
139#
140#/////////////////////////////////////////////////////////////////////////////
141  variable w_tabset
[6207115]142  variable wt_vars
143  variable wt_funcs
[7a3f24e]144  variable OnSelectItem
145
[0731938]146  $wt_vars selection clear
147  $wt_vars item delete all
148  $wt_funcs selection clear
149  $wt_funcs item delete all
[6207115]150 
[0731938]151  $w_tabset itemconfigure Variables -text [mc Variables] -state normal
152  $w_tabset itemconfigure Functions -state normal
[7a3f24e]153
154  if { [string length $OnSelectItem] } {
155    $OnSelectItem
156  }
157}
158
159#/////////////////////////////////////////////////////////////////////////////
[6207115]160proc ::TolInspector::OpenObject { node } {
[7a3f24e]161#
[6207115]162# PURPOSE: Script called each time a node in wt_tree (left wtree) is opened.
[7a3f24e]163#
164# PARAMETERS:
[6207115]165#   node : The id of the node opened
[7a3f24e]166#
167#/////////////////////////////////////////////////////////////////////////////
[6207115]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
[ceea866]178  set tolReference [$wt_tree item text $node Reference]
[6207115]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
[7a3f24e]187    }
[6207115]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
[ceea866]195    set arguments(parent_grammar) [$wt_tree item text $node Grammar]
[6207115]196    set arguments(parent_tolref) $tolReference
197    ::tol::forallchild $tolReference ::TolInspector::InsertSubset
198    NotBusy
[7a3f24e]199  }
200}
201
202#/////////////////////////////////////////////////////////////////////////////
203proc ::TolInspector::InsertPackages {} {
204#
[6207115]205# PURPOSE: Inserts a node in wt_tree (left ::wtree) for each TOL packages
[7a3f24e]206#
207#/////////////////////////////////////////////////////////////////////////////
[6207115]208  variable wt_tree
[7a3f24e]209  #upvar \#0 ::TolTk::Images Images
[6207115]210 
[7a3f24e]211  set order 1
212  foreach pkg [::tol::info packages] {
[cc64b09]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"     
[7a3f24e]217    incr order
218  }
219}
220
221#/////////////////////////////////////////////////////////////////////////////
222proc ::TolInspector::InsertGrammars {} {
223#
[e933fd6]224# PURPOSE: Inserts a node in wt_tree (left ::wtree) for each TOL grammar
[7a3f24e]225#
226#/////////////////////////////////////////////////////////////////////////////
[6207115]227  variable wt_tree
[7a3f24e]228  #upvar \#0 ::TolTk::Images Images
[6207115]229 
[7a3f24e]230  set id 1
231  foreach g [::tol::info grammars] {
232    # takes an icon with the same name that the grammar
[cc64b09]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"
[7a3f24e]236    incr id
237  }
238}
239
240#/////////////////////////////////////////////////////////////////////////////
241proc ::TolInspector::InsertFiles { } {
242#
[6207115]243# PURPOSE: Inserts a node in wt_tree (left treeview) for each Included file
[7a3f24e]244#
245#/////////////////////////////////////////////////////////////////////////////
[6207115]246  variable wt_tree
[7a3f24e]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]
[6207115]256    # Tail del fichero. Podría hacerse configurable por el usuario
[7a3f24e]257    set label [file tail $f]
[cc64b09]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]
[7a3f24e]261    incr index
262  }
263}
264
265#/////////////////////////////////////////////////////////////////////////////
266proc ::TolInspector::InsertConsoleObj { } {
267#
[6207115]268# PURPOSE: Inserts a node in wt_tree (left treeview) for each Console object
[7a3f24e]269#
270#/////////////////////////////////////////////////////////////////////////////
[6207115]271  variable wt_tree
[7a3f24e]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      }
[cc64b09]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"
[7a3f24e]295    }
296    incr index
297  }
298}
299
300#/////////////////////////////////////////////////////////////////////////////
301proc ::TolInspector::InsertSubset { args } {
302#
[6207115]303# PURPOSE: Inserts a node in wt_tree (left treeview) for each child of a Set
[7a3f24e]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#/////////////////////////////////////////////////////////////////////////////
[6207115]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
[0731938]326  set parent_tolref $arguments(parent_tolref)
[6207115]327 
[7a3f24e]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"
[6207115]333    if { $parent_grammar eq "NameBlock" } {
[7a3f24e]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]
[6207115]345    # indices es el indice completo desde el Set root
346    set indices     [lindex $args 5]
[7a3f24e]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 {
[6207115]353      set objRef $parent_tolref
354      lappend objRef [ lindex $indices end ]
[7a3f24e]355      set objAddress [ tol::info address $objRef ]
356      set icon [ ::ImageManager::getIconForInstance $objAddress ]
357    }
[6207115]358    # Tail por si es un fichero. Podría hacerse configurable por el usuario
[7a3f24e]359    set label [file tail $name]
[6207115]360    #puts [list InsertSubset, indices {lindex $args 5} = $indices]
361   
362    set index [lindex $indices end]
[ceea866]363    set tolRefe [eval list [$wt_tree item text $parent_node Reference] $index]
[7a3f24e]364    if {$label eq ""} {
365      if {[set label [TrimContent DONTCARE [lindex $args 4]]] eq ""} {
366        set label " "
367      }
368    }
[6207115]369
[cc64b09]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    }
[7a3f24e]376  }
[6207115]377  } msg
[7a3f24e]378}
379
380#/////////////////////////////////////////////////////////////////////////////
381proc ::TolInspector::SelectObject { } {
382#
[6207115]383# PURPOSE: Script called each time a node in wt_tree (left wtree) is selected.
[7a3f24e]384#
385#/////////////////////////////////////////////////////////////////////////////
386  variable w_tabset
[6207115]387  variable wt_tree
388  variable arguments
[0731938]389 
[6207115]390  set node [$wt_tree selection get 0]
391  if { ![string length $node] } return
392  if { $node == 0 } {
[7a3f24e]393    ClearHiertables
[0731938]394    #@D $w_tabset itemconfigure Variables -state disabled
395    #@D $w_tabset itemconfigure Functions -state disabled   
[7a3f24e]396    return
397  }
[6207115]398 
[ceea866]399  set tolReference [$wt_tree item text $node Reference]
[6207115]400 
[7a3f24e]401  Busy
[6207115]402  if { [llength $tolReference] == 1 } {
403    #@ Aquí llegan los nodos raíz y las gramáticas
404    #@ Argumentos pasados por atributo
[0731938]405    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock 
[6207115]406    set arguments(parent_grammar) ""
407    switch $tolReference {
408      Package SelectPackageRoot
409      File    SelectFileRoot
410      Console SelectConsoleRoot
[0731938]411      default {
412        ClearHiertables
413        #@D $w_tabset itemconfigure Variables -state disabled
414        #@D $w_tabset itemconfigure Functions -state disabled
415      }
[7a3f24e]416    }
[6207115]417  } elseif { [lindex $tolReference 0] == "Grammar" } {
418    #@ Argumentos pasados por atributo
[0731938]419    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock
[6207115]420    set arguments(parent_grammar) ""
421    SelectGrammar
422  } else {
[0731938]423    #@ Argumentos pasados por atributo
424    #@  + parent_grammar es usado por InsertItem para saber si es NameBlock
[ceea866]425    set arguments(parent_grammar) [$wt_tree item text $node Grammar]
[6207115]426    SelectSet $tolReference
[7a3f24e]427  }
428  NotBusy
429}
430
[6207115]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
[0731938]447  $w_tabset itemconfigure Variables -text [mc Packages] 
448  $w_tabset raise Variables 
[cc64b09]449  #@D $w_tabset itemconfigure Functions -state disabled   
[6207115]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}
[7a3f24e]460
461#/////////////////////////////////////////////////////////////////////////////
462proc ::TolInspector::SelectFileRoot { } {
463#
[6207115]464# PURPOSE: Script called each time 'Included Files' node in wt_tree is
[7a3f24e]465#          selected. Gets information about each node that must be in
[6207115]466#          included files, and inserts it in the right wtree.
[7a3f24e]467#
468#/////////////////////////////////////////////////////////////////////////////
469  variable w_tabset
[6207115]470  variable arguments
471 
472  #@ Argumentos pasados por atributo
473  #@  + index es usado e incrementado por InsertItem
474  set arguments(index) 1
[7a3f24e]475
476  ClearHiertables
[0731938]477  $w_tabset itemconfigure Variables -text [mc Files]
478  $w_tabset raise Variables
479  #@D $w_tabset itemconfigure Functions -state disabled
[6207115]480 
[7a3f24e]481  foreach f [lreverse [::tol::info included]] {
[6207115]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]       
[7a3f24e]490  }
491}
492
493#/////////////////////////////////////////////////////////////////////////////
494proc ::TolInspector::SelectConsoleRoot { } {
495#
[6207115]496# PURPOSE: Script called each time 'Console Objects' node in wt_tree is
[7a3f24e]497#          selected. Gets information about each node that must be in console,
[6207115]498#          and inserts it in the right wtree.
[7a3f24e]499#
500#/////////////////////////////////////////////////////////////////////////////
[6207115]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
[7a3f24e]507
508  ClearHiertables
[0731938]509
[7a3f24e]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] {
[6207115]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)]
[7a3f24e]524    switch [lindex $co 0 ] {
525      Code {
[6207115]526        InsertChild $gra $name $cont $path $desc 0
[7a3f24e]527      }
528      NameBlock -
529      Set {
530        #puts "switch: SelectConsoleRoot $gra"
[6207115]531        InsertChild $gra $name $cont $path $desc \
532            $arguments(index) [lindex $co 5] [lindex $co 6] [lindex $co 7]
[7a3f24e]533      }
534      default {
[6207115]535        InsertChild $gra $name $cont $path $desc
[7a3f24e]536      }
537    }
538  }
[6207115]539  set arguments(tolref) ""
[7a3f24e]540}
541
542#/////////////////////////////////////////////////////////////////////////////
543proc ::TolInspector::SelectGrammar { } {
544#
[6207115]545# PURPOSE: Script called each time a Grammar node in wt_tree is selected. Gets
[7a3f24e]546#          information about each var and function of this grammar, and
547#          inserts them in the right treeview.
548#
549#/////////////////////////////////////////////////////////////////////////////
550  variable w_tabset
[6207115]551  variable wt_tree
[7a3f24e]552  variable OnSelectItem
[6207115]553  variable arguments
554 
555  #@ Argumentos pasados por atributo
556  #@  + index es usado e incrementado por InsertItem 
557  set arguments(index) 1
558 
[7a3f24e]559  ClearHiertables
[6207115]560 
561  set selAnchor [$wt_tree selection get 0]
562 
[ceea866]563  set grammar [$wt_tree item text $selAnchor Name ]
[7a3f24e]564  if { [string compare $grammar "Anything"] } {
[6207115]565    #@ Por aquí si no es Anything
[7a3f24e]566    if { [string length $OnSelectItem] } {
567      $OnSelectItem [::tol::info grammars $grammar]
568    }
[6207115]569    foreach var [::tol::info variables $grammar] {
[7a3f24e]570      if {[catch {
571        set vinfo [::tol::info variables [list $grammar $var]]
[6207115]572        #@ Devuelve:
573        #@ Grammar Name Content Path Description [IsFile HasSubset ? Subtype?]
[7a3f24e]574      } msg]} {
575        Tol_HciWriter "<E>in ::TolInspector::SelectGrammar : $msg\n</E>"
576        continue
577      }
[6207115]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]
[7a3f24e]582      if { [string equal $grammar "Code"] } {
[6207115]583        InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [lindex $vinfo 4] 1 
[7a3f24e]584      } elseif { $grammar eq "Set" || $grammar eq "NameBlock" } {
[6207115]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]
[7a3f24e]587      } else {
[6207115]588        InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [lindex $vinfo 4]
[7a3f24e]589      } 
590    }
591  } else {
[0731938]592    $w_tabset raise Functions 
593    #@D $w_tabset itemconfigure Variables -state disabled
[7a3f24e]594  }
595  foreach fun  [::tol::info functions $grammar] {
596    set finfo [::tol::info functions $grammar $fun]
[6207115]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   
[7a3f24e]601  }
602}
603
604#/////////////////////////////////////////////////////////////////////////////
[6207115]605proc ::TolInspector::SelectSet { tolReference } {
[7a3f24e]606#
[6207115]607# PURPOSE: Script called each time a Set node in wt_tree is selected. Gets
[7a3f24e]608#          information about each child of this set, and inserts it in the
609#          right treeview.
610#
[6207115]611#/////////////////////////////////////////////////////////////////////////////
[7a3f24e]612  variable var_id 1
613  variable fun_id 1
[6207115]614  variable arguments
[7a3f24e]615 
616  ClearHiertables
617 
[6207115]618  #@ Argumentos pasados por atributo
[0731938]619  #@  + index es usado e incrementado por InsertItem
[6207115]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) ""
[0731938]624  set arguments(parent_tolref) $tolReference
[6207115]625  ::tol::forallchild $tolReference ::TolInspector::InsertChild
[7a3f24e]626}
627
628#/////////////////////////////////////////////////////////////////////////////
[6207115]629proc ::TolInspector::CloseObject { node } {
[7a3f24e]630#
[6207115]631# PURPOSE: Script called each time a node in wt_tree (left treeview) is closed.
[7a3f24e]632#
633# PARAMETERS:
[6207115]634#   node : The id of the node closed
[7a3f24e]635#
636#/////////////////////////////////////////////////////////////////////////////
[6207115]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  }   
[7a3f24e]645}
646
647#/////////////////////////////////////////////////////////////////////////////
[6207115]648proc ::TolInspector::OpenVariable { node } {
[7a3f24e]649#
[6207115]650# PURPOSE: Script called each time a node in wt_vars (right wtree) is opened.
[7a3f24e]651#
652# PARAMETERS:
[6207115]653#   node : The id of the node opened
[7a3f24e]654#
655#/////////////////////////////////////////////////////////////////////////////
[6207115]656  variable wt_tree
657  variable wt_vars
[e933fd6]658
[6207115]659  if { ![string length $node] } { return }
[b23291d]660 
[6207115]661  set treeParent [$wt_tree selection get 0]
[ceea866]662  set treeParent_tolRef [$wt_tree item text $treeParent Reference]
[b23291d]663  if { [llength $treeParent_tolRef] < 1 } return
664  if { [lindex $treeParent_tolRef 0] eq "Grammar" } return 
665 
[6207115]666  set treeNode -1
[b23291d]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
[7a3f24e]678      }
679    }
[b23291d]680  } else {
681    return
[7a3f24e]682  }
[b23291d]683 
[6207115]684  if { $treeNode != -1 } {
[7a3f24e]685    update
[6207115]686    $wt_tree selection clear   
687    $wt_tree selection add $treeNode
[7a3f24e]688  }
689}
690
691#/////////////////////////////////////////////////////////////////////////////
[6207115]692proc ::TolInspector::SelectItem { wt } {
[7a3f24e]693#
694# PURPOSE: Procedure that is executed when the user selects an element of
[6207115]695#          the trees of variables or functions.
[7a3f24e]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#
[6207115]700# PARAMETERS: path of wt_* (::wtree of variables or of functions)
[7a3f24e]701#
702#/////////////////////////////////////////////////////////////////////////////
[6207115]703# variable w_text       ;# TODO: ????
704  variable OnSelectItem ;#Command to invoke on SelectItem in wt_*
705 
[cc64b09]706  #@ entry era el 'selection anchor'
[6207115]707  set entry [$wt selection get end] ;# id of entry selected
708
[7a3f24e]709  if { [string length $OnSelectItem] } {
710    # there are associated command
711    if { [string length $entry] } {
[6207115]712      # almost one entry of wt_* selected
[ceea866]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]
[7a3f24e]718      if { [string equal \"\n\" $value] } {
719        # hasn't value       
720        set value {"\n"}
721      } else {
722        set value [string trim $value]
723      }
[ceea866]724      set desc [$wt item text $entry Description]
725      set grammar [$wt item text $entry Grammar]
726      set icon [$wt item image $entry Name]
[7a3f24e]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
[6207115]735}
Note: See TracBrowser for help on using the repository browser.