KickJava   Java API By Example, From Geeks To Geeks.

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


1 package ist.coach.coachEmfClientComponents.gui;
2
3 import ist.coach.coachEmsMib.IpNodeValueType;
4 import intt.itu.itut_x780.ManagedObjectValueType;
5 import java.util.Vector JavaDoc;
6 import java.util.Hashtable JavaDoc;
7 import ist.coach.coachEmfClientComponents.InvokeSetData;
8 import ist.coach.coachEmfCommon.Utils;
9 import javax.swing.JPopupMenu JavaDoc;
10
11 import javax.swing.ImageIcon JavaDoc;
12
13 public class VisualIpNode
14 extends VisualManagedElement {
15
16     static String JavaDoc[] subordinate_names = new String JavaDoc[0]; // { "IpNode"};
17
// static String[] subordinate_vtype = new String[0]; // { "VisualIpNode"};
18

19     static boolean canRefresh = true;
20
21     static String JavaDoc object_type = "IpNode";
22     static String JavaDoc emsClassName = "ist.coach.coachEmsMib.IpNode_F";
23
24     static String JavaDoc DISPLAY_TYPE = "IpNode";
25     //
26
// create arguments
27
//
28
static String JavaDoc[] create_arg_name = {"Name",
29                                         "Domain Name",
30                                         "Host Name",
31                                         "IP Address",
32                                         "SNMP Version",
33                                         "User Label",
34                                         "Product Vendor",
35                                         "Product Version",
36                                         "Location",
37                                         "SNMP Port",
38                                         "System Name",
39                                         "Contact Person"};
40     static String JavaDoc[] create_arg_editor = { "", "", "", "", "", "", "" };
41     static String JavaDoc[] create_arg_renderer = { "", "", "", "", "", "", "" };
42     //
43
// get/set arguments
44
//
45
static String JavaDoc[] attributes_name = {"Name",
46                                         "Element Type",
47                                         "Creation Source",
48                                         "Delete Policy",
49                                                 // ManagedElement attributes
50
"Administrative State",
51                                         "Operational State",
52                                         "Usage State",
53                                         "User Label",
54                                         "Product Vendor",
55                                         "Product Version",
56                                         "Location",
57                                                 // IpNode attributes
58
"Domain Name",
59                                         "Host Name",
60                                         "IP Address",
61                                         "SNMP Version",
62                                         "SNMP Port",
63                                         "Number of Interfaces",
64                                         "System Description",
65                                         "SystemOID",
66                                         "SNMP Agent Up Time",
67                                         "System Services",
68                                         "System Name",
69                                         "Contact Person",
70                                     };
71     static boolean[] attributes_readonly = {false,
72                                             false,
73                                             false,
74                                             false,
75                                                 // ManagedElement attributes
76
true,
77                                             false,
78                                             false,
79                                             true,
80                                             true,
81                                             true,
82                                             true,
83                                                 // IpNode attributes
84
false,
85                                             false,
86                                             false,
87                                             false,
88                                             false,
89                                             false,
90                                             false,
91                                             false,
92                                             false,
93                                             false,
94                                             true,
95                                             true };
96                                             
97                                     
98             //
99
// settable arguments
100
//
101
static int SYSNAME_POS = 21;
102         static int CONTACT_POS = 22;
103
104
105     public VisualIpNode(String JavaDoc key) {
106
107         super(key);
108         leafIcon = new ImageIcon JavaDoc(
109             VisualIpNode.class.getResource("images/ipnode_icon.gif"));
110
111         nodeIcon = new ImageIcon JavaDoc(
112             VisualIpNode.class.getResource("images/ipnode_icon.gif"));
113
114     }
115
116     public Object JavaDoc[] translate_values( ManagedObjectValueType original_value_type) {
117
118         if (original_value_type == null)
119             return new Object JavaDoc[0];
120
121         Object JavaDoc[] mo_values = super.translate_values(original_value_type);
122         Object JavaDoc[] values = new Object JavaDoc[attributes_name.length];
123
124         //System.err.println("Attributes of managed_element size = " +
125
// mo_values.length);
126
int i = 0;
127         for (i = 0 ; i < mo_values.length; i++) {
128                     values[i] = mo_values[i];
129         // System.err.println(i + "= " + values[i]);
130
}
131
132         for (int k = i; k < values.length; k++)
133                 values[k] = "unspecified";
134
135         IpNodeValueType value_type = (IpNodeValueType) original_value_type;
136
137         String JavaDoc domainName = value_type.domainName;
138         if (domainName != null && domainName.length() > 0)
139             values[i] = new String JavaDoc(domainName);
140         i++;
141
142         String JavaDoc hostname = value_type.hostname;
143         if (hostname != null && hostname.length() > 0)
144             values[i] = new String JavaDoc(hostname);
145         i++;
146
147         if (value_type.managementIPAddress.length > 0)
148             values[i] = new String JavaDoc(value_type.managementIPAddress);
149         i++;
150
151         values[i] = String.valueOf(value_type.supportedSnmpVersions);
152         i++;
153     
154         values[i] = String.valueOf(value_type.snmpPort);
155         i++;
156         values[i] = String.valueOf(value_type.ifNumber);
157         i++;
158
159         String JavaDoc sysDescr = value_type.sysDescr;
160         if (sysDescr != null && sysDescr.length() > 0)
161             values[i] = new String JavaDoc(sysDescr);
162         i++;
163
164         String JavaDoc sysObjectID = value_type.sysObjectID;
165         if (sysObjectID != null && sysDescr.length() > 0)
166             values[i] = new String JavaDoc(sysObjectID);
167         i++;
168
169         values[i] = String.valueOf(value_type.sysUpTime);
170         i++;
171
172         //values[i++] = String.valueOf(value_type.sysServices);
173
values[i] = SysServicesParser.parseSysServices(value_type.sysServices);
174         i++;
175
176         String JavaDoc sysName = value_type.sysName;
177         if (sysName != null && sysName.length() > 0)
178             values[i] = new String JavaDoc(sysName);
179         i++;
180     
181         String JavaDoc sysContact = value_type.sysContact;
182         if (sysContact != null && sysContact.length() > 0)
183             values[i] = new String JavaDoc(sysContact);
184         i++;
185
186         return values;
187     }
188
189     public Vector JavaDoc translate_updates(Hashtable JavaDoc values) {
190
191         System.err.println("Translate has been called on VisualIpNode!");
192         Vector JavaDoc updates = super.translate_updates(values);
193          org.omg.CosNaming.NameComponent JavaDoc[] objectName = Utils.string2name(key);
194
195          if (values.containsKey(attributes_name[SYSNAME_POS])) {
196
197             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[SYSNAME_POS]);
198             Object JavaDoc[] arg_val = {objectName, attr_value};
199             InvokeSetData data_set = new InvokeSetData(emsClassName,
200                         "sysNameSet",
201                             arg_val
202             );
203             updates.add(data_set);
204         }
205     
206          if (values.containsKey(attributes_name[CONTACT_POS])) {
207
208             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[CONTACT_POS]);
209             Object JavaDoc[] arg_val = {objectName, attr_value};
210             InvokeSetData data_set = new InvokeSetData(emsClassName,
211                         "sysContactSet",
212                             arg_val
213             );
214             updates.add(data_set);
215         }
216         return updates;
217     }
218
219 }
220
Popular Tags