KickJava   Java API By Example, From Geeks To Geeks.

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


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 ist.coach.coachEmsMib.LogicalInterfaceValueType;
10 import ist.coach.coachEmfClientComponents.InvokeSetData;
11
12 import ist.coach.coachEmfCommon.Utils;
13 public class VisualLogicalInterface
14 extends MOTreeObject {
15
16     static String JavaDoc[] subordinate_names = new String JavaDoc[0];
17 // static String[] subordinate_vtype = new String[0];
18

19         // HACK
20
// This must be the type declared in idl as objectClass!!!!!
21
static String JavaDoc object_type = "LogicalInterface";
22     static String JavaDoc emsClassName = "ist.coach.coachEmsMib.LogicalInterface_F";
23
24     static String JavaDoc DISPLAY_TYPE = "Logical Interface";
25     static boolean canRefresh = false;
26     //
27
// create arguments
28
//
29
static String JavaDoc[] create_arg_name = new String JavaDoc[0];
30     static String JavaDoc[] create_arg_editor = new String JavaDoc[0];
31     static String JavaDoc[] create_arg_renderer = new String JavaDoc[0];
32     //
33
// get/set arguments
34
//
35

36     static String JavaDoc[] attributes_name = { //ManagedObject
37
"Name",
38                                         "Element Type",
39                                         "Creation Source",
40                                         "Delete Policy",
41                                                 //TP
42
"Related Objects",
43                                         "Operational State",
44                                                 //Logical Interface
45
"Administrative State",
46                                         "Interface Index",
47                                         "Description",
48                                         "Physical/MAC Type",
49                                         "Maximum Transfer Unit (MTU)",
50                                         "Bandwidth (bps)",
51                                         "Physical Address",
52                                         "Last State Change Time",
53                                         "Number of Received Octets",
54                                         "Incoming Unicast Packets Served",
55                                         "Incoming Non Unicast Packets Served",
56                                         "Incoming Packets Discarded",
57                                         "Incoming Erroneous Packets",
58                                         "Incoming Unsupported Packets Received",
59                                         "Number of Sent Octets",
60                                         "Outgoing Unicast Packets Served",
61                                         "Outgoing Non Unicast Packets Served",
62                                         "Outgoing Packets Discarded",
63                                         "Outgoing Erroneous Packets",
64                                         "Length of Output Queue",
65                                         "MIB Object Identifier"
66                     };
67                             
68     static boolean[] attributes_readonly = {
69                     false,
70                     false,
71                     false,
72                     false,
73                     false,
74                     false,
75                     false, //true,
76
false,
77                     false,
78                     false,
79                     false,
80                     false,
81                     false,
82                     false, //true,
83
false,
84                     false,
85                     false,
86                     false,
87                     false,
88                     false,
89                     false,
90                     false,
91                     false,
92                     false,
93                     false,
94                     false,
95                     false,
96                     false
97     };
98
99     //settable arguments
100
static int ADMIN_POS = 6;
101     static int LASTCANGE_POS = 13;
102
103 public VisualLogicalInterface(String JavaDoc key) {
104
105     super(key);
106     leafIcon = new ImageIcon JavaDoc(VisualLogicalInterface.class.getResource(
107                 "images/logicalinterface_icon.gif"));
108     nodeIcon = new ImageIcon JavaDoc(VisualLogicalInterface.class.getResource(
109                     "images/logicalinterface_icon.gif"));
110     toolTipText = new String JavaDoc(DISPLAY_TYPE);
111
112
113 }
114
115     public Object JavaDoc[] translate_values(ManagedObjectValueType original_value_type) {
116
117         Object JavaDoc[] values = new Object JavaDoc[attributes_name.length];
118         for (int i = 0; i < values.length; i++)
119             values[i] = "unspecified";
120
121         if (original_value_type == null)
122             return values;
123
124         Object JavaDoc[] mo_values = super.translate_values(original_value_type);
125         int i = 0;
126         for (i = 0; i < mo_values.length; i++)
127             values[i] = mo_values[i];
128
129         LogicalInterfaceValueType value_type;
130         value_type = (LogicalInterfaceValueType) original_value_type;
131
132             //
133
// TP
134
//
135
//related objects...
136
String JavaDoc related_objs_str = "unspecified";
137         for (int j = 0; j < value_type.supportedByObjectList.length; j++ ) {
138             if (value_type.supportedByObjectList[j] != null) {
139                 related_objs_str += Utils.name2string(
140                             value_type.supportedByObjectList[j]);
141             }
142             if (j < value_type.supportedByObjectList.length -1 )
143                 related_objs_str += ", ";
144         }
145         values[i++] = related_objs_str;
146
147         switch(value_type.operationalState.value()) {
148             case OperationalStateType._disabled :
149                 values[i++] = new String JavaDoc("Disabled");
150                  break;
151             case OperationalStateType._enabled :
152                 values[i++] = new String JavaDoc("Enabled");
153                 break;
154             default:
155                 values[i++] = new String JavaDoc("Unknown");
156         }
157
158             //
159
// LogicalInterface
160
//
161
//values[i++] = String.valueOf(value_type.ifAdminStatus);
162
switch(value_type.ifAdminStatus) {
163             case ist.coach.coachEmsMib.LogicalInterface_F.up :
164             case ist.coach.coachEmsMib.LogicalInterface_F.testing :
165                 values[i++] = new String JavaDoc("Up");
166                 break;
167             case ist.coach.coachEmsMib.LogicalInterface_F.down :
168                     values[i++] = new String JavaDoc("Disabled");
169                     break;
170             default:
171                 values[i++] = new String JavaDoc("Unknown");
172         }
173         values[i++] = String.valueOf(value_type.ifIndex);
174
175         String JavaDoc sysDescr = value_type.ifDescr;
176         if (sysDescr != null && sysDescr.length() > 0)
177             values[i] = sysDescr;
178         i++;
179
180         values[i++] = String.valueOf(value_type.ifType);
181         values[i++] = String.valueOf(value_type.ifMtu);
182         values[i++] = String.valueOf(value_type.ifSpeed);
183
184         if (value_type.ifPhysAddress != null &&
185                 value_type.ifPhysAddress.length > 0) {
186
187             //values[i] = new String(value_type.ifPhysAddress);
188

189             String JavaDoc hexAddressStr = new String JavaDoc();
190             String JavaDoc shortStr = new String JavaDoc();
191             for (int j = 0; j < value_type.ifPhysAddress.length; j++) {
192                 hexAddressStr += Integer.toHexString(
193                     new Byte JavaDoc((value_type.ifPhysAddress[j])).intValue() & 0x000000ff);
194
195                 if (j < value_type.ifPhysAddress.length - 1)
196                     hexAddressStr += ":";
197             }
198             values[i] = hexAddressStr;
199
200         }
201         else
202             values[i] = "none";
203         i++;
204
205         if (value_type.ifLastChange >= 0)
206             values[i] = String.valueOf(value_type.ifLastChange);
207         i++;
208         values[i++] = String.valueOf(value_type.ifInOctets);
209         values[i++] = String.valueOf(value_type.ifInUcastPkts);
210
211         if (value_type.ifInNUcastPkts >= 0)
212             values[i] = String.valueOf(value_type.ifInNUcastPkts);
213         i++;
214
215         values[i++] = String.valueOf(value_type.ifInDiscards);
216
217         values[i++] = String.valueOf(value_type.ifInErrors);
218
219         if (value_type.ifInUnknownProtos >= 0)
220             values[i] = String.valueOf(value_type.ifInUnknownProtos);
221         i++;
222
223         values[i++] = String.valueOf(value_type.ifOutOctets);
224         values[i++] = String.valueOf(value_type.ifOutUcastPkts);
225
226         if (value_type.ifOutNUcastPkts >= 0)
227             values[i] = String.valueOf(value_type.ifOutNUcastPkts);
228         i++;
229
230         values[i++] = String.valueOf(value_type.ifOutDiscards);
231
232         values[i++] = String.valueOf(value_type.ifOutErrors);
233         values[i++] = String.valueOf(value_type.ifOutQLen);
234
235         String JavaDoc ifSpecific = value_type.ifSpecific;
236         if (ifSpecific!= null && ifSpecific.length()> 0)
237             values[i] = ifSpecific;
238         i++;
239
240         return values;
241     }
242
243     java.util.Vector JavaDoc translate_updates(java.util.Hashtable JavaDoc values) {
244
245         java.util.Vector JavaDoc updates = new java.util.Vector JavaDoc();
246         org.omg.CosNaming.NameComponent JavaDoc[] objectName = Utils.string2name(key);
247             
248         if (values.containsKey(attributes_name[ADMIN_POS])) {
249
250             String JavaDoc attr_value_str = (String JavaDoc) values.get(attributes_name[ADMIN_POS]);
251             if (attr_value_str != null && attr_value_str.length() > 0) {
252
253                 int attr_value = Integer.parseInt(attr_value_str);
254
255                 Object JavaDoc[] arg_val = {objectName, new Integer JavaDoc(attr_value)};
256                 InvokeSetData data_set = new InvokeSetData(emsClassName,
257                             "ifAdminStatusSet",
258                             arg_val
259                 );
260                 updates.add(data_set);
261             }
262         }
263
264         if (values.containsKey(attributes_name[LASTCANGE_POS])) {
265
266             String JavaDoc attr_value_str = (String JavaDoc) values.get(attributes_name[LASTCANGE_POS]);
267
268             if (attr_value_str != null && attr_value_str.length() > 0) {
269
270                 int attr_value = Integer.parseInt(attr_value_str);
271
272
273                 Object JavaDoc[] arg_val = {objectName, new Integer JavaDoc(attr_value)};
274                 InvokeSetData data_set = new InvokeSetData(emsClassName,
275                             "ifLastChangeSet",
276                             arg_val
277                 );
278                 updates.add(data_set);
279             }
280         }
281             return updates;
282     }
283
284 }
285
Popular Tags