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

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

Refs #1933
Se prescinden de algunos métodos auxiliares creados en tolinspe para usar wtree/treectrl.
Quedan algunos por revisar.

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

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