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 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 [] subordinate_names = new String [0]; 17 static String object_type = "ManagedElement"; 23 static String emsClassName = "intt.itu.itut_m3120.ManagedElement_F"; 24 25 static String DISPLAY_TYPE = "ManagedElement"; 26 static String [] create_arg_name = {"Name", 30 "User Label", 31 "Product Vendor", 32 "Product Version", 33 "Location" 34 }; 35 static String [] create_arg_editor = { "", ""}; 36 static String [] create_arg_renderer = { "", ""}; 37 41 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 [] 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 key) { 76 77 super(key); 78 leafIcon = new ImageIcon (VisualManagedElement.class.getResource( 79 "images/managedobject_icon.gif")); 80 nodeIcon = new ImageIcon (VisualManagedElement.class.getResource( 81 "images/managedobject_icon.gif")); 82 toolTipText = new String (DISPLAY_TYPE); 83 84 85 } 86 87 public Object [] translate_values(ManagedObjectValueType original_value_type) { 88 89 Object [] values = new Object [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 [] 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 ("Locked"); 107 break; 108 case AdministrativeStateType._unlocked : 109 values[i++] = new String ("Unlocked"); 110 break; 111 case AdministrativeStateType._shuttingDown : 112 values[i++] = new String ("Shutting Down"); 113 break; 114 default: 115 values[i++] = new String ("Unknown"); 116 } 117 118 switch(value_type.operationalState.value()) { 119 case OperationalStateType._disabled : 120 values[i++] = new String ("Disabled"); 121 break; 122 case OperationalStateType._enabled : 123 values[i++] = new String ("Enabled"); 124 break; 125 default: 126 values[i++] = new String ("Unknown"); 127 } 128 129 switch(value_type.usageState.value()) { 130 case UsageStateType._idle : 131 values[i++] = new String ("Disabled"); 132 break; 133 case UsageStateType._active : 134 values[i++] = new String ("Active"); 135 break; 136 case UsageStateType._busy : 137 values[i++] = new String ("Busy"); 138 break; 139 default: 140 values[i++] = new String ("Unknown"); 141 } 142 143 String userLabel = value_type.userLabel; 144 if (userLabel != null && userLabel.length() > 0) 145 values[i] = new String (userLabel); 146 i++; 147 148 String vendorName = value_type.vendorName; 149 if (vendorName != null && vendorName.length() > 0) 150 values[i] = new String (vendorName); 151 i++; 152 153 String version = value_type.version; 154 if (version != null && version.length() > 0) 155 values[i] = new String (version); 156 i++; 157 158 String locationName = value_type.locationName; 159 if (locationName != null && locationName.length() > 0) 160 values[i] = new String (locationName); 161 i++; 162 163 return values; 164 } 165 166 java.util.Vector translate_updates(java.util.Hashtable values) { 167 168 java.util.Vector updates = new java.util.Vector (); 169 org.omg.CosNaming.NameComponent [] 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 attr_value = (String ) 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 [] 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 attr_value = (String ) values.get(attributes_name[LABEL_POS]); 200 Object [] 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 attr_value = (String ) values.get(attributes_name[VENDOR_POS]); 210 Object [] 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 attr_value = (String ) values.get(attributes_name[VERSION_POS]); 221 Object [] 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 attr_value = (String ) values.get(attributes_name[LOCATION_POS]); 231 Object [] 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 |