Changeset 4592f76 in tol
- Timestamp:
- Nov 15, 2016, 9:06:12 AM (10 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 20907d9
- Parents:
- 87b1c46
- Location:
- tolbase/lib/toltk
- Files:
-
- 3 edited
-
bftrview.tcl (modified) (1 diff)
-
tclIndex (modified) (3 diffs)
-
tolprj.tcl (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolbase/lib/toltk/bftrview.tcl
r87b1c46 r4592f76 5 5 #///////////////////////////////////////////////////////////////////////////// 6 6 7 #@ OBSOLETO 7 8 8 9 #///////////////////////////////////////////////////////////////////////////// -
tolbase/lib/toltk/tclIndex
r87b1c46 r4592f76 79 79 set auto_index(::TolConsole::TableRecent) [list source [file join $dir tolbase.tcl]] 80 80 set auto_index(::TolConsole::TableRecentClear) [list source [file join $dir tolbase.tcl]] 81 set auto_index(::BayesTreeview::TreeviewFromFile) [list source [file join $dir bftrview.tcl]]82 set auto_index(::BayesTreeview::TreeviewToFile) [list source [file join $dir bftrview.tcl]]83 set auto_index(::BayesTreeview::NodeToFile) [list source [file join $dir bftrview.tcl]]84 set auto_index(::BayesTreeview::NodeFromFile) [list source [file join $dir bftrview.tcl]]85 81 set auto_index(::ODBCDialog::Create) [list source [file join $dir odbc.tcl]] 86 82 set auto_index(::ODBCDialog::Destroy) [list source [file join $dir odbc.tcl]] … … 810 806 set auto_index(::ListOrder::Down) [list source [file join $dir listorde.tcl]] 811 807 812 set auto_index( Blt_ViewMode) [list source [file join $dir graph.tcl]]813 set auto_index(:: blt::SetZoomScale) [list source [file join $dir graph.tcl]]814 set auto_index(:: blt::ClearMode) [list source [file join $dir graph.tcl]]815 set auto_index(:: blt::ZoomScale) [list source [file join $dir graph.tcl]]816 set auto_index(:: blt::SetZoomPoint) [list source [file join $dir graph.tcl]]817 set auto_index(:: blt::SetScrollPoint) [list source [file join $dir graph.tcl]]818 set auto_index(:: blt::Scroll) [list source [file join $dir graph.tcl]]808 set auto_index(Rbc_ViewMode) [list source [file join $dir graph.tcl]] 809 set auto_index(::rbc::SetZoomScale) [list source [file join $dir graph.tcl]] 810 set auto_index(::rbc::ClearMode) [list source [file join $dir graph.tcl]] 811 set auto_index(::rbc::ZoomScale) [list source [file join $dir graph.tcl]] 812 set auto_index(::rbc::SetZoomPoint) [list source [file join $dir graph.tcl]] 813 set auto_index(::rbc::SetScrollPoint) [list source [file join $dir graph.tcl]] 814 set auto_index(::rbc::Scroll) [list source [file join $dir graph.tcl]] 819 815 820 816 set auto_index(setini) [list source [file join $dir ini.tcl]] … … 1007 1003 set auto_index(::bayesGraph::GrapOptGetNamesLines) [list source [file join $dir bysgropt.tcl]] 1008 1004 set auto_index(::bayesGraph::GrapOptGetIdLines) [list source [file join $dir bysgropt.tcl]] 1005 set auto_index(::TolProject::Node) [list source [file join $dir tolprj.tcl]] 1006 set auto_index(::TolProject::NodeDef) [list source [file join $dir tolprj.tcl]] 1007 set auto_index(::TolProject::NiFileName) [list source [file join $dir tolprj.tcl]] 1008 set auto_index(::TolProject::NiDescription) [list source [file join $dir tolprj.tcl]] 1009 set auto_index(::TolProject::NiType) [list source [file join $dir tolprj.tcl]] 1010 set auto_index(::TolProject::NiExclude) [list source [file join $dir tolprj.tcl]] 1011 set auto_index(::TolProject::NiExcludeTOL) [list source [file join $dir tolprj.tcl]] 1012 set auto_index(::TolProject::WtreeFromFile) [list source [file join $dir bftrview.tcl]] 1013 set auto_index(::TolProject::WtreeToFile) [list source [file join $dir bftrview.tcl]] 1014 set auto_index(::TolProject::BNodeToFile) [list source [file join $dir tolprj.tcl]] 1015 set auto_index(::TolProject::BNodeFromFile) [list source [file join $dir tolprj.tcl]] 1009 1016 set auto_index(::TolProject::ComputeFullPath) [list source [file join $dir tolprj.tcl]] 1010 1017 set auto_index(::TolProject::New) [list source [file join $dir tolprj.tcl]] -
tolbase/lib/toltk/tolprj.tcl
r87b1c46 r4592f76 41 41 } 42 42 43 #///////////////////////////////////////////////////////////////////////////// 44 proc ::TolProject::NodeDef { } { 45 #///////////////////////////////////////////////////////////////////////////// 46 return [list \ 47 [list {image text} -label FileName] \ 48 [list text -label Description] \ 49 [list text -label Type] \ 50 [list text -label Exclude] \ 51 [list text -label ExcludeTOL] 52 ] 53 } 54 55 #///////////////////////////////////////////////////////////////////////////// 56 proc ::TolProject::Node {icon filename desc type exclude excludetol} { 57 #///////////////////////////////////////////////////////////////////////////// 58 return [list \ 59 [list $icon $filename] \ 60 [list $desc] \ 61 [list $type] \ 62 [list $exclude] \ 63 [list $excludetol] \ 64 ] 65 } 66 67 proc ::TolProject::NiFileName { } { return 0 } 68 proc ::TolProject::NiDescription { } { return 1 } 69 proc ::TolProject::NiType { } { return 2 } 70 proc ::TolProject::NiExclude { } { return 3 } 71 proc ::TolProject::NiExcludeTOL { } { return 4 } 43 72 44 73 #///////////////////////////////////////////////////////////////////////////// … … 300 329 $data(f) configure -title "[mc Project] $data(labelWindow)" 301 330 set tv [GetTreeview $this] 302 $tv entry configure root -label [file tail $data(labelWindow)]\303 -data [list FileName $data(nameFile)]331 #@ Antes se usaba $data(nameFile) como FileName y $data(labelWindow) como label 332 $tv item text root [NiFileName] [file tail $data(labelWindow)] 304 333 } 305 334 … … 419 448 # treeview y scroll 420 449 ScrolledWindow $f.sw 421 set data(treeview) [blt::treeview $f.sw.t -hideroot no -activeicons ""\ 422 -highlightthickness 0 -font $toltk_options(fonts,Label)\ 423 -selectcommand [list ::TolProject::SelectProc $this]] 424 $data(treeview) column insert end FileName Description Type Exclude ExcludeTOL \ 425 -hide true 426 $data(treeview) style configure text -bg white 450 set data(treeview) [::wtree $f.sw.t -table 0 -filter no \ 451 -background white -showroot 1 -selectmode single -showheader 0 \ 452 -highlightbackground gray75 -highlightcolor black \ 453 -highlightthickness 0 -font $toltk_options(fonts,Label) \ 454 -columns [::TolProject::NodeDef] ] 455 $data(treeview) item style set root [NiFileName] [$data(treeview) column cget [NiFileName] -itemstyle] 456 $data(treeview) item style set root [NiDescription] [$data(treeview) column cget [NiDescription] -itemstyle] 457 $data(treeview) item style set root [NiType] [$data(treeview) column cget [NiType] -itemstyle] 458 $data(treeview) item style set root [NiExclude] [$data(treeview) column cget [NiExclude] -itemstyle] 459 $data(treeview) item style set root [NiExcludeTOL] [$data(treeview) column cget [NiExcludeTOL] -itemstyle] 460 $data(treeview) column configure "range 1 end" -visible no 461 $data(treeview) column configure first -expand yes -weight 1 462 $data(treeview) column configure all -itembackground "" 463 $data(treeview) notify bind $data(treeview) <Selection> "::TolProject::SelectProc $this" 464 427 465 $f.sw setwidget $f.sw.t 428 429 466 430 467 # empaquetamos los label de estado … … 440 477 441 478 442 bind $data(treeview) <Control-KeyRelease> [list ::TolProject::OnControlKey $this %K %k] 443 444 bind $data(treeview) <Button-1> "::focus $data(treeview)" 445 $data(treeview) bind all <Button-1> "+break" 446 $data(treeview) bind all <Button-3> +[list ::TolProject::PostVariable $this %X %Y] 447 $data(treeview) bind all <Double-Button-1> "+mdidoc disableglobalraise; \ 448 ::TolProject::OpenNodeIfTerminal $this" 449 $data(treeview) bind all <KeyPress-Return> +[list ::TolProject::OpenNodeIfTerminal $this] 450 451 $data(treeview) bind all <KeyPress-space> +[list ::TolProject::NodeActiveAttributes $this] 452 $data(treeview) bind all <KeyPress-Delete> +[list ::TolProject::DeleteActiveNode $this] 453 $data(treeview) bind all <KeyPress-F9> "::TolProject::CompileActiveNode $this ; break" 454 $data(treeview) bind all <KeyPress-F8> "::TolProject::DecompileActiveNode $this ; break" 479 bind $data(treeview).frameTree.t <Control-KeyRelease> [list ::TolProject::OnControlKey $this %K %k] 480 481 bind $data(treeview).frameTree.t <Button-1> "::focus $data(treeview)" 455 482 456 set data(mainMenu) [menu $data(treeview).m -tearoff 0] 483 bind $data(treeview).frameTree.t <Button-3> +[list ::TolProject::PostVariable $this %X %Y] 484 485 set prevBind [bind $data(treeview).frameTree.t <Double-1>] 486 set newBind "[lrange $prevBind 0 [expr [llength $prevBind]-3]] ; mdidoc disableglobalraise ; ::TolProject::OpenNodeIfTerminal $this ; break" 487 #@ mdidoc disableglobalraise y break parece que cumplen el mismo cometido 488 bind $data(treeview).frameTree.t <Double-1> $newBind 489 490 set prevBind [bind $data(treeview).frameTree.t <KeyPress-Return>] 491 set newBind "[lrange $prevBind 0 [expr [llength $prevBind]-3]] ; ::TolProject::OpenNodeIfTerminal $this ; break" 492 bind $data(treeview).frameTree.t <KeyPress-Return> $newBind 493 494 bind $data(treeview).frameTree.t <KeyPress-space> +[list ::TolProject::NodeActiveAttributes $this] 495 bind $data(treeview).frameTree.t <KeyPress-Delete> +[list ::TolProject::DeleteActiveNode $this] 496 bind $data(treeview).frameTree.t <KeyPress-F9> "::TolProject::CompileActiveNode $this ; break" 497 bind $data(treeview).frameTree.t <KeyPress-F8> "::TolProject::DecompileActiveNode $this ; break" 498 499 set data(mainMenu) [menu $data(treeview).m -tearoff 0] 457 500 458 501 bind $data(f) <Destroy> +[list ::TolProject::Destroy $this %W] … … 498 541 set tv [GetTreeview $this] 499 542 if [string equal [CheckOpen $this] "cancel"] return 500 $tv delete root543 $tv item delete all 501 544 set img [GetImageFromType ROOT] 502 $tv entry configure root -icons [list $img $img]\ 503 -data [list FileName "" Description "Root node" Type ROOT Exclude 0 ExcludeTOL 0] 545 $tv item image root [NiFileName] $img 546 $tv item text root [NiFileName] "" 547 $tv item text root [NiDescription] "Root node" 548 $tv item text root [NiType] "ROOT" 549 $tv item text root [NiExclude] 0 550 $tv item text root [NiExcludeTOL] 0 504 551 InitState $this new 505 552 } … … 579 626 } 580 627 581 582 628 #///////////////////////////////////////////////////////////////////////////// 583 629 proc ::TolProject::GetFromFile {this path {run 0}} { … … 594 640 upvar \#0 ${this}::data data 595 641 set tv [GetTreeview $this] 596 $tv delete root 597 foreach item [$tv tag names] { 598 $tv tag forget $item 599 } 600 if {[::BayesTreeview::TreeviewFromFile $tv $path ::TolProject::GetImageFromType]} { 642 $tv item delete all 643 if {[::TolProject::WtreeFromFile $tv $path ::TolProject::GetImageFromType]} { 601 644 set data(baseDir) [file dirname $path] 602 645 set data(lastOpenedNodeDir) $data(baseDir) … … 752 795 753 796 #Guardar la transformación de treeview a archivo 754 if {[:: BayesTreeview::TreeviewToFile [GetTreeview $this] \797 if {[::TolProject::WtreeToFile [GetTreeview $this] \ 755 798 [::TolProject::ComputeFullPath $this $path]]} { 756 799 #Añadir al archivo la entrada para que pueda ser llamado desde tol.exe … … 803 846 set tv [GetTreeview $this] 804 847 # Guardar data del nodo actual 805 array set aryData [$tv entry cget $index -data] 806 #rcsi 807 if {![info exists aryData(ExcludeTOL)]} { 808 set aryData(ExcludeTOL) 0 809 } 810 #rcsf 811 if ![string equal $aryData(ExcludeTOL) 1] { 848 set excludeTOL [$tv item text $index [NiExcludeTOL]] 849 if ![string equal $excludeTOL 1] { 812 850 if {[IsCompilable $this $index] } { 851 set filename [$tv item text $index [NiFileName]] 813 852 set item "Set $name.$data(num)" 814 set value "Include(\"$ aryData(FileName)\");"853 set value "Include(\"$filename\");" 815 854 Tolcon_Trace "item: $item, value: $value" 816 855 writeini $fd $key $item $value … … 818 857 } 819 858 # Llamar recursivamente para los hijos 820 foreach child [$tv entrychildren $index] {859 foreach child [$tv item children $index] { 821 860 NodeToFile $this $child $fd $name 822 861 } … … 863 902 upvar \#0 ${this}::data data 864 903 set tv [GetTreeview $this] 865 set node [$tv index anchor] 866 array set aryData [$tv entry cget $node -data] 867 $data(sb,desc) configure -text $aryData(Description) 904 set node [$tv selection get end] ;# anchor 905 if { $node eq "" } return 906 set description [$tv item text $node [NiDescription]] 907 $data(sb,desc) configure -text "$description" 868 908 } 869 909 … … 887 927 set state [expr {$data(compiling)? "disabled" : "normal" }] 888 928 889 set node [$tv index current]929 set node [$tv selection get end] ;# current 890 930 if { [string length $node] } { 891 931 if [IsTerminal $this $node] { … … 894 934 895 935 # Compute insertion point and prepare menu entry 896 set parent [$tv index parent] 897 set prev [$tv index prevsibling] 936 set nodefocus [$tv selection get end] ;# focus 937 set parent [$tv item parent $nodefocus] 938 set prev [$tv item prevsibling $nodefocus] 898 939 if {[string equal $prev ""]} { 899 940 set prevCount 1 900 941 } else { 901 set prevCount [expr [lsearch [$tv entrychildren $parent] $node] + 1]942 set prevCount [expr [lsearch [$tv item children $parent] $node] + 1] 902 943 } 903 944 $menu add command -label [mc "Add node"] \ … … 954 995 upvar \#0 ${this}::data data 955 996 set tv [GetTreeview $this] 956 set node [$tv index anchor]997 set node [$tv selection get end] ;# anchor 957 998 OpenNode $this $node 958 999 } … … 972 1013 set tv [GetTreeview $this] 973 1014 974 array set aryData [$tv entry cget $node -data] 975 switch $aryData(Type) { 1015 set type [$tv item text $node [NiType]] 1016 set filename [$tv item text $node [NiFileName]] 1017 switch $type { 976 1018 TOL { ::Editor::Open \ 977 [::TolProject::ComputeFullPath $this $ aryData(FileName)] }1019 [::TolProject::ComputeFullPath $this $filename] } 978 1020 BDT - 979 1021 BST { ::EditTable::Open \ 980 [::TolProject::ComputeFullPath $this $ aryData(FileName)] }1022 [::TolProject::ComputeFullPath $this $filename] } 981 1023 } 982 1024 } … … 1030 1072 } 1031 1073 1032 set i dx [$tv insert -at $node $prev "$data(name)"]1033 $tv entry configure $idx -label $data(name) \1034 -data [list FileName $data(name) Description $data(desc)\1035 Type $data(type) Exclude $data(exclude)\1036 ExcludeTOL $data(excludeTOL)]1037 if ![string equal [set img [GetImageFromType $data(type)]] ""] {1038 $tv entry configure $idx -icons [list $img $img]1074 set img [GetImageFromType $data(type)] 1075 set tv_row [::TolProject::Node $img $data(name) $data(desc) $data(type) $data(exclude) $data(excludeTOL)] 1076 if {$prev eq "end"} { 1077 set where end 1078 } else { 1079 set where next 1080 set node $prev 1039 1081 } 1082 if { $data(type) eq "Fol" } { 1083 set hasbutton 1 1084 } else { 1085 set hasbutton 0 1086 } 1087 #@ Tolcon_Trace "prev $prev node $node where $where" 1088 $tv insert $tv_row -at $where -relative $node -button $hasbutton 1040 1089 set data(isSaved) 0 1041 1090 } … … 1048 1097 upvar \#0 ${this}::data data 1049 1098 set tv [GetTreeview $this] 1050 set node [$tv index anchor]1099 set node [$tv selection get end] ;# anchor 1051 1100 NodeAttributes $this $node 1052 1101 } … … 1069 1118 set excl_old $data(exclude) 1070 1119 set exct_old $data(excludeTOL) 1071 set title "[$tv entry cget $node -label] [mc Attributes]"1120 set title "[$tv item text $node [NiFileName]] [mc Attributes]" 1072 1121 DialogAttributes $this $tv $title 1073 1122 # si no se ha pulsado cancelar … … 1078 1127 ![string equal $excl_old $data(exclude)] || 1079 1128 ![string equal $exct_old $data(excludeTOL)]} { 1080 $tv entry configure $node -label $data(name) \ 1081 -data [list FileName $data(name) Description $data(desc)\ 1082 Exclude $data(exclude) ExcludeTOL $data(excludeTOL)] 1129 $tv item text root FileName $data(name) 1130 $tv item text root Description $data(desc) 1131 $tv item text root Exclude $data(exclude) 1132 $tv item text root ExcludeTOL $data(excludeTOL) 1083 1133 set data(isSaved) 0 1084 1134 } … … 1093 1143 upvar \#0 ${this}::data data 1094 1144 set tv [GetTreeview $this] 1095 set node [$tv index current]1145 set node [$tv selection get end] ;# current 1096 1146 DeleteNode $this $node 1097 1147 } … … 1110 1160 1111 1161 set tv [GetTreeview $this] 1112 set name [$tv entry cget $node -label]1162 set name [$tv item text $node [NiFileName]] 1113 1163 set answer [tk_messageBox -title [mc "Question"]\ 1114 1164 -parent $tv\ … … 1116 1166 -type yesno -icon question] 1117 1167 if { [string compare $answer yes] == 0 } { 1118 1119 $tv delete $node 1168 $tv item delete $node 1120 1169 set data(isSaved) 0 1121 1170 } … … 1128 1177 upvar \#0 ${this}::data data 1129 1178 set tv [GetTreeview $this] 1130 set node [$tv index current]1179 set node [$tv selection get end] ;# current 1131 1180 CompileNode $this $node 1132 1181 } … … 1145 1194 upvar \#0 ${this}::data data 1146 1195 set tv [GetTreeview $this] 1147 array set aryData [$tv entry cget $node -data]1148 if ![string equal $ aryData(Exclude) 1] {1196 set exclude [$tv item text $node [NiExclude]] 1197 if ![string equal $exclude 1] { 1149 1198 if [IsCompilable $this $node] { 1150 1199 #Tolcon_Trace " Compilo $node" 1151 1200 set data(compiling) 1 1201 #@T set filename $aryData(FileName) 1202 set filename [$tv item text $node [NiFileName]] 1152 1203 ::TolConsole::Include \ 1153 [::TolProject::ComputeFullPath $this $ aryData(FileName)]1204 [::TolProject::ComputeFullPath $this $filename] 1154 1205 set data(compiling) 0 1155 1206 } 1156 foreach child [$tv entrychildren $node] {1207 foreach child [$tv item children $node] { 1157 1208 CompileNode $this $child 1158 1209 } … … 1173 1224 #///////////////////////////////////////////////////////////////////////////// 1174 1225 set tv [GetTreeview $this] 1175 array set aryData [$tv entry cget $node -data]1176 1226 #Tolcon_Trace "CompileIfBeforeNode. node: $node, ref: $ref" 1177 if ![$tv entry isbefore $node $ref] { 1227 set isbefore [expr [$tv item order $node] < [$tv item order $ref]] 1228 if !$isbefore { 1178 1229 CompileNode $this $node 1179 1230 } else { 1180 foreach child [$tv entrychildren $node] {1231 foreach child [$tv item children $node] { 1181 1232 CompileIfBeforeNode $this $child $ref 1182 1233 } … … 1197 1248 #///////////////////////////////////////////////////////////////////////////// 1198 1249 set tv [GetTreeview $this] 1199 array set aryData [$tv entry cget $node -data]1200 #Tolcon_Trace "CompileIfBeforeNode. node: $node, ref: $ref"1250 #Tolcon_Trace "CompileUpToHereNode. node: $node, ref: $ref" 1251 set isbefore [expr [$tv item order $node] < [$tv item order $ref]] 1201 1252 if {((![string eq root $node] && [string eq $node $ref]) || 1202 (![string eq root $node] && [$tv entry isbefore $node $ref]))} {1253 (![string eq root $node] && $isbefore))} { 1203 1254 CompileNode $this $node 1204 1255 } else { 1205 foreach child [$tv entrychildren $node] {1256 foreach child [$tv item children $node] { 1206 1257 CompileUpToHereNode $this $child $ref 1207 1258 } … … 1215 1266 upvar \#0 ${this}::data data 1216 1267 set tv [GetTreeview $this] 1217 set node [$tv index current]1268 set node [$tv selection get end] ;# current 1218 1269 DecompileNode $this $node 1219 1270 } … … 1230 1281 #///////////////////////////////////////////////////////////////////////////// 1231 1282 set tv [GetTreeview $this] 1232 array set aryData [$tv entry cget $node -data]1233 if ![string equal $ aryData(Exclude)1] {1283 set exclude [$tv item text $node [NiExclude]] 1284 if ![string equal $exclude 1] { 1234 1285 if [IsCompilable $this $node] { 1286 set filename [$tv item text $node [NiFileName]] 1235 1287 catch {::TolInspector::DecompileFile \ 1236 [::TolProject::ComputeFullPath $this $ aryData(FileName)]}1288 [::TolProject::ComputeFullPath $this $filename]} 1237 1289 ::TolInspector::UpdateFileRoot 1238 1290 } 1239 foreach child [$tv entrychildren $node] {1291 foreach child [$tv item children $node] { 1240 1292 DecompileNode $this $child 1241 1293 } … … 1276 1328 upvar \#0 ${this}::data data 1277 1329 set tv [GetTreeview $this] 1278 array set aryData [$tv entry cget $index -data] 1279 set data(name) $aryData(FileName) 1280 set data(desc) $aryData(Description) 1281 set data(type) $aryData(Type) 1282 set data(exclude) $aryData(Exclude) 1283 #rcsi 1284 # Hay proyectos que no tienen esta variable, le damos valor 0 1285 if {![info exists aryData(ExcludeTOL)]} { 1286 set aryData(ExcludeTOL) 0 1287 } 1288 #rcsf 1289 set data(excludeTOL) $aryData(ExcludeTOL) 1330 set data(name) [$tv item text $index [NiFileName]] 1331 set data(desc) [$tv item text $index [NiDescription]] 1332 set data(type) [$tv item text $index [NiType]] 1333 set data(exclude) [$tv item text $index [NiExclude]] 1334 set data(excludeTOL) [$tv item text $index [NiExcludeTOL]] ;#$aryData(ExcludeTOL) 1290 1335 } 1291 1336 … … 1328 1373 set terminal 0 1329 1374 set tv [GetTreeview $this] 1330 array set aryData [$tv entry cget $node -data]1331 switch $ aryData(Type){1375 set type [$tv item text $node [NiType]] 1376 switch $type { 1332 1377 Fol - 1333 1378 ROOT { set terminal 0 } … … 1354 1399 set compilable 0 1355 1400 set tv [GetTreeview $this] 1356 array set aryData [$tv entry cget $node -data]1357 switch $ aryData(Type){1401 set type [$tv item text $node [NiType]] 1402 switch $type { 1358 1403 Fol - 1359 1404 ROOT { set compilable 0 } … … 1845 1890 1846 1891 1892 #@ Métodos (4) antes en ::BayesTreeview (bftrview.tcl) 1893 1894 #///////////////////////////////////////////////////////////////////////////// 1895 proc ::TolProject::WtreeFromFile {tv path {proc ""}} { 1896 # 1897 # PURPOSE: Loads a wtree info data from a text especification file of a wtree. 1898 # 1899 # PARAMETERS: 1900 # tv -> wtree's path 1901 # path -> name of file 1902 # proc -> procedure that converts type node to the path of the image of node 1903 # 1904 # RETURN: Returns 1 if wtree has been loaded correctly or 0 if not. 1905 # 1906 #///////////////////////////////////////////////////////////////////////////// 1907 if ![file exists $path] { 1908 return -code error "File $path doesn't exist" 1909 } 1910 #@ Tolcon_Trace "Llamada a WtreeFromFile" 1911 set fd [iniparse:openfile $path] 1912 BNodeFromFile $tv root "" $fd $proc 1913 iniparse:closefile $fd 1914 return 1 1915 } 1916 1917 1918 #///////////////////////////////////////////////////////////////////////////// 1919 proc ::TolProject::WtreeToFile {tv path} { 1920 # 1921 # PURPOSE: Saves a wtree info data into a text especification file of a wtree. 1922 # 1923 # PARAMETERS: 1924 # tv -> wtree's path 1925 # path -> name of file 1926 # 1927 # RETURN: Returns 1 if file has been saved correctly or 0 if not. 1928 # 1929 #///////////////////////////////////////////////////////////////////////////// 1930 #borrar archivo pq iniparse:openfile abre para solo lectura si existe 1931 file delete $path 1932 set fd [iniparse:openfile $path] 1933 BNodeToFile $tv root $fd 1934 iniparse:closefile $fd 1935 return 1 1936 } 1937 1938 1939 #///////////////////////////////////////////////////////////////////////////// 1940 proc ::TolProject::BNodeToFile {tv index fd} { 1941 # 1942 # PURPOSE: Saves a wtree's node info data into a text file. 1943 # 1944 # PARAMETERS: 1945 # tv -> wtree's path 1946 # index -> wtree node index 1947 # fd -> channel identifier of text file 1948 # 1949 #///////////////////////////////////////////////////////////////////////////// 1950 set key $index 1951 1952 # Guardar data del nodo actual 1953 #@T array set aryData [$tv entry cget $index -data] 1954 #@T set columnNames [array names aryData] 1955 set columnNames [list FileName Description Type Exclude ExcludeTOL] 1956 foreach item $columnNames { 1957 writeini $fd $key $item [$tv item text $index [Ni$item]] 1958 } 1959 1960 #@T writeini $fd $key Label [$tv entry cget $index -label] 1961 writeini $fd $key Label [$tv item text $index [NiFileName]] 1962 # Guardar sus hijos 1963 #@T writeini $fd $key Children [$tv entry children $index] 1964 writeini $fd $key Children [$tv item children $index] 1965 1966 # Llamar recursivamente para los hijos 1967 foreach child [$tv item children $index] { 1968 Tolcon_Trace "child $child" 1969 BNodeToFile $tv $child $fd 1970 } 1971 } 1972 1973 1974 #///////////////////////////////////////////////////////////////////////////// 1975 proc ::TolProject::BNodeFromFile {tv index parent fd {imgFromType ""}} { 1976 # 1977 # PURPOSE: Loads a wtree's node info data from a text file. 1978 # 1979 # PARAMETERS: 1980 # tv -> wtree's path 1981 # index -> wtree node index 1982 # parent -> wtree node's parent index 1983 # fd -> channel identifier of text file 1984 # 1985 #///////////////////////////////////////////////////////////////////////////// 1986 set key $index 1987 1988 #@T if ![string equal $parent ""] { 1989 #@T set idx [$tv insert -at $parent end $index ] 1990 #@T } else { 1991 #@T set idx root 1992 #@T } 1993 #@T # Configurar data del nodo actual 1994 #@T foreach item [readini $fd $key] { 1995 #@T set value [readini $fd $key $item] 1996 #@T if {[lsearch -exact [$tv column names] $item] != -1} { 1997 #@T $tv entry configure $idx -data [list $item $value] 1998 #@T } 1999 #@T if [string equal $item "Label"] { 2000 #@T $tv entry configure $idx -label $value 2001 #@T } 2002 #@T if {[string equal $item "Type"] && ![string equal $imgFromType ""]} { 2003 #@T if ![string equal [set img [$imgFromType $value]] ""] { 2004 #@T #@ $tv entry configure $idx -icons [list $img $img] 2005 #@T $tv item image $idx FileName $img 2006 #@T } 2007 #@T } 2008 #@T } 2009 set image "" 2010 set filename "" 2011 set description "" 2012 set type "" 2013 set exclude 0 2014 set excludeTOL 0 ;#@T!! puede que no lo tenga el prj 2015 foreach item [readini $fd $key] { 2016 set value [readini $fd $key $item] 2017 switch -exact $item { 2018 FileName { set filename $value } 2019 Description { set description $value } 2020 Type { set type $value } 2021 Exclude { set exclude $value } 2022 ExcludeTOL { set excludeTOL $value } 2023 Label { set void 0 } 2024 } 2025 if {[string equal $item "Type"] && ![string equal $imgFromType ""]} { 2026 if ![string equal [set img [$imgFromType $value]] ""] { 2027 #@ $tv entry configure $idx -icons [list $img $img] 2028 set image $img 2029 } 2030 } 2031 } 2032 if ![string equal $parent ""] { 2033 #@T se inserta un nodo 2034 #@T set idx [$tv insert -at $parent end $index ] 2035 set tv_row [::TolProject::Node $img $filename $description $type $exclude $excludeTOL] 2036 if { $type eq "Fol" } { 2037 set hasbutton 1 2038 } else { 2039 set hasbutton 0 2040 } 2041 set idx [$tv insert $tv_row -at end -relative $parent -button $hasbutton] 2042 } else { 2043 #@T se actualiza root 2044 $tv item image root [NiFileName] $img 2045 $tv item text root [NiFileName] $filename 2046 $tv item text root [NiDescription] $description 2047 $tv item text root [NiType] $type 2048 $tv item text root [NiExclude] $exclude 2049 $tv item text root [NiExcludeTOL] $excludeTOL 2050 set idx root 2051 } 2052 # Llamar recursivamente para los hijos 2053 foreach child [readini $fd $key Children] { 2054 BNodeFromFile $tv $child $idx $fd $imgFromType 2055 } 2056 } 2057 1847 2058 ::TolProject::ReadIniSpecial
Note: See TracChangeset
for help on using the changeset viewer.
