KickJava   Java API By Example, From Geeks To Geeks.

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


1 package ist.coach.coachEmfClientComponents.gui;
2
3 import javax.swing.ImageIcon JavaDoc;
4 import java.util.Vector JavaDoc;
5 import intt.itu.itut_x780.ManagedObjectValueType;
6 import ist.coach.coachEmsMib.SnmpProtocolMonitorValueType;
7 import ist.coach.coachEmfClientComponents.InvokeSetData;
8
9 import ist.coach.coachEmfCommon.Utils;
10
11
12 public class VisualSnmpProtocolMonitor
13 extends MOTreeObject {
14
15     static String JavaDoc[] subordinate_names = new String JavaDoc[0];
16
17     static boolean canRefresh = false;
18     static String JavaDoc object_type = "SnmpProtocolMonitor";
19     static String JavaDoc emsClassName = "ist.coach.coachEmsMib.SnmpProtocolMonitor_F";
20
21     static String JavaDoc DISPLAY_TYPE = "SNMP Protocol Monitor";
22
23         //
24
// create arguments
25
//
26
static String JavaDoc[] create_arg_name = new String JavaDoc[0];
27     static String JavaDoc[] create_arg_editor = new String JavaDoc[0];
28     static String JavaDoc[] create_arg_renderer = new String JavaDoc[0];
29
30             //
31
// settable arguments
32
//
33
static int ENABLE_AUTH_TRAP_POS = 31;
34
35
36     static String JavaDoc[] attributes_name = { //ManagedObject
37
"Name",
38                                         "Element Type",
39                                         "Creation Source",
40                                         "Delete Policy",
41                                             //SnmpProtocolMonitor
42
"Incoming SNMP Messages Received",
43                                         "Outgoing SNMP Messages Sent",
44                                         "Incoming SNMP Messages with Unsupported Version ",
45                                         "Incoming SNMP Messages with Unknown Community",
46                                         "Incoming SNMP Messages with Unsupported Operation on Community",
47                                         "Incoming SNMP Messages with ASN.1 or BER Errors",
48                                         "Incoming SNMP PDUs with Error Status Set to \"tooBig\"",
49                                         "Incoming SNMP PDUs with Error Status Set to \"noSuchName\"",
50                                         "Incoming SNMP PDUs with Error Status Set to \"badValue\"",
51                                         "Incoming SNMP PDUs with Error Status Set to \"readOnly\"",
52                                         "Incoming SNMP PDUs with Error Status Set to \"genErr\"",
53                                         "Total Number of Successfully Retrieved MIB Objects",
54                                         "Total Number of Successfully Altered MIB Objects",
55                                         "Total Number of SNMP Get Requests Processed",
56                                         "Total Number of SNMP Get Next Requests Processed",
57                                         "Total Number of SNMP Set Requests Processed",
58                                         "Total Number of SNMP Get Response PDUs Processed",
59                                         "Total Number of SNMP Traps Accepted",
60                                         "Outgoing SNMP PDUs with Error Status Set to \"tooBig\"",
61                                         "Outgoing SNMP PDUs with Error Status Set to \"noSuchName\"",
62                                         "Outgoing SNMP PDUs with Error Status Set to \"badValue\"",
63                                         "Outgoing SNMP PDUs with Error Status Set to \"genErr\"",
64                                         "Total Number of SNMP Get Requests Generated",
65                                         "Total Number of SNMP Get Next Requests Generated",
66                                         "Total Number of SNMP Set Requests Generated",
67                                         "Total Number of SNMP Get Response PDUs Generated",
68                                         "Total Number of SNMP Traps Generated",
69                                         "Generation of Authentication Failure Traps"
70
71
72                     };
73
74      static boolean[] attributes_readonly = {
75                     false,
76                     false,
77                     false,
78                     false,
79                     false,
80                     false,
81                     false,
82                     false,
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                     false,
98                     false,
99                     false,
100                     false,
101                     false,
102                     false,
103                     false,
104                     false,
105                     false,
106                     true
107     };
108
109     public VisualSnmpProtocolMonitor(String JavaDoc key) {
110         super(key);
111         leafIcon = new ImageIcon JavaDoc(VisualSnmpProtocolMonitor.class.getResource(
112                 "images/protocol_icon.gif"));
113         nodeIcon = new ImageIcon JavaDoc(VisualSnmpProtocolMonitor.class.getResource(
114                 "images/protocol_icon.gif"));
115          toolTipText = new String JavaDoc(DISPLAY_TYPE);
116     }
117
118     public Object JavaDoc[] translate_values(ManagedObjectValueType original_value_type) {
119
120         Object JavaDoc[] values = new Object JavaDoc[attributes_name.length];
121         for (int i = 0; i < values.length; i++)
122             values[i] = "unspecified";
123
124         if (original_value_type == null)
125             return values;
126
127         Object JavaDoc[] mo_values = super.translate_values(original_value_type);
128         int i = 0;
129         for (i = 0; i < mo_values.length; i++)
130             values[i] = mo_values[i];
131
132         SnmpProtocolMonitorValueType value_type;
133         value_type = (SnmpProtocolMonitorValueType) original_value_type;
134
135         values[i++] = String.valueOf(value_type.snmpInPkts);
136         values[i++] = String.valueOf(value_type.snmpOutPkts);
137         values[i++] = String.valueOf(value_type.snmpInBadVersions);
138         values[i++] = String.valueOf(value_type.snmpInBadCommunityNames);
139         values[i++] = String.valueOf(value_type.snmpInBadCommunityUses);
140         values[i++] = String.valueOf(value_type.snmpInASNParseErrs);
141         values[i++] = String.valueOf(value_type.snmpInTooBigs);
142         values[i++] = String.valueOf(value_type.snmpInNoSuchNames);
143         values[i++] = String.valueOf(value_type.snmpInBadValues);
144         values[i++] = String.valueOf(value_type.snmpInReadOnlys);
145         values[i++] = String.valueOf(value_type.snmpInGenErrs);
146         values[i++] = String.valueOf(value_type.snmpInTotalReqVars);
147         values[i++] = String.valueOf(value_type.snmpInTotalSetVars);
148         values[i++] = String.valueOf(value_type.snmpInGetRequests);
149         values[i++] = String.valueOf(value_type.snmpInGetNexts);
150         values[i++] = String.valueOf(value_type.snmpInSetRequests);
151         values[i++] = String.valueOf(value_type.snmpInGetResponses);
152         values[i++] = String.valueOf(value_type.snmpInTraps);
153         values[i++] = String.valueOf(value_type.snmpOutTooBigs);
154         values[i++] = String.valueOf(value_type.snmpOutNoSuchNames);
155         values[i++] = String.valueOf(value_type.snmpOutBadValues);
156         values[i++] = String.valueOf(value_type.snmpOutGenErrs);
157         values[i++] = String.valueOf(value_type.snmpOutGetRequests);
158         values[i++] = String.valueOf(value_type.snmpOutGetNexts);
159         values[i++] = String.valueOf(value_type.snmpOutSetRequests);
160         values[i++] = String.valueOf(value_type.snmpOutGetResponses);
161         values[i++] = String.valueOf(value_type.snmpOutTraps);
162
163         switch(value_type.snmpEnableAuthenTraps) {
164         case 2:
165             values[i] = new String JavaDoc("Disabled");
166             break;
167         case 1:
168             values[i] = new String JavaDoc("Enabled");
169             break;
170         default:
171             values[i] = new String JavaDoc("Unknown");
172             break;
173         }
174         return values;
175     }
176
177     java.util.Vector JavaDoc translate_updates(java.util.Hashtable JavaDoc values) {
178
179          Vector JavaDoc updates = new Vector JavaDoc();
180          org.omg.CosNaming.NameComponent JavaDoc[] objectName = Utils.string2name(key);
181
182          if (values.containsKey(attributes_name[ENABLE_AUTH_TRAP_POS])) {
183
184             String JavaDoc attr_value = (String JavaDoc) values.get(attributes_name[ENABLE_AUTH_TRAP_POS]);
185
186             int auth_allowed_value =
187                 ist.coach.coachEmsMib.SnmpProtocolMonitor_F.enabled;
188
189             if (attr_value.equalsIgnoreCase("disabled")) {
190                 auth_allowed_value =ist.coach.coachEmsMib.SnmpProtocolMonitor_F.disabled;
191             }
192
193             Object JavaDoc[] arg_val = {objectName, new Integer JavaDoc(auth_allowed_value)};
194
195             InvokeSetData data_set = new InvokeSetData(emsClassName,
196                         "snmpEnableAuthenTrapsSet",
197                             arg_val
198             );
199
200             updates.add(data_set);
201         }
202
203
204         return updates;
205     }
206 }
207
Popular Tags