KickJava   Java API By Example, From Geeks To Geeks.

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


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.SourceIndicatorType;
7 import intt.itu.itut_x780.notDeletable;
8 import intt.itu.itut_x780.deleteOnlyIfNoContainedObjects;
9 import intt.itu.itut_x780.deleteContainedObjects;
10
11 public class MOTreeObject {
12     String JavaDoc key;
13     ImageIcon JavaDoc leafIcon, nodeIcon;
14     String JavaDoc toolTipText;
15
16     static String JavaDoc[] subordinate_names = { "ManagedObject",
17                                             "ManagedElement",
18                                             "IpNode"};
19 // static String[] subordinate_vtype = { "MOTreeObject",
20
// "VisualManagedElement",
21
// "VisualIpNode"};
22
static boolean canRefresh = false;
23
24         // HACK
25
// This must be the type declared in idl as objectClass!!!!!
26
static String JavaDoc object_type = "ManagedObject";
27
28     static String JavaDoc DISPLAY_TYPE = "ManagedObject";
29     //
30
// create arguments
31
//
32
static String JavaDoc[] create_arg_name = {"Name"};
33     static String JavaDoc[] create_arg_editor = { "", ""};
34     static String JavaDoc[] create_arg_renderer = { "", ""};
35     //
36
// get/set arguments
37
//
38
static String JavaDoc[] attributes_name = {"Name",
39                                         "Element Type",
40                                         "Creation Source",
41                                         "Delete Policy"};
42
43     static boolean[] attributes_readonly = {false, false, false, false};
44     private String JavaDoc label = null;
45     
46  
47     //static JPopupMenu popup = null;
48

49
50 public MOTreeObject(String JavaDoc key) {
51
52     this.key = key;
53     leafIcon = new ImageIcon JavaDoc(MOTreeObject.class.getResource("images/managedobject_icon.gif"));
54     nodeIcon = new ImageIcon JavaDoc(MOTreeObject.class.getResource("images/managedobject_icon.gif"));
55     toolTipText = new String JavaDoc(DISPLAY_TYPE);
56
57         //
58
// setup the label
59
//
60
int objIndex = 0;
61     int lastIndex = key.lastIndexOf("/");
62
63     if (lastIndex > 0) {
64         String JavaDoc object_id = key.substring(0, lastIndex);
65         if (object_id != null && object_id.length() > 0 &&
66                 (objIndex = object_id.lastIndexOf("/")) > 0) {
67
68                 label = object_id.substring(objIndex+1);
69         }
70         else
71                 label = key;
72         lastIndex =label.lastIndexOf(".");
73         if (lastIndex > 0)
74                 label = label.substring(0, lastIndex);
75     }
76     else {
77         lastIndex = key.lastIndexOf(".");
78         if (lastIndex > 0)
79             label = key.substring(0, lastIndex);
80         else
81             label = key;
82     }
83
84 }
85
86
87 /*
88  This operation is used to provide the label of the tree node
89 */

90     public String JavaDoc toString() {
91         return label;
92     }
93
94     public String JavaDoc key() {
95         return key;
96     }
97
98     public Object JavaDoc[] translate_values(ManagedObjectValueType value_type) {
99
100         Object JavaDoc[] values = new Object JavaDoc[attributes_name.length];
101         for(int i = 0; i < values.length; i++)
102             values[i] = "unspecified";
103
104         if (value_type == null)
105             return values;
106
107         String JavaDoc name_str = new String JavaDoc();
108         if (value_type.name != null && value_type.name.length > 0) {
109             for (int i = 0; i < value_type.name.length; i++) {
110                 name_str = name_str.concat(value_type.name[i].id
111                             + "." + value_type.name[i].kind);
112
113                 if (i < value_type.name.length -1 ) {
114                     name_str = name_str.concat("/");
115                 }
116             }
117         }
118         else
119                 GuiClient.println("name value retrieved is null");
120
121         values[0] = new String JavaDoc(name_str);
122         values[1] = new String JavaDoc(value_type.objectClass);
123         switch(value_type.creationSource.value()) {
124             case SourceIndicatorType._resourceOperation :
125                 values[2] = new String JavaDoc("System Created");
126                 break;
127             case SourceIndicatorType._managementOperation :
128                 values[2] = new String JavaDoc("Manager Created");
129                 break;
130             default:
131                 values[2] = new String JavaDoc("Unknown");
132         }
133         switch(value_type.deletePolicy) {
134             case intt.itu.itut_x780.notDeletable.value:
135                 values[3] = new String JavaDoc("Not Deletable");
136                 break;
137             case intt.itu.itut_x780.deleteOnlyIfNoContainedObjects.value:
138                 values[3] = new String JavaDoc("Delete only if zero contained objects");
139                 break;
140             case intt.itu.itut_x780.deleteContainedObjects.value:
141                 values[3] = new String JavaDoc("Remove will also remove subordinate objects");
142                 break;
143         }
144     
145         return values;
146     }
147
148     java.util.Vector JavaDoc translate_updates(java.util.Hashtable JavaDoc values) {
149
150             System.err.println("Translate has been called on MOTreeObject!");
151             return new java.util.Vector JavaDoc();
152     }
153 }
154
Popular Tags