| 1 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | # FILE : tolinspe.tcl |
|---|
| 3 | # PURPOSE : This file contains a namespace called TolInspector with its |
|---|
| 4 | # functions. Its for creating a the TOL object inspector and |
|---|
| 5 | # managing its events. |
|---|
| 6 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 7 | |
|---|
| 8 | package require bguifunction |
|---|
| 9 | package require snit |
|---|
| 10 | package require btable |
|---|
| 11 | |
|---|
| 12 | if { 0 && ![info exists toltk_script_path] } { |
|---|
| 13 | set toltk_script_path [file dirname [info script]] |
|---|
| 14 | source [file join $toltk_script_path init_toltk.tcl] |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | if {"unix" eq $::tcl_platform(platform)} { |
|---|
| 18 | foreach "but units" [list 4 -5 5 5] { |
|---|
| 19 | set comm [string map "%d $units" { |
|---|
| 20 | %W yview scroll %d units |
|---|
| 21 | }] |
|---|
| 22 | bind TreeView <$but> $comm |
|---|
| 23 | } |
|---|
| 24 | } else { |
|---|
| 25 | bind TreeView <MouseWheel> { |
|---|
| 26 | %W yview scroll [expr int(-1*%D/36)] units |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | # |
|---|
| 30 | ##///////////////////////////////////////////////////////////////////////////// |
|---|
| 31 | #proc dump { args } { |
|---|
| 32 | ## |
|---|
| 33 | ## PURPOSE: Auxiliary procedure to show a string |
|---|
| 34 | ## |
|---|
| 35 | ##///////////////////////////////////////////////////////////////////////////// |
|---|
| 36 | #puts $args |
|---|
| 37 | #} |
|---|
| 38 | |
|---|
| 39 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 40 | proc startupResources { } { |
|---|
| 41 | # |
|---|
| 42 | # PURPOSE: Establishes the preferences of the inspector |
|---|
| 43 | # |
|---|
| 44 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 45 | global tcl_platform |
|---|
| 46 | global toltk_options |
|---|
| 47 | DynamicHelp::configure -background #FFFFC0 |
|---|
| 48 | if {[string equal $tcl_platform(platform) "windows"]} { |
|---|
| 49 | set toltk_options(colors,SystemButtonFace) SystemButtonFace |
|---|
| 50 | set toltk_options(fonts,MenuNor) {Tahoma 8} |
|---|
| 51 | set toltk_options(fonts,Fixed) {{Courier New} 9} |
|---|
| 52 | set toltk_options(fonts,FixSmall) {{Courier New} 8} |
|---|
| 53 | set toltk_options(fonts,Title1) {Arial 9 bold} |
|---|
| 54 | set toltk_options(fonts,Label) {Arial 9} |
|---|
| 55 | set toltk_options(fonts,TxtSmall) {Arial 8} |
|---|
| 56 | set toltk_options(relief,ridge) ridge |
|---|
| 57 | } else { |
|---|
| 58 | set toltk_options(colors,SystemButtonFace) #d4d4d4 |
|---|
| 59 | set toltk_options(fonts,MenuNor) {-*-helvetica-medium-r} |
|---|
| 60 | set toltk_options(fonts,Fixed) {Courier 9} |
|---|
| 61 | set toltk_options(fonts,FixSmall) {-*-courier-small-r} |
|---|
| 62 | set toltk_options(fonts,Title1) {-*-helvetica-bold-r} |
|---|
| 63 | set toltk_options(fonts,Label) {-*-helvetica-medium-r} |
|---|
| 64 | set toltk_options(fonts,TxtSmall) {-*-helvetica-small-r} |
|---|
| 65 | set toltk_options(relief,ridge) raised |
|---|
| 66 | } |
|---|
| 67 | option add *background $toltk_options(colors,SystemButtonFace) user |
|---|
| 68 | option add *Label.font $toltk_options(fonts,Label) user |
|---|
| 69 | option add *Radiobutton.font $toltk_options(fonts,Label) user |
|---|
| 70 | option add *Checkbutton.font $toltk_options(fonts,Label) user |
|---|
| 71 | option add *Button.font $toltk_options(fonts,Label) user |
|---|
| 72 | option add *Menu.font $toltk_options(fonts,MenuNor) user |
|---|
| 73 | option add *TitleFrame.l.font $toltk_options(fonts,Title1) user |
|---|
| 74 | option add *Tabset.selectForeground black user |
|---|
| 75 | |
|---|
| 76 | option readfile [file join $::toltk_script_path toltk.rc] user |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 80 | namespace eval ::TolInspector { |
|---|
| 81 | # |
|---|
| 82 | # PURPOSE: The purpose of this namespace is creating a the TOL object |
|---|
| 83 | # inspector and managing its events. |
|---|
| 84 | # VARIABLES: |
|---|
| 85 | # data: |
|---|
| 86 | # regFunLst: List array with functions defined by user |
|---|
| 87 | # tolset: Name of the current TOL set variable |
|---|
| 88 | # tolindex: |
|---|
| 89 | # at_set: |
|---|
| 90 | # node_prefix: |
|---|
| 91 | # ht_tree: Tree widget containing the TOL objects (:blt::treeview) |
|---|
| 92 | # blt_tree: Tree widget containing the TOL objects (:blt::tree) |
|---|
| 93 | # w_tabset: Tabset widget containing trees of variables and functions |
|---|
| 94 | # ht_vars: Tree widget containing the tree of Variables |
|---|
| 95 | # (:blt::treeview) |
|---|
| 96 | # blt_vartree: Tree widget containing the tree of Variables (:blt::tree) |
|---|
| 97 | # data_menu: Array with data of menus |
|---|
| 98 | # group_id: |
|---|
| 99 | # ht_funcs: Tree widget containing the tree of Functions |
|---|
| 100 | # (:blt::treeview) |
|---|
| 101 | # blt_functree: Tree widget containing the tree of Functions (:blt::tree) |
|---|
| 102 | # item_data: Array to hold the full content & description of items |
|---|
| 103 | # item_id: Current index of item to insert in ht_* starting from 1 |
|---|
| 104 | # OnSelectItem: Command to invoke on SelectItem in ht_* |
|---|
| 105 | # OnBusyCmd: Command to invoke when busy |
|---|
| 106 | # SubTypeImgs: Images associated to types of set |
|---|
| 107 | # |
|---|
| 108 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 109 | variable data |
|---|
| 110 | |
|---|
| 111 | # List array with functions defined by user |
|---|
| 112 | variable regFunLst |
|---|
| 113 | |
|---|
| 114 | # name of the current TOL set variable. |
|---|
| 115 | variable tolset "" |
|---|
| 116 | variable tolindex "" |
|---|
| 117 | # estas variables desapareceran cuando ::tol::forallchild admita scripts |
|---|
| 118 | # completos y no solo nombres de proc |
|---|
| 119 | variable at_set |
|---|
| 120 | variable node_prefix |
|---|
| 121 | |
|---|
| 122 | variable gra_parent "" |
|---|
| 123 | # tree widget containing the TOL objects. |
|---|
| 124 | variable ht_tree ;# is a ::blt::treeview |
|---|
| 125 | variable blt_tree ;# is a ::blt::tree |
|---|
| 126 | |
|---|
| 127 | # tabset widget containing trees of variables and functions |
|---|
| 128 | variable w_tabset |
|---|
| 129 | |
|---|
| 130 | # list widget containing the variables. It's the window of |
|---|
| 131 | # the tab Variable |
|---|
| 132 | variable ht_vars ;# is a ::blt::treeview |
|---|
| 133 | variable blt_vartree ;# is a ::blt::tree |
|---|
| 134 | |
|---|
| 135 | variable data_menu |
|---|
| 136 | variable group_id -1 |
|---|
| 137 | |
|---|
| 138 | # list widget containing the functions. It's the window of |
|---|
| 139 | # the tab Functions |
|---|
| 140 | variable ht_funcs ;# is a ::blt::treeview |
|---|
| 141 | variable blt_functree ;# is a ::blt::tree |
|---|
| 142 | |
|---|
| 143 | # array to hold the full content & description of items |
|---|
| 144 | variable item_data |
|---|
| 145 | |
|---|
| 146 | # current index of item to insert in ht_* starting from 1 |
|---|
| 147 | variable item_id |
|---|
| 148 | |
|---|
| 149 | # tell if we are processing a SelectSet event |
|---|
| 150 | |
|---|
| 151 | #variable selecting_set |
|---|
| 152 | #variable closing |
|---|
| 153 | |
|---|
| 154 | # command to invoke on SelectItem in ht_* |
|---|
| 155 | variable OnSelectItem |
|---|
| 156 | |
|---|
| 157 | # command to invoke when busy |
|---|
| 158 | variable OnBusyCmd "" |
|---|
| 159 | |
|---|
| 160 | # images associated to types of set. |
|---|
| 161 | variable SubTypeImgs { |
|---|
| 162 | GenericSet MODFile PRJFile DIRFile TOLFile |
|---|
| 163 | BDCFile BDTFile BSTFile BMTFile BSIFile TSIFile BMIFile |
|---|
| 164 | StructuredSet TableSet} |
|---|
| 165 | |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 169 | proc ::TolInspector::SubTypeImage { idx } { |
|---|
| 170 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 171 | variable SubTypeImgs |
|---|
| 172 | |
|---|
| 173 | #Tolcon_Trace "SubTypeImage $idx = [lindex $SubTypeImgs $idx]" |
|---|
| 174 | ::Bitmap::get [lindex $SubTypeImgs $idx] |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 178 | proc ::TolInspector::CreateColumns { ht } { |
|---|
| 179 | # |
|---|
| 180 | # PURPOSE: Creates the columns (index, name, content, path, description ) |
|---|
| 181 | # of the tree of variables or functions |
|---|
| 182 | # |
|---|
| 183 | # PARAMETERS: |
|---|
| 184 | # ht: path of ::blt::treeview of variables or ::blt::treeview of functions |
|---|
| 185 | # |
|---|
| 186 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 187 | # main column ==> Name |
|---|
| 188 | $ht column configure treeView -text [mc "Name"] -justify left \ |
|---|
| 189 | -bg white -activetitlebackground gray90 -pad 3 |
|---|
| 190 | # index column |
|---|
| 191 | $ht column insert 0 Index \ |
|---|
| 192 | -bg white -justify left -activetitlebackground gray90 |
|---|
| 193 | # columns Content Path & Description |
|---|
| 194 | $ht column insert end Content Path Description Reference\ |
|---|
| 195 | -bg white -justify left -activetitlebackground gray90 -pad 3 |
|---|
| 196 | foreach c {Index Content Path Description} { |
|---|
| 197 | $ht column configure $c -text [mc "$c"] |
|---|
| 198 | } |
|---|
| 199 | # associates the command of order to each one of the titles of the |
|---|
| 200 | # columns of the trees |
|---|
| 201 | foreach column [$ht column names] { |
|---|
| 202 | $ht column configure $column \ |
|---|
| 203 | -command [list ::TolInspector::SortColumn $ht $column] |
|---|
| 204 | } |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 208 | proc ::TolInspector::SortColumn {ht column} { |
|---|
| 209 | # |
|---|
| 210 | # PURPOSE: Associates the command of order to the title of a column of the |
|---|
| 211 | # tree of variables or the tree of functions |
|---|
| 212 | # |
|---|
| 213 | # PARAMETERS: |
|---|
| 214 | # ht: path of ::blt::treeview of variables or ::blt::treeview of |
|---|
| 215 | # functions |
|---|
| 216 | # column: name of the column of this tree |
|---|
| 217 | # |
|---|
| 218 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 219 | set old [$ht sort cget -column] |
|---|
| 220 | set decreasing 0 |
|---|
| 221 | if { "$old" == "$column" } { |
|---|
| 222 | set decreasing [$ht sort cget -decreasing] |
|---|
| 223 | set decreasing [expr !$decreasing] |
|---|
| 224 | } |
|---|
| 225 | $ht sort configure -decreasing $decreasing -column $column -mode integer |
|---|
| 226 | $ht configure -flat no |
|---|
| 227 | $ht sort auto yes |
|---|
| 228 | |
|---|
| 229 | blt::busy hold $ht |
|---|
| 230 | update |
|---|
| 231 | blt::busy release $ht |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 236 | proc ::TolInspector::Create { w args } { |
|---|
| 237 | # |
|---|
| 238 | # PURPOSE: Creates the object inspector, that contains two panels with three |
|---|
| 239 | # treeviews and three trees. |
|---|
| 240 | # - One for the left side of the inspector (with grammars, |
|---|
| 241 | # included files, console objects and object's spool) |
|---|
| 242 | # - And two for the right one (one for variables tab and one for |
|---|
| 243 | # functions tab) |
|---|
| 244 | # |
|---|
| 245 | # PARAMETERS: |
|---|
| 246 | # w: path where tol inspector must be created |
|---|
| 247 | # args: list of pairs {-option value} with options for the inspector. |
|---|
| 248 | # -onselcmd Comand to execute when a node is selected |
|---|
| 249 | # -wleft relative weight of left pane |
|---|
| 250 | # -wrigth relative weight of rigth pane |
|---|
| 251 | # |
|---|
| 252 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 253 | global toltk_options |
|---|
| 254 | variable ht_tree |
|---|
| 255 | variable blt_tree |
|---|
| 256 | variable ht_vars |
|---|
| 257 | variable blt_vartree |
|---|
| 258 | variable data_menu |
|---|
| 259 | variable ht_funcs |
|---|
| 260 | variable blt_functree |
|---|
| 261 | variable w_tabset |
|---|
| 262 | variable OnSelectItem |
|---|
| 263 | variable OnBusyCmd "" |
|---|
| 264 | |
|---|
| 265 | # this should be used insted of a lot of scalar variables. |
|---|
| 266 | # but, what can we do now? |
|---|
| 267 | |
|---|
| 268 | variable widgets |
|---|
| 269 | variable data |
|---|
| 270 | |
|---|
| 271 | array set data { |
|---|
| 272 | pool,objects "" |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | array set options { |
|---|
| 276 | -onselcmd "" |
|---|
| 277 | -wleft 3 |
|---|
| 278 | -wright 7 |
|---|
| 279 | } |
|---|
| 280 | array set options $args |
|---|
| 281 | |
|---|
| 282 | # initializes the command OnSelectItem to "" |
|---|
| 283 | set OnSelectItem $options(-onselcmd) |
|---|
| 284 | |
|---|
| 285 | #variable selecting_set 0 |
|---|
| 286 | #variable closing 0 |
|---|
| 287 | |
|---|
| 288 | #upvar \#0 ::TolTk::Images Images |
|---|
| 289 | |
|---|
| 290 | # creation of PANED WINDOW MAIN |
|---|
| 291 | set pwMain [PanedWindow $w -side bottom -pad 0 -width 4] |
|---|
| 292 | # creation of pane left and pane right |
|---|
| 293 | set paneLeft [$pwMain add -weight $options(-wleft)] |
|---|
| 294 | set paneRight [$pwMain add -weight $options(-wright)] |
|---|
| 295 | set widgets(panes,left) $paneLeft |
|---|
| 296 | set widgets(panes,right) $paneRight |
|---|
| 297 | |
|---|
| 298 | # when a panel is destroyed, the item 'geometry,side' of the array variable |
|---|
| 299 | # data gives the value of the width of panel 'side' (left or right) |
|---|
| 300 | bind $paneLeft <Destroy> { |
|---|
| 301 | namespace eval ::TolInspector { |
|---|
| 302 | variable data |
|---|
| 303 | variable widgets |
|---|
| 304 | set data(geometry,left) [winfo width $widgets(panes,left)] |
|---|
| 305 | } |
|---|
| 306 | } |
|---|
| 307 | bind $paneRight <Destroy> { |
|---|
| 308 | namespace eval ::TolInspector { |
|---|
| 309 | variable data |
|---|
| 310 | variable widgets |
|---|
| 311 | set data(geometry,right) [winfo width $widgets(panes,right)] |
|---|
| 312 | } |
|---|
| 313 | } |
|---|
| 314 | # bind for destruction of paned window main |
|---|
| 315 | bind $pwMain <Destroy> ::TolInspector::Destroy |
|---|
| 316 | |
|---|
| 317 | # creation of pane left with tree with the TOL OBJECTS |
|---|
| 318 | CreatePaneLeft $paneLeft |
|---|
| 319 | # creation of the right panel with TABSET of VARIABLES and FUNCTIONS |
|---|
| 320 | CreatePaneRight $paneRight |
|---|
| 321 | # creation of the menus |
|---|
| 322 | CreateMenus |
|---|
| 323 | # packing the panedwindowmain |
|---|
| 324 | pack $pwMain -fill both -expand yes |
|---|
| 325 | |
|---|
| 326 | # esto es para evitar que aparezca el icono open cuando |
|---|
| 327 | # relleno estando el mouse sobre ht_* |
|---|
| 328 | $ht_vars bind Entry <Enter> "" |
|---|
| 329 | $ht_vars bind Entry <Leave> "" |
|---|
| 330 | $ht_funcs bind Entry <Enter> "" |
|---|
| 331 | $ht_funcs bind Entry <Leave> "" |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 335 | proc ::TolInspector::CreatePaneLeft { paneLeft } { |
|---|
| 336 | # |
|---|
| 337 | # PURPOSE: Creation of TREE LEFT with the TOL OBJECTS |
|---|
| 338 | # |
|---|
| 339 | # PARAMETERS: |
|---|
| 340 | # paneLeft: path of the pane of the left in TolInspector |
|---|
| 341 | # |
|---|
| 342 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 343 | global toltk_options |
|---|
| 344 | variable blt_tree |
|---|
| 345 | variable ht_tree |
|---|
| 346 | |
|---|
| 347 | # creation of the ScrolledWindow of the left side |
|---|
| 348 | set sw1 [ScrolledWindow $paneLeft.sw -ipad 0 -borderwidth 0 -scrollbar both ] |
|---|
| 349 | # creation of the left tree |
|---|
| 350 | set blt_tree [::blt::tree create tree$sw1.ht] |
|---|
| 351 | set ht_tree [::blt::treeview $sw1.ht -tree $blt_tree -bg white \ |
|---|
| 352 | -hideroot no -activeicons "" \ |
|---|
| 353 | -selectbackground gray75 -selectforeground black \ |
|---|
| 354 | -selectcommand ::TolInspector::SelectObject \ |
|---|
| 355 | -highlightthickness 0 -font $toltk_options(fonts,Label)] |
|---|
| 356 | # configuration of the left tree |
|---|
| 357 | $ht_tree configure \ |
|---|
| 358 | -closecommand "::TolInspector::CloseObject %#" \ |
|---|
| 359 | -opencommand "::TolInspector::OpenObject %#" |
|---|
| 360 | $ht_tree style configure text -bg white |
|---|
| 361 | $ht_tree column configure treeView -bg white |
|---|
| 362 | $ht_tree column insert end FileName -hide true |
|---|
| 363 | # creation of the root node "Tol Objects" |
|---|
| 364 | set img [::Bitmap::get Objects] |
|---|
| 365 | $ht_tree entry configure root -label [mc "Tol Objects"]\ |
|---|
| 366 | -icons [list $img $img] |
|---|
| 367 | # creation of the node father "Grammars" |
|---|
| 368 | set img [::Bitmap::get Grammars] |
|---|
| 369 | set blt_idx [$blt_tree insert root -label "root-grammars"\ |
|---|
| 370 | -tags "root-grammars"] |
|---|
| 371 | $ht_tree entry configure $blt_idx -label [mc "Grammars"]\ |
|---|
| 372 | -icons [list $img $img] |
|---|
| 373 | # Inserts in the node of grammars a node by each grammar that exists in Tol |
|---|
| 374 | InsertGrammars |
|---|
| 375 | # creation of the node father "Included Files" |
|---|
| 376 | set img [::Bitmap::get "Files"] |
|---|
| 377 | set blt_idx [$blt_tree insert root -label "root-files" -tags "root-files"] |
|---|
| 378 | $ht_tree entry configure $blt_idx -label [mc "Included Files"] \ |
|---|
| 379 | -icons [list $img $img] -button yes |
|---|
| 380 | # creation of the node father "Console Objects" |
|---|
| 381 | set img [::Bitmap::get "Console"] |
|---|
| 382 | set blt_idx [$blt_tree insert root -label "root-console"\ |
|---|
| 383 | -tags "root-console"] |
|---|
| 384 | $ht_tree entry configure $blt_idx -label [mc "Console Objects"] \ |
|---|
| 385 | -icons [list $img $img] -button yes |
|---|
| 386 | # creation of the node father "Objects' Spool" |
|---|
| 387 | set img [::Bitmap::get "pool"] |
|---|
| 388 | set blt_idx [$blt_tree insert root -label "root-pool" -tags "root-pool"] |
|---|
| 389 | $ht_tree entry configure $blt_idx -label [mc "Objects' Spool"] \ |
|---|
| 390 | -icons [list $img $img] -button yes |
|---|
| 391 | # associates the tree to scrolled window |
|---|
| 392 | $sw1 setwidget $ht_tree |
|---|
| 393 | # packing |
|---|
| 394 | pack $sw1 -fill both -expand yes |
|---|
| 395 | # bind the focus on tree |
|---|
| 396 | bind $ht_tree <Button-1> "::focus $ht_tree" |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 400 | proc ::TolInspector::CreatePaneRight { paneRight } { |
|---|
| 401 | # |
|---|
| 402 | # PURPOSE: Creation of the right pane with TABSET with VARIABLES and FUNCTIONS |
|---|
| 403 | # |
|---|
| 404 | # PARAMETERS: |
|---|
| 405 | # paneLeft: path of the pane of the right in TolInspector |
|---|
| 406 | # |
|---|
| 407 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 408 | global toltk_options |
|---|
| 409 | variable w_tabset |
|---|
| 410 | variable blt_vartree |
|---|
| 411 | variable ht_vars |
|---|
| 412 | variable blt_functree |
|---|
| 413 | variable ht_funcs |
|---|
| 414 | |
|---|
| 415 | # creates the tabset to display the variables & functions |
|---|
| 416 | #set w_tabset [::blt::tabset $paneRight.ts -relief flat\ |
|---|
| 417 | -bd 0 -outerpad 0 -tier 2 -slant none -textside top \ |
|---|
| 418 | -highlightthickness 0 -side left -rotate 90] |
|---|
| 419 | set w_tabset [::blt::tabset $paneRight.ts -relief flat\ |
|---|
| 420 | -bd 0 -outerpad 0 -tier 2 -slant right -textside right \ |
|---|
| 421 | -highlightthickness 0] |
|---|
| 422 | # creates the scrolled windows for each one of the tabs |
|---|
| 423 | set sw21 [ScrolledWindow $w_tabset.sw1] |
|---|
| 424 | set sw22 [ScrolledWindow $w_tabset.sw2] |
|---|
| 425 | # inserts in the tabset the tabs of functions and variables |
|---|
| 426 | $w_tabset insert end \ |
|---|
| 427 | Variables -text [mc Variables] -selectbackground \#d9d9d9 -bg gray75 \ |
|---|
| 428 | -image [::Bitmap::get Variables] -pady 0\ |
|---|
| 429 | Functions -text [mc Functions] -selectbackground \#d9d9d9 -bg gray75 \ |
|---|
| 430 | -image [::Bitmap::get Functions] -pady 0 |
|---|
| 431 | |
|---|
| 432 | # Creation of the right TREE RIGHT with VARIABLES |
|---|
| 433 | set blt_vartree [::blt::tree create tree$sw21.vars] |
|---|
| 434 | set ht_vars [::blt::treeview $sw21.vars -tree $blt_vartree -flat no\ |
|---|
| 435 | -bg white -hideroot yes -linewidth 0 -activeicons {}\ |
|---|
| 436 | -selectmode multiple\ |
|---|
| 437 | -selectbackground gray75 -selectforeground black \ |
|---|
| 438 | -highlightthickness 0 -font $toltk_options(fonts,Label)] |
|---|
| 439 | #tv_ordered_selection tvsel -tv $ht_vars |
|---|
| 440 | # configuration of the tree of variables |
|---|
| 441 | $ht_vars configure \ |
|---|
| 442 | -opencommand "::TolInspector::OpenVariable %#" \ |
|---|
| 443 | -selectcommand "::TolInspector::SelectItem $ht_vars" |
|---|
| 444 | $ht_vars style configure text -bg white |
|---|
| 445 | bind $ht_vars <Button-1> "::focus $ht_vars" |
|---|
| 446 | |
|---|
| 447 | # Creation of the right TREE RIGHT with FUNCTIONS |
|---|
| 448 | set blt_functree [::blt::tree create tree$sw22.funcs] |
|---|
| 449 | set ht_funcs [::blt::treeview $sw22.funcs -tree $blt_functree -flat no\ |
|---|
| 450 | -bg white -hideroot yes -linewidth 0 -activeicons {} \ |
|---|
| 451 | -selectmode multiple\ |
|---|
| 452 | -selectbackground gray75 -selectforeground black \ |
|---|
| 453 | -highlightthickness 0 -font $toltk_options(fonts,Label)] |
|---|
| 454 | # configuration of the tree of functions |
|---|
| 455 | $ht_funcs configure -selectcommand "::TolInspector::SelectItem $ht_funcs" |
|---|
| 456 | $ht_funcs style configure text -bg white |
|---|
| 457 | bind $ht_funcs <Button-1> "::focus $ht_funcs" |
|---|
| 458 | |
|---|
| 459 | # associates the trees to scrolled windows |
|---|
| 460 | $sw21 setwidget $ht_vars |
|---|
| 461 | $sw22 setwidget $ht_funcs |
|---|
| 462 | # configure the tabs |
|---|
| 463 | $w_tabset tab configure Variables -window $sw21 -fill both -padx 0 |
|---|
| 464 | $w_tabset tab configure Functions -window $sw22 -fill both -padx 0 |
|---|
| 465 | # create the columns of the trees of variables and functions |
|---|
| 466 | CreateColumns $ht_vars |
|---|
| 467 | CreateColumns $ht_funcs |
|---|
| 468 | # packing the tabset |
|---|
| 469 | pack $w_tabset -fill both -expand yes |
|---|
| 470 | $w_tabset tab configure Variables\ |
|---|
| 471 | -command "::TolInspector::SelectItem $ht_vars" |
|---|
| 472 | $w_tabset tab configure Functions\ |
|---|
| 473 | -command "::TolInspector::SelectItem $ht_funcs" |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 477 | proc ::TolInspector::CreateMenus {} { |
|---|
| 478 | # |
|---|
| 479 | # PURPOSE: Create the menus of the trees |
|---|
| 480 | # |
|---|
| 481 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 482 | variable data_menu |
|---|
| 483 | variable ht_vars |
|---|
| 484 | variable ht_funcs |
|---|
| 485 | variable ht_tree |
|---|
| 486 | |
|---|
| 487 | set data_menu(main) [menu $ht_vars.m -tearoff 0] |
|---|
| 488 | set data_menu(Code,File) [menu $data_menu(main).mcof -tearoff 0] |
|---|
| 489 | set data_menu(Complex,File) [menu $data_menu(main).mcxf -tearoff 0] |
|---|
| 490 | set data_menu(Date,File) [menu $data_menu(main).mdaf -tearoff 0] |
|---|
| 491 | set data_menu(Matrix,File) [menu $data_menu(main).mmaf -tearoff 0] |
|---|
| 492 | set data_menu(VMatrix,File) [menu $data_menu(main).mvmf -tearoff 0] |
|---|
| 493 | set data_menu(Polyn,File) [menu $data_menu(main).mpof -tearoff 0] |
|---|
| 494 | set data_menu(Ratio,File) [menu $data_menu(main).mraf -tearoff 0] |
|---|
| 495 | set data_menu(Real,File) [menu $data_menu(main).mref -tearoff 0] |
|---|
| 496 | set data_menu(Serie,File) [menu $data_menu(main).msef -tearoff 0] |
|---|
| 497 | set data_menu(Set,File) [menu $data_menu(main).mstf -tearoff 0] |
|---|
| 498 | set data_menu(File,File) [menu $data_menu(main).mfif -tearoff 0] |
|---|
| 499 | set data_menu(Anything,File) [menu $data_menu(main).mspf -tearoff 0] |
|---|
| 500 | set data_menu(Text,File) [menu $data_menu(main).mtef -tearoff 0] |
|---|
| 501 | set data_menu(TimeSet,File) [menu $data_menu(main).mtif -tearoff 0] |
|---|
| 502 | set data_menu(NameBlock,File) [menu $data_menu(main).mnbf -tearoff 0] |
|---|
| 503 | |
|---|
| 504 | set data_menu(Code,Functions) [menu $data_menu(main).mcofu -tearoff 0] |
|---|
| 505 | set data_menu(Complex,Functions) [menu $data_menu(main).mcxfu -tearoff 0] |
|---|
| 506 | set data_menu(Date,Functions) [menu $data_menu(main).mdafu -tearoff 0] |
|---|
| 507 | set data_menu(Matrix,Functions) [menu $data_menu(main).mmafu -tearoff 0] |
|---|
| 508 | set data_menu(VMatrix,Functions) [menu $data_menu(main).mvmfu -tearoff 0] |
|---|
| 509 | set data_menu(Polyn,Functions) [menu $data_menu(main).mpofu -tearoff 0] |
|---|
| 510 | set data_menu(Ratio,Functions) [menu $data_menu(main).mrafu -tearoff 0] |
|---|
| 511 | set data_menu(Real,Functions) [menu $data_menu(main).mrefu -tearoff 0] |
|---|
| 512 | set data_menu(Serie,Functions) [menu $data_menu(main).msefu -tearoff 0] |
|---|
| 513 | set data_menu(Set,Functions) [menu $data_menu(main).mstfu -tearoff 0] |
|---|
| 514 | set data_menu(File,Functions) [menu $data_menu(main).mfifu -tearoff 0] |
|---|
| 515 | set data_menu(Anything,Functions) [menu $data_menu(main).mspfu -tearoff 0] |
|---|
| 516 | set data_menu(Text,Functions) [menu $data_menu(main).mtefu -tearoff 0] |
|---|
| 517 | set data_menu(TimeSet,Functions) [menu $data_menu(main).mtifu -tearoff 0] |
|---|
| 518 | set data_menu(NameBlock,Functions) [menu $data_menu(main).mnbfu -tearoff 0] |
|---|
| 519 | |
|---|
| 520 | set data_menu(Matrix,Table) [menu $data_menu(main).mmat -tearoff 0] |
|---|
| 521 | set data_menu(Matrix,Export) [menu $data_menu(main).mmae -tearoff 0] |
|---|
| 522 | set data_menu(Matrix,Draw) [menu $data_menu(main).mmac -tearoff 0] |
|---|
| 523 | set data_menu(Matrix,Export,BDT) [menu $data_menu(main).mmaebdt -tearoff 0] |
|---|
| 524 | set data_menu(Serie,DrawAutocor) [menu $data_menu(main).mseda -tearoff 0] |
|---|
| 525 | set data_menu(Serie,TableAutocor) [menu $data_menu(main).mseta -tearoff 0] |
|---|
| 526 | set data_menu(Set,Table) [menu $data_menu(main).mstt -tearoff 0] |
|---|
| 527 | set data_menu(Set,Table2) [menu $data_menu(main).mstt2 -tearoff 0] |
|---|
| 528 | set data_menu(Set,Draw) [menu $data_menu(main).mstd -tearoff 0] |
|---|
| 529 | set data_menu(Set,Draw,Special) [menu $data_menu(main).mstds -tearoff 0] |
|---|
| 530 | set data_menu(Set,Draw,Special,M) [menu $data_menu(main).mstdsm -tearoff 0] |
|---|
| 531 | set data_menu(File,View) [menu $data_menu(main).mfiv -tearoff 0] |
|---|
| 532 | set data_menu(File,Decompile) [menu $data_menu(main).mfid -tearoff 0] |
|---|
| 533 | set data_menu(TimeSet,View) [menu $data_menu(main).mtiv -tearoff 0] |
|---|
| 534 | #$ht_vars bind Entry <Button-3> +[$ht_vars bind Entry <Button-1>] |
|---|
| 535 | |
|---|
| 536 | # composes the menus for each one of the trees, depending the node |
|---|
| 537 | # that is selected |
|---|
| 538 | $ht_vars bind all <Button-3> +[list ::TolInspector::PostVariable %X %Y] |
|---|
| 539 | $ht_funcs bind all <Button-3> +[list ::TolInspector::PostFunction %X %Y] |
|---|
| 540 | $ht_tree bind all <Button-3> +[list ::TolInspector::PostTree %X %Y] |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 544 | proc ::TolInspector::GetWeight { pane } { |
|---|
| 545 | # |
|---|
| 546 | # PURPOSE: Set data(geometry,$pane) to the value of the current geometry |
|---|
| 547 | # of the pane |
|---|
| 548 | # |
|---|
| 549 | # PARAMETERS: |
|---|
| 550 | # pane -> string with a value "left" or "right" for each one of panels |
|---|
| 551 | # |
|---|
| 552 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 553 | variable widgets |
|---|
| 554 | variable data |
|---|
| 555 | |
|---|
| 556 | if {[winfo exists $widgets(panes,$pane)]} { |
|---|
| 557 | set data(geometry,$pane) [winfo width $widgets(panes,$pane)] |
|---|
| 558 | } |
|---|
| 559 | set data(geometry,$pane) |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 563 | proc ::TolInspector::Destroy { } { |
|---|
| 564 | # |
|---|
| 565 | # PURPOSE: Destroys the three trees of TolInspector and array with full |
|---|
| 566 | # content & description of items |
|---|
| 567 | # |
|---|
| 568 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 569 | variable blt_tree |
|---|
| 570 | variable blt_vartree |
|---|
| 571 | variable blt_functree |
|---|
| 572 | variable item_data |
|---|
| 573 | |
|---|
| 574 | ::blt::tree destroy $blt_tree |
|---|
| 575 | ::blt::tree destroy $blt_vartree |
|---|
| 576 | ::blt::tree destroy $blt_functree |
|---|
| 577 | unset item_data |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 581 | proc ::TolInspector::OneLine { str } { |
|---|
| 582 | # |
|---|
| 583 | # PURPOSE: Gives a string with carriage returns \n and return this string |
|---|
| 584 | # until the first carriage return that appears after a word, |
|---|
| 585 | # replacing the rest by ... if some word existed after that carriage |
|---|
| 586 | # return |
|---|
| 587 | # Examples: the str "a\n b c" returns "a..." |
|---|
| 588 | # "\n \n a\n b" returns "a..." |
|---|
| 589 | # "\n \n a\n" returns "a" |
|---|
| 590 | # PARAMETERS: |
|---|
| 591 | # str -> string with \n |
|---|
| 592 | # |
|---|
| 593 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 594 | set str [string trim $str] |
|---|
| 595 | set lnidx [string first "\n" $str] |
|---|
| 596 | if { $lnidx != -1 } { |
|---|
| 597 | if { [incr lnidx -1] > 0 } { |
|---|
| 598 | return "[string range $str 0 $lnidx]..." |
|---|
| 599 | } else { |
|---|
| 600 | return "..." |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | set str |
|---|
| 604 | } |
|---|
| 605 | |
|---|
| 606 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 607 | proc ::TolInspector::TrimContent { grammar content } { |
|---|
| 608 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 609 | if { [string equal "Real" $grammar] } { |
|---|
| 610 | return [::TolConsole::Format $content] |
|---|
| 611 | } else { |
|---|
| 612 | if { [string equal \"\n\" $content] } { |
|---|
| 613 | set content {"\n"} |
|---|
| 614 | } |
|---|
| 615 | return [OneLine $content] |
|---|
| 616 | set content [string trim $content] |
|---|
| 617 | set lnidx [string first "\n" $content] |
|---|
| 618 | if { $lnidx != -1 } { |
|---|
| 619 | if { [incr lnidx -1] > 0 } { |
|---|
| 620 | return "[string range $content 0 $lnidx]..." |
|---|
| 621 | } else { |
|---|
| 622 | return "..." |
|---|
| 623 | } |
|---|
| 624 | } |
|---|
| 625 | set content |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 630 | proc ::TolInspector::_InsertChild { args } { |
|---|
| 631 | # |
|---|
| 632 | # PURPOSE: este proc es para ancapsular desc en una lista |
|---|
| 633 | # |
|---|
| 634 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 635 | eval InsertChild [lrange $args 0 3] [list [list [lindex $args 4]]] [lrange $args 5 end] |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 639 | proc ::TolInspector::InsertChild { args } { |
|---|
| 640 | # |
|---|
| 641 | # PURPOSE: Inserts a node in the corresponding treeview of the right panel. |
|---|
| 642 | # |
|---|
| 643 | # PARAMETERS: |
|---|
| 644 | # args[0] -> grammar |
|---|
| 645 | # args[1] -> name |
|---|
| 646 | # args[2] -> content |
|---|
| 647 | # args[3] -> path |
|---|
| 648 | # args[4] -> desc |
|---|
| 649 | # Si grammar == "Code" |
|---|
| 650 | # args[5] -> ¿es una variable? |
|---|
| 651 | # Si grammar == "Set" || "NameBlock" |
|---|
| 652 | # args[5] -> indexes of the set |
|---|
| 653 | # args[6] -> is file? |
|---|
| 654 | # args[7] -> has subset? |
|---|
| 655 | # args[8] -> subtype |
|---|
| 656 | # args[end] -> "Reference {reference}" end > 4 |
|---|
| 657 | # |
|---|
| 658 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 659 | variable ht_vars |
|---|
| 660 | variable blt_vartree |
|---|
| 661 | variable ht_funcs |
|---|
| 662 | variable blt_functree |
|---|
| 663 | variable gra_parent |
|---|
| 664 | |
|---|
| 665 | #puts "InsertChild: args=$args [info level 1]" |
|---|
| 666 | set grammar [lindex $args 0] |
|---|
| 667 | set name [ lindex $args 1 ] |
|---|
| 668 | set content [lindex $args 2] |
|---|
| 669 | set path [lindex $args 3] |
|---|
| 670 | set desc [lindex [lindex $args 4] 0] |
|---|
| 671 | |
|---|
| 672 | |
|---|
| 673 | if {[llength [lindex $args end]] >= 2} { |
|---|
| 674 | #set ref [list [lindex [lindex $args end] 0] [lrange [lindex $args end] 1 end]] |
|---|
| 675 | set ref [concat [lindex [lindex $args end] 0] [lrange [lindex $args end] 1 end]] |
|---|
| 676 | } else { |
|---|
| 677 | set ref "" |
|---|
| 678 | } |
|---|
| 679 | #puts "InsertChild: ref=$ref" |
|---|
| 680 | switch $grammar { |
|---|
| 681 | Code { |
|---|
| 682 | set isvar [lindex $args 5] |
|---|
| 683 | if { [string equal $isvar "1"] } { |
|---|
| 684 | Insert_HTItem $ht_vars $blt_vartree $grammar $name $content $path $desc $ref |
|---|
| 685 | } else { |
|---|
| 686 | Insert_HTItem $ht_funcs $blt_functree $grammar $name $content $path $desc $ref |
|---|
| 687 | } |
|---|
| 688 | } |
|---|
| 689 | NameBlock - |
|---|
| 690 | Set { |
|---|
| 691 | # args[5] is the index of the set object |
|---|
| 692 | # args[6] is the flag file |
|---|
| 693 | # args[8] is the subtype |
|---|
| 694 | Insert_HTItem $ht_vars $blt_vartree $grammar $name $content $path $desc \ |
|---|
| 695 | [lindex $args 5] [lindex $args 6] [lindex $args 8] $ref |
|---|
| 696 | } |
|---|
| 697 | default { |
|---|
| 698 | Insert_HTItem $ht_vars $blt_vartree $grammar $name $content $path $desc $ref |
|---|
| 699 | } |
|---|
| 700 | } |
|---|
| 701 | } |
|---|
| 702 | |
|---|
| 703 | # si grammar == "Set" |
|---|
| 704 | # args[0] -> indexes |
|---|
| 705 | # args[1] -> ¿is a file? |
|---|
| 706 | # args[2] -> subtype |
|---|
| 707 | |
|---|
| 708 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 709 | proc ::TolInspector::Insert_HTItem {ht tree grammar name content path desc args} { |
|---|
| 710 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 711 | variable ht_tree |
|---|
| 712 | variable tolset |
|---|
| 713 | variable tolindex |
|---|
| 714 | variable node_prefix |
|---|
| 715 | variable item_data |
|---|
| 716 | variable item_id |
|---|
| 717 | variable gra_parent |
|---|
| 718 | |
|---|
| 719 | #upvar \#0 ::TolTk::Images Images |
|---|
| 720 | |
|---|
| 721 | if { $gra_parent eq "NameBlock" } { |
|---|
| 722 | array set info_member [ FilterNameBlockMember $name ] |
|---|
| 723 | if { !$info_member(-show) } { |
|---|
| 724 | incr item_id |
|---|
| 725 | return |
|---|
| 726 | } |
|---|
| 727 | set fcolor $info_member(-fcolor) |
|---|
| 728 | } else { |
|---|
| 729 | set fcolor "black" |
|---|
| 730 | } |
|---|
| 731 | |
|---|
| 732 | set brief_cont [TrimContent $grammar $content] |
|---|
| 733 | set brief_desc [TrimContent DONTCARE $desc] |
|---|
| 734 | #puts "Insert_HTItem: args=$args" |
|---|
| 735 | if {[llength [lindex $args end]] >= 2} { |
|---|
| 736 | set ref_value [lindex [lindex $args end] 1] |
|---|
| 737 | } elseif {[regexp -- "console" $node_prefix]} { |
|---|
| 738 | set ref_value [list Console] |
|---|
| 739 | eval lappend ref_value $tolindex $item_id |
|---|
| 740 | } else { |
|---|
| 741 | set ref_value "" |
|---|
| 742 | } |
|---|
| 743 | |
|---|
| 744 | #puts "Insert_HTItem: ref_value=$ref_value tolindex=$tolindex item_id=$item_id node_prefix=$node_prefix" |
|---|
| 745 | #puts "\ttolset=$tolset" |
|---|
| 746 | set data [list Index $item_id \ |
|---|
| 747 | Content $brief_cont \ |
|---|
| 748 | Path $path \ |
|---|
| 749 | Description $brief_desc \ |
|---|
| 750 | Reference $ref_value] |
|---|
| 751 | |
|---|
| 752 | if {$grammar eq "Set" || $grammar eq "NameBlock"} { |
|---|
| 753 | if {[string length $tolset] || [regexp "console" $node_prefix]} { |
|---|
| 754 | # OJO: si tolset == "" no implica que no estemos en un Set |
|---|
| 755 | # por ejemplo un Set de la consola. |
|---|
| 756 | set item [GetItemName $node_prefix [lindex $args 0]] |
|---|
| 757 | #Tolcon_Trace "InsertHTItem. item(if): $item" |
|---|
| 758 | } else { |
|---|
| 759 | switch [lindex [$ht_tree get -full anchor] end] { |
|---|
| 760 | root-files { |
|---|
| 761 | set item file$item_id |
|---|
| 762 | } |
|---|
| 763 | root-console { |
|---|
| 764 | set item console$item_id |
|---|
| 765 | } |
|---|
| 766 | root-pool { |
|---|
| 767 | set item pool$item_id |
|---|
| 768 | } |
|---|
| 769 | default { |
|---|
| 770 | set item item$item_id |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | } |
|---|
| 774 | # aqui hay que pedir el bitmap en funcion del subtype: args[2] |
|---|
| 775 | if {$grammar eq "Set"} { |
|---|
| 776 | set icon_grammar [SubTypeImage [lindex $args 2]] |
|---|
| 777 | } else { |
|---|
| 778 | set icon_grammar [::Bitmap::get "NameBlock"] |
|---|
| 779 | } |
|---|
| 780 | } else { |
|---|
| 781 | set item "item$item_id" |
|---|
| 782 | set icon_grammar [::Bitmap::get $grammar] |
|---|
| 783 | } |
|---|
| 784 | set idnew [$tree insert 0 -label $item] |
|---|
| 785 | set label [OneLine $name] |
|---|
| 786 | if {$label eq ""} { |
|---|
| 787 | if {[set label $brief_desc] eq ""} { |
|---|
| 788 | set label " " |
|---|
| 789 | } |
|---|
| 790 | } |
|---|
| 791 | $ht entry configure $idnew -label $label \ |
|---|
| 792 | -icons [list $icon_grammar $icon_grammar] -data $data \ |
|---|
| 793 | -foreground $fcolor |
|---|
| 794 | set item_data($item_id) [list $content $desc $grammar] |
|---|
| 795 | incr item_id |
|---|
| 796 | } |
|---|
| 797 | |
|---|
| 798 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 799 | proc ::TolInspector::ClearHiertables { } { |
|---|
| 800 | # |
|---|
| 801 | # PURPOSE: |
|---|
| 802 | # |
|---|
| 803 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 804 | variable w_tabset |
|---|
| 805 | variable ht_vars |
|---|
| 806 | variable ht_funcs |
|---|
| 807 | variable item_data |
|---|
| 808 | variable OnSelectItem |
|---|
| 809 | |
|---|
| 810 | $ht_vars entry delete root 0 end |
|---|
| 811 | $ht_funcs entry delete root 0 end |
|---|
| 812 | $ht_vars column configure Index -hide no |
|---|
| 813 | $ht_funcs column configure Index -hide no |
|---|
| 814 | catch { |
|---|
| 815 | unset item_data |
|---|
| 816 | } |
|---|
| 817 | $w_tabset tab configure Variables -text [mc Variables] -state normal |
|---|
| 818 | $w_tabset tab configure Functions -state normal |
|---|
| 819 | |
|---|
| 820 | if { [string length $OnSelectItem] } { |
|---|
| 821 | $OnSelectItem |
|---|
| 822 | } |
|---|
| 823 | } |
|---|
| 824 | |
|---|
| 825 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 826 | proc ::TolInspector::OpenObject { index } { |
|---|
| 827 | # |
|---|
| 828 | # PURPOSE: Script called each time a node in ht_tree (left treeview) is |
|---|
| 829 | # opened. |
|---|
| 830 | # |
|---|
| 831 | # PARAMETERS: |
|---|
| 832 | # index : The id of the node opened |
|---|
| 833 | # |
|---|
| 834 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 835 | variable tolset |
|---|
| 836 | variable tolindex |
|---|
| 837 | variable at_set |
|---|
| 838 | variable node_prefix |
|---|
| 839 | variable ht_tree |
|---|
| 840 | variable data |
|---|
| 841 | |
|---|
| 842 | #puts "OpenObject: index=$index" |
|---|
| 843 | set path [$ht_tree get -full $index] |
|---|
| 844 | if { $index } { |
|---|
| 845 | set parent1 [lindex $path 1] |
|---|
| 846 | if { [set isfile [string equal $parent1 "root-files"]] || |
|---|
| 847 | [set isconsole [string equal $parent1 "root-console"]] || |
|---|
| 848 | [string equal $parent1 "root-pool"] } { |
|---|
| 849 | set lpath [llength $path] |
|---|
| 850 | #puts "lpath = $lpath" |
|---|
| 851 | if { $lpath == 2 } { |
|---|
| 852 | if { $isfile } { |
|---|
| 853 | InsertFiles |
|---|
| 854 | } elseif { $isconsole } { |
|---|
| 855 | InsertConsoleObj |
|---|
| 856 | } else { |
|---|
| 857 | InsertPoolObj |
|---|
| 858 | } |
|---|
| 859 | } else { |
|---|
| 860 | #puts "OpenObject: path = $path" |
|---|
| 861 | set leaf [lindex $path end] |
|---|
| 862 | set leaf_info [split $leaf "-"] |
|---|
| 863 | set node_prefix [lindex $leaf_info 0] |
|---|
| 864 | set _tolset $tolset |
|---|
| 865 | if { [string equal $parent1 "root-pool"] } { |
|---|
| 866 | #Tolcon_Trace "OpenObject. tolset=$tolset" |
|---|
| 867 | set tolset $data(pool,reference,[lindex $leaf_info 0]) |
|---|
| 868 | #puts "OpenObject: Spool: tolset=$tolset, leaf_info=$leaf_info" |
|---|
| 869 | if { $lpath == 3 } { |
|---|
| 870 | set tolindex [lrange $tolset 1 end] |
|---|
| 871 | set tolset [lindex $tolset 0] |
|---|
| 872 | } else { |
|---|
| 873 | set tolindex [lrange $leaf_info 1 end] |
|---|
| 874 | if {[lindex $tolset 0] eq "Console"} { |
|---|
| 875 | set tolset [lindex $tolset 0] |
|---|
| 876 | } else { |
|---|
| 877 | set tolset [lrange $tolset 0 1] |
|---|
| 878 | } |
|---|
| 879 | #set tolindex [lrange $tolset 1 end] |
|---|
| 880 | #set tolset [lindex $tolset 0] |
|---|
| 881 | #lappend tolindex [lindex $leaf_info end] |
|---|
| 882 | } |
|---|
| 883 | #Tolcon_Trace "OpenObject. tolset=$tolset" |
|---|
| 884 | } elseif {[regexp -- "console(.+)" $node_prefix --> idx_con]} { |
|---|
| 885 | set tolset "Console" |
|---|
| 886 | #puts "OpenObject: Console: leaf_info = $leaf_info" |
|---|
| 887 | if {[llength $leaf_info] == 1} { |
|---|
| 888 | set tolindex $idx_con |
|---|
| 889 | } else { |
|---|
| 890 | #set tolindex [list $idx_con [lrange $leaf_info 1 end]] |
|---|
| 891 | set tolindex [lrange $leaf_info 1 end] |
|---|
| 892 | } |
|---|
| 893 | } else { |
|---|
| 894 | set idx [$ht_tree find -name $node_prefix] |
|---|
| 895 | array set aryData [$ht_tree entry cget $idx -data] |
|---|
| 896 | set tolset [list File $aryData(FileName)] |
|---|
| 897 | #set tolset [$ht_tree entry cget [$ht_tree find -name $node_prefix] -label] |
|---|
| 898 | if { $lpath == 3 } { |
|---|
| 899 | set tolindex "" |
|---|
| 900 | } else { |
|---|
| 901 | set tolindex [lrange $leaf_info 1 end] |
|---|
| 902 | } |
|---|
| 903 | } |
|---|
| 904 | Busy |
|---|
| 905 | set at_set $index |
|---|
| 906 | #set set_ref [eval list [list $tolset] $tolindex] |
|---|
| 907 | set set_ref [eval list $tolset $tolindex] |
|---|
| 908 | variable gra_parent [ GetParentGrammar $set_ref ] |
|---|
| 909 | ::tol::forallchild $set_ref ::TolInspector::InsertSubset |
|---|
| 910 | set tolset $_tolset |
|---|
| 911 | NotBusy |
|---|
| 912 | } |
|---|
| 913 | } |
|---|
| 914 | } |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 918 | proc ::TolInspector::InsertGrammars {} { |
|---|
| 919 | # |
|---|
| 920 | # PURPOSE: Inserts a node in ht_tree (left ::blt::treeview) for each TOL |
|---|
| 921 | # grammar |
|---|
| 922 | # |
|---|
| 923 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 924 | variable ht_tree |
|---|
| 925 | #upvar \#0 ::TolTk::Images Images |
|---|
| 926 | |
|---|
| 927 | set id 1 |
|---|
| 928 | foreach g [::tol::info grammars] { |
|---|
| 929 | # takes an icon with the same name that the grammar |
|---|
| 930 | set img [::Bitmap::get $g] |
|---|
| 931 | $ht_tree insert -at "root-grammars" end grammar-$id -label $g\ |
|---|
| 932 | -icons [list $img $img] |
|---|
| 933 | incr id |
|---|
| 934 | } |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 938 | proc ::TolInspector::InsertFiles { } { |
|---|
| 939 | # |
|---|
| 940 | # PURPOSE: Inserts a node in ht_tree (left treeview) for each Included file |
|---|
| 941 | # |
|---|
| 942 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 943 | variable ht_tree |
|---|
| 944 | variable blt_tree |
|---|
| 945 | |
|---|
| 946 | set index 1 |
|---|
| 947 | #set img [::Bitmap::get "File"] |
|---|
| 948 | foreach f [lreverse [::tol::info included]] { |
|---|
| 949 | set finfo [::tol::info included $f] |
|---|
| 950 | set button [lindex $finfo 3] |
|---|
| 951 | set subtype [lindex $finfo 4] |
|---|
| 952 | # tomar la imagen en funcion del subtype |
|---|
| 953 | set img [SubTypeImage $subtype] |
|---|
| 954 | set tag_file "file$index" |
|---|
| 955 | set blt_idx [$blt_tree insert "root-files" \ |
|---|
| 956 | -label $tag_file -tags $tag_file] |
|---|
| 957 | # Tail del fichero. PodrÃa hacerse configurable por el usuario |
|---|
| 958 | set label [file tail $f] |
|---|
| 959 | $ht_tree entry configure $blt_idx -label $label\ |
|---|
| 960 | -icons [list $img $img] -button $button -data [list "FileName" $f] |
|---|
| 961 | incr index |
|---|
| 962 | } |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 966 | proc ::TolInspector::InsertConsoleObj { } { |
|---|
| 967 | # |
|---|
| 968 | # PURPOSE: Inserts a node in ht_tree (left treeview) for each Console object |
|---|
| 969 | # |
|---|
| 970 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 971 | variable ht_tree |
|---|
| 972 | variable has_button 0 |
|---|
| 973 | |
|---|
| 974 | set index 1 |
|---|
| 975 | foreach co [::tol::console stack list] { |
|---|
| 976 | set grammar [lindex $co 0] |
|---|
| 977 | if {$grammar eq "Set" || $grammar eq "NameBlock"} { |
|---|
| 978 | # SUBTYPE: icono en funcion de [lindex $co 7] |
|---|
| 979 | if {$grammar eq "Set"} { |
|---|
| 980 | set icon [SubTypeImage [lindex $co 7]] |
|---|
| 981 | } else { |
|---|
| 982 | set icon [::Bitmap::get "NameBlock"] |
|---|
| 983 | } |
|---|
| 984 | set name [lindex $co 1] |
|---|
| 985 | #tol::forallchild $name HasSubset |
|---|
| 986 | set has_button [lindex $co 6] |
|---|
| 987 | if {$name eq ""} { |
|---|
| 988 | if {[set name [TrimContent DONTCARE [lindex $co 4]]] eq ""} { |
|---|
| 989 | set name " " |
|---|
| 990 | } |
|---|
| 991 | } |
|---|
| 992 | $ht_tree insert -at root-console end "console$index" -label $name \ |
|---|
| 993 | -icons [list $icon $icon] -button $has_button -data [list "FileName" $index] |
|---|
| 994 | } |
|---|
| 995 | incr index |
|---|
| 996 | } |
|---|
| 997 | } |
|---|
| 998 | |
|---|
| 999 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1000 | proc ::TolInspector::InsertPoolObj { } { |
|---|
| 1001 | # |
|---|
| 1002 | # PURPOSE: Inserts a node in ht_tree (left treeview) for each object in Spool |
|---|
| 1003 | # |
|---|
| 1004 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1005 | variable data |
|---|
| 1006 | variable ht_tree |
|---|
| 1007 | array unset data pool,reference,* |
|---|
| 1008 | set index 1 |
|---|
| 1009 | |
|---|
| 1010 | foreach _obj $data(pool,objects) { |
|---|
| 1011 | #Tolcon_Trace "InsertPoolObj. _obj=$_obj" |
|---|
| 1012 | array set obj $_obj |
|---|
| 1013 | if { [string equal $obj(grammar) "Set"] || [string equal $obj(grammar) "NameBlock"] } { |
|---|
| 1014 | #Si la referencia del objeto tiene espacios en la ruta, el |
|---|
| 1015 | # llength me darÃa > 1, por eso añado la 2ª parte de la condicion |
|---|
| 1016 | if { ([llength $obj(reference)] > 1) && \ |
|---|
| 1017 | ![string equal $obj(reference) $obj(objName)]} { |
|---|
| 1018 | set infoObj [::tol::info variable $obj(reference)] |
|---|
| 1019 | } else { |
|---|
| 1020 | if {[catch { set infoObj [concat [list "Set" $obj(reference)] \ |
|---|
| 1021 | [::tol::info included $obj(reference)]] }]} { |
|---|
| 1022 | set infoObj [concat [list "Set" $obj(reference)] \ |
|---|
| 1023 | [::tol::info variable "Set" $obj(reference)]] |
|---|
| 1024 | } else { |
|---|
| 1025 | # Insertamos el 1 de isFile |
|---|
| 1026 | set infoObj [linsert $infoObj 5 1] |
|---|
| 1027 | } |
|---|
| 1028 | } |
|---|
| 1029 | #Tolcon_Trace "infoObj=$infoObj" |
|---|
| 1030 | if {[set name [file tail [lindex $infoObj 1]]] eq ""} { |
|---|
| 1031 | if {[set name [TrimContent DONTCARE [lindex $infoObj 4]]] eq ""} { |
|---|
| 1032 | set name " " |
|---|
| 1033 | } |
|---|
| 1034 | } |
|---|
| 1035 | set has_button [lindex $infoObj 6] |
|---|
| 1036 | #set icon [SubTypeImage [lindex $infoObj 7]] |
|---|
| 1037 | if {$obj(grammar) eq "Set"} { |
|---|
| 1038 | set icon [SubTypeImage [lindex $infoObj 7]] |
|---|
| 1039 | } else { |
|---|
| 1040 | set icon [::Bitmap::get "NameBlock"] |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | $ht_tree insert -at root-pool end "pool$index" -label $name \ |
|---|
| 1044 | -icon [list $icon $icon] -button $has_button |
|---|
| 1045 | #Tolcon_Trace "InsertPoolObj. name=$name" |
|---|
| 1046 | if { ([llength $obj(reference)] > 1) && \ |
|---|
| 1047 | [string equal $obj(reference) $obj(objName)]} { |
|---|
| 1048 | set obj(reference) [list $obj(reference)] |
|---|
| 1049 | } |
|---|
| 1050 | set data(pool,reference,pool$index) $obj(reference) |
|---|
| 1051 | } |
|---|
| 1052 | incr index |
|---|
| 1053 | } |
|---|
| 1054 | } |
|---|
| 1055 | |
|---|
| 1056 | proc ::TolInspector::FilterNameBlockMember { name } { |
|---|
| 1057 | set st_reg [ regexp {(.+::)?(_)?(\.)?(.*)} $name => p1 p2 p3 p4 ] |
|---|
| 1058 | if { !$st_reg } { |
|---|
| 1059 | list -show 1 -fcolor "black" -name $name |
|---|
| 1060 | } elseif { $p2 eq "_" } { |
|---|
| 1061 | if { $p3 eq "." } { |
|---|
| 1062 | # es un miembro de solo lectura |
|---|
| 1063 | list -show 1 -fcolor "gray50" -name "_.$p4" |
|---|
| 1064 | } else { |
|---|
| 1065 | # es un miembro oculto |
|---|
| 1066 | list -show 0 |
|---|
| 1067 | } |
|---|
| 1068 | } else { |
|---|
| 1069 | list -show 1 -fcolor "black" -name $p4 |
|---|
| 1070 | } |
|---|
| 1071 | } |
|---|
| 1072 | |
|---|
| 1073 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1074 | proc ::TolInspector::InsertSubset { args } { |
|---|
| 1075 | # |
|---|
| 1076 | # PURPOSE: Inserts a node in ht_tree (left treeview) for each child of a Set |
|---|
| 1077 | # |
|---|
| 1078 | # PARAMETERS: |
|---|
| 1079 | # args[0] -> grammar |
|---|
| 1080 | # args[1] -> name |
|---|
| 1081 | # args[2] -> content |
|---|
| 1082 | # args[3] -> path |
|---|
| 1083 | # args[4] -> desc |
|---|
| 1084 | # Si grammar == "Set" |
|---|
| 1085 | # args[5] -> indexes of the set |
|---|
| 1086 | # args[6] -> is file? |
|---|
| 1087 | # args[7] -> has subset? |
|---|
| 1088 | # args[8] -> subtype |
|---|
| 1089 | # |
|---|
| 1090 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1091 | variable ht_tree |
|---|
| 1092 | variable at_set |
|---|
| 1093 | variable tolset |
|---|
| 1094 | variable node_prefix |
|---|
| 1095 | variable has_button 0 |
|---|
| 1096 | variable blt_tree |
|---|
| 1097 | variable gra_parent |
|---|
| 1098 | |
|---|
| 1099 | #puts "InsertSubset, args=$args" |
|---|
| 1100 | set grammar [lindex $args 0] |
|---|
| 1101 | if {$grammar eq "Set" || $grammar eq "NameBlock"} { |
|---|
| 1102 | |
|---|
| 1103 | if { $gra_parent eq "NameBlock" } { |
|---|
| 1104 | array set info_member [ FilterNameBlockMember [ lindex $args 1 ] ] |
|---|
| 1105 | if { !$info_member(-show) } { |
|---|
| 1106 | return |
|---|
| 1107 | } |
|---|
| 1108 | set name $info_member(-name) |
|---|
| 1109 | set fcolor $info_member(-fcolor) |
|---|
| 1110 | } else { |
|---|
| 1111 | set name [ lindex $args 1 ] |
|---|
| 1112 | set fcolor "black" |
|---|
| 1113 | } |
|---|
| 1114 | set content [lindex $args 2] |
|---|
| 1115 | set idx [lindex $args 5] |
|---|
| 1116 | set isfile [lindex $args 6] |
|---|
| 1117 | set has_button [lindex $args 7] |
|---|
| 1118 | set subtype [lindex $args 8] |
|---|
| 1119 | #tol::forallchild $tolset $idx HasSubset |
|---|
| 1120 | if {$grammar eq "Set"} { |
|---|
| 1121 | set icon [SubTypeImage $subtype] |
|---|
| 1122 | } else { |
|---|
| 1123 | set icon [::Bitmap::get "NameBlock"] |
|---|
| 1124 | } |
|---|
| 1125 | # Tail por si es un fichero. PodrÃa hacerse configurable por el usuario |
|---|
| 1126 | set label [file tail $name] |
|---|
| 1127 | #puts [list InsertSubset, idx {lindex $args 5} = $idx] |
|---|
| 1128 | set idnew [ $blt_tree insert $at_set \ |
|---|
| 1129 | -label [ GetItemName $node_prefix $idx ] ] |
|---|
| 1130 | |
|---|
| 1131 | #puts "InsertSubset, node_prefix = $node_prefix" |
|---|
| 1132 | #puts "InsertSubset, idnew = $idnew" |
|---|
| 1133 | #puts "InsertSubset, -label = [GetItemName $node_prefix $idx]" |
|---|
| 1134 | |
|---|
| 1135 | if {$label eq ""} { |
|---|
| 1136 | if {[set label [TrimContent DONTCARE [lindex $args 4]]] eq ""} { |
|---|
| 1137 | set label " " |
|---|
| 1138 | } |
|---|
| 1139 | } |
|---|
| 1140 | $ht_tree entry configure $idnew -label $label -button $has_button \ |
|---|
| 1141 | -icons [list $icon $icon] -foreground $fcolor |
|---|
| 1142 | } |
|---|
| 1143 | } |
|---|
| 1144 | |
|---|
| 1145 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1146 | proc ::TolInspector::ClearConsoleObj { } { |
|---|
| 1147 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1148 | variable ht_tree |
|---|
| 1149 | variable data |
|---|
| 1150 | |
|---|
| 1151 | set idx_con [$ht_tree index root-console] |
|---|
| 1152 | $ht_tree entry delete $idx_con 0 end |
|---|
| 1153 | |
|---|
| 1154 | #Quitamos del spool todos los objetos que provengan de la consola |
|---|
| 1155 | foreach _obj $data(pool,objects) { |
|---|
| 1156 | array set obj $_obj |
|---|
| 1157 | if {[string equal $obj(origin) "root-console"]} { |
|---|
| 1158 | set idx [lsearch $data(pool,objects) $_obj] |
|---|
| 1159 | set data(pool,objects) [lreplace $data(pool,objects) $idx $idx] |
|---|
| 1160 | } |
|---|
| 1161 | } |
|---|
| 1162 | UpdatePoolObj |
|---|
| 1163 | #Finalmente limpiamos el stack de la consola de tol |
|---|
| 1164 | ::tol::console stack release |
|---|
| 1165 | } |
|---|
| 1166 | |
|---|
| 1167 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1168 | proc ::TolInspector::ClearConsoleObjSel {ht} { |
|---|
| 1169 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1170 | variable vars_selected |
|---|
| 1171 | variable data |
|---|
| 1172 | |
|---|
| 1173 | foreach var $vars_selected { |
|---|
| 1174 | set name [$ht entry cget $var -label] |
|---|
| 1175 | #puts "name=$name" |
|---|
| 1176 | #Quitamos del spool todos los objetos que provengan de la consola |
|---|
| 1177 | foreach _obj $data(pool,objects) { |
|---|
| 1178 | array set obj $_obj |
|---|
| 1179 | #puts "_obj=$_obj" |
|---|
| 1180 | if {[string equal $obj(origin) "root-console"] && [string equal $obj(objName) $name]} { |
|---|
| 1181 | set idx [lsearch $data(pool,objects) $_obj] |
|---|
| 1182 | set data(pool,objects) [lreplace $data(pool,objects) $idx $idx] |
|---|
| 1183 | } |
|---|
| 1184 | } |
|---|
| 1185 | UpdatePoolObj |
|---|
| 1186 | #Finalmente quitamos el objeto de la consola de tol |
|---|
| 1187 | ::tol::console stack release $name |
|---|
| 1188 | } |
|---|
| 1189 | UpdateConsoleObj |
|---|
| 1190 | } |
|---|
| 1191 | |
|---|
| 1192 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1193 | proc ::TolInspector::UpdateFileRoot { } { |
|---|
| 1194 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1195 | variable ht_tree |
|---|
| 1196 | set open 0 |
|---|
| 1197 | set idx_file [$ht_tree index root-files] |
|---|
| 1198 | if { [$ht_tree entry isopen $idx_file] } { |
|---|
| 1199 | $ht_tree close $idx_file |
|---|
| 1200 | set open 1 |
|---|
| 1201 | } |
|---|
| 1202 | if { [$ht_tree index focus] == $idx_file } { |
|---|
| 1203 | SelectObject |
|---|
| 1204 | } |
|---|
| 1205 | if $open { |
|---|
| 1206 | $ht_tree open $idx_file |
|---|
| 1207 | } |
|---|
| 1208 | } |
|---|
| 1209 | |
|---|
| 1210 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1211 | proc ::TolInspector::UpdateConsoleObj { } { |
|---|
| 1212 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1213 | variable ht_tree |
|---|
| 1214 | |
|---|
| 1215 | set idx_con [$ht_tree index root-console] |
|---|
| 1216 | if { [$ht_tree entry isopen $idx_con] } { |
|---|
| 1217 | $ht_tree close $idx_con |
|---|
| 1218 | } |
|---|
| 1219 | $ht_tree selection anchor root-console |
|---|
| 1220 | $ht_tree selection mark root-console |
|---|
| 1221 | #Tolcon_Trace "Abierto el nodo root-console" |
|---|
| 1222 | if { [$ht_tree index focus] == $idx_con } { |
|---|
| 1223 | SelectObject |
|---|
| 1224 | } |
|---|
| 1225 | } |
|---|
| 1226 | |
|---|
| 1227 | |
|---|
| 1228 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1229 | proc ::TolInspector::UpdatePoolObj { } { |
|---|
| 1230 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1231 | variable ht_tree |
|---|
| 1232 | |
|---|
| 1233 | set idx_pool [$ht_tree index root-pool] |
|---|
| 1234 | if { [$ht_tree entry isopen $idx_pool] } { |
|---|
| 1235 | $ht_tree close $idx_pool |
|---|
| 1236 | } |
|---|
| 1237 | if { [$ht_tree index focus] == $idx_pool } { |
|---|
| 1238 | SelectObject |
|---|
| 1239 | } |
|---|
| 1240 | } |
|---|
| 1241 | |
|---|
| 1242 | |
|---|
| 1243 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1244 | proc ::TolInspector::SelectObject { } { |
|---|
| 1245 | # |
|---|
| 1246 | # PURPOSE: Script called each time a node in ht_tree (left treeview) is |
|---|
| 1247 | # selected. |
|---|
| 1248 | # |
|---|
| 1249 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1250 | #Tolcon_Trace "LLAMADA A SELECTOBJECT" |
|---|
| 1251 | variable w_tabset |
|---|
| 1252 | variable ht_tree |
|---|
| 1253 | #variable set_type "" |
|---|
| 1254 | variable tolset |
|---|
| 1255 | variable tolindex |
|---|
| 1256 | #variable closing |
|---|
| 1257 | variable node_prefix "" |
|---|
| 1258 | variable data |
|---|
| 1259 | |
|---|
| 1260 | set index [$ht_tree index anchor] |
|---|
| 1261 | |
|---|
| 1262 | if { ![string length $index] } { |
|---|
| 1263 | ClearHiertables |
|---|
| 1264 | return |
|---|
| 1265 | } |
|---|
| 1266 | ClearHiertables |
|---|
| 1267 | |
|---|
| 1268 | set tolset "" |
|---|
| 1269 | if { $index } { |
|---|
| 1270 | #puts "SelectObject index = $index" |
|---|
| 1271 | #puts "SelectObject: full = [$ht_tree get -full $index]" |
|---|
| 1272 | set info_node [split [lindex [$ht_tree get -full $index] end] "-"] ;# ojo si el path tiene - |
|---|
| 1273 | set node_type [lindex $info_node 0] |
|---|
| 1274 | set node_name [lindex $info_node 1] |
|---|
| 1275 | #puts "SelectObject: info_node = $info_node" |
|---|
| 1276 | } else { |
|---|
| 1277 | set node_type root |
|---|
| 1278 | set node_name root |
|---|
| 1279 | } |
|---|
| 1280 | |
|---|
| 1281 | Busy |
|---|
| 1282 | #puts "SelectObject: node_type = $node_type" |
|---|
| 1283 | switch -regexp $node_type { |
|---|
| 1284 | root { |
|---|
| 1285 | switch $node_name { |
|---|
| 1286 | root - |
|---|
| 1287 | grammars { |
|---|
| 1288 | ClearHiertables |
|---|
| 1289 | #$w_tabset tab configure Variables -state disabled |
|---|
| 1290 | #$w_tabset tab configure Functions -state disabled |
|---|
| 1291 | } |
|---|
| 1292 | files { |
|---|
| 1293 | SelectFileRoot |
|---|
| 1294 | } |
|---|
| 1295 | console { |
|---|
| 1296 | SelectConsoleRoot |
|---|
| 1297 | } |
|---|
| 1298 | pool { |
|---|
| 1299 | SelectPoolRoot |
|---|
| 1300 | } |
|---|
| 1301 | } |
|---|
| 1302 | } |
|---|
| 1303 | grammar { |
|---|
| 1304 | SelectGrammar |
|---|
| 1305 | } |
|---|
| 1306 | default { |
|---|
| 1307 | set node_prefix $node_type |
|---|
| 1308 | #puts "SelectObject: node_prefix = $node_prefix" |
|---|
| 1309 | if {[regexp -- "pool" $node_type]} { |
|---|
| 1310 | set tolset $data(pool,reference,[lindex $node_type 0]) |
|---|
| 1311 | #puts "SelectObject: Spool: tolset=$tolset, info_node=$info_node" |
|---|
| 1312 | if { [llength $info_node] == 1 } { |
|---|
| 1313 | set tolindex [lrange $tolset 1 end] |
|---|
| 1314 | set tolset [lindex $tolset 0] |
|---|
| 1315 | } else { |
|---|
| 1316 | #set tolindex [lrange $tolset 1 end] |
|---|
| 1317 | #set tolset [lindex $tolset 0] |
|---|
| 1318 | #lappend tolindex [lindex $info_node end] |
|---|
| 1319 | set tolindex [lrange $info_node 1 end] |
|---|
| 1320 | if {[lindex $tolset 0] eq "Console"} { |
|---|
| 1321 | set tolset [lindex $tolset 0] |
|---|
| 1322 | } else { |
|---|
| 1323 | set tolset [lrange $tolset 0 1] |
|---|
| 1324 | } |
|---|
| 1325 | } |
|---|
| 1326 | } elseif {[regexp -- "console(.+)" $node_type --> idx_con]} { |
|---|
| 1327 | #puts "SelectObject: Console: tolset=$tolset info_node=$info_node idx_con=$idx_con" |
|---|
| 1328 | set tolset "Console" |
|---|
| 1329 | #set idx [$ht_tree find -name $node_type] |
|---|
| 1330 | #array set aryData [$ht_tree entry cget $idx -data] |
|---|
| 1331 | #set tolindex [eval list $aryData(FileName) [lrange $info_node 1 end]] |
|---|
| 1332 | if {[llength $info_node] == 1} { |
|---|
| 1333 | set tolindex $idx_con |
|---|
| 1334 | } else { |
|---|
| 1335 | set tolindex [lrange $info_node 1 end] |
|---|
| 1336 | #set tolindex [concat [list $idx_con] $tolindex] |
|---|
| 1337 | } |
|---|
| 1338 | } else { |
|---|
| 1339 | set idx [$ht_tree find -name $node_type] |
|---|
| 1340 | array set aryData [$ht_tree entry cget $idx -data] |
|---|
| 1341 | #puts "SelectObject: FileName=$aryData(FileName) info_node=$info_node" |
|---|
| 1342 | set tolset [list File $aryData(FileName)] |
|---|
| 1343 | set tolindex [lrange $info_node 1 end] |
|---|
| 1344 | #set tolindex [lrange $info_node 2 end] |
|---|
| 1345 | } |
|---|
| 1346 | #puts "SelectObject end: tolset=$tolset, tolindex=$tolindex" |
|---|
| 1347 | SelectSet |
|---|
| 1348 | } |
|---|
| 1349 | } |
|---|
| 1350 | NotBusy |
|---|
| 1351 | } |
|---|
| 1352 | |
|---|
| 1353 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1354 | proc ::TolInspector::SelectFileRoot { } { |
|---|
| 1355 | # |
|---|
| 1356 | # PURPOSE: Script called each time 'Included Files' node in ht_tree is |
|---|
| 1357 | # selected. Gets information about each node that must be in |
|---|
| 1358 | # included files, and inserts it in the right treeview. |
|---|
| 1359 | # |
|---|
| 1360 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1361 | variable item_id 1 |
|---|
| 1362 | variable w_tabset |
|---|
| 1363 | |
|---|
| 1364 | ClearHiertables |
|---|
| 1365 | $w_tabset tab configure Variables -text [mc Files] |
|---|
| 1366 | # $w_tabset tab configure Functions -state disabled |
|---|
| 1367 | $w_tabset select 0 |
|---|
| 1368 | foreach f [lreverse [::tol::info included]] { |
|---|
| 1369 | set fi [::tol::info included $f] |
|---|
| 1370 | # tener en cuenta el subtype cuando lo retorne |
|---|
| 1371 | InsertChild Set $f \ |
|---|
| 1372 | [lindex $fi 0] [lindex $fi 1] [list [lindex $fi 2]] $item_id 1 [lindex $fi 3] [lindex $fi 4] |
|---|
| 1373 | } |
|---|
| 1374 | } |
|---|
| 1375 | |
|---|
| 1376 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1377 | proc ::TolInspector::SelectConsoleRoot { } { |
|---|
| 1378 | # |
|---|
| 1379 | # PURPOSE: Script called each time 'Console Objects' node in ht_tree is |
|---|
| 1380 | # selected. Gets information about each node that must be in console, |
|---|
| 1381 | # and inserts it in the right treeview. |
|---|
| 1382 | # |
|---|
| 1383 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1384 | variable w_tabset |
|---|
| 1385 | variable ht_vars |
|---|
| 1386 | variable ht_funcs |
|---|
| 1387 | variable item_id 1 |
|---|
| 1388 | |
|---|
| 1389 | ClearHiertables |
|---|
| 1390 | $ht_vars column configure Index -hide yes |
|---|
| 1391 | # $w_tabset tab configure Functions -state disabled |
|---|
| 1392 | |
|---|
| 1393 | foreach co [::tol::console stack list] { |
|---|
| 1394 | #puts "SelectConsoleRoot: co = $co" |
|---|
| 1395 | set gra [lindex $co 0] |
|---|
| 1396 | set name [lindex $co 1] |
|---|
| 1397 | set cont [lindex $co 2] |
|---|
| 1398 | set path [lindex $co 3] |
|---|
| 1399 | set desc [lindex $co 4] |
|---|
| 1400 | switch [lindex $co 0 ] { |
|---|
| 1401 | Code { |
|---|
| 1402 | InsertChild $gra $name $cont $path [list $desc] 0 |
|---|
| 1403 | } |
|---|
| 1404 | NameBlock - |
|---|
| 1405 | Set { |
|---|
| 1406 | #puts "switch: SelectConsoleRoot $gra" |
|---|
| 1407 | InsertChild $gra $name $cont $path [list $desc] \ |
|---|
| 1408 | $item_id [lindex $co 5] [lindex $co 6] [lindex $co 7] \ |
|---|
| 1409 | [list Reference [list "Console" $item_id]] |
|---|
| 1410 | } |
|---|
| 1411 | default { |
|---|
| 1412 | InsertChild $gra $name $cont $path [list $desc] \ |
|---|
| 1413 | [list Reference [list "Console" $item_id]] |
|---|
| 1414 | } |
|---|
| 1415 | } |
|---|
| 1416 | } |
|---|
| 1417 | } |
|---|
| 1418 | |
|---|
| 1419 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1420 | proc ::TolInspector::SelectPoolRoot { } { |
|---|
| 1421 | # |
|---|
| 1422 | # PURPOSE: Script called each time 'Spool Objects' node in ht_tree is |
|---|
| 1423 | # selected. Gets information about each node that must be in pool, |
|---|
| 1424 | # and inserts it in the right treeview. |
|---|
| 1425 | # |
|---|
| 1426 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1427 | variable w_tabset |
|---|
| 1428 | variable ht_vars |
|---|
| 1429 | variable data |
|---|
| 1430 | variable item_id 1 |
|---|
| 1431 | |
|---|
| 1432 | ClearHiertables |
|---|
| 1433 | $ht_vars column configure Index -hide yes |
|---|
| 1434 | |
|---|
| 1435 | array unset data pool,variables,* |
|---|
| 1436 | # Para cada uno de los objetos que debe haber en el spool |
|---|
| 1437 | # busco la información del nodo y lo inserto en el treeview de la derecha |
|---|
| 1438 | foreach _obj $data(pool,objects) { |
|---|
| 1439 | array set obj $_obj |
|---|
| 1440 | #Si la referencia del objeto tiene espacios en la ruta, el |
|---|
| 1441 | # llength me darÃa > 1, por eso añado la 2ª parte de la condicion |
|---|
| 1442 | #puts "SelectPoolRoot: obj(grammar)=$obj(grammar) obj(objName)=$obj(objName) obj(reference)=$obj(reference)" |
|---|
| 1443 | if { ([llength $obj(reference)] > 1) && ![string equal $obj(reference) $obj(objName)]} { |
|---|
| 1444 | if {$obj(grammar) eq "Code"} { |
|---|
| 1445 | set infoObj [concat [list $obj(grammar) $obj(objName)] \ |
|---|
| 1446 | [::tol::info function $obj(reference)]] |
|---|
| 1447 | } else { |
|---|
| 1448 | set infoObj [::tol::info variable $obj(reference)] |
|---|
| 1449 | } |
|---|
| 1450 | #Tolcon_Trace "tol info (var|function) reference" |
|---|
| 1451 | } else { |
|---|
| 1452 | if {[catch { set infoObj [concat [list "Set" $obj(reference)] \ |
|---|
| 1453 | [::tol::info included $obj(reference)]] }]} { |
|---|
| 1454 | if {$obj(grammar) eq "Code"} { |
|---|
| 1455 | set infoObj [concat [list $obj(grammar) $obj(reference)] \ |
|---|
| 1456 | [::tol::info function $obj(graApply) $obj(reference)]] |
|---|
| 1457 | } else { |
|---|
| 1458 | #set infoObj [concat [list $obj(grammar) $obj(reference)] \ |
|---|
| 1459 | # [::tol::info variable $obj(grammar) $obj(reference)]] |
|---|
| 1460 | set infoObj [::tol::info variable [list $obj(grammar) $obj(reference)]] |
|---|
| 1461 | } |
|---|
| 1462 | #Tolcon_Trace "tol info (var|function) Grammar nameGlobal" |
|---|
| 1463 | } else { |
|---|
| 1464 | # Insertamos el 1 de isFile |
|---|
| 1465 | set infoObj [linsert $infoObj 5 1] |
|---|
| 1466 | #Tolcon_Trace "tol info included" |
|---|
| 1467 | } |
|---|
| 1468 | } |
|---|
| 1469 | #Tolcon_Trace "INFOOBJ: $infoObj" |
|---|
| 1470 | set gra [lindex $infoObj 0] |
|---|
| 1471 | set name [lindex $infoObj 1] |
|---|
| 1472 | set cont [lindex $infoObj 2] |
|---|
| 1473 | set path [lindex $infoObj 3] |
|---|
| 1474 | set desc [lindex $infoObj 4] |
|---|
| 1475 | set data(pool,variables,$item_id) $obj(reference) |
|---|
| 1476 | |
|---|
| 1477 | switch $gra { |
|---|
| 1478 | Code { |
|---|
| 1479 | InsertChild $gra $name $cont $path [list $desc] 0 "Reference $obj(reference)" |
|---|
| 1480 | } |
|---|
| 1481 | Set - |
|---|
| 1482 | NameBlock { |
|---|
| 1483 | InsertChild $gra $name $cont $path [list $desc] \ |
|---|
| 1484 | $item_id [lindex $infoObj 5] [lindex $infoObj 6] [lindex $infoObj 7] "Reference $obj(reference)" |
|---|
| 1485 | } |
|---|
| 1486 | default { |
|---|
| 1487 | InsertChild $gra $name $cont $path [list $desc] "Reference $obj(reference)" |
|---|
| 1488 | } |
|---|
| 1489 | } |
|---|
| 1490 | } |
|---|
| 1491 | } |
|---|
| 1492 | |
|---|
| 1493 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1494 | proc ::TolInspector::SelectGrammar { } { |
|---|
| 1495 | # |
|---|
| 1496 | # PURPOSE: Script called each time a Grammar node in ht_tree is selected. Gets |
|---|
| 1497 | # information about each var and function of this grammar, and |
|---|
| 1498 | # inserts them in the right treeview. |
|---|
| 1499 | # |
|---|
| 1500 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1501 | variable w_tabset |
|---|
| 1502 | variable ht_tree |
|---|
| 1503 | variable ht_vars |
|---|
| 1504 | variable ht_funcs |
|---|
| 1505 | variable item_id 1 |
|---|
| 1506 | variable OnSelectItem |
|---|
| 1507 | |
|---|
| 1508 | ClearHiertables |
|---|
| 1509 | $ht_vars column configure Index -hide yes |
|---|
| 1510 | $ht_funcs column configure Index -hide yes |
|---|
| 1511 | set grammar [$ht_tree entry cget anchor -label] |
|---|
| 1512 | if { [string compare $grammar "Anything"] } { |
|---|
| 1513 | if { [string length $OnSelectItem] } { |
|---|
| 1514 | $OnSelectItem [::tol::info grammars $grammar] |
|---|
| 1515 | } |
|---|
| 1516 | foreach var [::tol::info variables $grammar] { |
|---|
| 1517 | if {[catch { |
|---|
| 1518 | set vinfo [::tol::info variables [list $grammar $var]] |
|---|
| 1519 | } msg]} { |
|---|
| 1520 | Tol_HciWriter "<E>in ::TolInspector::SelectGrammar : $msg\n</E>" |
|---|
| 1521 | continue |
|---|
| 1522 | } |
|---|
| 1523 | if { [string equal $grammar "Code"] } { |
|---|
| 1524 | #Tolcon_Trace "Code : -- $vinfo --" |
|---|
| 1525 | InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [list [lindex $vinfo 4]] 1 |
|---|
| 1526 | } elseif { [string equal $grammar "Set"] } { |
|---|
| 1527 | #Tolcon_Trace "Set : -- $vinfo --" |
|---|
| 1528 | InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [list [lindex $vinfo 4]] \ |
|---|
| 1529 | $item_id [lindex $vinfo 5] [lindex $vinfo 6] [lindex $vinfo 7] |
|---|
| 1530 | } else { |
|---|
| 1531 | InsertChild $grammar $var [lindex $vinfo 2] [lindex $vinfo 3] [list [lindex $vinfo 4]] $item_id 0 |
|---|
| 1532 | } |
|---|
| 1533 | } |
|---|
| 1534 | } else { |
|---|
| 1535 | # $w_tabset tab configure Variables -state disabled |
|---|
| 1536 | # $w_tabset select 1 |
|---|
| 1537 | } |
|---|
| 1538 | foreach fun [::tol::info functions $grammar] { |
|---|
| 1539 | set finfo [::tol::info functions $grammar $fun] |
|---|
| 1540 | InsertChild Code $fun [lindex $finfo 0] [lindex $finfo 1] [list [lindex $finfo 2]] 0 |
|---|
| 1541 | } |
|---|
| 1542 | } |
|---|
| 1543 | |
|---|
| 1544 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1545 | proc ::TolInspector::SelectSet { } { |
|---|
| 1546 | # |
|---|
| 1547 | # PURPOSE: Script called each time a Set node in ht_tree is selected. Gets |
|---|
| 1548 | # information about each child of this set, and inserts it in the |
|---|
| 1549 | # right treeview. |
|---|
| 1550 | # |
|---|
| 1551 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1552 | variable ht_tree |
|---|
| 1553 | variable ht_vars |
|---|
| 1554 | variable ht_funcs |
|---|
| 1555 | |
|---|
| 1556 | variable tolset |
|---|
| 1557 | variable tolindex |
|---|
| 1558 | variable var_id 1 |
|---|
| 1559 | variable fun_id 1 |
|---|
| 1560 | variable item_id |
|---|
| 1561 | #variable selecting_set |
|---|
| 1562 | |
|---|
| 1563 | # if { $selecting_set } { |
|---|
| 1564 | #puts "eoooo ..." |
|---|
| 1565 | # return |
|---|
| 1566 | # } |
|---|
| 1567 | ClearHiertables |
|---|
| 1568 | # set selecting_set 1 |
|---|
| 1569 | set item_id 1 |
|---|
| 1570 | |
|---|
| 1571 | #puts "SelectSet: tolset=$tolset tolindex=$tolindex" |
|---|
| 1572 | set set_ref [eval list $tolset $tolindex] |
|---|
| 1573 | variable gra_parent [ GetParentGrammar $set_ref ] |
|---|
| 1574 | ::tol::forallchild $set_ref ::TolInspector::_InsertChild |
|---|
| 1575 | # set selecting_set 0 |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | proc ::TolInspector::GetParentGrammar { set_ref } { |
|---|
| 1579 | set root [ lindex $set_ref 0 ] |
|---|
| 1580 | set L [ llength $set_ref ] |
|---|
| 1581 | if { ( $root eq "File" && $L <= 2 ) } { |
|---|
| 1582 | set root |
|---|
| 1583 | } else { |
|---|
| 1584 | lindex [ tol::info var $set_ref ] 0 |
|---|
| 1585 | } |
|---|
| 1586 | } |
|---|
| 1587 | |
|---|
| 1588 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1589 | proc ::TolInspector::CloseObject { index } { |
|---|
| 1590 | # |
|---|
| 1591 | # PURPOSE: Script called each time a node in ht_tree (left treeview) is |
|---|
| 1592 | # closed. |
|---|
| 1593 | # |
|---|
| 1594 | # PARAMETERS: |
|---|
| 1595 | # index : The id of the node closed |
|---|
| 1596 | # |
|---|
| 1597 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1598 | variable ht_tree |
|---|
| 1599 | #variable closing 1 |
|---|
| 1600 | set path [$ht_tree get -full $index] |
|---|
| 1601 | if { $index } { |
|---|
| 1602 | set parent1 [lindex $path 1] |
|---|
| 1603 | if { [string equal $parent1 "root-files"] || |
|---|
| 1604 | [string equal $parent1 "root-console"] || |
|---|
| 1605 | [string equal $parent1 "root-pool"] } { |
|---|
| 1606 | $ht_tree entry delete $index 0 end |
|---|
| 1607 | } |
|---|
| 1608 | } |
|---|
| 1609 | } |
|---|
| 1610 | |
|---|
| 1611 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1612 | proc ::TolInspector::HasSubset { args } { |
|---|
| 1613 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1614 | if { [string equal [lindex $args 0] "Set"] } { |
|---|
| 1615 | variable has_button 1 |
|---|
| 1616 | return 0 |
|---|
| 1617 | } |
|---|
| 1618 | return 1 |
|---|
| 1619 | } |
|---|
| 1620 | |
|---|
| 1621 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1622 | proc ::TolInspector::OpenVariable { index } { |
|---|
| 1623 | # |
|---|
| 1624 | # PURPOSE: ???? |
|---|
| 1625 | # |
|---|
| 1626 | # PARAMETERS: |
|---|
| 1627 | # index -> |
|---|
| 1628 | # |
|---|
| 1629 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1630 | variable tolset ;# Name of the current TOL set variable |
|---|
| 1631 | variable ht_vars ;# ::blt::treeview of variables |
|---|
| 1632 | variable ht_tree ;# ::blt::treeview left |
|---|
| 1633 | variable blt_tree ;# ::blt::tree left |
|---|
| 1634 | variable item_data ;# Array to hold the full content & description of items |
|---|
| 1635 | |
|---|
| 1636 | if { ![string length $index] } { |
|---|
| 1637 | return |
|---|
| 1638 | } |
|---|
| 1639 | set node_anchor [lindex [$ht_tree get -full anchor] end] |
|---|
| 1640 | |
|---|
| 1641 | set tree_index -1 |
|---|
| 1642 | #puts "OpenVariable = $item_data([lindex [$ht_vars entry cget $index -data] end])" |
|---|
| 1643 | if { ![regexp -- "grammar-" $node_anchor] } { |
|---|
| 1644 | set grammar [lindex $item_data([lindex [$ht_vars entry cget $index -data] end]) 2] |
|---|
| 1645 | if {$grammar eq "Set" || $grammar eq "NameBlock"} { |
|---|
| 1646 | $ht_tree open anchor |
|---|
| 1647 | #puts "full = [$ht_vars get -full $index]" |
|---|
| 1648 | set local_name [lindex [$ht_vars get -full $index] end] |
|---|
| 1649 | set idx_anchor [$ht_tree index anchor] |
|---|
| 1650 | #puts "a buscar $local_name dentro de $idx_anchor" |
|---|
| 1651 | if {[set tree_index [$blt_tree findchild $idx_anchor $local_name]] == -1} { |
|---|
| 1652 | foreach idx [$ht_tree entry children anchor] { |
|---|
| 1653 | if { [string equal $local_name [lindex [$ht_tree get -full $idx] end]] } { |
|---|
| 1654 | set tree_index $idx |
|---|
| 1655 | break |
|---|
| 1656 | } |
|---|
| 1657 | } |
|---|
| 1658 | } |
|---|
| 1659 | } |
|---|
| 1660 | } |
|---|
| 1661 | if { $tree_index != -1 } { |
|---|
| 1662 | update |
|---|
| 1663 | blt::tv::SetSelectionAnchor $ht_tree $tree_index |
|---|
| 1664 | set blt::tv::scroll 1 |
|---|
| 1665 | #$ht_tree selection clearall |
|---|
| 1666 | #$ht_tree see $tree_index |
|---|
| 1667 | #$ht_tree focus $tree_index |
|---|
| 1668 | #$ht_tree selection set $tree_index |
|---|
| 1669 | #$ht_tree selection anchor $tree_index |
|---|
| 1670 | #set blt::Hiertable::scroll 1 |
|---|
| 1671 | } |
|---|
| 1672 | } |
|---|
| 1673 | |
|---|
| 1674 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1675 | proc ::TolInspector::SelectItem { ht } { |
|---|
| 1676 | # |
|---|
| 1677 | # PURPOSE: Procedure that is executed when the user selects an element of |
|---|
| 1678 | # the trees of variables orfunctions. |
|---|
| 1679 | # First it take all the arguments necessary of the node of tree to |
|---|
| 1680 | # execute the procedure stored in the variable OnSelectItem, and |
|---|
| 1681 | # later executes it passing those arguments. |
|---|
| 1682 | # |
|---|
| 1683 | # PARAMETERS: path of ht_* (::blt::treeview of variables or of functions) |
|---|
| 1684 | # |
|---|
| 1685 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1686 | # variable w_text ;# TODO: ???? |
|---|
| 1687 | variable OnSelectItem ;#Command to invoke on SelectItem in ht_* |
|---|
| 1688 | variable item_data ;# Array to hold the full content & description of items |
|---|
| 1689 | |
|---|
| 1690 | set entry [$ht index anchor] ;# id of entry selected |
|---|
| 1691 | if { [string length $OnSelectItem] } { |
|---|
| 1692 | # there are associated command |
|---|
| 1693 | if { [string length $entry] } { |
|---|
| 1694 | # almost one entry of ht_* selected |
|---|
| 1695 | array set aryData [$ht entry cget $entry -data] |
|---|
| 1696 | set name [$ht entry cget $entry -label] ;# name of item |
|---|
| 1697 | set itemid $aryData(Index) ;# id of item |
|---|
| 1698 | set path $aryData(Path) ;# path of file of item |
|---|
| 1699 | set full_data $item_data($itemid) ;# {value} {desc} {grammar} |
|---|
| 1700 | set value [lindex $full_data 0] ;# value of item PE: |
|---|
| 1701 | # Anything Field(Set s, Text nombre) |
|---|
| 1702 | |
|---|
| 1703 | if { [string equal \"\n\" $value] } { |
|---|
| 1704 | # hasn't value |
|---|
| 1705 | set value {"\n"} |
|---|
| 1706 | } else { |
|---|
| 1707 | set value [string trim $value] |
|---|
| 1708 | } |
|---|
| 1709 | set desc [string trim [lindex $full_data 1]] |
|---|
| 1710 | set grammar [lindex $full_data 2] |
|---|
| 1711 | set icon [lindex [$ht entry cget $entry -icons] 0] |
|---|
| 1712 | set args [list $icon $grammar $name $value $path $desc] |
|---|
| 1713 | } else { |
|---|
| 1714 | set args "" |
|---|
| 1715 | } |
|---|
| 1716 | eval "$OnSelectItem $args" |
|---|
| 1717 | } |
|---|
| 1718 | return |
|---|
| 1719 | #;# TODO: ???? |
|---|
| 1720 | # if { [string length $entry] } { |
|---|
| 1721 | # FillText $ht $entry |
|---|
| 1722 | # } else { |
|---|
| 1723 | # $w_text delete 1.0 end |
|---|
| 1724 | # } |
|---|
| 1725 | } |
|---|
| 1726 | |
|---|
| 1727 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1728 | proc ::TolInspector::FillText { ht entry } { |
|---|
| 1729 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1730 | variable w_text |
|---|
| 1731 | variable item_data |
|---|
| 1732 | #upvar #0 ::TolTk::Images Images |
|---|
| 1733 | |
|---|
| 1734 | $w_text delete 1.0 end |
|---|
| 1735 | array set aryData [$ht entry cget $entry -data] |
|---|
| 1736 | set name [$ht entry cget $entry -label] |
|---|
| 1737 | set itemid $aryData(Index) |
|---|
| 1738 | set full_data $item_data($itemid) |
|---|
| 1739 | |
|---|
| 1740 | set value [lindex $full_data 0] |
|---|
| 1741 | if { [string equal \"\n\" $value] } { |
|---|
| 1742 | set value {"\n"} |
|---|
| 1743 | } |
|---|
| 1744 | set desc [string trim [lindex $full_data 1]] |
|---|
| 1745 | set grammar [lindex $full_data 2] |
|---|
| 1746 | set icon [lindex [$ht entry cget $entry -icons] 0] |
|---|
| 1747 | foreach {prop val} [list "Grammar: " $grammar "Name: " $name "Value: " [string trim $value]] { |
|---|
| 1748 | set idx_start [$w_text index "end -1 chars"] |
|---|
| 1749 | $w_text insert end $prop |
|---|
| 1750 | set idx_end [$w_text index "end -1 chars"] |
|---|
| 1751 | $w_text tag add tagLabel $idx_start $idx_end |
|---|
| 1752 | if {[string equal $prop "Grammar: "]} { |
|---|
| 1753 | $w_text image create end -image $icon |
|---|
| 1754 | $w_text insert end " " |
|---|
| 1755 | } |
|---|
| 1756 | $w_text insert end "$val\n" |
|---|
| 1757 | $w_text tag add tagValue $idx_end [$w_text index "end -1 chars"] |
|---|
| 1758 | } |
|---|
| 1759 | $w_text tag configure tagLabel -font fnBold |
|---|
| 1760 | $w_text tag configure tagValue -wrap none |
|---|
| 1761 | if { [string length $desc] } { |
|---|
| 1762 | set idx_start [$w_text index "end -1 chars"] |
|---|
| 1763 | $w_text insert end "Description\n" |
|---|
| 1764 | set idx_end [$w_text index "end -1 chars"] |
|---|
| 1765 | $w_text tag add tagPropLabel $idx_start $idx_end |
|---|
| 1766 | $w_text insert end $desc |
|---|
| 1767 | $w_text tag add tagPropValue $idx_end [$w_text index "end -1 chars"] |
|---|
| 1768 | $w_text tag configure tagPropLabel -font fnBold -underline 1 |
|---|
| 1769 | $w_text tag configure tagPropValue -wrap word |
|---|
| 1770 | } |
|---|
| 1771 | } |
|---|
| 1772 | |
|---|
| 1773 | #proc ::TolInspector::GetIndexes { nodeid } { |
|---|
| 1774 | # variable ht_tree |
|---|
| 1775 | # # No se utiliza |
|---|
| 1776 | # # name is prefix-i1-i2-i3-...-in |
|---|
| 1777 | # |
|---|
| 1778 | # if { $nodeid } { |
|---|
| 1779 | # lrange [split [$ht_tree get $nodeid] "-"] 1 end |
|---|
| 1780 | # } else list |
|---|
| 1781 | #} |
|---|
| 1782 | |
|---|
| 1783 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1784 | proc ::TolInspector::GetItemName { prefix idx_list } { |
|---|
| 1785 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1786 | set node_id $prefix |
|---|
| 1787 | foreach id $idx_list { |
|---|
| 1788 | append node_id "-$id" |
|---|
| 1789 | } |
|---|
| 1790 | set node_id |
|---|
| 1791 | } |
|---|
| 1792 | |
|---|
| 1793 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1794 | proc ::TolInspector::OnBusy { cmd } { |
|---|
| 1795 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1796 | variable OnBusyCmd $cmd |
|---|
| 1797 | } |
|---|
| 1798 | |
|---|
| 1799 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1800 | proc ::TolInspector::Busy { } { |
|---|
| 1801 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1802 | variable OnBusyCmd |
|---|
| 1803 | variable ht_tree |
|---|
| 1804 | variable ht_vars |
|---|
| 1805 | |
|---|
| 1806 | $ht_tree configure -cursor watch |
|---|
| 1807 | $ht_vars configure -cursor watch |
|---|
| 1808 | if { [string length $OnBusyCmd] } { |
|---|
| 1809 | eval $OnBusyCmd 1 |
|---|
| 1810 | } |
|---|
| 1811 | } |
|---|
| 1812 | |
|---|
| 1813 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1814 | proc ::TolInspector::NotBusy { } { |
|---|
| 1815 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1816 | variable OnBusyCmd |
|---|
| 1817 | variable ht_tree |
|---|
| 1818 | variable ht_vars |
|---|
| 1819 | |
|---|
| 1820 | $ht_tree configure -cursor "" |
|---|
| 1821 | $ht_vars configure -cursor "" |
|---|
| 1822 | |
|---|
| 1823 | if { [string length $OnBusyCmd] } { |
|---|
| 1824 | eval $OnBusyCmd 0 |
|---|
| 1825 | } |
|---|
| 1826 | } |
|---|
| 1827 | |
|---|
| 1828 | proc Tol_ObjIsClassOf { obj_addr cls_name } { |
|---|
| 1829 | tol::console eval [ string map [ list %A $obj_addr %C $cls_name ] { |
|---|
| 1830 | Real __gui_check__ = IsInstanceOf( GetObjectFromAddress( "%A" ),"%C" ) |
|---|
| 1831 | } ] |
|---|
| 1832 | set info [ tol::info variable {Real __gui_check__} ] |
|---|
| 1833 | set x [ lindex $info 2 ] |
|---|
| 1834 | tol::console stack release __gui_check__ |
|---|
| 1835 | expr { round($x) } |
|---|
| 1836 | } |
|---|
| 1837 | |
|---|
| 1838 | proc Tol_ClassOf { obj_addr } { |
|---|
| 1839 | tol::console eval [ string map [ list %A $obj_addr ] { |
|---|
| 1840 | Text __gui_classof__ = { |
|---|
| 1841 | Anything obj = GetObjectFromAddress( "%A" ); |
|---|
| 1842 | // WriteLn( "Tol_ClassOf " << Grammar( obj ) ); |
|---|
| 1843 | Text If( Grammar( obj ) == "NameBlock", ClassOf( obj ), "" ) |
|---|
| 1844 | } |
|---|
| 1845 | } ] |
|---|
| 1846 | set info [ tol::info variable {Text __gui_classof__} ] |
|---|
| 1847 | set x [ string trim [ lindex $info 2 ] \" ] |
|---|
| 1848 | tol::console stack release __gui_classof__ |
|---|
| 1849 | set x |
|---|
| 1850 | } |
|---|
| 1851 | |
|---|
| 1852 | proc TolGui_GetMenuEntries { selection idx } { |
|---|
| 1853 | array set instances {} |
|---|
| 1854 | array set menu_class {} |
|---|
| 1855 | set i 0 |
|---|
| 1856 | foreach obj_info $selection { |
|---|
| 1857 | set tcl_ref [ lindex $obj_info 0 ] |
|---|
| 1858 | set obj_addr [ ::tol::info address $tcl_ref ] |
|---|
| 1859 | set class [ Tol_ClassOf $obj_addr ] |
|---|
| 1860 | if { $class ne "" } { |
|---|
| 1861 | lappend instances($class) $obj_addr |
|---|
| 1862 | set name_inst [ lindex $obj_info 1 ] |
|---|
| 1863 | set menu_items [ TolGui_GetObjMenu $obj_addr ] |
|---|
| 1864 | # esto hace que estemos guardando la ultima instancia, asumimos |
|---|
| 1865 | # tambien que todas las instancia tienen la misma espcificacion |
|---|
| 1866 | # de menu |
|---|
| 1867 | if { ![ llength [ array names menu_class $class ] ] || $i == $idx } { |
|---|
| 1868 | set menu_class($class) \ |
|---|
| 1869 | [ list $name_inst $obj_addr $menu_items ] |
|---|
| 1870 | } |
|---|
| 1871 | } |
|---|
| 1872 | incr i |
|---|
| 1873 | } |
|---|
| 1874 | set menu_info [ list ] |
|---|
| 1875 | foreach c [ array names instances ] { |
|---|
| 1876 | lappend menu_info [ list $c $menu_class($c) $instances($c) ] |
|---|
| 1877 | } |
|---|
| 1878 | set menu_info |
|---|
| 1879 | } |
|---|
| 1880 | |
|---|
| 1881 | proc TolGui_GetObjMenu { obj_addr } { |
|---|
| 1882 | set try [ catch { |
|---|
| 1883 | tol::console eval [ string map [ list %A $obj_addr ] { |
|---|
| 1884 | @MenuDesc __aux_menu__ = GetObjectFromAddress("%A"); |
|---|
| 1885 | Set __gui_menu_entries__ = __aux_menu__::getMenuEntries(?) |
|---|
| 1886 | } ] } msg ] |
|---|
| 1887 | if { $try } { |
|---|
| 1888 | puts "ERROR TolGui_GetMenuEntries : $msg" |
|---|
| 1889 | set result "" |
|---|
| 1890 | } else { |
|---|
| 1891 | set result [ TolObj2TclObj {Set __gui_menu_entries__} ] |
|---|
| 1892 | } |
|---|
| 1893 | tol::console stack release __aux_menu__ |
|---|
| 1894 | tol::console stack release __gui_menu_entries__ |
|---|
| 1895 | set result |
|---|
| 1896 | } |
|---|
| 1897 | |
|---|
| 1898 | proc TolGui_InvokeMethod { method obj_addr } { |
|---|
| 1899 | set try [ catch { |
|---|
| 1900 | tol::console eval [ string map [ list %A $obj_addr %M $method ] { |
|---|
| 1901 | NameBlock __aux_instance__ = GetObjectFromAddress("%A"); |
|---|
| 1902 | Real __aux_result__ = __aux_instance__::%M(?) |
|---|
| 1903 | } ] } msg ] |
|---|
| 1904 | if { $try } { |
|---|
| 1905 | puts "ERROR TolGui_InvokeMethod : $msg" |
|---|
| 1906 | } |
|---|
| 1907 | tol::console stack release __aux_instance__ |
|---|
| 1908 | tol::console stack release __aux_result__ |
|---|
| 1909 | } |
|---|
| 1910 | |
|---|
| 1911 | proc TclList2SetOfText { lst } { |
|---|
| 1912 | set result [ list ] |
|---|
| 1913 | foreach i $lst { |
|---|
| 1914 | lappend result \"$i\" |
|---|
| 1915 | } |
|---|
| 1916 | return "SetOfText([join $result ,])" |
|---|
| 1917 | } |
|---|
| 1918 | |
|---|
| 1919 | proc TolGui_InvokeGroup { cname function group } { |
|---|
| 1920 | set SOA [ TclList2SetOfText $group ] |
|---|
| 1921 | set try [ catch { |
|---|
| 1922 | tol::console eval \ |
|---|
| 1923 | [ string map [ list %C $cname %F $function %S $SOA ] { |
|---|
| 1924 | Real __aux_result__ = %C::%F( %S ) |
|---|
| 1925 | } ] } msg ] |
|---|
| 1926 | if { $try } { |
|---|
| 1927 | puts "ERROR TolGui_InvokeGroup : $msg" |
|---|
| 1928 | } |
|---|
| 1929 | tol::console stack release __aux_result__ |
|---|
| 1930 | } |
|---|
| 1931 | |
|---|
| 1932 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1933 | proc ::TolInspector::PostVariable { x y } { |
|---|
| 1934 | # |
|---|
| 1935 | # PURPOSE: Composes a popup menu for variables and displays it. Its composed |
|---|
| 1936 | # depending on the node/s clicked by user. |
|---|
| 1937 | # |
|---|
| 1938 | # PARAMETERS: |
|---|
| 1939 | # x -> x-coordinate where popup menu is drawn |
|---|
| 1940 | # y -> y-coordinate where popup menu is drawn |
|---|
| 1941 | # |
|---|
| 1942 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1943 | variable data_menu |
|---|
| 1944 | variable vars_selected |
|---|
| 1945 | variable options_selected |
|---|
| 1946 | variable ht_vars |
|---|
| 1947 | variable ht_tree |
|---|
| 1948 | variable item_data |
|---|
| 1949 | variable data |
|---|
| 1950 | |
|---|
| 1951 | variable tolset |
|---|
| 1952 | variable tolindex |
|---|
| 1953 | |
|---|
| 1954 | #User functions to contextual menu |
|---|
| 1955 | ::TolInspector::ReadUserFunctions |
|---|
| 1956 | |
|---|
| 1957 | array unset options_selected |
|---|
| 1958 | |
|---|
| 1959 | foreach it [array names data_menu] { |
|---|
| 1960 | $data_menu($it) delete 0 end |
|---|
| 1961 | } |
|---|
| 1962 | set InRootConsole [string equal [lindex [$ht_tree get -full anchor] end] "root-console"] |
|---|
| 1963 | set InRootPool [string equal [lindex [$ht_tree get -full anchor] end] "root-pool"] |
|---|
| 1964 | set InRootFiles [string equal [lindex [$ht_tree get -full anchor] end] "root-files"] |
|---|
| 1965 | #puts "PostVariable: InRootConsole,InRootPool,InRootFiles = $InRootConsole,$InRootPool,$InRootFiles" |
|---|
| 1966 | set node_act [$ht_vars index current] |
|---|
| 1967 | if { [string length $node_act] } { |
|---|
| 1968 | set vars_selected [$ht_vars curselection] |
|---|
| 1969 | if { [lsearch $vars_selected $node_act] >= 0 } { |
|---|
| 1970 | foreach var $vars_selected { |
|---|
| 1971 | array set aryData [$ht_vars entry cget $var -data] |
|---|
| 1972 | #puts "PostVariable: aryData = [array get aryData]" |
|---|
| 1973 | set itemid $aryData(Index) |
|---|
| 1974 | set path $aryData(Path) |
|---|
| 1975 | set grammar [lindex $item_data($itemid) 2] |
|---|
| 1976 | set objName [$ht_vars entry cget $var -label] |
|---|
| 1977 | #puts "OBJECT=$objName, PATH=$path" |
|---|
| 1978 | if { $InRootPool } { |
|---|
| 1979 | set object $data(pool,variables,$itemid) |
|---|
| 1980 | } else { |
|---|
| 1981 | if {[llength $aryData(Reference)]} { |
|---|
| 1982 | #set object [lindex $aryData(Reference) 0] |
|---|
| 1983 | set object [lrange $aryData(Reference) 0 end] |
|---|
| 1984 | } else { |
|---|
| 1985 | if { [string length $tolset] } { |
|---|
| 1986 | #set object [concat [list File $tolset] $tolindex $itemid] |
|---|
| 1987 | set object [concat $tolset $tolindex $itemid] |
|---|
| 1988 | #puts "tolset = $tolset" |
|---|
| 1989 | } else { |
|---|
| 1990 | if [llength $objName] { |
|---|
| 1991 | set object [list $grammar $objName] |
|---|
| 1992 | } else { |
|---|
| 1993 | set object $objName |
|---|
| 1994 | } |
|---|
| 1995 | } |
|---|
| 1996 | } |
|---|
| 1997 | } |
|---|
| 1998 | #puts "PostVariable: OBJECT=$object OBJNAME=$objName TOLSET=$tolset PATH=$path GRAMMAR=$grammar" |
|---|
| 1999 | switch -- $grammar { |
|---|
| 2000 | Code - |
|---|
| 2001 | Complex - |
|---|
| 2002 | Date - |
|---|
| 2003 | Matrix - |
|---|
| 2004 | VMatrix - |
|---|
| 2005 | Polyn - |
|---|
| 2006 | Ratio - |
|---|
| 2007 | Real - |
|---|
| 2008 | Serie - |
|---|
| 2009 | Anything - |
|---|
| 2010 | Text - |
|---|
| 2011 | NameBlock - |
|---|
| 2012 | TimeSet { |
|---|
| 2013 | lappend options_selected($grammar) [list $object $objName $path] |
|---|
| 2014 | } |
|---|
| 2015 | Set { |
|---|
| 2016 | # Si el objeto se da como referencia |
|---|
| 2017 | if { [llength $object] > 1 } { |
|---|
| 2018 | #puts "PostVariable: Set: object = $object" |
|---|
| 2019 | if {$InRootFiles} { |
|---|
| 2020 | set isFile 1 |
|---|
| 2021 | } else { |
|---|
| 2022 | set info [::tol::info var $object] |
|---|
| 2023 | set isFile [expr [lindex $info 7] == 4] |
|---|
| 2024 | } |
|---|
| 2025 | #set desc [lindex $info 4] |
|---|
| 2026 | } else { |
|---|
| 2027 | if {[catch "::tol::info included $object" info]} { |
|---|
| 2028 | set info [::tol::info var [list Set $objName]] |
|---|
| 2029 | #set isFile [expr [lindex $info 5] == 4] |
|---|
| 2030 | set isFile [expr [lindex $info 7] == 4] |
|---|
| 2031 | #set desc [lindex $info 4] |
|---|
| 2032 | } else { |
|---|
| 2033 | #set info [::tol::info included $objName] |
|---|
| 2034 | #set isFile [expr [lindex $info 4] == 4] |
|---|
| 2035 | set isFile 1 |
|---|
| 2036 | #set desc "" |
|---|
| 2037 | } |
|---|
| 2038 | } |
|---|
| 2039 | if $isFile { |
|---|
| 2040 | lappend options_selected(File) [list $object $objName $path] |
|---|
| 2041 | } else { |
|---|
| 2042 | lappend options_selected($grammar) [list $object $objName $path] |
|---|
| 2043 | } |
|---|
| 2044 | } |
|---|
| 2045 | } |
|---|
| 2046 | } |
|---|
| 2047 | set grammar_selected [array names options_selected] |
|---|
| 2048 | if { [llength $grammar_selected] } { |
|---|
| 2049 | foreach grammar $grammar_selected { |
|---|
| 2050 | switch -- $grammar { |
|---|
| 2051 | VMatrix - |
|---|
| 2052 | Matrix { |
|---|
| 2053 | $data_menu(main) add cascade -label [mc "Export matrix"]\ |
|---|
| 2054 | -menu $data_menu(Matrix,Export) |
|---|
| 2055 | if {[llength $options_selected($grammar)] == 1} { |
|---|
| 2056 | set object [lindex [lindex $options_selected($grammar) 0] 0] |
|---|
| 2057 | puts "PostVariable:Matrix: object=$object" |
|---|
| 2058 | $data_menu(main) add command -label [mc "Table matrix"] \ |
|---|
| 2059 | -command [list ::TolInspector::TableMatrix $object] |
|---|
| 2060 | $data_menu(Matrix,Export) add command -label "BDT" \ |
|---|
| 2061 | -command [list ::TolInspector::ExportBDTMatrix $object] |
|---|
| 2062 | $data_menu(main) add command -label [mc "Draw matrix"] \ |
|---|
| 2063 | -command [list ::TolInspector::DrawMatrix $object] |
|---|
| 2064 | } else { |
|---|
| 2065 | $data_menu(main) add cascade -label [mc "Table matrix"] \ |
|---|
| 2066 | -menu $data_menu(Matrix,Table) |
|---|
| 2067 | $data_menu(Matrix,Export) add cascade -label "BDT" \ |
|---|
| 2068 | -menu $data_menu(Matrix,Export,BDT) |
|---|
| 2069 | $data_menu(main) add cascade -label [mc "Draw matrix"] \ |
|---|
| 2070 | -menu $data_menu(Matrix,Draw) |
|---|
| 2071 | foreach objInfo $options_selected(Matrix) { |
|---|
| 2072 | $data_menu(Matrix,Table) add command -label [lindex $objInfo 1]\ |
|---|
| 2073 | -command [list ::TolInspector::TableMatrix [lindex $objInfo 0]] |
|---|
| 2074 | $data_menu(Matrix,Export,BDT) add command -label [lindex $objInfo 1]\ |
|---|
| 2075 | -command [list ::TolInspector::ExportBDTMatrix [lindex $objInfo 0]] |
|---|
| 2076 | $data_menu(Matrix,Draw) add command -label [lindex $objInfo 1] \ |
|---|
| 2077 | -command [list ::TolInspector::DrawMatrix [lindex $objInfo 0]] |
|---|
| 2078 | } |
|---|
| 2079 | } |
|---|
| 2080 | } |
|---|
| 2081 | Serie { |
|---|
| 2082 | if {[llength $options_selected(Serie)] == 1} { |
|---|
| 2083 | set lblSerie "serie" |
|---|
| 2084 | } else { |
|---|
| 2085 | set lblSerie "series" |
|---|
| 2086 | } |
|---|
| 2087 | $data_menu(main) add command -label [mc "Draw $lblSerie"]\ |
|---|
| 2088 | -command ::TolInspector::DrawSerie |
|---|
| 2089 | $data_menu(main) add command -label [mc "Table $lblSerie"]\ |
|---|
| 2090 | -command ::TolInspector::TableSerie |
|---|
| 2091 | if {[llength $options_selected(Serie)] == 1} { |
|---|
| 2092 | set object [lindex [lindex $options_selected(Serie) 0] 0] |
|---|
| 2093 | $data_menu(main) add command -label [mc "Draw autocorrelation"] \ |
|---|
| 2094 | -command [list ::TolInspector::DrawAutocorSerie $object] |
|---|
| 2095 | $data_menu(main) add command -label [mc "Table autocorrelation"] \ |
|---|
| 2096 | -command [list ::TolInspector::TableAutocorSerie $object] |
|---|
| 2097 | } else { |
|---|
| 2098 | $data_menu(main) add cascade -label [mc "Draw autocorrelation"] \ |
|---|
| 2099 | -menu $data_menu(Serie,DrawAutocor) |
|---|
| 2100 | $data_menu(main) add cascade -label [mc "Table autocorrelation"] \ |
|---|
| 2101 | -menu $data_menu(Serie,TableAutocor) |
|---|
| 2102 | foreach objInfo $options_selected(Serie) { |
|---|
| 2103 | $data_menu(Serie,DrawAutocor) add command -label [lindex $objInfo 1]\ |
|---|
| 2104 | -command [list ::TolInspector::DrawAutocorSerie [lindex $objInfo 0]] |
|---|
| 2105 | $data_menu(Serie,TableAutocor) add command -label [lindex $objInfo 1]\ |
|---|
| 2106 | -command [list ::TolInspector::TableAutocorSerie [lindex $objInfo 0]] |
|---|
| 2107 | } |
|---|
| 2108 | } |
|---|
| 2109 | $data_menu(main) add command -label [mc "Table statistics"]\ |
|---|
| 2110 | -command ::TolInspector::TableStatisticsSerie |
|---|
| 2111 | } |
|---|
| 2112 | TimeSet { |
|---|
| 2113 | if {[llength $options_selected(TimeSet)] == 1} { |
|---|
| 2114 | set object [lindex [lindex $options_selected(TimeSet) 0] 0] |
|---|
| 2115 | $data_menu(main) add command -label [mc "View timeset"] \ |
|---|
| 2116 | -command [list ::TolInspector::ViewTimeSet $object] |
|---|
| 2117 | } else { |
|---|
| 2118 | $data_menu(main) add cascade -label [mc "View timeset"] \ |
|---|
| 2119 | -menu $data_menu(TimeSet,View) |
|---|
| 2120 | foreach objInfo $options_selected(TimeSet) { |
|---|
| 2121 | $data_menu(TimeSet,View) add command -label [lindex $objInfo 1] \ |
|---|
| 2122 | -command [list ::TolInspector::ViewTimeSet [lindex $objInfo 0]] |
|---|
| 2123 | } |
|---|
| 2124 | } |
|---|
| 2125 | } |
|---|
| 2126 | NameBlock { |
|---|
| 2127 | set sel_length [ llength $options_selected(NameBlock) ] |
|---|
| 2128 | if { $sel_length } { |
|---|
| 2129 | set idx_current [ lsearch $vars_selected $node_act ] |
|---|
| 2130 | set all_nb_options \ |
|---|
| 2131 | [ TolGui_GetMenuEntries \ |
|---|
| 2132 | $options_selected(NameBlock) $idx_current ] |
|---|
| 2133 | set num_options [ llength $all_nb_options ] |
|---|
| 2134 | foreach mi $all_nb_options { |
|---|
| 2135 | set _cname [ lindex $mi 0 ] |
|---|
| 2136 | set cname [ string map [ list @ "" . _ ] $_cname ] |
|---|
| 2137 | foreach { ninst obj_addr entries } [ lindex $mi 1 ] break |
|---|
| 2138 | set instances [ lindex $mi 2 ] |
|---|
| 2139 | # creo el menu de la clase si no existe |
|---|
| 2140 | set mclass $data_menu(main).cls$cname |
|---|
| 2141 | if { ![ winfo exists $mclass ] } { |
|---|
| 2142 | menu $mclass -tearoff 0 |
|---|
| 2143 | } else { |
|---|
| 2144 | $mclass delete 0 end |
|---|
| 2145 | } |
|---|
| 2146 | if { $num_options > 1 } { |
|---|
| 2147 | $data_menu(main) add cascade -label $cname -menu $mclass |
|---|
| 2148 | set target_menu $mclass |
|---|
| 2149 | } else { |
|---|
| 2150 | set target_menu $data_menu(main) |
|---|
| 2151 | } |
|---|
| 2152 | foreach inst_entry $entries { |
|---|
| 2153 | foreach { label single group } $inst_entry break |
|---|
| 2154 | set opt_label \ |
|---|
| 2155 | "$label [ expr { $sel_length>1 ? $ninst : {} } ]" |
|---|
| 2156 | $target_menu add command -label $opt_label \ |
|---|
| 2157 | -command [ list TolGui_InvokeMethod \ |
|---|
| 2158 | $single $obj_addr ] |
|---|
| 2159 | if { $group ne "" && [ llength $instances ] > 1 } { |
|---|
| 2160 | # hay una funcion que se aplica a toda la seleccion |
|---|
| 2161 | $target_menu add command -label "$label All" \ |
|---|
| 2162 | -command [ list TolGui_InvokeGroup \ |
|---|
| 2163 | $_cname $group $instances ] |
|---|
| 2164 | } |
|---|
| 2165 | } |
|---|
| 2166 | } |
|---|
| 2167 | } |
|---|
| 2168 | } |
|---|
| 2169 | Set { |
|---|
| 2170 | if {[llength $options_selected(Set)] == 1} { |
|---|
| 2171 | set object [lindex [lindex $options_selected(Set) 0] 0] |
|---|
| 2172 | $data_menu(main) add command -label [mc "Table set"] \ |
|---|
| 2173 | -command [list ::TolInspector::TableSet $object] |
|---|
| 2174 | $data_menu(main) add command -label [mc "Draw set"] \ |
|---|
| 2175 | -command [list ::TolInspector::DrawSet $object] |
|---|
| 2176 | # menu special |
|---|
| 2177 | $data_menu(main) add cascade -label [mc "Draw set special"] \ |
|---|
| 2178 | -menu $data_menu(Set,Draw,Special) |
|---|
| 2179 | $data_menu(Set,Draw,Special) add command \ |
|---|
| 2180 | -label [mc SetGraphAllFirst] \ |
|---|
| 2181 | -command [list ::TolInspector::DrawSet $object 1] |
|---|
| 2182 | $data_menu(Set,Draw,Special) add command \ |
|---|
| 2183 | -label [mc SetGraphAllGeneric] \ |
|---|
| 2184 | -command [list ::TolInspector::DrawSet $object 2] |
|---|
| 2185 | $data_menu(Set,Draw,Special) add command \ |
|---|
| 2186 | -label [mc SetGraphEvenUneven] \ |
|---|
| 2187 | -command [list ::TolInspector::DrawSet $object 3] |
|---|
| 2188 | } else { |
|---|
| 2189 | $data_menu(main) add cascade -label [mc "Table set"] \ |
|---|
| 2190 | -menu $data_menu(Set,Table) |
|---|
| 2191 | $data_menu(main) add cascade -label [mc "Draw set"] \ |
|---|
| 2192 | -menu $data_menu(Set,Draw) |
|---|
| 2193 | foreach objInfo $options_selected(Set) { |
|---|
| 2194 | $data_menu(Set,Table) add command -label [lindex $objInfo 1] \ |
|---|
| 2195 | -command [list ::TolInspector::TableSet [lindex $objInfo 0]] |
|---|
| 2196 | $data_menu(Set,Draw) add command -label [lindex $objInfo 1] \ |
|---|
| 2197 | -command [list ::TolInspector::DrawSet [lindex $objInfo 0]] |
|---|
| 2198 | } |
|---|
| 2199 | # menu special |
|---|
| 2200 | set i 0 |
|---|
| 2201 | $data_menu(main) add cascade -label [mc "Draw set special"] \ |
|---|
| 2202 | -menu $data_menu(Set,Draw,Special,M) |
|---|
| 2203 | foreach objInfo $options_selected(Set) { |
|---|
| 2204 | # exists menu previus ? |
|---|
| 2205 | if {[winfo exists $data_menu(Set,Draw,Special,M).setdrawspecialm$i]} { |
|---|
| 2206 | destroy $data_menu(Set,Draw,Special,M).setdrawspecialm$i |
|---|
| 2207 | } |
|---|
| 2208 | set mn \ |
|---|
| 2209 | [menu $data_menu(Set,Draw,Special,M).setdrawspecialm$i \ |
|---|
| 2210 | -tearoff 0] |
|---|
| 2211 | $data_menu(Set,Draw,Special,M) add cascade \ |
|---|
| 2212 | -label [lindex $objInfo 1] -menu $mn |
|---|
| 2213 | $mn add command -label [mc SetGraphAllFirst] \ |
|---|
| 2214 | -command [list ::TolInspector::DrawSet [lindex $objInfo 0] 1] |
|---|
| 2215 | $mn add command -label [mc SetGraphAllGeneric] \ |
|---|
| 2216 | -command [list ::TolInspector::DrawSet [lindex $objInfo 0] 2] |
|---|
| 2217 | $mn add command -label [mc SetGraphEvenUneven] \ |
|---|
| 2218 | -command [list ::TolInspector::DrawSet [lindex $objInfo 0] 3] |
|---|
| 2219 | incr i |
|---|
| 2220 | } |
|---|
| 2221 | } |
|---|
| 2222 | } |
|---|
| 2223 | File { |
|---|
| 2224 | if {[llength $options_selected(File)] == 1} { |
|---|
| 2225 | set objName [lindex [lindex $options_selected(File) 0] 1] |
|---|
| 2226 | $data_menu(main) add command -label [mc "View file"] \ |
|---|
| 2227 | -command [list ::TolInspector::ViewFile $objName] |
|---|
| 2228 | if $InRootFiles { |
|---|
| 2229 | $data_menu(main) add command -label [mc "Decompile file"] \ |
|---|
| 2230 | -command [list ::TolInspector::DecompileFile $objName] |
|---|
| 2231 | } |
|---|
| 2232 | } else { |
|---|
| 2233 | $data_menu(main) add cascade -label [mc "View file"] \ |
|---|
| 2234 | -menu $data_menu(File,View) |
|---|
| 2235 | foreach objInfo $options_selected(File) { |
|---|
| 2236 | $data_menu(File,View) add command -label [lindex $objInfo 1] \ |
|---|
| 2237 | -command [list ::TolInspector::ViewFile [lindex $objInfo 1]] |
|---|
| 2238 | } |
|---|
| 2239 | if $InRootFiles { |
|---|
| 2240 | $data_menu(main) add cascade -label [mc "Decompile file"] \ |
|---|
| 2241 | -menu $data_menu(File,Decompile) |
|---|
| 2242 | foreach objInfo $options_selected(File) { |
|---|
| 2243 | $data_menu(File,Decompile) add command -label [lindex $objInfo 1] \ |
|---|
| 2244 | -command [list ::TolInspector::DecompileFile [lindex $objInfo 1]] |
|---|
| 2245 | } |
|---|
| 2246 | } |
|---|
| 2247 | } |
|---|
| 2248 | } |
|---|
| 2249 | } ;# end del switch |
|---|
| 2250 | $data_menu(main) add separator |
|---|
| 2251 | puts "grammar = $grammar" |
|---|
| 2252 | $data_menu(main) add cascade -label [mc "Functions"] \ |
|---|
| 2253 | -menu $data_menu($grammar,Functions) |
|---|
| 2254 | ShowMenuUserFunc $grammar |
|---|
| 2255 | if {[llength $options_selected($grammar)] == 1} { |
|---|
| 2256 | set objName [lindex [lindex $options_selected($grammar) 0] 1] |
|---|
| 2257 | set path [lindex [lindex $options_selected($grammar) 0] 2] |
|---|
| 2258 | $data_menu(main) add command -label [mc "View %1\$s's definition" $grammar] \ |
|---|
| 2259 | -command [list ::TolInspector::ViewDefinition $objName $path $grammar] |
|---|
| 2260 | } else { |
|---|
| 2261 | $data_menu(main) add cascade -label [mc "View %1\$s's definition" $grammar] \ |
|---|
| 2262 | -menu $data_menu($grammar,File) |
|---|
| 2263 | foreach objInfo $options_selected($grammar) { |
|---|
| 2264 | $data_menu($grammar,File) add command -label [lindex $objInfo 1]\ |
|---|
| 2265 | -command [list ::TolInspector::ViewDefinition\ |
|---|
| 2266 | [lindex $objInfo 1] [lindex $objInfo 2] $grammar] |
|---|
| 2267 | } |
|---|
| 2268 | } |
|---|
| 2269 | $data_menu(main) add separator |
|---|
| 2270 | } ;#end del foreach |
|---|
| 2271 | if { $InRootPool } { |
|---|
| 2272 | $data_menu(main) add command -label [mc "Remove from spool"] \ |
|---|
| 2273 | -command [list ::TolInspector::RemoveFromSpool $ht_vars] |
|---|
| 2274 | } else { |
|---|
| 2275 | $data_menu(main) add command -label [mc "Add to spool"] \ |
|---|
| 2276 | -command [list ::TolInspector::AddToSpool $ht_vars [lindex [$ht_tree get -full anchor] 1]] |
|---|
| 2277 | } |
|---|
| 2278 | $data_menu(main) add command -label [mc "To Eval window"] \ |
|---|
| 2279 | -command [list ::TolInspector::AddToEvalWindow $ht_vars] |
|---|
| 2280 | $data_menu(main) add separator |
|---|
| 2281 | if { $InRootConsole} { |
|---|
| 2282 | $data_menu(main) add command -label [mc "Decompile"] \ |
|---|
| 2283 | -command [list ::TolInspector::ClearConsoleObjSel $ht_vars] |
|---|
| 2284 | $data_menu(main) add separator |
|---|
| 2285 | } |
|---|
| 2286 | $data_menu(main) add command -label [mc "Select all"] \ |
|---|
| 2287 | -command [list ::TolInspector::SelectAll $ht_vars] |
|---|
| 2288 | $data_menu(main) add command -label [mc "Toggle selection"] \ |
|---|
| 2289 | -command [list ::TolInspector::ToggleSelection $ht_vars] |
|---|
| 2290 | tk_popup $data_menu(main) $x $y |
|---|
| 2291 | } ;#end del if |
|---|
| 2292 | } |
|---|
| 2293 | } |
|---|
| 2294 | } |
|---|
| 2295 | |
|---|
| 2296 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2297 | proc ::TolInspector::PostFunction { x y } { |
|---|
| 2298 | # |
|---|
| 2299 | # PURPOSE: Composes a popup menu for functions and displays it. Its composed |
|---|
| 2300 | # depending on the node/s clicked by user. |
|---|
| 2301 | # |
|---|
| 2302 | # PARAMETERS: |
|---|
| 2303 | # x -> x-coordinate where popup menu is drawn |
|---|
| 2304 | # y -> y-coordinate where popup menu is drawn |
|---|
| 2305 | # |
|---|
| 2306 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2307 | variable data_menu |
|---|
| 2308 | variable vars_selected |
|---|
| 2309 | variable ht_funcs |
|---|
| 2310 | variable ht_tree |
|---|
| 2311 | variable item_data |
|---|
| 2312 | variable data |
|---|
| 2313 | |
|---|
| 2314 | variable tolset |
|---|
| 2315 | variable tolindex |
|---|
| 2316 | |
|---|
| 2317 | array unset options_selected |
|---|
| 2318 | puts "PostFunction" |
|---|
| 2319 | foreach it [array names data_menu] { |
|---|
| 2320 | $data_menu($it) delete 0 end |
|---|
| 2321 | } |
|---|
| 2322 | |
|---|
| 2323 | set InRootPool [string equal [lindex [$ht_tree get -full anchor] end] "root-pool"] |
|---|
| 2324 | set node_act [$ht_funcs index current] |
|---|
| 2325 | if { [string length $node_act] } { |
|---|
| 2326 | set vars_selected [$ht_funcs curselection] |
|---|
| 2327 | if { [lsearch $vars_selected $node_act] >= 0 } { |
|---|
| 2328 | foreach var $vars_selected { |
|---|
| 2329 | array set aryData [$ht_funcs entry cget $var -data] |
|---|
| 2330 | set itemid $aryData(Index) |
|---|
| 2331 | set path $aryData(Path) |
|---|
| 2332 | set grammar [lindex $item_data($itemid) 2] |
|---|
| 2333 | set objName [$ht_funcs entry cget $var -label] |
|---|
| 2334 | |
|---|
| 2335 | if { $InRootPool } { |
|---|
| 2336 | set object $data(pool,variables,$itemid) |
|---|
| 2337 | } else { |
|---|
| 2338 | if { [string length $tolset] } { |
|---|
| 2339 | set object [concat [list $tolset] $tolindex $itemid] |
|---|
| 2340 | } else { |
|---|
| 2341 | set object $objName |
|---|
| 2342 | } |
|---|
| 2343 | } |
|---|
| 2344 | # La única gramática seleccionable en ht_funcs es Code |
|---|
| 2345 | lappend code_selected [list $object $objName $path] |
|---|
| 2346 | } |
|---|
| 2347 | |
|---|
| 2348 | if {[llength $code_selected] == 1} { |
|---|
| 2349 | set objName [lindex [lindex $code_selected 0] 1] |
|---|
| 2350 | set path [lindex [lindex $code_selected 0] 2] |
|---|
| 2351 | $data_menu(main) add command -label [mc "View %1\$s's definition" $grammar] \ |
|---|
| 2352 | -command [list ::TolInspector::ViewDefinition $objName $path $grammar] |
|---|
| 2353 | } else { |
|---|
| 2354 | $data_menu(main) add cascade -label [mc "View %1\$s's definition" $grammar] \ |
|---|
| 2355 | -menu $data_menu($grammar,File) |
|---|
| 2356 | foreach objInfo $code_selected { |
|---|
| 2357 | $data_menu($grammar,File) add command -label [lindex $objInfo 1]\ |
|---|
| 2358 | -command [list ::TolInspector::ViewDefinition\ |
|---|
| 2359 | [lindex $objInfo 1] [lindex $objInfo 2] $grammar] |
|---|
| 2360 | } |
|---|
| 2361 | } |
|---|
| 2362 | |
|---|
| 2363 | if { $InRootPool } { |
|---|
| 2364 | $data_menu(main) add command -label [mc "Remove from spool"] \ |
|---|
| 2365 | -command [list ::TolInspector::RemoveFromSpool $ht_funcs] |
|---|
| 2366 | } else { |
|---|
| 2367 | $data_menu(main) add command -label [mc "Add to spool"] \ |
|---|
| 2368 | -command [list ::TolInspector::AddToSpool $ht_funcs [lindex [$ht_tree get -full anchor] 1]] |
|---|
| 2369 | } |
|---|
| 2370 | $data_menu(main) add command -label [mc "To Eval window"] \ |
|---|
| 2371 | -command [list ::TolInspector::AddToEvalWindow $ht_funcs] |
|---|
| 2372 | $data_menu(main) add separator |
|---|
| 2373 | $data_menu(main) add command -label [mc "Select all"] \ |
|---|
| 2374 | -command [list ::TolInspector::SelectAll $ht_funcs] |
|---|
| 2375 | $data_menu(main) add command -label [mc "Toggle selection"] \ |
|---|
| 2376 | -command [list ::TolInspector::ToggleSelection $ht_funcs] |
|---|
| 2377 | tk_popup $data_menu(main) $x $y |
|---|
| 2378 | } |
|---|
| 2379 | } |
|---|
| 2380 | } |
|---|
| 2381 | |
|---|
| 2382 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2383 | proc ::TolInspector::PostTree { x y } { |
|---|
| 2384 | # |
|---|
| 2385 | # PURPOSE: Composes a popup menu for left treeview and displays it. Its |
|---|
| 2386 | # composed depending on the node clicked by user. |
|---|
| 2387 | # |
|---|
| 2388 | # PARAMETERS: |
|---|
| 2389 | # x -> x-coordinate where popup menu is drawn |
|---|
| 2390 | # y -> y-coordinate where popup menu is drawn |
|---|
| 2391 | # |
|---|
| 2392 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2393 | variable data_menu |
|---|
| 2394 | variable vars_selected |
|---|
| 2395 | variable ht_tree |
|---|
| 2396 | variable item_data |
|---|
| 2397 | variable data |
|---|
| 2398 | variable tolset |
|---|
| 2399 | variable tolindex |
|---|
| 2400 | variable item_id |
|---|
| 2401 | #puts "ht_tree: $ht_tree" |
|---|
| 2402 | #No terminado todavÃa |
|---|
| 2403 | #return |
|---|
| 2404 | array unset options_selected |
|---|
| 2405 | |
|---|
| 2406 | puts "::TolInspector::PostTree $x $y" |
|---|
| 2407 | foreach it [array names data_menu] { |
|---|
| 2408 | $data_menu($it) delete 0 end |
|---|
| 2409 | } |
|---|
| 2410 | set InRootPool [string equal [lindex [$ht_tree get -full anchor] end-1] "root-pool"] |
|---|
| 2411 | #puts "InRootPool: $InRootPool" |
|---|
| 2412 | # InRootFiles has a value 1 if node is a File |
|---|
| 2413 | set InRootFiles [string equal [lindex [$ht_tree get -full anchor] end-1] "root-files"] |
|---|
| 2414 | #puts "InRootFiles: $InRootFiles" |
|---|
| 2415 | # index of the selected node |
|---|
| 2416 | set node_act [$ht_tree index current] |
|---|
| 2417 | #puts "node_act: $node_act" |
|---|
| 2418 | if { [string length $node_act] } { |
|---|
| 2419 | set vars_selected [$ht_tree curselection] |
|---|
| 2420 | puts "vars_selected: $vars_selected" |
|---|
| 2421 | if { [lsearch $vars_selected $node_act] >= 0 } { ;# Not root node |
|---|
| 2422 | set index [$ht_tree index anchor] |
|---|
| 2423 | puts "index: $index" |
|---|
| 2424 | if { $index } { |
|---|
| 2425 | set info_node [split [lindex [$ht_tree get -full $index] end] "-"] |
|---|
| 2426 | puts "info_node: $info_node" |
|---|
| 2427 | set node_type [lindex $info_node 0] |
|---|
| 2428 | puts "node_type: $node_type" |
|---|
| 2429 | set node_name [lindex $info_node 1] |
|---|
| 2430 | puts "node_name: $node_name" |
|---|
| 2431 | } else { ;# root node |
|---|
| 2432 | set node_type root |
|---|
| 2433 | set node_name root |
|---|
| 2434 | } |
|---|
| 2435 | # if user selects a root or a grammar doesn't nothing |
|---|
| 2436 | switch -regexp $node_type { |
|---|
| 2437 | root - |
|---|
| 2438 | grammar { return } |
|---|
| 2439 | } |
|---|
| 2440 | # label of object showed in the tree |
|---|
| 2441 | set objName [$ht_tree entry cget $index -label] |
|---|
| 2442 | puts "objName: $objName" |
|---|
| 2443 | set object $objName |
|---|
| 2444 | |
|---|
| 2445 | if {$InRootFiles} { |
|---|
| 2446 | array set aryData [$ht_tree entry cget $index -data] |
|---|
| 2447 | if [info exist aryData(FileName)] { |
|---|
| 2448 | set objName $aryData(FileName) |
|---|
| 2449 | } |
|---|
| 2450 | } |
|---|
| 2451 | #puts "2objName: $objName" |
|---|
| 2452 | if { $InRootPool } { |
|---|
| 2453 | #puts "es InRootPool" |
|---|
| 2454 | set itemid $item_id |
|---|
| 2455 | set object $data(pool,variables,$itemid) |
|---|
| 2456 | } else { |
|---|
| 2457 | #puts "NO InRootPool" |
|---|
| 2458 | if { [string length $tolset] } { |
|---|
| 2459 | set object [concat [list $tolset] $tolindex] |
|---|
| 2460 | } else { |
|---|
| 2461 | set object $objName |
|---|
| 2462 | } |
|---|
| 2463 | } |
|---|
| 2464 | puts "object = $objName '[$ht_tree entry cget $index -data]'" |
|---|
| 2465 | #Tolcon_Trace "***********************************" {red} |
|---|
| 2466 | #Tolcon_Trace "index=$index, node_type=$node_type, node_name=$node_name" {red} |
|---|
| 2467 | #Tolcon_Trace "tolset=$tolset, tolindex=$tolindex, aryData= [$ht_tree entry cget $index -data]" {red} |
|---|
| 2468 | #Tolcon_Trace "object=$object, label=$objName" {red} |
|---|
| 2469 | #Tolcon_Trace "***********************************" {red} |
|---|
| 2470 | set stackList [::tol::console stack list] |
|---|
| 2471 | #puts "stackList: $stackList" |
|---|
| 2472 | set stackValue {} |
|---|
| 2473 | foreach stackItem $stackList { |
|---|
| 2474 | #puts "stackItem: $stackItem" |
|---|
| 2475 | #puts "lindex $stackValue 1: [lindex $stackValue 1]" |
|---|
| 2476 | #puts "objName: $objName" |
|---|
| 2477 | if {[lindex $stackItem 1] eq $objName} { |
|---|
| 2478 | set stackValue $stackItem |
|---|
| 2479 | } |
|---|
| 2480 | break |
|---|
| 2481 | } |
|---|
| 2482 | #puts "stackValue: $stackValue" |
|---|
| 2483 | set grammar [lindex $stackValue 0] |
|---|
| 2484 | #puts "grammar: $grammar" |
|---|
| 2485 | #set full_data $item_data($index) ;# {value} {desc} {grammar} |
|---|
| 2486 | #set grammar [lindex $full_data 2] |
|---|
| 2487 | |
|---|
| 2488 | #foreach fun [::tol::info functions $grammar] { |
|---|
| 2489 | # set finfo [::tol::info functions $grammar $fun] |
|---|
| 2490 | # InsertChild Code $fun [lindex $finfo 0] [lindex $finfo 1] [list [lindex $finfo 2]] 0 |
|---|
| 2491 | #} |
|---|
| 2492 | if {[catch {set info [::tol::info included $objName]}]} { |
|---|
| 2493 | if { !($grammar eq "")} { |
|---|
| 2494 | if {[catch {set info [::tol::info var [list $grammar $object]}]} { |
|---|
| 2495 | #set info [concat [list "$grammar" $objName ] [::tol::info var $grammar $objName]] |
|---|
| 2496 | set info [::tol::info var [list $grammar $objName]] |
|---|
| 2497 | #Tolcon_Trace "INFO de ::tol::info var Set objName" |
|---|
| 2498 | } else { |
|---|
| 2499 | set info [::tol::info var [list $grammar $object]] |
|---|
| 2500 | #Tolcon_Trace "INFO de ::tol::info var $grammar object" |
|---|
| 2501 | } |
|---|
| 2502 | set isFile [expr [lindex $info 5] == 4] |
|---|
| 2503 | } else { |
|---|
| 2504 | set isFile 0 |
|---|
| 2505 | } |
|---|
| 2506 | |
|---|
| 2507 | } else { |
|---|
| 2508 | set info [::tol::info included $objName] |
|---|
| 2509 | #Tolcon_Trace "INFO de ::tol::info included objName" |
|---|
| 2510 | set isFile 1 |
|---|
| 2511 | } |
|---|
| 2512 | #puts "paso" |
|---|
| 2513 | |
|---|
| 2514 | if $isFile { |
|---|
| 2515 | #puts "entro como fichero" |
|---|
| 2516 | $data_menu(main) add command -label [mc "View file"] \ |
|---|
| 2517 | -command [list ::TolInspector::ViewFile $objName] |
|---|
| 2518 | if $InRootFiles { |
|---|
| 2519 | $data_menu(main) add command -label [mc "Decompile file"] \ |
|---|
| 2520 | -command [list ::TolInspector::DecompileFile $objName] |
|---|
| 2521 | } |
|---|
| 2522 | } else { |
|---|
| 2523 | #puts "no entro como fichero" |
|---|
| 2524 | if { $grammar eq "Set" } { |
|---|
| 2525 | $data_menu(main) add command -label [mc "Table set"] \ |
|---|
| 2526 | -command [list ::TolInspector::TableSet $object] |
|---|
| 2527 | $data_menu(main) add command -label [mc "Draw set"] \ |
|---|
| 2528 | -command [list ::TolInspector::DrawSet $object] |
|---|
| 2529 | } |
|---|
| 2530 | } |
|---|
| 2531 | tk_popup $data_menu(main) $x $y |
|---|
| 2532 | } |
|---|
| 2533 | } |
|---|
| 2534 | } |
|---|
| 2535 | |
|---|
| 2536 | |
|---|
| 2537 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2538 | # Procedures asociated with tol inspector popup menu |
|---|
| 2539 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2540 | |
|---|
| 2541 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2542 | proc ::TolInspector::RemoveFromSpool {ht} { |
|---|
| 2543 | # |
|---|
| 2544 | # PURPOSE: Removes from spool all selected objects |
|---|
| 2545 | # |
|---|
| 2546 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2547 | variable vars_selected |
|---|
| 2548 | variable item_data |
|---|
| 2549 | variable tolset |
|---|
| 2550 | variable tolindex |
|---|
| 2551 | variable data |
|---|
| 2552 | |
|---|
| 2553 | foreach var $vars_selected { |
|---|
| 2554 | array set aryData [$ht entry cget $var -data] |
|---|
| 2555 | set itemid $aryData(Index) |
|---|
| 2556 | set path $aryData(Path) |
|---|
| 2557 | set reference $aryData(Reference) |
|---|
| 2558 | set grammar [lindex $item_data($itemid) 2] |
|---|
| 2559 | |
|---|
| 2560 | set objName [$ht entry cget $var -label] |
|---|
| 2561 | |
|---|
| 2562 | set _objpool [list "grammar" $grammar "objName" $objName "reference" $reference "path" $path] |
|---|
| 2563 | if {$grammar eq "Code"} { |
|---|
| 2564 | set graApply [lindex $aryData(Content) 0] |
|---|
| 2565 | lappend _objpool "graApply" $graApply |
|---|
| 2566 | } |
|---|
| 2567 | #Tolcon_Trace "OBJPOOL on REMOVE: $_objpool" |
|---|
| 2568 | |
|---|
| 2569 | # Buscamos el objeto (identificador: referencia) |
|---|
| 2570 | array set objpool $_objpool |
|---|
| 2571 | foreach _obj $data(pool,objects) { |
|---|
| 2572 | array set obj $_obj |
|---|
| 2573 | #Tolcon_Trace "obj(reference)=$obj(reference), objpool(reference)=$objpool(reference)" |
|---|
| 2574 | if {[string equal $obj(reference) $objpool(reference)]} { |
|---|
| 2575 | if {$obj(grammar) eq "Code"} { |
|---|
| 2576 | if {[string equal $obj(graApply) $objpool(graApply)]} { |
|---|
| 2577 | set idx [lsearch $data(pool,objects) $_obj] |
|---|
| 2578 | #Tolcon_Trace "El obj a quitar tiene idx=$idx" |
|---|
| 2579 | set data(pool,objects) [lreplace $data(pool,objects) $idx $idx] |
|---|
| 2580 | } |
|---|
| 2581 | } else { |
|---|
| 2582 | set idx [lsearch $data(pool,objects) $_obj] |
|---|
| 2583 | #Tolcon_Trace "El obj a quitar tiene idx=$idx" |
|---|
| 2584 | set data(pool,objects) [lreplace $data(pool,objects) $idx $idx] |
|---|
| 2585 | } |
|---|
| 2586 | } |
|---|
| 2587 | } |
|---|
| 2588 | } |
|---|
| 2589 | #Tolcon_Trace "P.O. after REMOVE: $data(pool,objects)" |
|---|
| 2590 | UpdatePoolObj |
|---|
| 2591 | } |
|---|
| 2592 | |
|---|
| 2593 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2594 | proc ::TolInspector::AddToSpool {ht origin} { |
|---|
| 2595 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2596 | variable vars_selected |
|---|
| 2597 | variable item_data |
|---|
| 2598 | variable tolset |
|---|
| 2599 | variable tolindex |
|---|
| 2600 | variable data |
|---|
| 2601 | |
|---|
| 2602 | foreach var $vars_selected { |
|---|
| 2603 | array set aryData [$ht entry cget $var -data] |
|---|
| 2604 | set itemid $aryData(Index) |
|---|
| 2605 | set path $aryData(Path) |
|---|
| 2606 | set grammar [lindex $item_data($itemid) 2] |
|---|
| 2607 | set objName [$ht entry cget $var -label] |
|---|
| 2608 | #puts "AddToSpool: Reference=$aryData(Reference) tolset=$tolset grammar=$grammar" |
|---|
| 2609 | if {[llength $aryData(Reference)]} { |
|---|
| 2610 | set reference $aryData(Reference) |
|---|
| 2611 | } else { |
|---|
| 2612 | if { [string length $tolset] } { |
|---|
| 2613 | #set object [concat [list $tolset] $tolindex $itemid] |
|---|
| 2614 | #set object [concat [list File $tolset] $tolindex $itemid] |
|---|
| 2615 | set object [concat $tolset $tolindex $itemid] |
|---|
| 2616 | #puts "AddToSpool: object=$object" |
|---|
| 2617 | set reference [::tol::info reference $object] |
|---|
| 2618 | } else { |
|---|
| 2619 | if {$grammar eq "Set"} { |
|---|
| 2620 | #puts "AddToSpool: origin=$origin" |
|---|
| 2621 | set reference [::tol::info reference [list Set $objName]] |
|---|
| 2622 | #Tolcon_Trace "reference de ::tol::info reference [list $objName]" |
|---|
| 2623 | } else { |
|---|
| 2624 | if [catch {set reference [::tol::info reference [list $grammar $objName]]}] { |
|---|
| 2625 | set reference $objName |
|---|
| 2626 | #Tolcon_Trace "reference NO SE QUE PONER" |
|---|
| 2627 | } |
|---|
| 2628 | #Tolcon_Trace "reference de ::tol::info reference $grammar $objName" |
|---|
| 2629 | } |
|---|
| 2630 | } |
|---|
| 2631 | } |
|---|
| 2632 | set _objpool [list "origin" $origin "grammar" $grammar "objName" $objName "reference" $reference "path" $path] |
|---|
| 2633 | if {$grammar eq "Code"} { |
|---|
| 2634 | set graApply [lindex $aryData(Content) 0] |
|---|
| 2635 | lappend _objpool "graApply" $graApply |
|---|
| 2636 | } |
|---|
| 2637 | #Tolcon_Trace "***************" |
|---|
| 2638 | #Tolcon_Trace "OBJPOOL on ADD:" |
|---|
| 2639 | #Tolcon_Trace "***************" |
|---|
| 2640 | #foreach {key value} $_objpool { |
|---|
| 2641 | # Tolcon_Trace " $key=$value" |
|---|
| 2642 | #} |
|---|
| 2643 | set inserted 0 |
|---|
| 2644 | # Si la referencia es igual, el objeto es el mismo (salvo para obj de tipo Code) |
|---|
| 2645 | array set objpool $_objpool |
|---|
| 2646 | foreach _obj $data(pool,objects) { |
|---|
| 2647 | array set obj $_obj |
|---|
| 2648 | if {[string equal $obj(reference) $objpool(reference)]} { |
|---|
| 2649 | #Si es de la gramatica Code miro a ver la gramatica sobre la que se aplica |
|---|
| 2650 | if {$objpool(grammar) eq "Code"} { |
|---|
| 2651 | if {[string equal $obj(graApply) $objpool(graApply)]} { |
|---|
| 2652 | set inserted 1 |
|---|
| 2653 | } |
|---|
| 2654 | } else { |
|---|
| 2655 | set inserted 1 |
|---|
| 2656 | } |
|---|
| 2657 | } |
|---|
| 2658 | } |
|---|
| 2659 | if {!$inserted} { |
|---|
| 2660 | lappend data(pool,objects) $_objpool |
|---|
| 2661 | #puts "AddToSpool: P.O. after ADD: $data(pool,objects)" |
|---|
| 2662 | } else { |
|---|
| 2663 | #puts "$_objpool ALREADY IN SPOOL" |
|---|
| 2664 | } |
|---|
| 2665 | } |
|---|
| 2666 | |
|---|
| 2667 | } |
|---|
| 2668 | |
|---|
| 2669 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2670 | proc ::TolInspector::AddToEvalWindow {ht} { |
|---|
| 2671 | # |
|---|
| 2672 | # PURPOSE: Adds names of selected objects (vars or functions) in treeview ht |
|---|
| 2673 | # to eval window |
|---|
| 2674 | # |
|---|
| 2675 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2676 | variable ht_vars |
|---|
| 2677 | variable vars_selected |
|---|
| 2678 | |
|---|
| 2679 | set names "" |
|---|
| 2680 | foreach var $vars_selected { |
|---|
| 2681 | lappend names [$ht entry cget $var -label] |
|---|
| 2682 | } |
|---|
| 2683 | ::TolConsole::ToEvalWindow [ListToStr $names] |
|---|
| 2684 | } |
|---|
| 2685 | |
|---|
| 2686 | |
|---|
| 2687 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2688 | proc ::TolInspector::SelectAll {ht} { |
|---|
| 2689 | # |
|---|
| 2690 | # PURPOSE: Selects all nodes of a given treeview |
|---|
| 2691 | # |
|---|
| 2692 | # PARAMETERS: |
|---|
| 2693 | # ht -> treeview's path |
|---|
| 2694 | # |
|---|
| 2695 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2696 | set found [$ht find] |
|---|
| 2697 | if {[llength $found] > 1} { |
|---|
| 2698 | $ht selection set [lindex $found 1] [lindex $found end] |
|---|
| 2699 | } |
|---|
| 2700 | } |
|---|
| 2701 | |
|---|
| 2702 | |
|---|
| 2703 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2704 | proc ::TolInspector::ToggleSelection {ht} { |
|---|
| 2705 | # |
|---|
| 2706 | # PURPOSE: Toggles selection of nodes of a given treeview |
|---|
| 2707 | # |
|---|
| 2708 | # PARAMETERS: |
|---|
| 2709 | # ht -> treeview's path |
|---|
| 2710 | # |
|---|
| 2711 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2712 | set found [$ht find] |
|---|
| 2713 | if {[llength $found] > 1} { |
|---|
| 2714 | $ht selection toggle [lindex $found 1] [lindex $found end] |
|---|
| 2715 | } |
|---|
| 2716 | } |
|---|
| 2717 | |
|---|
| 2718 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2719 | proc ::TolInspector::DrawSet {setref {type 0}} { |
|---|
| 2720 | # |
|---|
| 2721 | # PURPOSE: Graph a Set. For it it calls to a form for the selection of |
|---|
| 2722 | # columns to graph |
|---|
| 2723 | # |
|---|
| 2724 | # PARAMETERS: |
|---|
| 2725 | # setref -> Set to graph |
|---|
| 2726 | # type -> 0 for custom association of data columns |
|---|
| 2727 | # -> 1 for all data columns to first one |
|---|
| 2728 | # -> 2 for all data columns to generic |
|---|
| 2729 | # -> 3 for even data columns to odd ones |
|---|
| 2730 | # |
|---|
| 2731 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2732 | variable group_id |
|---|
| 2733 | variable w_tabset |
|---|
| 2734 | #puts "::TolInspector::DrawSet. setref: $setref" |
|---|
| 2735 | incr group_id |
|---|
| 2736 | if {[llength $setref] > 1} { |
|---|
| 2737 | set name [lindex [::tol::info variable $setref] 1] |
|---|
| 2738 | } else { |
|---|
| 2739 | set name $setref |
|---|
| 2740 | } |
|---|
| 2741 | set cmd tablecmd$group_id |
|---|
| 2742 | if {![catch {::tol::tableset create $cmd $setref}]} { |
|---|
| 2743 | switch $type { |
|---|
| 2744 | 0 { |
|---|
| 2745 | set tl [::project::CreateForm \ |
|---|
| 2746 | -width 500 -height 500 -type Graphs \ |
|---|
| 2747 | -iniconfig Graph \ |
|---|
| 2748 | -title [mc "Set graph: %s" $name] -helpkey "Tb4GraSet"] |
|---|
| 2749 | $tl withdraw |
|---|
| 2750 | set tlf [$tl getframe] |
|---|
| 2751 | if {[set Instance [::SetGraphDialog::Init $tlf.g $cmd $setref]] != 0} { |
|---|
| 2752 | bind $tlf.g <Destroy> +[list ::tol::tableset destroy $cmd] |
|---|
| 2753 | pack $tlf.g -fill both -expand yes |
|---|
| 2754 | $tl restore |
|---|
| 2755 | update |
|---|
| 2756 | # Esta opción se debe aplicar cuando el gráfico esté empacado |
|---|
| 2757 | ::bayesGraph::GrapOptApplyAxisTicks $Instance ${Instance}::options gr,0 |
|---|
| 2758 | } else { |
|---|
| 2759 | destroy $tl |
|---|
| 2760 | return |
|---|
| 2761 | } |
|---|
| 2762 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 2763 | } |
|---|
| 2764 | 1 - |
|---|
| 2765 | 2 - |
|---|
| 2766 | 3 { |
|---|
| 2767 | # windows |
|---|
| 2768 | set tl [::project::CreateForm \ |
|---|
| 2769 | -title [mc "Set graph: %s" $name] -type Graphs -iniconfig SetGraph] |
|---|
| 2770 | $tl withdraw |
|---|
| 2771 | set tlf [$tl getframe] |
|---|
| 2772 | set Instance [::SetGraphDialog::DrawSet $tlf.g $cmd $setref $type] |
|---|
| 2773 | bind $tlf.g <Destroy> +[list ::tol::tableset destroy $cmd] |
|---|
| 2774 | pack $tlf.g -fill both -expand yes |
|---|
| 2775 | $tl restore |
|---|
| 2776 | update |
|---|
| 2777 | # Esta opción se debe aplicar cuando el gráfico esté empacado |
|---|
| 2778 | ::bayesGraph::GrapOptApplyAxisTicks $Instance ${Instance}::options gr,0 |
|---|
| 2779 | } |
|---|
| 2780 | } |
|---|
| 2781 | } else { |
|---|
| 2782 | tk_messageBox -type ok -icon warning \ |
|---|
| 2783 | -message [mc "Set is not graficable: %s" $::errorInfo] \ |
|---|
| 2784 | -parent $w_tabset -title [mc "Warning"] |
|---|
| 2785 | } |
|---|
| 2786 | } |
|---|
| 2787 | |
|---|
| 2788 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2789 | proc ::TolInspector::DrawMatrix {matref} { |
|---|
| 2790 | # |
|---|
| 2791 | # PURPOSE: draw the given matrix |
|---|
| 2792 | # |
|---|
| 2793 | # PARAMETERS: |
|---|
| 2794 | # matref -> reference to the tol matrix |
|---|
| 2795 | # |
|---|
| 2796 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2797 | variable group_id |
|---|
| 2798 | variable w_tabset |
|---|
| 2799 | |
|---|
| 2800 | incr group_id |
|---|
| 2801 | if {[llength $matref] > 1} { |
|---|
| 2802 | set name [lindex [::tol::info variable $matref] 1] |
|---|
| 2803 | } else { |
|---|
| 2804 | if { ([info exists obj]) } { |
|---|
| 2805 | set name $obj |
|---|
| 2806 | } |
|---|
| 2807 | } |
|---|
| 2808 | if { ([info exists name]) } { |
|---|
| 2809 | set cmd tablecmd$group_id |
|---|
| 2810 | if {![catch {::tol::tablematrix create $cmd $matref}]} { |
|---|
| 2811 | set tl [::project::CreateForm \ |
|---|
| 2812 | -width 500 -height 500 -type Graphs \ |
|---|
| 2813 | -iniconfig Graph \ |
|---|
| 2814 | -title [mc "Matrix graph: %s" $name] -helpkey "Tb4Gra"] |
|---|
| 2815 | $tl withdraw |
|---|
| 2816 | |
|---|
| 2817 | set tlf [$tl getframe] |
|---|
| 2818 | if {[set Instance [::SetGraphDialog::Init $tlf.g $cmd $matref]] != 0} { |
|---|
| 2819 | bind $tlf.g <Destroy> +[list ::tol::tablematrix destroy $cmd] |
|---|
| 2820 | pack $tlf.g -fill both -expand yes |
|---|
| 2821 | $tl restore |
|---|
| 2822 | update |
|---|
| 2823 | # Esta opción se debe aplicar cuando el gráfico esté empacado |
|---|
| 2824 | ::bayesGraph::GrapOptApplyAxisTicks $Instance ${Instance}::options gr,0 |
|---|
| 2825 | } else { |
|---|
| 2826 | destroy $tl |
|---|
| 2827 | return |
|---|
| 2828 | } |
|---|
| 2829 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 2830 | } else { |
|---|
| 2831 | tk_messageBox -type ok -icon warning \ |
|---|
| 2832 | -message [mc "Matrix is not graficable: %s" $::errorInfo] \ |
|---|
| 2833 | -parent $w_tabset -title [mc "Warning"] |
|---|
| 2834 | } |
|---|
| 2835 | } |
|---|
| 2836 | } |
|---|
| 2837 | |
|---|
| 2838 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2839 | proc ::TolInspector::TableSet { set } { |
|---|
| 2840 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2841 | variable w_tabset |
|---|
| 2842 | variable group_id |
|---|
| 2843 | |
|---|
| 2844 | incr group_id |
|---|
| 2845 | if {[llength $set] > 1} { |
|---|
| 2846 | set nameSet [lindex [::tol::info variable $set] 1] |
|---|
| 2847 | } else { |
|---|
| 2848 | set nameSet $set |
|---|
| 2849 | } |
|---|
| 2850 | set setgrp group$group_id |
|---|
| 2851 | if {![catch {::tol::tableset create $setgrp $set}]} { |
|---|
| 2852 | # create |
|---|
| 2853 | set tl [::project::CreateForm \ |
|---|
| 2854 | -title "[mc "Set table"]: $nameSet" \ |
|---|
| 2855 | -iniconfig SetTable \ |
|---|
| 2856 | -type Tables -helpkey "Tb4Edt" |
|---|
| 2857 | ] |
|---|
| 2858 | set tlf [$tl getframe] |
|---|
| 2859 | # config |
|---|
| 2860 | btable $tlf.t -parent $tl \ |
|---|
| 2861 | -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \ |
|---|
| 2862 | -iniconfig btable |
|---|
| 2863 | $tlf.t fillSet $setgrp |
|---|
| 2864 | pack $tlf.t -fill both -expand yes |
|---|
| 2865 | bind $tlf.t <Destroy> +[list ::tol::tableset destroy $setgrp] |
|---|
| 2866 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 2867 | update |
|---|
| 2868 | } else { |
|---|
| 2869 | tk_messageBox -type ok -icon warning -message [mc "Set not tabulable"]\ |
|---|
| 2870 | -parent $w_tabset -title [mc Warning] |
|---|
| 2871 | } |
|---|
| 2872 | } |
|---|
| 2873 | |
|---|
| 2874 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2875 | proc ::TolInspector::TableMatrix { matrix } { |
|---|
| 2876 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2877 | set mattb [::tol::matrix $matrix] |
|---|
| 2878 | # create |
|---|
| 2879 | set tl [::project::CreateForm \ |
|---|
| 2880 | -title "[mc {Matrix table}]: [lindex $mattb 0]" \ |
|---|
| 2881 | -iniconfig MatrixTable \ |
|---|
| 2882 | -type Tables -helpkey "Tb4Edt" |
|---|
| 2883 | ] |
|---|
| 2884 | set tlf [$tl getframe] |
|---|
| 2885 | # create matrix |
|---|
| 2886 | btable $tlf.t -parent $tl \ |
|---|
| 2887 | -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \ |
|---|
| 2888 | -iniconfig btable |
|---|
| 2889 | $tlf.t fillMatrix $mattb |
|---|
| 2890 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 2891 | pack $tlf.t -fill both -expand yes |
|---|
| 2892 | |
|---|
| 2893 | #if {$grammar == "VMatrix"} { |
|---|
| 2894 | #::tol::console stack release "zxw._.wxz" |
|---|
| 2895 | #} |
|---|
| 2896 | } |
|---|
| 2897 | |
|---|
| 2898 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2899 | proc ::TolInspector::ExportBDTMatrix { matrix } { |
|---|
| 2900 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2901 | variable group_id |
|---|
| 2902 | |
|---|
| 2903 | incr group_id |
|---|
| 2904 | set tl [toplevel .top$group_id] |
|---|
| 2905 | wm title $tl "ExportBDTMatrix" |
|---|
| 2906 | |
|---|
| 2907 | #pack $tl.t -fill both -expand yes |
|---|
| 2908 | } |
|---|
| 2909 | |
|---|
| 2910 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2911 | proc ::TolInspector::DrawSerie { } { |
|---|
| 2912 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2913 | variable options_selected |
|---|
| 2914 | upvar \#0 ::TolInspector::options_selected(Serie) series_selected |
|---|
| 2915 | |
|---|
| 2916 | #puts "DrawSerie: series_selected=$series_selected" |
|---|
| 2917 | set series "" |
|---|
| 2918 | foreach it $series_selected { |
|---|
| 2919 | lappend series [lindex $it 0] |
|---|
| 2920 | } |
|---|
| 2921 | DrawSeries $series |
|---|
| 2922 | } |
|---|
| 2923 | |
|---|
| 2924 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2925 | proc ::TolInspector::DrawSeries { series {gcf ""}} { |
|---|
| 2926 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2927 | variable group_id |
|---|
| 2928 | |
|---|
| 2929 | if { [llength $series] } { |
|---|
| 2930 | incr group_id |
|---|
| 2931 | # series |
|---|
| 2932 | set sergrp group$group_id |
|---|
| 2933 | set t0 [time { |
|---|
| 2934 | eval "::tol::seriegrp create $sergrp $series" |
|---|
| 2935 | }] |
|---|
| 2936 | # name |
|---|
| 2937 | set name [$sergrp serie 0 name] |
|---|
| 2938 | if { [$sergrp serie size] > 1} { |
|---|
| 2939 | set name ${name}... |
|---|
| 2940 | } |
|---|
| 2941 | # create |
|---|
| 2942 | set t1 [time { |
|---|
| 2943 | set tl [::project::CreateForm \ |
|---|
| 2944 | -title [mc "Series graph: %s" $name] \ |
|---|
| 2945 | -type Graphs \ |
|---|
| 2946 | -iniconfig SeriesGraph \ |
|---|
| 2947 | -width 900 -height 650 -helpkey "Tb4GraSer" |
|---|
| 2948 | ]}] |
|---|
| 2949 | set tlf [$tl getframe] |
|---|
| 2950 | # configuration |
|---|
| 2951 | set t2 [time { |
|---|
| 2952 | set Instance [::SeriesGraph::Create $tlf.g $sergrp] |
|---|
| 2953 | }] |
|---|
| 2954 | #puts "t0 = $t0" |
|---|
| 2955 | #puts "t1 = $t1" |
|---|
| 2956 | #puts "t2 = $t2" |
|---|
| 2957 | if { $gcf != "" } { |
|---|
| 2958 | ::bayesGraph::LoadGCF $Instance $gcf |
|---|
| 2959 | } |
|---|
| 2960 | bind $tlf.g <Destroy> +[list ::tol::seriegrp destroy $sergrp] |
|---|
| 2961 | pack $tlf.g -fill both -expand yes |
|---|
| 2962 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 2963 | update |
|---|
| 2964 | # Esta opción se debe aplicar cuando el gráfico esté empacado |
|---|
| 2965 | #::bayesGraph::GrapOptApplyAxisTicks $Instance ${Instance}::options gr,0 |
|---|
| 2966 | } |
|---|
| 2967 | } |
|---|
| 2968 | |
|---|
| 2969 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2970 | proc ::TolInspector::DrawAutocorSerie { serie } { |
|---|
| 2971 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2972 | variable group_id |
|---|
| 2973 | |
|---|
| 2974 | incr group_id |
|---|
| 2975 | # title |
|---|
| 2976 | |
|---|
| 2977 | if {[llength $serie] > 1} { |
|---|
| 2978 | set nameSerie [lindex [::tol::info variable $serie] 1] |
|---|
| 2979 | } else { |
|---|
| 2980 | set nameSerie $serie |
|---|
| 2981 | } |
|---|
| 2982 | # create |
|---|
| 2983 | set tl [::project::CreateForm \ |
|---|
| 2984 | -title "[mc "Autocorrelation graph"]: $nameSerie" \ |
|---|
| 2985 | -iniconfig AutocorGraph \ |
|---|
| 2986 | -type Graphs \ |
|---|
| 2987 | -width 900 -height 650 -helpkey "Tb4GraAco" |
|---|
| 2988 | ] |
|---|
| 2989 | set tlf [$tl getframe] |
|---|
| 2990 | # configuration |
|---|
| 2991 | ::AutocorGraph::Create $tlf.g $serie |
|---|
| 2992 | $tl bind <Control-F4> "$tl kill; break" |
|---|
| 2993 | pack $tlf.g -fill both -expand yes |
|---|
| 2994 | update |
|---|
| 2995 | } |
|---|
| 2996 | |
|---|
| 2997 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2998 | proc ::TolInspector::TableSerie { } { |
|---|
| 2999 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3000 | variable options_selected |
|---|
| 3001 | variable group_id |
|---|
| 3002 | upvar \#0 ::TolInspector::options_selected(Serie) series_selected |
|---|
| 3003 | |
|---|
| 3004 | set series "" |
|---|
| 3005 | foreach it $series_selected { |
|---|
| 3006 | lappend series [lindex $it 0] |
|---|
| 3007 | } |
|---|
| 3008 | |
|---|
| 3009 | if { [llength $series] } { |
|---|
| 3010 | incr group_id |
|---|
| 3011 | |
|---|
| 3012 | set sergrp group$group_id |
|---|
| 3013 | eval "::tol::seriegrp create $sergrp $series" |
|---|
| 3014 | |
|---|
| 3015 | # create |
|---|
| 3016 | set tl [::project::CreateForm \ |
|---|
| 3017 | -title [mc "Time series table"] \ |
|---|
| 3018 | -iniconfig SeriesTable \ |
|---|
| 3019 | -type Tables -helpkey "Tb4Edt" |
|---|
| 3020 | ] |
|---|
| 3021 | set tlf [$tl getframe] |
|---|
| 3022 | # configuration |
|---|
| 3023 | btable $tlf.t -parent $tl \ |
|---|
| 3024 | -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \ |
|---|
| 3025 | -iniconfig btable |
|---|
| 3026 | $tlf.t fillSerie $sergrp |
|---|
| 3027 | bind $tlf.t <Destroy> +[list ::tol::seriegrp destroy $sergrp] |
|---|
| 3028 | pack $tlf.t -fill both -expand yes |
|---|
| 3029 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 3030 | update |
|---|
| 3031 | } |
|---|
| 3032 | } |
|---|
| 3033 | |
|---|
| 3034 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3035 | proc ::TolInspector::TableAutocorSerie { serie } { |
|---|
| 3036 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3037 | variable group_id |
|---|
| 3038 | |
|---|
| 3039 | incr group_id |
|---|
| 3040 | # title |
|---|
| 3041 | if {[llength $serie] > 1} { |
|---|
| 3042 | set nameSerie [lindex [::tol::info variable $serie] 1] |
|---|
| 3043 | } else { |
|---|
| 3044 | set nameSerie $serie |
|---|
| 3045 | } |
|---|
| 3046 | # create |
|---|
| 3047 | set tl [::project::CreateForm \ |
|---|
| 3048 | -title "[mc "Autocorrelation table"]: $nameSerie" \ |
|---|
| 3049 | -iniconfig AutocorGraphTable \ |
|---|
| 3050 | -type Tables -helpkey "Tb4Edt" |
|---|
| 3051 | ] |
|---|
| 3052 | set tlf [$tl getframe] |
|---|
| 3053 | # configuration |
|---|
| 3054 | btable $tlf.t -parent $tl \ |
|---|
| 3055 | -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \ |
|---|
| 3056 | -iniconfig btable |
|---|
| 3057 | $tlf.t fillAutocor $serie "" |
|---|
| 3058 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 3059 | pack $tlf.t -fill both -expand yes |
|---|
| 3060 | } |
|---|
| 3061 | |
|---|
| 3062 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3063 | proc ::TolInspector::TableStatisticsSerie { } { |
|---|
| 3064 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3065 | variable options_selected |
|---|
| 3066 | variable group_id |
|---|
| 3067 | upvar \#0 ::TolInspector::options_selected(Serie) series_selected |
|---|
| 3068 | |
|---|
| 3069 | set series "" |
|---|
| 3070 | foreach it $series_selected { |
|---|
| 3071 | lappend series [lindex $it 0] |
|---|
| 3072 | } |
|---|
| 3073 | |
|---|
| 3074 | if { [llength $series] } { |
|---|
| 3075 | incr group_id |
|---|
| 3076 | |
|---|
| 3077 | set sergrp group$group_id |
|---|
| 3078 | eval "::tol::seriegrp create $sergrp $series" |
|---|
| 3079 | # create |
|---|
| 3080 | set tl [::project::CreateForm \ |
|---|
| 3081 | -title [mc "Statistics table"] \ |
|---|
| 3082 | -iniconfig StatisticsTable \ |
|---|
| 3083 | -type Tables -helpkey "Tb4Edt" |
|---|
| 3084 | ] |
|---|
| 3085 | set tlf [$tl getframe] |
|---|
| 3086 | # configuration |
|---|
| 3087 | btable $tlf.t -parent $tl \ |
|---|
| 3088 | -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \ |
|---|
| 3089 | -iniconfig btable |
|---|
| 3090 | $tlf.t fillStatistics $sergrp |
|---|
| 3091 | bind $tlf.t <Destroy> +[list ::tol::seriegrp destroy $sergrp] |
|---|
| 3092 | $tl bind <Control-F4> [list $tl kill] |
|---|
| 3093 | pack $tlf.t -fill both -expand yes |
|---|
| 3094 | } |
|---|
| 3095 | } |
|---|
| 3096 | |
|---|
| 3097 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3098 | proc ::TolInspector::ViewTimeSet { tms args } { |
|---|
| 3099 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3100 | variable group_id |
|---|
| 3101 | |
|---|
| 3102 | incr group_id |
|---|
| 3103 | |
|---|
| 3104 | #puts "::TolInspector::ViewTimeSet $tms" |
|---|
| 3105 | # args |
|---|
| 3106 | array set opts [list \ |
|---|
| 3107 | -title "[mc "TimeSet calendar"]: $tms" \ |
|---|
| 3108 | -geometry {} |
|---|
| 3109 | ] |
|---|
| 3110 | array set opts $args |
|---|
| 3111 | |
|---|
| 3112 | # create |
|---|
| 3113 | set tl [::project::CreateForm \ |
|---|
| 3114 | -title $opts(-title) \ |
|---|
| 3115 | -iniconfig Calendar \ |
|---|
| 3116 | -type TimeSets -width 470 -height 345 -helpkey "Tb4Cal" |
|---|
| 3117 | ] |
|---|
| 3118 | # geometry |
|---|
| 3119 | $tl setgeometry $opts(-geometry) |
|---|
| 3120 | |
|---|
| 3121 | set tlf [$tl getframe] |
|---|
| 3122 | # configuration |
|---|
| 3123 | set tmscmd tms$group_id |
|---|
| 3124 | ::tol::timeset create $tmscmd $tms |
|---|
| 3125 | ::CalendarTms::Create $tlf.t $tmscmd |
|---|
| 3126 | bind $tlf.t <Destroy> +[list ::tol::timeset destroy $tmscmd] |
|---|
| 3127 | bind $tl <Control-F4> [list $tl kill] |
|---|
| 3128 | pack $tlf.t -fill both -expand yes |
|---|
| 3129 | |
|---|
| 3130 | return $tl |
|---|
| 3131 | } |
|---|
| 3132 | |
|---|
| 3133 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3134 | proc ::TolInspector::ViewDefinition {name path grammar} { |
|---|
| 3135 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3136 | variable w_tabset |
|---|
| 3137 | if {$path == ""} { |
|---|
| 3138 | tk_messageBox -type ok -icon warning\ |
|---|
| 3139 | -message [mc "Object %1\$s is not defined in a tol file" $name]\ |
|---|
| 3140 | -parent $w_tabset -title [mc Warning] |
|---|
| 3141 | return |
|---|
| 3142 | } |
|---|
| 3143 | set ext [file extension $path] |
|---|
| 3144 | switch -- $ext { |
|---|
| 3145 | .tol - |
|---|
| 3146 | .TOL { |
|---|
| 3147 | set Instance [::Editor::Open $path] |
|---|
| 3148 | update |
|---|
| 3149 | if {[string equal $grammar "Code"] || |
|---|
| 3150 | [string equal $grammar "Anything"]} { |
|---|
| 3151 | append txtFind " " $name "( )*\\(" |
|---|
| 3152 | } else { |
|---|
| 3153 | #append txtFind $grammar "( )+" $name |
|---|
| 3154 | append txtFind $name |
|---|
| 3155 | } |
|---|
| 3156 | #Me situo al principio del texto |
|---|
| 3157 | set editor [::Editor::GetText $Instance] |
|---|
| 3158 | tk::TextSetCursor $editor 1.0 |
|---|
| 3159 | ::BayesText::FindShow $editor 1 $txtFind 1 |
|---|
| 3160 | #::Editor::CmdFindNext $Instance $txtFind |
|---|
| 3161 | } |
|---|
| 3162 | .bst - |
|---|
| 3163 | .BST - |
|---|
| 3164 | .bdt - |
|---|
| 3165 | .BDT { |
|---|
| 3166 | # Igual luego se abre como tabla |
|---|
| 3167 | ::Editor::Open $path |
|---|
| 3168 | } |
|---|
| 3169 | } |
|---|
| 3170 | } |
|---|
| 3171 | |
|---|
| 3172 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3173 | proc ::TolInspector::ViewFile {name} { |
|---|
| 3174 | # |
|---|
| 3175 | # PURPOSE: |
|---|
| 3176 | # |
|---|
| 3177 | # PARAMETERS: |
|---|
| 3178 | # name -> cadena con el nombre de un archivo o el de una variable |
|---|
| 3179 | # que hace referencia a un archivo |
|---|
| 3180 | # |
|---|
| 3181 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3182 | # En name puede venir el nombre de un archivo o el de una variable |
|---|
| 3183 | # que hace referencia a un archivo. |
|---|
| 3184 | #puts "ViewFile. name=$name" |
|---|
| 3185 | if [file isfile $name] { |
|---|
| 3186 | set path $name |
|---|
| 3187 | } else { |
|---|
| 3188 | set path [::tol::info path $name] |
|---|
| 3189 | } |
|---|
| 3190 | ::Editor::Open $path |
|---|
| 3191 | } |
|---|
| 3192 | |
|---|
| 3193 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3194 | proc ::TolInspector::DecompileFile {name} { |
|---|
| 3195 | # |
|---|
| 3196 | # PURPOSE: |
|---|
| 3197 | # |
|---|
| 3198 | # PARAMETERS: |
|---|
| 3199 | # name -> cadena con el nombre de un archivo o el de una variable |
|---|
| 3200 | # que hace referencia a un archivo |
|---|
| 3201 | # |
|---|
| 3202 | # TODO: Actualmente en name solo puede llegar el nombre de un archivo |
|---|
| 3203 | # |
|---|
| 3204 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3205 | variable data |
|---|
| 3206 | #puts "DECOMPILE 1.1, name=$name" |
|---|
| 3207 | if {[file isfile $name]} { |
|---|
| 3208 | set path $name |
|---|
| 3209 | } else { |
|---|
| 3210 | set path [::tol::info path $name] |
|---|
| 3211 | } |
|---|
| 3212 | #puts "DECOMPILE 1.2" |
|---|
| 3213 | #Comprobar si el archivo ya está abierto y si es asà poner que no está compilado |
|---|
| 3214 | if [namespace exists ::Editor] { |
|---|
| 3215 | foreach ins [namespace children ::Editor] { |
|---|
| 3216 | upvar \#0 ${ins}::data dataEd |
|---|
| 3217 | if [string equal $dataEd(nameFile) $path] { |
|---|
| 3218 | set dataEd(isCompiled) 0 |
|---|
| 3219 | } |
|---|
| 3220 | } |
|---|
| 3221 | } |
|---|
| 3222 | #puts "DECOMPILE 1.3" |
|---|
| 3223 | #Quitar del spool todos los objetos provenientes de este archivo |
|---|
| 3224 | |
|---|
| 3225 | foreach _obj $data(pool,objects) { |
|---|
| 3226 | array set obj $_obj |
|---|
| 3227 | #Tolcon_Trace "REFERENCIA: $obj(reference)" |
|---|
| 3228 | if {[string equal [lindex $obj(reference) 0] $path]} { |
|---|
| 3229 | set idx [lsearch $data(pool,objects) $_obj] |
|---|
| 3230 | set data(pool,objects) [lreplace $data(pool,objects) $idx $idx] |
|---|
| 3231 | } |
|---|
| 3232 | } |
|---|
| 3233 | ::tol::decompile $path |
|---|
| 3234 | ::TolInspector::UpdateFileRoot |
|---|
| 3235 | } |
|---|
| 3236 | |
|---|
| 3237 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3238 | proc ::TolInspector::ReadUserFunctions {} { |
|---|
| 3239 | # |
|---|
| 3240 | # PURPOSE: Recorre el set global que tiene la definicion de funciones y va |
|---|
| 3241 | # guardando esa informacion en arrays para almacenarla finalmente en |
|---|
| 3242 | # regFunLst |
|---|
| 3243 | # |
|---|
| 3244 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3245 | variable regFunLst |
|---|
| 3246 | |
|---|
| 3247 | #Set global que tiene la definicion de funciones |
|---|
| 3248 | set obj GuiFunction |
|---|
| 3249 | |
|---|
| 3250 | if { [llength [set infAry [TclInfoVar Set $obj]] ] } { |
|---|
| 3251 | #Tolcon_Trace "ReadUserFunctions: infAry = $infAry" |
|---|
| 3252 | array set info $infAry |
|---|
| 3253 | set nFun [lindex $info(CONTENT) 0] |
|---|
| 3254 | #Tolcon_Trace "Numero de funciones =$nFun" |
|---|
| 3255 | for {set idf 1} {$idf <= $nFun} {incr idf} { |
|---|
| 3256 | array set ifNameFun [TclInfoRef [list Set $obj $idf 1]] |
|---|
| 3257 | array set ifNameGui [TclInfoRef [list Set $obj $idf 2]] |
|---|
| 3258 | array set ifTypeGui [TclInfoRef [list Set $obj $idf 3]] |
|---|
| 3259 | array set ifTypeOut [TclInfoRef [list Set $obj $idf 4]] |
|---|
| 3260 | array set ifParams [TclInfoRef [list Set $obj $idf 5]] |
|---|
| 3261 | #Hago lindex $a(CONTENT) 0 para quitar las comillas |
|---|
| 3262 | set regFun($idf,nameFun) [lindex $ifNameFun(CONTENT) 0] |
|---|
| 3263 | set regFun($idf,nameGui) [lindex $ifNameGui(CONTENT) 0] |
|---|
| 3264 | set regFun($idf,typeGui) [lindex $ifTypeGui(CONTENT) 0] |
|---|
| 3265 | set regFun($idf,typeOut) [lindex $ifTypeOut(CONTENT) 0] |
|---|
| 3266 | set nPar [lindex $ifParams(CONTENT) 0] |
|---|
| 3267 | #Tolcon_Trace "Numero de parametros =$nPar" |
|---|
| 3268 | for {set idp 1} {$idp <= $nPar} {incr idp} { |
|---|
| 3269 | array set ipNameGui [TclInfoRef [list Set $obj $idf 5 $idp 1]] |
|---|
| 3270 | array set ipTypePar [TclInfoRef [list Set $obj $idf 5 $idp 2]] |
|---|
| 3271 | array set ipTypeSel [TclInfoRef [list Set $obj $idf 5 $idp 3]] |
|---|
| 3272 | array set ipListVal [TclInfoRef [list Set $obj $idf 5 $idp 4]] |
|---|
| 3273 | set regPar($idp,nameGui) [lindex $ipNameGui(CONTENT) 0] |
|---|
| 3274 | set regPar($idp,typePar) [lindex $ipTypePar(CONTENT) 0] |
|---|
| 3275 | set regPar($idp,typeSel) $ipTypeSel(CONTENT) |
|---|
| 3276 | set nVal [lindex $ipListVal(CONTENT) 0] |
|---|
| 3277 | #Tolcon_Trace "nVal=$nVal" |
|---|
| 3278 | set lstVal "" |
|---|
| 3279 | for {set idv 1} {$idv <= $nVal} {incr idv} { |
|---|
| 3280 | array set iVal [TclInfoRef [list Set $obj $idf 5 $idp 4 $idv]] |
|---|
| 3281 | lappend lstVal [lindex $iVal(CONTENT) 0] |
|---|
| 3282 | } |
|---|
| 3283 | set regPar($idp,lstVal) $lstVal |
|---|
| 3284 | } |
|---|
| 3285 | set regFun($idf,parameters) [array get regPar] |
|---|
| 3286 | array unset regPar |
|---|
| 3287 | #parray regFun |
|---|
| 3288 | } |
|---|
| 3289 | set regFunLst [array get regFun] |
|---|
| 3290 | } else { |
|---|
| 3291 | set regFunLst "" |
|---|
| 3292 | } |
|---|
| 3293 | } |
|---|
| 3294 | |
|---|
| 3295 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3296 | proc ::TolInspector::ShowMenuUserFunc {gra} { |
|---|
| 3297 | # |
|---|
| 3298 | # PURPOSE: Muestra un menu contextual que... |
|---|
| 3299 | # |
|---|
| 3300 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3301 | variable data_menu |
|---|
| 3302 | variable regFunLst |
|---|
| 3303 | |
|---|
| 3304 | puts "ShowMenuUserFunc: gra=$gra" |
|---|
| 3305 | if {[expr [info exist ::TolInspector::regFunLst] && [llength $regFunLst] ]} { |
|---|
| 3306 | array set regFun $regFunLst |
|---|
| 3307 | regsub -all ,nameGui \ |
|---|
| 3308 | [array names regFun *,nameGui] "" lstFun |
|---|
| 3309 | foreach idf [lsort -integer $lstFun] { |
|---|
| 3310 | set typeGui [split $regFun($idf,typeGui) .] |
|---|
| 3311 | switch [lindex $typeGui 0] { |
|---|
| 3312 | Ite - Set { |
|---|
| 3313 | if {[lindex $typeGui 1] eq $gra} { |
|---|
| 3314 | $data_menu($gra,Functions) add command -label [mc $regFun($idf,nameGui)]\ |
|---|
| 3315 | -command [list ::TolInspector::CallUserFunction $gra $idf] |
|---|
| 3316 | } |
|---|
| 3317 | } |
|---|
| 3318 | default { |
|---|
| 3319 | } |
|---|
| 3320 | } |
|---|
| 3321 | } |
|---|
| 3322 | } |
|---|
| 3323 | } |
|---|
| 3324 | |
|---|
| 3325 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3326 | proc ::TolInspector::CallUserFunction {grammar idx} { |
|---|
| 3327 | # |
|---|
| 3328 | # PURPOSE: Para los tipos de funciones Ite y Set, muestra un dialogo que |
|---|
| 3329 | # pide los |
|---|
| 3330 | # |
|---|
| 3331 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 3332 | variable regFunLst |
|---|
| 3333 | variable group_id |
|---|
| 3334 | variable data |
|---|
| 3335 | variable options_selected |
|---|
| 3336 | |
|---|
| 3337 | upvar \#0 ::TolInspector::options_selected($grammar) items_selected |
|---|
| 3338 | #puts "CallUserFunction. grammar=$grammar, idx=$idx, items_selected=$items_selected" |
|---|
| 3339 | |
|---|
| 3340 | set all_objs [ list ] |
|---|
| 3341 | foreach it $items_selected { |
|---|
| 3342 | set tcl_ref [ lindex $it 0 ] |
|---|
| 3343 | set obj_addr [ ::tol::info address $tcl_ref ] |
|---|
| 3344 | lappend all_objs "GetObjectFromAddress(\"$obj_addr\")" |
|---|
| 3345 | } |
|---|
| 3346 | |
|---|
| 3347 | if { [ llength $all_objs ] } { |
|---|
| 3348 | incr group_id |
|---|
| 3349 | array set regFun $regFunLst |
|---|
| 3350 | set gui [bguifunction .t$group_id \ |
|---|
| 3351 | -title $regFun($idx,nameGui) \ |
|---|
| 3352 | -regpars $regFun($idx,parameters)] |
|---|
| 3353 | set txtPars [join [$gui get values] ,] |
|---|
| 3354 | if {$txtPars ne ""} { |
|---|
| 3355 | set txtPars ",$txtPars" |
|---|
| 3356 | } |
|---|
| 3357 | destroy $gui |
|---|
| 3358 | set typeGui [split $regFun($idx,typeGui) .] |
|---|
| 3359 | switch [lindex $typeGui 0] { |
|---|
| 3360 | Ite { |
|---|
| 3361 | foreach obj $all_objs { |
|---|
| 3362 | set cmd "$regFun($idx,typeOut) $regFun($idx,nameFun) ($obj $txtPars)" |
|---|
| 3363 | #Tolcon_Trace "Ite.cmd=$cmd" |
|---|
| 3364 | ::tol::console eval $cmd |
|---|
| 3365 | ::TolConsole::SaveEval $cmd |
|---|
| 3366 | } |
|---|
| 3367 | } |
|---|
| 3368 | Set { |
|---|
| 3369 | set obj_args [join $all_objs ,] |
|---|
| 3370 | set setCmd "SetOf[lindex $typeGui 1] ($obj_args)" |
|---|
| 3371 | set cmd "$regFun($idx,typeOut) $regFun($idx,nameFun) ($setCmd $txtPars)" |
|---|
| 3372 | #Tolcon_Trace "Set.cmd=$cmd" |
|---|
| 3373 | ::tol::console eval $cmd |
|---|
| 3374 | ::TolConsole::SaveEval $cmd |
|---|
| 3375 | } |
|---|
| 3376 | default { |
|---|
| 3377 | } |
|---|
| 3378 | } |
|---|
| 3379 | ::TolInspector::UpdateConsoleObj |
|---|
| 3380 | } |
|---|
| 3381 | } |
|---|
| 3382 | |
|---|
| 3383 | namespace eval ::LoadStatus { |
|---|
| 3384 | variable data |
|---|
| 3385 | } |
|---|
| 3386 | |
|---|
| 3387 | #proc ::LoadStatus::Show {file} { |
|---|
| 3388 | # |
|---|
| 3389 | # set f [toplevel .topStatus] |
|---|
| 3390 | # #wm protocol $path WM_DELETE_WINDOW [list ::Editor::OnDelete $this] |
|---|
| 3391 | # # bind Destroy más abajo |
|---|
| 3392 | # |
|---|
| 3393 | # label $f.lfile -text $file |
|---|
| 3394 | # # frame y label para barra de estado |
|---|
| 3395 | # set data(sb,frame) [frame $f.fop -relief groove -bd 1 -height 7] |
|---|
| 3396 | # set data(sb,objs) [label $f.fop.objs -relief groove -bd 1 -width 16] |
|---|
| 3397 | # set data(sb,files) [label $f.fop.files -text [mc "Not Compiled"] \ |
|---|
| 3398 | # -relief raised -bd 1 -width 16] |
|---|
| 3399 | # set data(sb,time) [label $f.fop.time -bd 1 -width 14] |
|---|
| 3400 | # set data(sb,rell) [label $f.fop.rell -relief groove -bd 1] |
|---|
| 3401 | # |
|---|
| 3402 | # |
|---|
| 3403 | # # empaquetamos los label de estado |
|---|
| 3404 | # pack $f.fop.objs $f.fop.files $f.fop.time -side left |
|---|
| 3405 | # pack $f.fop.rell -expand true -fill x |
|---|
| 3406 | # |
|---|
| 3407 | # grid $f.lfile -sticky news |
|---|
| 3408 | # grid $f.fop -sticky ews |
|---|
| 3409 | # |
|---|
| 3410 | # grid rowconfigure $f 1 -weight 1 |
|---|
| 3411 | # grid columnconfigure $f 0 -weight 1 |
|---|
| 3412 | # |
|---|
| 3413 | #} |
|---|
| 3414 | # |
|---|
| 3415 | # |
|---|
| 3416 | #proc ::LoadStatus::Hide {w} { |
|---|
| 3417 | # |
|---|
| 3418 | # |
|---|