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