KickJava   Java API By Example, From Geeks To Geeks.

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


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.Enumeration JavaDoc;
26 import java.util.Hashtable JavaDoc;
27
28 import org.apache.log4j.Category;
29
30 /**
31  * This class is the implementation of a widget description object, it will be
32  * used to create a widget with this description in order to edit some
33  * parameters
34  *
35  * @author JC Meillaud
36  * @author A Peyrard
37  */

38 public class WidgetDescription {
39     static Category cat = Category.getInstance(WidgetDescription.class
40             .getName());
41
42     /**
43      * A simple text field
44      */

45     public static final int TEXT_FIELD = 0;
46     /**
47      * A radio button group
48      */

49     public static final int RADIO_GROUP = 1;
50     /**
51      * A check box group
52      */

53     public static final int CHECK_BOX = 2;
54     /**
55      * A group for grouping multiple widget
56      */

57     public static final int GROUP = 3;
58     /**
59      * A combo for grouping values
60      */

61     public static final int COMBO = 4;
62     /**
63      * A nfield for editing n values
64      */

65     public static final int NFIELD = 5;
66     /**
67      * A table widget
68      */

69     public static final int TABLE = 6 ;
70
71     private int type;
72     private String JavaDoc text;
73     private String JavaDoc label;
74     private Hashtable JavaDoc params;
75
76     /**
77      * Build a new widget description element
78      *
79      * @param t
80      * The type of the widget
81      * @param text
82      * The text of the widget if label is not defined (the name of the param)
83      * @param label The label of the widget
84      * @param p
85      * The parameters to build the widget
86      */

87     public WidgetDescription(int t, String JavaDoc text, String JavaDoc label, Hashtable JavaDoc p) {
88         cat.debug("-> constructor");
89         this.type = t;
90         this.text = text;
91         this.params = p;
92         this.label = label ;
93     }
94
95     /**
96      * @return Returns the params.
97      */

98     public Hashtable JavaDoc getParams() {
99         cat.debug("-> getParams");
100         return params;
101     }
102     /**
103      * @return Returns the text.
104      */

105     public String JavaDoc getText() {
106         cat.debug("-> getText");
107         return text;
108     }
109     /**
110      * @return Returns the type.
111      */

112     public int getType() {
113         cat.debug("-> getType");
114         return type;
115     }
116     /**
117      * @return Returns the label.
118      */

119     public String JavaDoc getLabel() {
120         return label;
121     }
122     /**
123      * @return Return a representation of the WidgetDescription
124      */

125     public String JavaDoc toString() {
126         String JavaDoc result = "";
127         switch (this.type) {
128             case CHECK_BOX :
129                 result = result+"type = checkbox\n";
130                 break;
131             case COMBO :
132                 result = result+"type = combo\n";
133                 break;
134             case GROUP :
135                 result = result+"type = group\n";
136                 break;
137             case RADIO_GROUP :
138                 result = result+"type = radio_group\n";
139                 break;
140             case TEXT_FIELD :
141                 result = result+"type = text_field\n";
142                 break;
143             case NFIELD :
144                 result = result+"type = nfield\n";
145                 break;
146             default :
147                 result = result+"type = unknown\n";
148             break;
149         }
150         result = result + "text of the widget = " + this.text + "\n";
151         if (this.params != null) {
152             Enumeration JavaDoc keys = this.params.keys();
153             while (keys.hasMoreElements()) {
154                 String JavaDoc key = (String JavaDoc) keys.nextElement();
155                 result = result + "Parameters :\n";
156                 //Vector ve = (Vector) this.params.get(key);
157
result = result + key + " : " + this.params.get(key) + "\n";
158             }
159         }
160
161         return result;
162     }
163 }
Popular Tags