1#########################################################################
2# COPYRIGHT (C) 2003         EDF R&D              WWW.CODE-ASTER.ORG    #
3#                                                                       #
4# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR         #
5# MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS        #
6# PUBLISHED BY THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE    #
7# LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.                       #
8# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,       #
9# BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF        #
10# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU      #
11# GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              #
12#                                                                       #
13# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     #
14# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO : EDF R&D CODE_ASTER,       #
15#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        #
16#########################################################################
17
18# $Id: ihm_commun.tcl 3649 2008-11-28 16:01:22Z courtois $
19
20# définition du nom des onglets et sous-onglet
21#################################################################
22proc def_onglet { } {
23   set n 1
24   set i 0
25   incr i
26   set astk::ihm(ong,$n,$i) "etude"
27   set astk::ihm(tit,$n,$i) [ashare::mess ihm 6]
28   set astk::ihm(ctx,$n,$i) 282
29   set astk::ihm(coch,$n)  1
30   set astk::ihm(nbong,$n) $i
31   incr n
32   set i 0
33   incr i
34   set astk::ihm(ong,$n,$i) "tests"
35   set astk::ihm(tit,$n,$i) [ashare::mess ihm 7]
36   set astk::ihm(ctx,$n,$i) 283
37   set astk::ihm(coch,$n)  1
38   set astk::ihm(nbong,$n) $i
39   incr n
40   set i 0
41   incr i
42   set astk::ihm(ong,$n,$i) "surcharge"
43   set astk::ihm(tit,$n,$i) [ashare::mess ihm 8]
44   set astk::ihm(ctx,$n,$i) 284
45   set astk::ihm(coch,$n)  1
46   set astk::ihm(nbong,$n) $i
47   set n $astk::ihm(nongl_agla)
48   set i 0
49   incr i
50   set astk::ihm(ong,$n,$i) "agla"
51   set astk::ihm(tit,$n,$i) [ashare::mess ihm 10]
52   set astk::ihm(ctx,$n,$i) 285
53   incr i
54   set astk::ihm(ong,$n,$i) "asno"
55   set astk::ihm(tit,$n,$i) [ashare::mess ihm 9]
56   set astk::ihm(ctx,$n,$i) 286
57   incr i
58   set astk::ihm(ong,$n,$i) "asdeno"
59   set astk::ihm(tit,$n,$i) [ashare::mess ihm 144]
60   set astk::ihm(ctx,$n,$i) 287
61   incr i
62   set astk::ihm(ong,$n,$i) "asdenot"
63   set astk::ihm(tit,$n,$i) [ashare::mess ihm 428]
64   set astk::ihm(ctx,$n,$i) 287
65   incr i
66   set astk::ihm(ong,$n,$i) "asquit"
67   set astk::ihm(tit,$n,$i) [ashare::mess ihm 152]
68   set astk::ihm(ctx,$n,$i) 288
69   incr i
70   set astk::ihm(ong,$n,$i) "asverif"
71   set astk::ihm(tit,$n,$i) [ashare::mess ihm 145]
72   set astk::ihm(ctx,$n,$i) 289
73   incr i
74   set astk::ihm(ong,$n,$i) "pre_eda"
75   set astk::ihm(tit,$n,$i) [ashare::mess ihm 146]
76   set astk::ihm(ctx,$n,$i) 290
77   incr i
78   set astk::ihm(ong,$n,$i) "asrest"
79   set astk::ihm(tit,$n,$i) [ashare::mess ihm 147]
80   set astk::ihm(ctx,$n,$i) 291
81   set astk::ihm(coch,$n)  1
82   set astk::ihm(nbong,$n) $i
83   incr n
84   set i 0
85   incr i
86   set astk::ihm(ong,$n,$i) "rex"
87   set astk::ihm(tit,$n,$i) [ashare::mess ihm 11]
88   set astk::ihm(ctx,$n,$i) 294
89   incr i
90   set astk::ihm(ong,$n,$i) "consult"
91   set astk::ihm(tit,$n,$i) [ashare::mess ihm 243]
92   set astk::ihm(ctx,$n,$i) 298
93   set astk::ihm(coch,$n)  0
94   set astk::ihm(nbong,$n) $i
95#
96   set astk::ihm(nbongM)  $n
97}
98
99# cree les onglets
100# si REINI = "DETR", on détruit l'onglet avant de le recréer
101#################################################################
102proc init_onglet { {REINI "INI"} } {
103   for {set i 1} {$i <= $astk::ihm(nbongM)} {incr i} {
104      if { $REINI == "DETR" } {
105         destroy $astk::ihm(fenetre).onglet.$astk::ihm(ong,$i,1)
106      }
107      fenEEC $astk::ihm(fenetre).onglet.$astk::ihm(ong,$i,1) $i
108   }
109}
110
111# cree une liste déroulante d'onglet
112# nongl : numéro de l'onglet principal
113#################################################################
114proc fenEEC { fenetre_parent nongl } {
115   global ongsel
116   pack [frame $fenetre_parent] -side left -padx 5
117   pack [frame $fenetre_parent.titre -relief raised -bd 1 -background $astk::ihm(couleur,onglet_inactif)]
118   set astk::ihm(ssong,$nongl) 1
119   if { $astk::ihm(nbong,$nongl) > 1 } {
120      set MenuButt [tk_optionMenu $fenetre_parent.titre.songl ongsel($nongl) $astk::ihm(tit,$nongl,1)]
121      $MenuButt configure \
122        -foreground $astk::ihm(couleur,menu_foreground) \
123        -background $astk::ihm(couleur,menu_background)
124      $MenuButt entryconfigure 1 -font $astk::ihm(font,labbout) -command "choix_ongletM $nongl 1"
125      set ashare::context($MenuButt,0) $astk::ihm(ctx,$nongl,1)
126      for {set j 2} {$j <= $astk::ihm(nbong,$nongl)} {incr j} {
127         $MenuButt add radiobutton
128         $MenuButt entryconfigure $j -label $astk::ihm(tit,$nongl,$j) -font $astk::ihm(font,labbout) -variable ongsel($nongl) -command "choix_ongletM $nongl $j"
129         set j1 [expr $j - 1]
130         set ashare::context($MenuButt,$j1) $astk::ihm(ctx,$nongl,$j)
131      }
132      bind $MenuButt <<MenuSelect>> {ShowStatus menu %W astk}
133   } else {
134      set ongsel($nongl) $astk::ihm(tit,$nongl,1)
135      button $fenetre_parent.titre.songl -text $astk::ihm(tit,$nongl,1) -font $astk::ihm(font,labbout) -command "choix_ongletM $nongl 1"
136   }
137   $fenetre_parent.titre.songl configure -relief raised -font $astk::ihm(font,labbout) -background $astk::ihm(couleur,onglet_inactif) -activebackground $astk::ihm(couleur,onglet_inactif)
138   pack $fenetre_parent.titre.songl -side left
139   if { $astk::ihm(coch,$nongl) } {
140      checkbutton $fenetre_parent.titre.choix \
141         -offvalue non    \
142         -onvalue oui      \
143         -variable astk::profil(M_$nongl) \
144         -command "coche_ongletM $nongl" \
145         -background $astk::ihm(couleur,onglet_inactif) \
146         -activebackground $astk::ihm(couleur,onglet_inactif)
147      pack $fenetre_parent.titre.choix -side right
148   }
149   # onglets inactivés
150   if { $astk::ihm(ong,$nongl,1) == "agla" && $astk::agla(status) != "on" } {
151      $fenetre_parent.titre.songl configure -state disabled
152      $fenetre_parent.titre.choix configure -state disabled
153      set astk::profil($astk::ihm(ong,$nongl,1)) non
154   }
155   # rex : desactiver si pas accès à mach_ref
156   if { ($astk::ihm(ong,$nongl,1) == "rex") &&  ($astk::agla(num_serv) == -1) } {
157      $fenetre_parent.titre.songl configure -state disabled
158   }
159# aide contextuelle
160   def_context $fenetre_parent.titre.songl $astk::ihm(ctx,$nongl,1)
161}
162
163# n'est plus utilisée avec la case à cocher
164#################################################################
165proc fenEEC2 {fenetre_parent chaine {vari titre} {coch 0}} {
166   pack [frame $fenetre_parent.titre -relief solid -bd 1 -background $astk::ihm(couleur,onglet_inactif)]
167   label $fenetre_parent.titre.label -font $astk::ihm(font,labbout) -text $chaine  -background $astk::ihm(couleur,onglet_inactif)
168   pack $fenetre_parent.titre.label -side left
169   if { $coch } {
170      checkbutton $fenetre_parent.titre.choix \
171         -offvalue non    \
172         -onvalue oui      \
173         -variable astk::profil($vari) \
174         -background $astk::ihm(couleur,onglet_inactif) \
175         -activebackground $astk::ihm(couleur,onglet_inactif)
176      pack $fenetre_parent.titre.choix -side right
177   }
178}
179
180# gère l'affichage des onglets
181#################################################################
182proc affiche_onglet { nom } {
183   global ongsel
184   set old $astk::profil(onglet_actif)
185   destroy $astk::ihm(fenetre).active
186   if { $nom != "none" } {
187      affiche_$nom
188   }
189
190   # onglet "pere" à désactiver
191   set ongP_off "X"
192   # onglet "pere" à activer
193   set ongP_on "X"
194   for {set i 1} {$i <= $astk::ihm(nbongM)} {incr i} {
195      for {set j 1} {$j <= $astk::ihm(nbong,$i)} {incr j} {
196         if { $astk::profil(onglet_actif) == $astk::ihm(ong,$i,$j) } {
197            set ongP_off $astk::ihm(ong,$i,1)
198         }
199         if { $nom == $astk::ihm(ong,$i,$j) } {
200            set ongP_on $astk::ihm(ong,$i,1)
201         # pour positionner la liste déroulante si on force l'affichage d'un onglet
202            set ongsel($i) $astk::ihm(tit,$i,$j)
203         }
204      }
205   }
206
207   $astk::ihm(fenetre).onglet.$ongP_off.titre.songl configure -relief raised -background $astk::ihm(couleur,onglet_inactif) -activebackground $astk::ihm(couleur,onglet_inactif)
208   # on s'arrete là si none
209   if { $nom == "none" } { return }
210   set astk::profil(onglet_actif) $nom
211   $astk::ihm(fenetre).onglet.$ongP_on.titre.songl configure -relief sunken -background $astk::ihm(couleur,onglet_actif) -activebackground $astk::ihm(couleur,onglet_actif)
212
213   # status
214   change_status [ashare::mess ihm 12]
215#
216   raffr_agla_surch
217   raffr_args_fixe
218}
219
220# choix du sous-onglet ssong de l'onglet maitre nongl
221#################################################################
222proc choix_ongletM { nongl ssong } {
223   global ongsel
224   set astk::ihm(ssong,$nongl) $ssong
225   verif_ongletM
226# affichage sauf pour l'agla et le rex (qui ne sont pas des onglets)
227   if { $astk::ihm(ong,$nongl,1) != "agla" && $astk::ihm(ong,$nongl,1) != "rex" } {
228      affiche_onglet $astk::ihm(ong,$nongl,$ssong)
229# actions du menu rex
230   } elseif { $astk::ihm(ong,$nongl,1) == "rex" } {
231      choix_rex $astk::ihm(ong,$nongl,$ssong)
232      set ongsel($nongl) $astk::ihm(tit,$nongl,1)
233   }
234# pour l'agla, pas d'action associée au choix
235}
236
237# règle les conflits entre les onglets cochés
238# ongletM : onglet "master"
239#################################################################
240proc coche_ongletM { nongl } {
241   set astk::profil($astk::ihm(ong,$nongl,$astk::ihm(ssong,$nongl))) $astk::profil(M_$nongl)
242   if { $ashare::dbg >= 4 } {
243      ashare::log "<DEBUG> (cochet_onglet) appel de coche_onglet_$astk::ihm(ong,$nongl,$astk::ihm(ssong,$nongl))\n        profil($astk::ihm(ong,$nongl,$astk::ihm(ssong,$nongl))) = $astk::profil($astk::ihm(ong,$nongl,$astk::ihm(ssong,$nongl)))"
244   }
245   # pour l'agla, il n'y a que l'onglet maitre qui se coche
246   if { $astk::ihm(ong,$nongl,1) == "agla" } {
247      set astk::profil(agla) $astk::profil(M_$nongl)
248      coche_onglet_agla
249   } else {
250      coche_onglet_$astk::ihm(ong,$nongl,$astk::ihm(ssong,$nongl))
251   }
252   verif_ongletM
253}
254
255# coche/decoche les onglets maitres (cochables) si on a coché/décoché le sous-onglet actif
256#################################################################
257proc verif_ongletM { } {
258   # pour l'agla, les sous-onglets sont cochés comme l'onglet maitre
259   for {set j 2} {$j <= $astk::ihm(nbong,$astk::ihm(nongl_agla)) } {incr j} {
260      set astk::profil($astk::ihm(ong,$astk::ihm(nongl_agla),$j)) non
261   }
262   set astk::profil($astk::ihm(ong,$astk::ihm(nongl_agla),$astk::ihm(ssong,$astk::ihm(nongl_agla)))) $astk::profil(agla)
263   # onglets maitres fonction du sous-onglet actif
264   for {set i 1} {$i <= $astk::ihm(nbongM)} {incr i} {
265      if { $astk::ihm(coch,$i) } {
266         if { $ashare::dbg >= 4 } {
267            ashare::log "<DEBUG> (verif_ongletM) profil($astk::ihm(ong,$i,$astk::ihm(ssong,$i))) = $astk::profil($astk::ihm(ong,$i,$astk::ihm(ssong,$i)))"
268         }
269         if { $astk::profil($astk::ihm(ong,$i,$astk::ihm(ssong,$i))) == "non" } {
270            set astk::profil(M_$i) "non"
271         } else {
272            set astk::profil(M_$i) "oui"
273         }
274      }
275   }
276}
277#############################
278proc coche_onglet_etude { } {
279   if { $astk::profil(etude) == "non" } {
280      # quand on decoche etude
281      mod_lancement disabled
282   } else {
283      # quand on coche etude
284      set astk::profil(agla) non
285      coche_onglet_agla
286      set astk::profil(tests) non
287      adapt_satellite 0
288      mod_lancement normal
289   }
290}
291proc coche_onglet_tests { } {
292   if { $astk::profil(tests) == "non" } {
293      # quand on decoche tests
294      set astk::profil(agla) non
295      coche_onglet_agla
296      mod_lancement normal
297   } else {
298      # quand on coche tests
299      set astk::profil(agla) non
300      coche_onglet_agla
301      set astk::profil(etude) non
302      adapt_satellite 0
303      mod_lancement disabled
304   }
305}
306proc coche_onglet_surcharge { } {
307   if { $astk::profil(surcharge) == "non" } {
308      # quand on decoche surcharge
309      set astk::profil(agla) non
310      coche_onglet_agla
311   } else {
312      # quand on coche surcharge
313   }
314}
315proc coche_onglet_agla { } {
316   if { $astk::profil(agla) == "non" } {
317      # quand on decoche agla
318      adapt_satellite 0
319      raffr_agla_surch
320   } else {
321      # quand on coche agla
322      set astk::profil(surcharge) oui
323      set astk::profil(etude) non
324      set astk::profil(tests) oui
325      adapt_satellite 1
326      raffr_agla_surch
327   }
328}
329
330# arguments pour l'exec dans etude et execution
331#################################################################
332proc affiche_arg { fen } {
333   pack [frame $fen.argu -relief raised -bd 0 ] -pady 4 -padx 5 -side bottom
334      pack [label $fen.argu.lbl -font $astk::ihm(font,lab) -font $astk::ihm(font,lab) -text [ashare::mess ihm 13]] -side left
335      pack [entry $fen.argu.txt -width 20 -font $astk::ihm(font,val) -textvariable astk::profil(args)] -side left
336      pack [entry $fen.argu.tx2 -width 25 -font $astk::ihm(font,val) -textvariable astk::profil(args_fixe) -state disabled] -side left
337      $fen.argu.txt configure -validate key -vcmd modprof
338   def_context $fen.argu.txt 281
339   def_context $fen.argu.tx2 361
340}
341
342# modifie un argument
343# opt : nom de l'option
344# arg : si oui, on demande une valeur
345#################################################################
346proc mod_argument { opt arg } {
347   global getValue_val
348
349   if { $arg == "oui" && $astk::profil(option,$opt) } {
350      set last $astk::profil(opt_val,$opt)
351      getValue_fen . 24 13 {} $last non_vide
352      tkwait window .fen_getv
353      if { $getValue_val != "_VIDE" } {
354         set astk::profil(opt_val,$opt) $getValue_val
355      } else {
356         set astk::profil(option,$opt) 0
357      }
358   }
359   raffr_args_fixe
360}
361
362# actualise la zone arguments fixes
363#################################################################
364proc raffr_args_fixe { } {
365    set astk::profil(args_fixe) ""
366    set narg [expr [llength $astk::ihm(l_arg)] / 3]
367    for {set i 0} {$i < $narg} {incr i} {
368      set arg  [lindex $astk::ihm(l_arg) [expr $i * 3]]
369      if { $astk::profil(option,$arg) == 1 } {
370         append astk::profil(args_fixe) "-$arg $astk::profil(opt_val,$arg) "
371      }
372    }
373}
374
375
376# modifie un paramètre
377#################################################################
378proc mod_param { m opt } {
379   global getValue_val
380# valeurs autorisées
381   set npar [expr [llength $astk::ihm(l_par)] / 3]
382   for {set i 0} {$i < $npar} {incr i} {
383      set var [lindex $astk::ihm(l_par) [expr $i * 3]]
384      if { $var == $opt } {
385         set lst [lindex $astk::ihm(l_par) [expr $i * 3 + 2]]
386         break
387      }
388   }
389# demande la valeur
390   set last $astk::profil(opt_val,$opt)
391   if { [lindex $lst 0 ] == "OUI" } {
392       getValue_chb . 24 $opt $lst $last
393   } else {
394       getValue_fen . 24 267 {} $last vide 1
395   }
396   tkwait window .fen_getv
397   if { $getValue_val != "_VIDE" } {
398      if { [lsearch -exact $lst $getValue_val] > -1 || [llength $lst] == 0 } {
399         set astk::profil(opt_val,$opt) $getValue_val
400         $m entryconfigure "$opt = $last" -label "$opt = $astk::profil(opt_val,$opt)"
401      } else {
402         set msg [ashare::mess erreur 5 $getValue_val]
403         change_status $msg
404         tk_messageBox -title [ashare::mess ihm 138] -message $msg -type ok -icon info -parent .
405      }
406   }
407}
408
409# modifie une option de lancement
410#################################################################
411proc mod_option { m opt } {
412   global getValue_val
413# valeurs autorisées
414   set npar [expr [llength $astk::ihm(l_opt)] / 3]
415   for {set i 0} {$i < $npar} {incr i} {
416      set var [lindex $astk::ihm(l_opt) [expr $i * 3]]
417      if { $var == $opt } {
418         set lst [lindex $astk::ihm(l_opt) [expr $i * 3 + 2]]
419         break
420      }
421   }
422# demande la valeur
423   set last $astk::profil(opt_val,$opt)
424   if { [lindex $lst 0 ] == "OUI" } {
425       getValue_chb . 24 $opt $lst $last
426   } else {
427       getValue_fen . 24 267 {} $last vide 1
428   }
429   tkwait window .fen_getv
430   if { $getValue_val == "" || [lsearch -exact $lst $getValue_val] > -1 || [llength $lst] == 0 } {
431      set astk::profil(opt_val,$opt) $getValue_val
432      $m entryconfigure "$opt = $last" -label "$opt = $astk::profil(opt_val,$opt)"
433   } else {
434      set msg [ashare::mess erreur 5 $getValue_val]
435      change_status $msg
436      tk_messageBox -title [ashare::mess ihm 138] -message $msg -type ok -icon info -parent .
437   }
438}
439
440# aide contextuelle
441# type : menu ou bouton
442# wmem : widget menu
443# prog : astk ou asjob (pour savoir quelle variable on modifie)
444#################################################################
445proc ShowStatus { typ wmen prog {etat "on"}} {
446   switch -exact -- $typ {
447      menu {
448         set ind [$wmen index active]
449         set varst [ashare::mess ihm 12]
450         catch {set varst [ashare::mess ihm $ashare::context($wmen,$ind)]}
451      }
452      bouton {
453         set varst $ashare::context($wmen,bouton)
454      }
455   }
456   if { $etat == "off" } {
457      set varst ""
458   }
459   switch -exact -- $prog {
460      astk {
461         change_status $varst
462      }
463      asjob {
464         set asjob::status $varst
465      }
466      bsf {
467         set tkgetdir::status $varst
468      }
469   }
470   update idletasks
471}
472
473# pour simplifier l'écriture de l'aide sur un widget survolé
474# w   : widget (évènements Enter/Leave)
475# num : numéro du message
476#################################################################
477proc def_context { w num } {
478   set ashare::context($w,bouton) [ashare::mess ihm $num]
479   bind $w <Enter> {ShowStatus bouton %W astk}
480   bind $w <Leave> {ShowStatus bouton %W astk off}
481}
482
483# crée la liste des derniers profils ouverts
484#################################################################
485proc dern_prof { parent } {
486   if { $astk::ihm(prof,nb) > $astk::config(-1,nb_reman) } {
487      set astk::ihm(prof,nb) $astk::config(-1,nb_reman)
488   }
489# longueur max (-3 pour ...)
490   set smax 37
491   if { $astk::ihm(prof,nb) > 0 } {
492      $parent add separator
493   }
494   for {set i 0} {$i < $astk::ihm(prof,nb)} {incr i} {
495      set lbl [expr $i + 1]
496      append lbl " "
497      append lbl $astk::ihm(prof,serv,$i)
498      append lbl ":"
499      set fich $astk::ihm(prof,$i)
500      set smax2 [expr $smax - [string length $astk::ihm(prof,serv,$i)]]
501      set sf [string length $fich]
502      if { $sf > $smax2 } {
503         append lbl "..."
504         set fich [string range $fich [expr $sf - $smax2] [expr $sf - 1]]
505      }
506      append lbl $fich
507      $parent add command -font $astk::ihm(font,labmenu) -label $lbl -underline 0 -command "ouvrir $astk::inv(serv,$astk::ihm(prof,serv,$i)) $astk::ihm(prof,$i)"
508   }
509}
510
511# mise à jour de la liste des derniers profils ouverts
512# après Fichier/Ouvrir - Enregistrer sous...
513# sans profil, on raffraichit simplement le menu
514#################################################################
515proc maj_prof { {serv -1 } { new "_VIDE" } } {
516   if { $ashare::dbg >= 4 } {
517      ashare::log "<DEBUG> (maj_prof) profil : $new"
518   }
519   if { $new != "_VIDE" && $new != [ashare::mess ihm 27] } {
520      set nb $astk::ihm(prof,nb)
521      for {set i 0} {$i < $nb} {incr i} {
522         set oldp($i) $astk::ihm(prof,$i)
523         set olds($i) $astk::ihm(prof,serv,$i)
524      }
525# le dernier doit apparaitre en premier
526      set astk::ihm(prof,0) $new
527      set astk::ihm(prof,serv,0) $astk::config($serv,nom)
528      set newnb 0
529      for {set i 0} {$i < $nb} {incr i} {
530         if { [regexp $new $oldp($i)] == 0 } {
531            incr newnb
532            set astk::ihm(prof,$newnb) $oldp($i)
533            set astk::ihm(prof,serv,$newnb) $olds($i)
534         }
535         if { $newnb >= [expr $astk::config(-1,nb_reman) - 1] } {
536            break
537         }
538      }
539      incr newnb
540      set astk::ihm(prof,nb) $newnb
541# sauvegarde la liste
542      set id [open $astk::fic_prof w]
543      puts $id "# AUTOMATICALLY GENERATED - DO NOT EDIT !"
544      puts $id "#"
545      for { set i 0 } { $i < $astk::ihm(prof,nb) } { incr i } {
546         puts $id "profil : $astk::ihm(prof,$i)"
547         puts $id "serv : $astk::ihm(prof,serv,$i)"
548      }
549      close $id
550   }
551# mise à jour du menu
552   create_menu_fichier $astk::ihm(menu) DETR
553}
554
555# crée la liste des noeuds
556#################################################################
557proc liste_machines { parent } {
558   set pastrouve 1
559   catch { destroy $parent.noeud }
560   set MenuNoeud [tk_optionMenu $parent.noeud astk::profil(noeud) $astk::ihm(lnoeud,0)]
561   $MenuNoeud configure \
562       -foreground $astk::ihm(couleur,menu_foreground) \
563       -background $astk::ihm(couleur,menu_background)
564   $MenuNoeud entryconfigure 0 -font $astk::ihm(font,lablst) -command "change_noeud"
565   for {set j 1} {$j < $astk::ihm(nb_noeud)} {incr j} {
566      $MenuNoeud add radiobutton
567      $MenuNoeud entryconfigure $j -label $astk::ihm(lnoeud,$j) -font $astk::ihm(font,lablst) -variable astk::profil(noeud) -command "change_noeud"
568      if { $astk::profil(noeud) == $astk::ihm(lnoeud,$j) } {
569         set pastrouve 0
570      }
571   }
572   $parent.noeud configure -font $astk::ihm(font,lablst)
573   pack $parent.noeud -fill x -expand 1
574   # on repositionne sur le premier si la machine selectionnee n'existe plus !
575   if { $pastrouve } {
576      set astk::profil(noeud) $astk::ihm(lnoeud,0)
577   }
578# aide contextuelle
579   def_context $parent.noeud 312
580}
581
582# crée la liste des versions
583#################################################################
584proc liste_versions { parent } {
585   set pastrouve 1
586   set trouvedef 0
587   catch { destroy $parent.vers }
588   catch {
589      if { $astk::profil(version) == $astk::ihm(lvers,0) } { set pastrouve 0 }
590   }
591   set MenuVers [tk_optionMenu $parent.vers astk::profil(version) $astk::ihm(lvers,0)]
592   $MenuVers configure \
593        -foreground $astk::ihm(couleur,menu_foreground) \
594        -background $astk::ihm(couleur,menu_background)
595   $MenuVers entryconfigure 0 -font $astk::ihm(font,lablst)
596   for {set j 1} {$j < $astk::ihm(nb_vers)} {incr j} {
597      $MenuVers add radiobutton
598      $MenuVers entryconfigure $j -label $astk::ihm(lvers,$j) -font $astk::ihm(font,lablst) -variable astk::profil(version)
599      if { $astk::profil(version) == $astk::ihm(lvers,$j) } {
600         set pastrouve 0
601      }
602      if { $astk::config(-1,def_vers) == $astk::ihm(lvers,$j) } {
603         set trouvedef 1
604      }
605   }
606   $parent.vers configure -font $astk::ihm(font,lablst)
607   pack $parent.vers -fill x -expand 1
608   # si la version actuelle n'a pas été trouvée et que
609   # la version préférée de l'utl est dispo, on la prend, sinon version 0
610   if { $pastrouve } {
611      if { $trouvedef } {
612         set astk::profil(version) $astk::config(-1,def_vers)
613      } else {
614         set astk::profil(version) $astk::ihm(lvers,0)
615      }
616   }
617# aide contextuelle
618   def_context $parent.vers 313
619}
620
621# appelé pour remettre à jour le nom du serveur, la liste des versions
622# quand on sélectionne un noeud différent
623# ihm="+ihm" pour mettre à jour l'ihm
624#################################################################
625proc change_noeud { } {
626   set serv [quel_serveur $astk::profil(noeud)]
627   if { $serv == "-" } {
628      set astk::profil(serveur) $astk::config(-1,nom)
629      return
630   }
631   set astk::profil(serveur) $astk::config($serv,nom)
632   if { $ashare::dbg >= 4 } {
633      ashare::log "<DEBUG> (change_noeud) $astk::profil(noeud) $serv $astk::profil(serveur)"
634   }
635   set oldbatch -1
636   catch { set oldbatch $astk::profil(batch) }
637   if { $oldbatch < 0 } {
638   #  batch par défaut si possible
639      if { $astk::config($serv,batch) == "oui" } {
640         set astk::profil(batch) 1
641      } else {
642         set astk::profil(batch) 0
643      }
644   }
645   # maj de la liste des versions
646   set astk::ihm(nb_vers) $astk::config($serv,nb_vers)
647   set astk::ihm(lvers,0) ""
648   for {set i 0} { $i < $astk::ihm(nb_vers) } {incr i} {
649      set astk::ihm(lvers,$i) $astk::config($serv,vers,$i)
650      if { $ashare::dbg >= 4 } {
651         ashare::log "<DEBUG> (change_noeud) Version $i : $astk::ihm(lvers,$i)" }
652   }
653   mod_batch
654   liste_versions $astk::ihm(satellite).subtit.version
655
656   if { $ashare::dbg >= 4 } {
657      ashare::log "<DEBUG> (change_noeud) Nouveaux serveur/noeud/version : $astk::profil(serveur) $astk::profil(noeud) $astk::profil(version)"
658   }
659}
660
661# retourne le label associé à un onglet
662#################################################################
663proc quel_onglet { var } {
664   set ONG ""
665   if { $var == "sources" } {
666      set var surcharge
667   }
668   for {set o 1} {$o <= $astk::ihm(nbongM)} {incr o} {
669      if { $var == $astk::ihm(ong,$o,1) } {
670         set ONG $astk::ihm(tit,$o,1)
671         break
672      }
673   }
674   return $ONG
675}
676