7fd59977 |
1 | ########################### |
2 | # # |
3 | # Version 1.3 # |
4 | # by FID & YAN # |
5 | # # |
6 | ########################### |
7 | # |
8 | # Open : double-clic or + |
9 | # Close : double-clic or - |
10 | # Refresh tree : close top level and re-open |
11 | # |
12 | # Attributes: |
13 | # white : interoperable |
14 | # white + c : non interoperable |
15 | # X : X Reference |
16 | # Red : not yet commited in transaction #0 |
17 | # |
18 | # |
19 | |
20 | proc __update { args } { |
21 | } |
22 | |
23 | proc dftree { DDF_Browser } { |
24 | |
25 | global DFTREE_WINDOWS |
26 | global DFTREE_LabelStyle |
27 | global DFTREE_LabelStyle1 |
28 | global DFTREE_AttributeStyle |
29 | global DFTREE_AttributeStyle1 |
30 | global DFTREE_AttributeStyle2 |
31 | |
32 | global $DDF_Browser |
33 | ## global $DDF_Browser |
34 | puts $DDF_Browser |
35 | |
36 | package require Tix |
37 | #tixPref:InitFontSet:14Point |
38 | |
39 | set DFTREE_LabelStyle [tixDisplayStyle imagetext \ |
40 | -font 9x15bold \ |
41 | -background Bisque3 \ |
42 | ] |
43 | |
44 | set DFTREE_LabelStyle1 [tixDisplayStyle imagetext \ |
45 | -font 9x15bold \ |
46 | -background Bisque3 \ |
47 | -foreground SeaGreen2 \ |
48 | ] |
49 | |
50 | set DFTREE_AttributeStyle [tixDisplayStyle imagetext \ |
51 | -font 9x15 \ |
52 | -background Bisque3 \ |
53 | ] |
54 | |
55 | set DFTREE_AttributeStyle1 [tixDisplayStyle imagetext \ |
56 | -font 9x15 \ |
57 | -background Bisque3 \ |
58 | -foreground DarkGreen \ |
59 | ] |
60 | |
61 | set DFTREE_AttributeStyle2 [tixDisplayStyle imagetext \ |
62 | -font 9x15 \ |
63 | -background Bisque3 \ |
64 | -foreground Red \ |
65 | ] |
66 | |
67 | set w .$DDF_Browser |
68 | toplevel $w |
69 | |
70 | set top [frame $w.thu -bd 1 -relief raised -background Bisque3] |
71 | |
72 | ################ |
73 | # Paned Window # |
74 | ################ |
75 | set p [tixPanedWindow $top.p -orient horizontal -height 400 -width 700] |
76 | pack $p -expand yes -fill both -padx 4 -pady 4 |
77 | |
78 | DFTREE:Tree:InitTreePanel $DDF_Browser $w $p |
79 | # DFTREE:Tree:InitTextPanel $DDF_Browser $w $p |
80 | |
81 | tixForm $top -left 2 -top 2 -right %99 -bottom %99 |
82 | |
83 | return |
84 | } |
85 | |
86 | ############################################################################### |
87 | # |
88 | # |
89 | proc DFTREE:Tree:InitTreePanel { DDF_Browser w p } { |
90 | global DFTREE_WINDOWS |
91 | global $DDF_Browser |
92 | |
93 | ######## |
94 | # Tree # |
95 | ######## |
96 | |
97 | set p1 [$p add pane1 -expand 1 -size 700] ; $p1 config -relief flat |
98 | set tree [tixTree $p1.tree \ |
99 | -opencmd [list DFTREE:Tree:Open $DDF_Browser $w] \ |
100 | -options { \ |
101 | hlist.separator "^" \ |
102 | hlist.font 9x15bold \ |
103 | hlist.background Bisque3 \ |
104 | hlist.foreground Black \ |
105 | } ] |
106 | pack $p1.tree -expand yes -fill both -padx 4 -pady 4 |
107 | |
108 | # -browsecmd DFTREE:Tree:BrowseCmd |
109 | # Cette option peut etre ajoutee a la commande tixTree, |
110 | # mais elle declanche l'appel a la procedure a chaque clic , |
111 | # double-clic, voire a chaque appui puis relachement de souris!!! |
112 | |
113 | # to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts? |
114 | # 8x13 8x13bold 9x15 9x15bold |
115 | # hlist.font 8x13bold |
116 | # hlist.gap "15" |
117 | # hlist.indent "30" |
118 | |
119 | set DFTREE_WINDOWS($w,NAV,tree) $tree |
120 | set DFTREE_WINDOWS($w,NAV,hlist) [$tree subwidget hlist] |
121 | $DFTREE_WINDOWS($w,NAV,hlist) add ^ \ |
122 | -text $DDF_Browser \ |
123 | -data [list $DDF_Browser DataFramework] |
124 | $DFTREE_WINDOWS($w,NAV,tree) setmode ^ open |
125 | } |
126 | |
127 | ############################################################################### |
128 | # |
129 | # |
130 | proc DFTREE:Tree:InitTextPanel { DDF_Browser w p } { |
131 | global DFTREE_WINDOWS |
132 | global $DDF_Browser |
133 | |
134 | ######## |
135 | # Text # |
136 | ######## |
137 | set p2 [$p add pane2 -expand 4 -size 400] ; $p2 config -relief flat |
138 | tixScrolledText $p2.st |
139 | pack $p2.st -expand yes -fill both -padx 4 -pady 4 |
140 | |
141 | set DFTREE_WINDOWS($w,NAV,text) [$p2.st subwidget text] |
142 | |
143 | |
144 | |
145 | $DFTREE_WINDOWS($w,NAV,text) insert end " Welcome to the QDF browser (Rev #.#)\n" |
146 | $DFTREE_WINDOWS($w,NAV,text) insert end "--------------------------------------\n\n" |
147 | $DFTREE_WINDOWS($w,NAV,text) insert end "This browser is an easy to use prototype made with Tix technology. We hope it will be usefull for understanding and debugging QDF.\n" |
148 | $DFTREE_WINDOWS($w,NAV,text) insert end "\t\t\t\tFID & YAN" |
149 | } |
150 | |
151 | ############################################################################### |
152 | # |
153 | # |
154 | proc DFTREE:Tree:BrowseCmd { dir } { |
155 | puts "Hello $dir !" |
156 | } |
157 | ############################################################################### |
158 | # Se positionne sur l'entry pere et update les fenetres. |
159 | # |
160 | proc DFTREE:Tree:Up { w } { |
161 | global DFTREE_WINDOWS |
162 | global DFTREE_GLOBALS |
163 | #puts "DFTREE:Tree:Up" |
164 | |
165 | if { [set here [$DFTREE_WINDOWS($w,NAV,hlist) info anchor]] != {} } { |
166 | if { [set up [$DFTREE_WINDOWS($w,NAV,hlist) info parent $here]] != {} } { |
167 | DFTREE:Tree:ShowUp $w $up |
168 | set DFTREE_GLOBALS(CWD) [lindex [$DFTREE_WINDOWS($w,NAV,hlist) info data $up] 0] |
169 | } |
170 | } |
171 | return |
172 | } |
173 | ############################################################################### |
174 | # Se positionne sur l'entry up sans update (History) |
175 | # |
176 | proc DFTREE:Tree:ShowUp { w dir } { |
177 | global DFTREE_WINDOWS |
178 | #puts "DFTREE:Tree:ShowUp" |
179 | |
180 | $DFTREE_WINDOWS($w,NAV,hlist) anchor clear |
181 | $DFTREE_WINDOWS($w,NAV,hlist) anchor set $dir |
182 | $DFTREE_WINDOWS($w,NAV,hlist) selection clear |
183 | $DFTREE_WINDOWS($w,NAV,hlist) selection set $dir |
184 | $DFTREE_WINDOWS($w,NAV,hlist) see $dir |
185 | return |
186 | } |
187 | ############################################################################### |
188 | # |
189 | # |
190 | proc DFTREE:Tree:Open { DDF_Browser w dir} { |
191 | global DFTREE_WINDOWS |
192 | global $DDF_Browser |
193 | #puts "DFTREE:Tree:Open" |
194 | |
195 | if {$dir == "^"} { |
196 | # This is root |
197 | if {[$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} { |
198 | # The root branch already exists in hlist. |
199 | # Clear all its children to force the tree to be updated. |
200 | foreach kid [$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] { |
201 | $DFTREE_WINDOWS($w,NAV,hlist) delete entry $kid |
202 | } |
203 | } |
204 | } |
205 | |
206 | if {[$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} { |
207 | # The branch exists in hlist. |
208 | foreach kid [$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] { |
209 | $DFTREE_WINDOWS($w,NAV,hlist) show entry $kid |
210 | } |
211 | set data [$DFTREE_WINDOWS($w,NAV,hlist) info data $dir] |
212 | set loc [lindex $data 0] |
213 | } else { |
214 | # The branch is unknown. |
215 | tixBusy $w on |
216 | update |
217 | DFTREE:Tree:Fill $DDF_Browser $w $dir |
218 | tixBusy $w off |
219 | } |
220 | return |
221 | } |
222 | ############################################################################### |
223 | # |
224 | # |
225 | proc DFTREE:Tree:Fill { DDF_Browser w dir } { |
226 | global DFTREE_WINDOWS |
227 | global DFTREE_GLOBALS |
228 | global $DDF_Browser |
229 | #puts "DFTREE:Tree:Fill" |
230 | |
231 | set data [$DFTREE_WINDOWS($w,NAV,hlist) info data $dir] |
232 | set loc [lindex $data 0] |
233 | set type [lindex $data 1] |
234 | |
235 | #puts "=====================" |
236 | #puts "Type $type" |
237 | #puts "Window $w" |
238 | #puts "Loc $loc" |
239 | #puts "Dir $dir" |
240 | switch -glob $type { |
241 | |
242 | DataFramework { |
243 | DFTREE:Tree:UpdateDataFramework $DDF_Browser $w $loc $dir |
244 | } |
245 | |
246 | Label { |
247 | DFTREE:Tree:UpdateLabel $DDF_Browser $w $loc $dir |
248 | } |
249 | |
250 | AttributeList { |
251 | set lab [lindex $data 2] |
252 | DFTREE:Tree:UpdateAttributeList $DDF_Browser $w $loc $dir $lab |
253 | } |
254 | |
255 | Attribute { |
256 | DFTREE:Tree:UpdateAttribute $DDF_Browser $w $loc $dir |
257 | } |
258 | |
259 | terminal { |
260 | DFTREE:Tree:terminal $DDF_Browser $w $loc $dir |
261 | } |
262 | |
263 | default { |
264 | puts "type non reconnu" |
265 | } |
266 | } |
267 | return |
268 | } |
269 | ############################################################################### |
270 | # ici dir = ^ |
271 | # |
272 | proc DFTREE:Tree:UpdateDataFramework { DDF_Browser w loc dir } { |
273 | global DFTREE_WINDOWS |
274 | global $DDF_Browser |
275 | global DFTREE_LabelStyle |
276 | global DFTREE_LabelStyle1 |
277 | |
278 | set litm {} |
279 | |
280 | foreach fullname [split [DFOpenLabel $DDF_Browser ""] "\\" ] { |
281 | FCTREE:Tree:DecodeLabelItem $DDF_Browser $w $loc $dir $fullname |
282 | } |
283 | |
284 | return |
285 | } |
286 | ############################################################################### |
287 | # $loc is a label entry, "1.3.2" for exemple. |
288 | # |
289 | proc DFTREE:Tree:UpdateLabel { DDF_Browser w loc dir } { |
290 | global DFTREE_WINDOWS |
291 | global $DDF_Browser |
292 | global DFTREE_LabelStyle |
293 | global DFTREE_LabelStyle1 |
294 | global DFTREE_AttributeStyle |
295 | global DFTREE_AttributeStyle1 |
296 | |
297 | set litm {} |
298 | foreach fullname [split [DFOpenLabel $DDF_Browser $loc ] "\\" ] { |
299 | FCTREE:Tree:DecodeLabelItem $DDF_Browser $w $loc $dir $fullname |
300 | } |
301 | return |
302 | } |
303 | ############################################################################### |
304 | # |
305 | # |
306 | proc DFTREE:Tree:UpdateAttributeList { DDF_Browser w loc dir lab} { |
307 | global DFTREE_WINDOWS |
308 | global $DDF_Browser |
309 | global DFTREE_AttributeStyle |
310 | global DFTREE_AttributeStyle1 |
311 | |
312 | set litm {} |
313 | set standardimage [tix getimage srcfile] |
314 | set otherimage [tix getimage file] |
315 | set xrefimage [tix getimage cross] |
316 | |
317 | # abv: index attributes |
318 | set num 0 |
319 | set attributes [split [DFOpenAttributeList $DDF_Browser $lab ] "\\" ] |
320 | set iattributes {} |
321 | foreach fullname $attributes { |
322 | set num [expr $num + 1] |
323 | lappend fullname $num |
324 | lappend iattributes $fullname |
325 | } |
326 | foreach fullname [lsort $iattributes] { |
327 | |
328 | # Information first split |
329 | set tmplist [split $fullname " "] |
330 | set name [lindex $tmplist 0] |
331 | set transaction [lindex $tmplist 1] |
332 | set valid [lindex $tmplist 2] |
333 | set forgotten [lindex $tmplist 3] |
334 | set backuped [lindex $tmplist 4] |
335 | set maybeopen [lindex $tmplist 5] |
336 | |
337 | # Package analysis to determine the icon type. |
338 | set pk [lindex [split $name _] 0] |
339 | set image $otherimage |
340 | if {$pk == "TDataStd" || $pk == "TNaming"} {set image $standardimage} |
341 | if {$pk == "TXRef"} {set image $xrefimage} |
342 | |
343 | # Name analysis to suppress the map address. |
344 | set shortlist [split $name "#"] |
345 | set shortname [lindex $shortlist 0] |
346 | set index [lindex $shortlist 1] |
347 | |
348 | set textname "$shortname" |
349 | |
350 | # if { [llength $tmplist] >5 } { set textname [lindex $tmplist 5] } |
351 | set textname "$textname [DFGetAttributeValue $DDF_Browser $lab [lindex $tmplist 6]]" |
352 | |
353 | # Transaction analysis |
354 | if {$transaction == "0"} { |
355 | set locstyle $DFTREE_AttributeStyle |
356 | } else { |
357 | # set textname "$textname T=$transaction" |
358 | set locstyle $DFTREE_AttributeStyle1 |
359 | } |
360 | |
361 | # Valid? |
362 | if {$valid == "NotValid"} {set textname "$textname $valid"} |
363 | |
364 | # Forgotten? |
365 | if {$forgotten == "Forgotten"} {set textname "$textname $forgotten"} |
366 | |
367 | # Backuped? |
368 | if {$backuped == "Backuped"} {set textname "$textname $backuped"} |
369 | |
370 | |
371 | $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^${name} \ |
372 | -itemtype imagetext \ |
373 | -text $textname \ |
374 | -image $image \ |
375 | -style $locstyle \ |
376 | -data [list ${index} Attribute] |
377 | if {$maybeopen == "1"} { |
378 | $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^${name} open |
379 | } |
380 | lappend litm [list $name $image] |
381 | } |
382 | return |
383 | } |
384 | ############################################################################### |
385 | # $loc is always the attribute index |
386 | # |
387 | proc DFTREE:Tree:UpdateAttribute { DDF_Browser w loc dir } { |
388 | global DFTREE_WINDOWS |
389 | global $DDF_Browser |
390 | global DFTREE_AttributeStyle |
391 | global DFTREE_AttributeStyle1 |
392 | global DFTREE_AttributeStyle2 |
393 | |
394 | set litm {} |
395 | set image [tix getimage minimize] |
396 | set tmplist [split [DFOpenAttribute $DDF_Browser $loc ] "\\"] |
397 | |
398 | # Failed or not? |
399 | if {[lindex $tmplist 0] == "Failed"} { |
400 | set locstyle $DFTREE_AttributeStyle2 |
401 | } else { |
402 | set locstyle $DFTREE_AttributeStyle |
403 | } |
404 | |
405 | foreach name $tmplist { |
406 | $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^${name} \ |
407 | -itemtype imagetext \ |
408 | -text $name \ |
409 | -image $image \ |
410 | -style $locstyle \ |
411 | -data [list ${loc}:${name} terminal] \ |
412 | -state disabled |
413 | #$DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^${name} open |
414 | lappend litm [list $name $image] |
415 | } |
416 | return |
417 | } |
418 | ############################################################################### |
419 | # item: |
420 | # "Entry Name=LeNomSIlExiste Modified|NotModified 0|1" |
421 | proc FCTREE:Tree:DecodeLabelItem { DDF_Browser w loc dir labelItem} { |
422 | global DFTREE_WINDOWS |
423 | global $DDF_Browser |
424 | global DFTREE_LabelStyle |
425 | global DFTREE_LabelStyle1 |
426 | global DFTREE_AttributeStyle |
427 | global DFTREE_AttributeStyle1 |
428 | |
429 | set image [tix getimage folder] |
430 | |
431 | set tmplist [split $labelItem " " ] |
432 | set labentry [lindex $tmplist 0] |
433 | set name [lindex $tmplist 1] |
434 | set modified [lindex $tmplist 2] |
435 | set maybeopen [lindex $tmplist 3] |
436 | |
437 | set textname "$labentry" |
438 | |
439 | if {$labentry == "AttributeList"} { |
440 | # Attribute List |
441 | # -------------- |
442 | |
443 | set modified [lindex $tmplist 1] |
444 | |
445 | # Modified or not? |
446 | if {$modified == "Modified"} { |
447 | set textname "$textname $modified" |
448 | set locstyle $DFTREE_AttributeStyle1 |
449 | } else { |
450 | set locstyle $DFTREE_AttributeStyle |
451 | } |
452 | |
453 | set image [tix getimage textfile] |
454 | $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^$labentry \ |
455 | -itemtype imagetext \ |
456 | -text $textname \ |
457 | -image $image \ |
458 | -style $locstyle \ |
459 | -data [list $labentry AttributeList $loc] |
460 | $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^$labentry open |
461 | lappend litm [list $labentry $image] |
462 | set image [tix getimage folder] |
463 | |
464 | } else { |
465 | # Sub-label(s) |
466 | # ------------ |
467 | |
468 | # Name? |
469 | set ll [expr [string length $name] -2] |
470 | if {$ll > 0} { |
471 | set textname "$textname [string range $name 1 $ll]" |
472 | } |
473 | |
474 | # Modified or not? |
475 | if {$modified == "Modified"} { |
476 | set textname "$textname $modified" |
477 | set locstyle $DFTREE_LabelStyle1 |
478 | } else { |
479 | set locstyle $DFTREE_LabelStyle |
480 | } |
481 | |
482 | $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^$labentry \ |
483 | -itemtype imagetext \ |
484 | -text $textname \ |
485 | -image $image \ |
486 | -style $locstyle \ |
487 | -data [list $labentry Label] |
488 | if {$maybeopen == "1"} { |
489 | $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^$labentry open |
490 | } |
491 | lappend litm [list $labentry $image] |
492 | } |
493 | } |
494 | ############################################################################### |
495 | # |
496 | # |
497 | proc DFTREE:Tree:terminal { DDF_Browser w loc dir } { |
498 | global DFTREE_WINDOWS |
499 | global $DDF_Browser |
500 | return |
501 | } |
502 | ############################################################################### |
503 | # loc est une adresse de label? |
504 | # |
505 | proc DFTREE:Tree:DisplayAttribute { DDF_Browser w loc dir } { |
506 | global DFTREE_WINDOWS |
507 | global $DDF_Browser |
508 | |
509 | return |
510 | } |
511 | ############################################################################### |
512 | # imprime tout ce qu'il y a dans hli ( Hlist ) |
513 | # |
514 | proc wokDBG { {root {}} } { |
515 | global DFTREE_GLOBALS |
516 | global DFTREE_WINDOWS |
517 | set w $DFTREE_GLOBALS(toplevel) |
518 | set hli $DFTREE_WINDOWS($w,NAV,hlist) |
519 | foreach c [$hli info children $root] { |
520 | puts "$c : data <[$hli info data $c]>" |
521 | wokDBG $c |
522 | } |
523 | return |
524 | } |
525 | |
526 | proc DFGetAttributeValue {browser lab index} { |
527 | global $browser; # necessary for DRAW command to see the browser |
528 | #puts "$lab $index" |
529 | # set names [split $dir ^] |
530 | # set len [expr [llength $names] -1] |
531 | # set lab [lindex $names [expr $len - 2]] |
532 | # set num [lindex $names $len] |
533 | # regexp {browser_(.*)} $browser whole doc |
534 | # XSAttributeValue browser_D a b |
535 | if {[catch "XAttributeValue $browser $lab $index" ret]} { |
536 | return "" |
537 | } |
538 | if {"$ret" == ""} { return "" } |
539 | return "\[$ret\]" |
540 | } |
541 | |