KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > gui > VisualManagedElement


1 package ist.coach.coachEmfClientComponents.gui;
2
3 import javax.swing.ImageIcon JavaDoc;
4
5 import intt.itu.itut_x780.ManagedObjectValueType;
6 import intt.itu.itut_x780.AdministrativeStateType;
7 import intt.itu.itut_x780.OperationalStateType;
8 import intt.itu.itut_x780.UsageStateType;
9 import intt.itu.itut_m3120.ManagedElementValueType;
10 import ist.coach.coachEmfClientComponents.InvokeSetData;
11
12 import ist.coach.coachEmfCommon.Utils;
13 public class VisualManagedElement
14 extends MOTreeObject {
15
16     static String JavaDoc[] subordinate_names = new String JavaDoc[0];
17     //static String[] subordinate_names = { "ManagedObject", "ManagedElement", "IpNode"};
18
//static String[] subordinate_vtype = { "MOTreeObject", "VisualManagedElement",
19
// "VisualIpNode"};
20
// HACK
21
// This must be the type declared in idl as objectClass!!!!!
22
static String JavaDoc object_type = "ManagedElement";
23     static String JavaDoc emsClassName = "intt.itu.itut_m3120.ManagedElement_F";
24
25     static String JavaDoc DISPLAY_TYPE = "ManagedElement";
26     //
27
// create arguments
28
//
29
static String JavaDoc[] create_arg_name = {"Name",
30                                         "User Label",
31                                         "Product Vendor",
32                                         "Product Version",
33                                         "Location"
34                                         };
35     static String JavaDoc[] create_arg_editor = { "", ""};
36     static String JavaDoc[] create_arg_renderer = { "", ""};
37     //
38
// get/set arguments
39
//
40

41             //
42
// settable arguments
43
//
44
static int ADMIN_POS = 4;
45     static int LABEL_POS = 7;
46     static int VENDOR_POS = 8;
47     static int VERSION_POS = 9;
48     static int LOCATION_POS = 10;
49
50     static String JavaDoc[] attributes_name = {"Name",
51                                         "Element Type",
52                                         "Creation Source",
53                                         "Delete Policy",
54                                         "Administrative State",
55                                         "Operational State",
56                                         "Usage State",
57                                         "User Label",
58                                         "Product Vendor",
59                                         "Product Version",
60                                         "Location"
61                                     };
62     static boolean[] attributes_readonly = {false,
63                                             false,
64                                             false,
65                                             false,
66                                             true,
67                                             false,
68                                             false,
69                                             true,
70                                             true,
71                                             true,
72                                             true
73                                             };
74
75 public VisualManagedElement(String JavaDoc key) {
76
77     super(key);
78     leafIcon = new ImageIcon JavaDoc(VisualManagedElement.class.getResource(
79                 "images/managedobject_icon.gif"));
80     nodeIcon = new ImageIcon JavaDoc(VisualManagedElement.class.getResource(
81                     "images/managedobject_icon.gif"));
82     toolTipText = new String JavaDoc(DISPLAY_TYPE);
83
84
85 }
86
87     public Object JavaDoc[] translate_values(ManagedObjectValueType original_value_type) {
88
89         Object JavaDoc[] values = new Object JavaDoc[attributes_name.length];
90         for (int i = 0; i < values.length; i++)
91             values[i] = "unspecified";
92
93         if (original_value_type == null)
94             return values;
95
96         Object JavaDoc[] mo_values = super.translate_values(original_value_type);
97         int i = 0;
98         for (i = 0; i < mo_values.length; i++)
99             values[i] = mo_values[i];
100
101         ManagedElementValueType value_type;
102         value_type = (ManagedElementValueType) original_value_type;
103
104         switch(value_type.administrativeState.value()) {
105             case AdministrativeStateType._locked :
106                 values[i++] = new String JavaDoc("Locked");
107                 break;
108             case AdministrativeStateType._unlocked :
109                 values[i++] = new String JavaDoc("Unlocked");
110                 break;
111             case AdministrativeStateType._shuttingDown :
112                 values[i++] = new String JavaDoc("Shutting Down");
113                 break;
114             default:
115                 values[i++] = new String JavaDoc("Unknown");
116         }
117
118         switch(value_type.operationalState.value()) {
119             case OperationalStateType._disabled :
120                 values[i++] = new String JavaDoc("Disabled");
121                  break;
122             case OperationalStateType._enabled :
123                 values[i++] = new String JavaDoc("Enabled");
124                 break;
125             default:
126                 values[i++] = new String JavaDoc("Unknown");
127         }
128
129         switch(value_type.usageState.value()) {
130             case UsageStateType._idle :
131                 values[i++] = new String JavaDoc("Disabled");
132                  break;
133             case UsageStateType._active :
134                 values[i++] = new String JavaDoc("Active");
135                 break;
136             case UsageStateType._busy :
137                 values[i++] = new String JavaDoc("Busy");
138                 break;
139             default:
140                 values[i++] = new String JavaDoc("Unknown");
141         }
142
143         String JavaDoc userLabel = value_type.userLabel;
144         if (userLabel != null && userLabel.length() > 0)
145             values[i] = new String JavaDoc(userLabel);
146         i++;
147
148         String JavaDoc vendorName = value_type.vendorName;
149         if (vendorName != null && vendorName.length() > 0)
150             values[i] = new String JavaDoc(vendorName);
151         i++;
152
153         String JavaDoc version = value_type.version;
154         if (version != null && version.length() > 0)
155             values[i] = new String JavaDoc(version);
156         i++;
157
158         String JavaDoc locationName = value_type.locationName;
159         if (locationName != null && locationName.length() > 0)
160             values[i] = new String JavaDoc(locationName);
161         i++;
162
163         return values;
164     }
165
166     java.util.Vector JavaDoc translate_updates(java.util.Hashtable JavaDoc values) {
167
168         java.util.Vector JavaDoc updates = new java.util.Vector JavaDoc();
169         org.omg.CosNaming.NameComponent JavaDoc[] objectName = Utils.string2name(key);
170
171         if (values.containsKey(attributes_name[ADMIN_POS])) {
172
173             intt.itu.itut_x780.AdministrativeStateType a_type;
174
175             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[ADMIN_POS]);
176
177             if (attr_value.equalsIgnoreCase("shuttingdown")) {
178                 a_type = intt.itu.itut_x780.AdministrativeStateType.shuttingDown;
179             }
180             else
181             if (attr_value.equalsIgnoreCase("unlocked")) {
182                 a_type = intt.itu.itut_x780.AdministrativeStateType.unlocked;
183             }
184             else
185                 a_type = intt.itu.itut_x780.AdministrativeStateType.locked;
186
187             Object JavaDoc[] arg_val = {objectName, a_type};
188
189             InvokeSetData data_set = new InvokeSetData(emsClassName,
190                             "administrativeStateSet",
191                             arg_val
192                         );
193
194             updates.add(data_set);
195         }
196
197         if (values.containsKey(attributes_name[LABEL_POS])) {
198
199             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[LABEL_POS]);
200             Object JavaDoc[] arg_val = {objectName, attr_value};
201             InvokeSetData data_set = new InvokeSetData(emsClassName,
202                             "userLabelSet",
203                             arg_val
204             );
205             updates.add(data_set);
206         }
207         if (values.containsKey(attributes_name[VENDOR_POS])) {
208
209             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[VENDOR_POS]);
210             Object JavaDoc[] arg_val = {objectName, attr_value};
211             InvokeSetData data_set = new InvokeSetData(emsClassName,
212                             "vendorNameSet",
213                             arg_val
214             );
215             updates.add(data_set);
216         }
217
218         if (values.containsKey(attributes_name[VERSION_POS])) {
219
220             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[VERSION_POS]);
221             Object JavaDoc[] arg_val = {objectName, attr_value};
222             InvokeSetData data_set = new InvokeSetData(emsClassName,
223                             "versionSet",
224                             arg_val
225             );
226             updates.add(data_set);
227         }
228         if (values.containsKey(attributes_name[LOCATION_POS])) {
229
230             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[LOCATION_POS]);
231             Object JavaDoc[] arg_val = {objectName, attr_value};
232             InvokeSetData data_set = new InvokeSetData(emsClassName,
233                         "locationNameSet",
234                             arg_val
235             );
236             updates.add(data_set);
237         }
238
239             return updates;
240     }
241
242 }
243
Popular Tags