1 package ist.coach.coachEmfClientComponents.gui; 2 3 import javax.swing.ImageIcon ; 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 [] subordinate_names = new String [0]; 17 19 static String object_type = "LogicalInterface"; 22 static String emsClassName = "ist.coach.coachEmsMib.LogicalInterface_F"; 23 24 static String DISPLAY_TYPE = "Logical Interface"; 25 static boolean canRefresh = false; 26 static String [] create_arg_name = new String [0]; 30 static String [] create_arg_editor = new String [0]; 31 static String [] create_arg_renderer = new String [0]; 32 36 static String [] attributes_name = { "Name", 38 "Element Type", 39 "Creation Source", 40 "Delete Policy", 41 "Related Objects", 43 "Operational State", 44 "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, false, 77 false, 78 false, 79 false, 80 false, 81 false, 82 false, 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 static int ADMIN_POS = 6; 101 static int LASTCANGE_POS = 13; 102 103 public VisualLogicalInterface(String key) { 104 105 super(key); 106 leafIcon = new ImageIcon (VisualLogicalInterface.class.getResource( 107 "images/logicalinterface_icon.gif")); 108 nodeIcon = new ImageIcon (VisualLogicalInterface.class.getResource( 109 "images/logicalinterface_icon.gif")); 110 toolTipText = new String (DISPLAY_TYPE); 111 112 113 } 114 115 public Object [] translate_values(ManagedObjectValueType original_value_type) { 116 117 Object [] values = new Object [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 [] 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 String 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 ("Disabled"); 150 break; 151 case OperationalStateType._enabled : 152 values[i++] = new String ("Enabled"); 153 break; 154 default: 155 values[i++] = new String ("Unknown"); 156 } 157 158 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 ("Up"); 166 break; 167 case ist.coach.coachEmsMib.LogicalInterface_F.down : 168 values[i++] = new String ("Disabled"); 169 break; 170 default: 171 values[i++] = new String ("Unknown"); 172 } 173 values[i++] = String.valueOf(value_type.ifIndex); 174 175 String 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 189 String hexAddressStr = new String (); 190 String shortStr = new String (); 191 for (int j = 0; j < value_type.ifPhysAddress.length; j++) { 192 hexAddressStr += Integer.toHexString( 193 new Byte ((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 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 translate_updates(java.util.Hashtable values) { 244 245 java.util.Vector updates = new java.util.Vector (); 246 org.omg.CosNaming.NameComponent [] objectName = Utils.string2name(key); 247 248 if (values.containsKey(attributes_name[ADMIN_POS])) { 249 250 String attr_value_str = (String ) 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 [] arg_val = {objectName, new Integer (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 attr_value_str = (String ) 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 [] arg_val = {objectName, new Integer (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 |