KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > plugin > gui > ParameterWidget


1 /*
2  * CLIF is a Load Injection Framework
3  * Copyright (C) 2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * CLIF
20  *
21  * Contact: clif@objectweb.org
22  */

23 package org.objectweb.clif.scenario.util.isac.plugin.gui;
24
25 import java.util.EventListener JavaDoc;
26 import java.util.Hashtable JavaDoc;
27 import java.util.StringTokenizer JavaDoc;
28 import java.util.Vector JavaDoc;
29
30 import org.apache.log4j.Category;
31 import org.eclipse.swt.SWT;
32 import org.eclipse.swt.custom.TableEditor;
33 import org.eclipse.swt.events.ModifyListener;
34 import org.eclipse.swt.events.SelectionEvent;
35 import org.eclipse.swt.events.SelectionListener;
36 import org.eclipse.swt.layout.FillLayout;
37 import org.eclipse.swt.layout.GridData;
38 import org.eclipse.swt.layout.GridLayout;
39 import org.eclipse.swt.widgets.Button;
40 import org.eclipse.swt.widgets.Combo;
41 import org.eclipse.swt.widgets.Composite;
42 import org.eclipse.swt.widgets.Control;
43 import org.eclipse.swt.widgets.Group;
44 import org.eclipse.swt.widgets.Label;
45 import org.eclipse.swt.widgets.Table;
46 import org.eclipse.swt.widgets.TableColumn;
47 import org.eclipse.swt.widgets.TableItem;
48 import org.eclipse.swt.widgets.Text;
49
50 /**
51  * Implementation of the object which included widgets to edit parameters
52  *
53  * @author JC Meillaud
54  * @author A Peyrard
55  */

56 public class ParameterWidget implements SelectionListener {
57
58     static Category cat = Category.getInstance(ParameterWidget.class.getName());
59
60     private static final String JavaDoc EMPTY = "to be edited...";
61
62     /**
63      * Store the widget style
64      */

65     private int style;
66
67     private Composite composite;
68
69     private String JavaDoc name;
70
71     private String JavaDoc labelValue;
72
73     private Text textField;
74
75     private Group radioGroup;
76
77     private Group checkBox;
78
79     private Group group;
80
81     private Vector JavaDoc buttons;
82
83     private Combo combo;
84
85     private EventListener JavaDoc listener;
86
87     private Vector JavaDoc nfield;
88
89     private Vector JavaDoc nfieldLabel;
90
91     private Button nfieldAdd;
92
93     private Button nfieldRemove;
94
95     private Group nfieldGroup;
96
97     private Composite parent;
98
99     private Table table;
100
101     private Vector JavaDoc cellEditors;
102
103     private int cellYAxis;
104
105     private Vector JavaDoc cellText;
106
107     private Vector JavaDoc tableColumns;
108
109     /**
110      * Constructor, build a new WidgetParam
111      *
112      * @param style
113      * The style of the widget for editing this param
114      * @param name
115      * The name of the parameter
116      * @param labelValue
117      * The value of the label for this widget, if it is not defined
118      * use the name of the param
119      * @param params
120      * The parameter to build the widget
121      * @param parent
122      * The parent composite to add the new widget
123      * @param listener
124      * The modify listener to set on the parameter widget
125      */

126     public ParameterWidget(int style, String JavaDoc name, String JavaDoc labelValue,
127             Hashtable JavaDoc params, Composite parent, EventListener JavaDoc listener) {
128         cat.debug("-> constructor");
129         this.listener = listener;
130         this.style = style;
131         this.name = name;
132         if (labelValue == null) {
133             this.labelValue = name;
134         } else {
135             if (labelValue.equals("")) {
136                 this.labelValue = name;
137             } else {
138                 this.labelValue = labelValue;
139             }
140         }
141         // init the widgets
142
this.textField = null;
143         this.radioGroup = null;
144         this.checkBox = null;
145         this.group = null;
146         this.buttons = null;
147         this.nfield = null;
148         this.nfieldLabel = null;
149         this.nfieldAdd = null;
150         this.nfieldRemove = null;
151         this.nfieldGroup = null;
152         this.table = null;
153         this.tableColumns = null;
154         // costruct the main composite
155
this.parent = parent;
156         this.composite = new Composite(parent, SWT.FLAT);
157         this.composite.setBackground(parent.getDisplay().getSystemColor(
158                 SWT.COLOR_WHITE));
159         GridLayout gridLayout = new GridLayout();
160         gridLayout.numColumns = 1;
161         this.composite.setLayout(gridLayout);
162         // set grid data to the main composite
163
GridData gridData = new GridData();
164         gridData.horizontalAlignment = GridData.FILL;
165         gridData.grabExcessHorizontalSpace = true;
166         this.composite.setLayoutData(gridData);
167         // consruct the widget depending it style
168
switch (style) {
169         case WidgetDescription.TEXT_FIELD:
170             initField(params, this.composite);
171             break;
172         case WidgetDescription.RADIO_GROUP:
173             initRadioGroup(params, this.composite);
174             break;
175         case WidgetDescription.CHECK_BOX:
176             initCheckBox(params, this.composite);
177             break;
178         case WidgetDescription.GROUP:
179             initGroup(params, this.composite);
180             break;
181         case WidgetDescription.COMBO:
182             initCombo(params, this.composite);
183             break;
184         case WidgetDescription.NFIELD:
185             initNField(params, this.composite);
186             break;
187         case WidgetDescription.TABLE:
188             initTable(params, this.composite);
189             break;
190         default:
191             cat.warn("UNKNOW WIDGET STYLE : " + style);
192         }
193     }
194
195     /**
196      * Method which permit to get the parameter value
197      */

198     public String JavaDoc getValue() {
199         cat.debug("-> getValue");
200         switch (this.style) {
201         case WidgetDescription.TEXT_FIELD:
202             return getValueField();
203         case WidgetDescription.RADIO_GROUP:
204             return getValueRadioGroup();
205         case WidgetDescription.CHECK_BOX:
206             return getValueCheckBox();
207         case WidgetDescription.GROUP:
208             return getValueGroup();
209         case WidgetDescription.COMBO:
210             return getValueCombo();
211         case WidgetDescription.NFIELD:
212             return getValueNField();
213         case WidgetDescription.TABLE:
214             return getValueTable();
215         default:
216             cat.warn("UNKNOW WIDGET STYLE...");
217             return null;
218         }
219     }
220
221     /**
222      * Set the widget value
223      *
224      * @param value
225      * The value to set
226      */

227     public void setValue(String JavaDoc value) {
228         cat.debug("-> setValue");
229         // remove the listeners because this changes are made by the system
230
// and it do not need to be ntoify of this changes...
231
removeListeners();
232         switch (this.style) {
233         case WidgetDescription.TEXT_FIELD:
234             setValueField(value);
235             break;
236         case WidgetDescription.RADIO_GROUP:
237             setValueRadioGroup(value);
238             break;
239         case WidgetDescription.CHECK_BOX:
240             setValueCheckBox(value);
241             break;
242         case WidgetDescription.GROUP:
243             setValueGroup(value);
244             break;
245         case WidgetDescription.COMBO:
246             setValueCombo(value);
247             break;
248         case WidgetDescription.NFIELD:
249             setValueNField(value);
250             break;
251         case WidgetDescription.TABLE:
252             setValueTable(value);
253             break;
254         default:
255             cat.warn("UNKNOW WIDGET STYLE...");
256         }
257         addListeners();
258     }
259
260     /**
261      * Set the values of a combo
262      *
263      * @param values
264      * The values to be setted
265      */

266     public void setComboValues(Vector JavaDoc values) {
267         cat.debug("-> setComboValues");
268         for (int i = 0; i < values.size(); i++) {
269             this.combo.add((String JavaDoc) values.elementAt(i));
270         }
271     }
272
273     /**
274      * Add a new field to the current nfield
275      *
276      * @param source
277      * The source of the event
278      */

279     public boolean addEmtyFieldForNField(Object JavaDoc source) {
280         cat.debug("-> addEmptyFieldForNField");
281         // if the source is the add widget button
282
if (source != this.nfieldAdd)
283             return false;
284         // create a new label
285
Label label = new Label(this.nfieldGroup, SWT.NONE);
286         label
287                 .setBackground(parent.getDisplay().getSystemColor(
288                         SWT.COLOR_WHITE));
289         // init the text label
290
label.setText("field " + this.nfield.size() + " : ");
291         // add it to the label vector
292
this.nfieldLabel.add(label);
293         // create the text field
294
Text text = new Text(this.nfieldGroup, SWT.BORDER);
295         text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
296         // add a modify listener
297
text.addModifyListener((ModifyListener) this.listener);
298         // add the field to the fields vector
299
this.nfield.add(text);
300         // refresh the group
301
this.nfieldGroup.layout();
302         this.composite.layout();
303         this.parent.layout();
304         return true;
305     }
306
307     /**
308      * This method adds an entry on the table widget
309      *
310      * @param source
311      * The source of the event
312      * @return true if the source is our add button, else false
313      */

314     public boolean addEmtyEntryForTable(Object JavaDoc source) {
315         if (source != this.nfieldAdd)
316             return false;
317         TableItem temp = new TableItem(table, SWT.NONE);
318         // set the default values for each cell
319
String JavaDoc[] values = new String JavaDoc[this.tableColumns.size()];
320         for (int i = 0; i < this.tableColumns.size(); i++) {
321             values[i] = new String JavaDoc(EMPTY);
322         }
323         temp.setText(values);
324         return true;
325     }
326
327     /**
328      * This method removes the last entry of the table widget
329      *
330      * @param source
331      * The source of the event
332      * @return true if the source is our remove button, else false
333      */

334     public boolean removeLastEntryForTable(Object JavaDoc source) {
335         if (source != this.nfieldRemove)
336             return false;
337         this.table.remove(this.table.getItemCount() - 1);
338         return true;
339     }
340
341     /**
342      * Remove the last field of the nfield
343      *
344      * @param source
345      * The source of the event
346      */

347     public boolean removeLastFieldForNField(Object JavaDoc source) {
348         cat.debug("-> removeLastFieldForNField");
349         // if the source is the remove widget button
350
if (source != this.nfieldRemove)
351             return false;
352         if (this.nfield.isEmpty())
353             return true;
354         // get the last label and last text
355
Label lastLabel = (Label) this.nfieldLabel.elementAt(this.nfieldLabel
356                 .size() - 1);
357         Text lastText = (Text) this.nfield.elementAt(this.nfield.size() - 1);
358         // remove the vector entries
359
this.nfield.remove(lastText);
360         this.nfieldLabel.remove(lastLabel);
361         // dispose the widgets
362
lastLabel.dispose();
363         lastText.dispose();
364         // refresh the group
365
this.nfieldGroup.layout();
366         this.composite.layout();
367         this.parent.layout();
368         return true;
369     }
370
371     ///////////////////////////////////////////
372
// Listeners methods
373
//////////////////////////////////////////
374

375     /**
376      * This method remove the listener of the current widget
377      */

378     public void removeListeners() {
379         switch (this.style) {
380         case WidgetDescription.TEXT_FIELD:
381             this.textField.removeModifyListener((ModifyListener) listener);
382             return;
383         case WidgetDescription.RADIO_GROUP:
384             this.removeButtonsListeners();
385             return;
386         case WidgetDescription.CHECK_BOX:
387             this.removeButtonsListeners();
388             return;
389         case WidgetDescription.COMBO:
390             this.combo.removeSelectionListener((SelectionListener) listener);
391             return;
392         case WidgetDescription.NFIELD:
393             this.removeNFieldListeners();
394             return;
395         case WidgetDescription.TABLE:
396             // this.table.removeListener(SWT.Modify, (Listener)this.listener) ;
397
return;
398         default:
399             cat.warn("UNKNOW WIDGET STYLE...");
400         }
401     }
402
403     /**
404      * This method add a listener to the current widget
405      */

406     public void addListeners() {
407         switch (this.style) {
408         case WidgetDescription.TEXT_FIELD:
409             this.textField.addModifyListener((ModifyListener) listener);
410             return;
411         case WidgetDescription.RADIO_GROUP:
412             this.addButtonsListeners();
413             return;
414         case WidgetDescription.CHECK_BOX:
415             this.addButtonsListeners();
416             return;
417         case WidgetDescription.COMBO:
418             this.combo.addSelectionListener((SelectionListener) listener);
419             return;
420         case WidgetDescription.NFIELD:
421             this.addNFieldListeners();
422             return;
423         case WidgetDescription.TABLE:
424             // this.table.addListener(SWT.Modify, (Listener)this.listener) ;
425
return;
426         default:
427             cat.warn("UNKNOW WIDGET STYLE...");
428         }
429     }
430
431     /**
432      * This method remove the listeners on the buttons (used for check box
433      * widgets or radio group...)
434      */

435     private void removeButtonsListeners() {
436         for (int i = 0; i < this.buttons.size(); i++)
437             ((Button) this.buttons.elementAt(i))
438                     .removeSelectionListener((SelectionListener) listener);
439     }
440
441     private void addButtonsListeners() {
442         for (int i = 0; i < this.buttons.size(); i++)
443             ((Button) this.buttons.elementAt(i))
444                     .addSelectionListener((SelectionListener) listener);
445     }
446
447     /**
448      * Remove the listeners of each fields
449      */

450     private void removeNFieldListeners() {
451         for (int i = 0; i < this.nfield.size(); i++) {
452             ((Text) this.nfield.elementAt(i))
453                     .removeModifyListener((ModifyListener) this.listener);
454         }
455     }
456
457     /**
458      * Add the listeners of each fields
459      */

460     private void addNFieldListeners() {
461         for (int i = 0; i < this.nfield.size(); i++) {
462             ((Text) this.nfield.elementAt(i))
463                     .addModifyListener((ModifyListener) this.listener);
464         }
465     }
466
467     ///////////////////////////////////////////
468
// Initialisation widgets
469
///////////////////////////////////////////
470

471     /**
472      * Method which initialize a new table widget
473      */

474     private void initTable(Hashtable JavaDoc params, Composite parent) {
475         cat.debug("-> initTable, p=" + params);
476         // initialize a new group
477
this.nfieldGroup = new Group(parent, SWT.BORDER);
478         this.nfieldGroup.setBackground(parent.getDisplay().getSystemColor(
479                 SWT.COLOR_WHITE));
480         this.nfieldGroup.setText(this.labelValue + " : ");
481         // set the grid data of the group
482
this.nfieldGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
483         // init the layout of the group
484
GridLayout gd = new GridLayout();
485         gd.numColumns = 1;
486         this.nfieldGroup.setLayout(gd);
487         Composite cButtons = new Composite(this.nfieldGroup, SWT.FLAT);
488         GridLayout gdc = new GridLayout();
489         gdc.numColumns = 2;
490         cButtons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
491         cButtons.setBackground(parent.getDisplay().getSystemColor(
492                 SWT.COLOR_WHITE));
493         cButtons.setLayout(gdc);
494         // initialise the two buttons
495
this.nfieldAdd = new Button(cButtons, SWT.FLAT);
496         // set the grid data
497
this.nfieldAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
498         this.nfieldAdd.setText("Add entry");
499         this.nfieldAdd.addSelectionListener((SelectionListener) this.listener);
500         this.nfieldRemove = new Button(cButtons, SWT.FLAT);
501         this.nfieldRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
502         this.nfieldRemove.setText("Remove entry");
503         this.nfieldRemove
504                 .addSelectionListener((SelectionListener) this.listener);
505         // init the new table
506
this.table = new Table(this.nfieldGroup, SWT.BORDER);
507         this.table.setLayoutData(new GridData(GridData.FILL_BOTH));
508         // this.table.addListener(SWT.Modify, (Listener)this.listener) ;
509
this.tableColumns = new Vector JavaDoc();
510         // init the columns
511
String JavaDoc cols = (String JavaDoc) params.get("cols");
512         Vector JavaDoc colsNames = getRealTokens(";",cols);
513         for (int i=0;i<colsNames.size();i++) {
514             TableColumn col = new TableColumn(this.table, SWT.LEFT);
515             col.setText((String JavaDoc)colsNames.elementAt(i));
516             col.setWidth(60);
517             this.tableColumns.add(col);
518         }
519         table.setHeaderVisible(true);
520         table.setLinesVisible(true);
521         // set the line editable
522
table.addSelectionListener(this);
523         //init vectors
524
this.cellEditors = new Vector JavaDoc();
525         this.cellText = new Vector JavaDoc();
526     }
527
528     /**
529      * Method which initialise the label of the parameter
530      */

531     private void initLabel() {
532         cat.debug("-> initLabel");
533         Label label = new Label(this.composite, SWT.RIGHT);
534         label.setBackground(composite.getDisplay().getSystemColor(
535                 SWT.COLOR_WHITE));
536         label.setText(this.labelValue + " : ");
537     }
538
539     /**
540      * Init a new text field
541      *
542      * @param params
543      * The parameters to build the widget
544      * @param parent
545      * The parent composite to add the new widget
546      */

547     private void initField(Hashtable JavaDoc params, Composite parent) {
548         cat.debug("-> initField");
549         // change the composite layout
550
((GridLayout) this.composite.getLayout()).numColumns = 2;
551         // intialise the label of the parameter
552
this.initLabel();
553         // intiailise the text field
554
this.textField = new Text(this.composite, SWT.SINGLE | SWT.BORDER);
555         // set the background color
556
this.textField.setBackground(parent.getDisplay().getSystemColor(
557                 SWT.COLOR_WHITE));
558
559         // set grid data to the textfield
560
GridData gridData = new GridData();
561         gridData.horizontalAlignment = GridData.FILL;
562         gridData.grabExcessHorizontalSpace = true;
563         this.textField.setLayoutData(gridData);
564         // set the default text to the field
565
if (params != null) {
566             if (params.containsKey("text")) {
567                 this.textField.setText((String JavaDoc) params.get("text"));
568             }
569         }
570         // add the modify listener
571
this.textField.addModifyListener((ModifyListener) listener);
572     }
573
574     /**
575      * Init a new nField
576      *
577      * @param params
578      * The parameters to build the widget
579      * @param parent
580      * The parent composite to add the new widget
581      */

582     private void initNField(Hashtable JavaDoc params, Composite parent) {
583         cat.debug("-> initNField");
584         // initialize a new group
585
this.nfieldGroup = new Group(parent, SWT.BORDER);
586         this.nfieldGroup.setBackground(parent.getDisplay().getSystemColor(
587                 SWT.COLOR_WHITE));
588         this.nfieldGroup.setText(this.labelValue + " : ");
589         // set the grid data of the group
590
this.nfieldGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
591         // init the layout of the group
592
GridLayout gd = new GridLayout();
593         gd.numColumns = 2;
594         this.nfieldGroup.setLayout(gd);
595         // initialise the two buttons
596
this.nfieldAdd = new Button(this.nfieldGroup, SWT.FLAT);
597         // set the grid data
598
this.nfieldAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
599         this.nfieldAdd.setText("Add field");
600         this.nfieldAdd.addSelectionListener((SelectionListener) this.listener);
601         this.nfieldRemove = new Button(this.nfieldGroup, SWT.FLAT);
602         this.nfieldRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
603         this.nfieldRemove.setText("Remove field");
604         this.nfieldRemove
605                 .addSelectionListener((SelectionListener) this.listener);
606         // init the fields vector
607
this.nfield = new Vector JavaDoc();
608         this.nfieldLabel = new Vector JavaDoc();
609     }
610
611     /**
612      * Init a new radio group
613      *
614      * @param params
615      * The parameters to build the widget
616      * @param parent
617      * The parent composite to add the new widget
618      */

619     private void initRadioGroup(Hashtable JavaDoc params, Composite parent) {
620         cat.debug("-> initRadioGroup");
621         this.radioGroup = new Group(parent, SWT.BORDER);
622         // set the background color
623
this.radioGroup.setBackground(parent.getDisplay().getSystemColor(
624                 SWT.COLOR_WHITE));
625
626         this.radioGroup.setText(this.labelValue);
627         // set grid data to the group
628
GridData gridData = new GridData();
629         gridData.horizontalAlignment = GridData.FILL;
630         gridData.grabExcessHorizontalSpace = true;
631         this.radioGroup.setLayoutData(gridData);
632         FillLayout fill = new FillLayout();
633         fill.type = SWT.VERTICAL;
634         this.radioGroup.setLayout(fill);
635
636         this.buttons = new Vector JavaDoc();
637         // get the differents choices
638
Vector JavaDoc choices = null;
639         if (params.containsKey("choices")) {
640             choices = (Vector JavaDoc) params.get("choices");
641         }
642         Vector JavaDoc selected = null;
643         if (params.containsKey("selected")) {
644             selected = (Vector JavaDoc) params.get("selected");
645         }
646         // add the button
647
if (choices != null) {
648             for (int i = 0; i < choices.size(); i++) {
649                 Button temp = new Button(this.radioGroup, SWT.RADIO);
650                 temp.setBackground(parent.getDisplay().getSystemColor(
651                         SWT.COLOR_WHITE));
652                 String JavaDoc buttonName = (String JavaDoc) choices.elementAt(i);
653                 temp.setText(buttonName);
654                 // add a selection listener to get changes
655
temp.addSelectionListener((SelectionListener) listener);
656                 this.buttons.add(temp);
657                 // if the button is in the selcted vector, select it
658
if (selected.contains(buttonName))
659                     temp.setSelection(true);
660             }
661         }
662     }
663
664     /**
665      * Init a new check box
666      *
667      * @param params
668      * The parameters to build the widget
669      * @param parent
670      * The parent composite to add the new widget
671      */

672     private void initCheckBox(Hashtable JavaDoc params, Composite parent) {
673         cat.debug("-> initCheckBox");
674         this.checkBox = new Group(parent, SWT.BORDER);
675         // set the background color
676
this.checkBox.setBackground(parent.getDisplay().getSystemColor(
677                 SWT.COLOR_WHITE));
678
679         this.checkBox.setText(this.labelValue);
680         // set grid data to the group
681
GridData gridData = new GridData();
682         gridData.horizontalAlignment = GridData.FILL;
683         gridData.grabExcessHorizontalSpace = true;
684         this.checkBox.setLayoutData(gridData);
685         FillLayout fill = new FillLayout();
686         fill.type = SWT.VERTICAL;
687         this.checkBox.setLayout(fill);
688
689         this.buttons = new Vector JavaDoc();
690
691         // get the differents choices
692
Vector JavaDoc choices = null;
693         if (params.containsKey("choices")) {
694             choices = (Vector JavaDoc) params.get("choices");
695         }
696         Vector JavaDoc selected = null;
697         if (params.containsKey("selected")) {
698             selected = (Vector JavaDoc) params.get("selected");
699         }
700         // add the button
701
if (choices != null) {
702             for (int i = 0; i < choices.size(); i++) {
703                 Button temp = new Button(this.checkBox, SWT.CHECK);
704                 temp.setBackground(parent.getDisplay().getSystemColor(
705                         SWT.COLOR_WHITE));
706                 String JavaDoc buttonName = (String JavaDoc) choices.elementAt(i);
707                 temp.setText(buttonName);
708                 temp.addSelectionListener((SelectionListener) listener);
709                 this.buttons.add(temp);
710                 // if the button is in the selcted vector, select it
711
if (selected.contains(buttonName))
712                     temp.setSelection(true);
713             }
714         }
715     }
716
717     /**
718      * Init a new combo
719      *
720      * @param params
721      * The parameters to build the widget
722      * @param parent
723      * The parent composite to add the new widget
724      */

725     private void initCombo(Hashtable JavaDoc params, Composite parent) {
726         cat.debug("-> initCombo");
727         // change the composite layout
728
((GridLayout) this.composite.getLayout()).numColumns = 2;
729         // intialise the label of the parameter
730
this.initLabel();
731         this.combo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
732         // set the background color
733
this.combo.setBackground(parent.getDisplay().getSystemColor(
734                 SWT.COLOR_WHITE));
735
736         // set grid data to the group
737
GridData gridData = new GridData();
738         gridData.horizontalAlignment = GridData.FILL;
739         gridData.grabExcessHorizontalSpace = true;
740         this.combo.setLayoutData(gridData);
741         // get the differents choices
742
Vector JavaDoc choices = null;
743         // if thzere is no parameters, we have all done
744
if (params == null)
745             return;
746         if (params.containsKey("choices")) {
747             choices = (Vector JavaDoc) params.get("choices");
748         }
749         if (choices != null) {
750             // add the values
751
for (int i = 0; i < choices.size(); i++) {
752                 this.combo.add((String JavaDoc) choices.elementAt(i));
753             }
754         }
755         this.combo.addSelectionListener((SelectionListener) listener);
756     }
757
758     /**
759      * Init a new group
760      *
761      * @param params
762      * The parameters to build the widget
763      * @param parent
764      * The parent composite to add the new widget
765      */

766     private void initGroup(Hashtable JavaDoc params, Composite parent) {
767         cat.debug("-> initGroup");
768         this.group = new Group(parent, SWT.BORDER);
769         // set the background color
770
this.group.setBackground(parent.getDisplay().getSystemColor(
771                 SWT.COLOR_WHITE));
772         this.group.setText(this.labelValue);
773         // set grid data to the group
774
GridData gridData = new GridData();
775         gridData.horizontalAlignment = GridData.FILL;
776         gridData.grabExcessHorizontalSpace = true;
777         this.group.setLayoutData(gridData);
778         GridLayout groupLayout = new GridLayout();
779         groupLayout.numColumns = 1;
780         this.group.setLayout(groupLayout);
781     }
782
783