Changeset 849 for vanHelsing/trunk/gui/src/de
- Timestamp:
- Mar 23, 2010, 3:01:06 PM (15 years ago)
- Location:
- vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java
r848 r849 30 30 ResourceInfo[] ri; 31 31 SimpleResource sr; 32 ((ClientItem)selectedObject).setName("ClientNameTest");32 //((ClientItem)selectedObject).setName("ClientNameTest"); 33 33 34 34 Client c = new Client(); 35 //String[] nodes = {"Director", "Storage", "Catalog", "Autochanger", "Client", "FileSet", "FDClient", "Schedule", "SDStorage", "Console", "Catalog", "SDDevice", "Job", "JobDefs", "Messages", "Pool"};36 String[] nodes = {"Client"};35 String[] nodes = {"Director", "Storage", "Catalog", "Autochanger", "Client", "FileSet", "FDClient", "Schedule", "SDStorage", "Console", "Catalog", "SDDevice", "Job", "JobDefs", "Messages", "Pool"}; 36 //String[] nodes = {"Client"}; 37 37 setTree(super.createTree(root, nodes, "Configuration")); 38 38 39 // \forall header wird eine ResourceList[] angefragt39 //forall header wird eine ResourceList[] angefragt 40 40 for(int i = 0; i < tree.getChildCount(root); i++){ 41 41 header = (DefaultMutableTreeNode)tree.getChild(root, i); … … 49 49 //myNode = null; 50 50 myNode = addNode(header, type, ri[j]); 51 //Node mit Daten befüllen 52 grt = new GetResourceType(); 53 grt.setDirector(lrt.getDirector()); 54 grt.setResId(ri[j].getResId()); 55 sr = c.getSimpleResource(grt); 56 myNode = addNode(myNode, type, sr.getResourceAttributeType()); 51 57 if (myNode != null){ 52 58 header.add(myNode); … … 54 60 } 55 61 } 56 for (int i = 0; i < tree.getChildCount(root); i++){62 /*for (int i = 0; i < tree.getChildCount(root); i++){ 57 63 header = (DefaultMutableTreeNode)tree.getChild(root, i); 58 64 … … 71 77 72 78 } 73 } 79 }*/ 74 80 75 81 … … 78 84 DefaultMutableTreeNode node; 79 85 UserObjectItem userObject; 86 selectedObject = new ArrayList<ViewItem>(); 80 87 String Id = BeanUtil.getRequestParameter("userObject.resId"); 81 88 node = getNode(Id, tree); 82 89 String type = ((UserObjectItem)((UserObjectItemType)node.getUserObject()).getUserObject()).getResType(); 90 String classType = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 91 //Daten aus dem UserObjectItem extrahieren 92 try { 83 93 94 UserObjectItem item = ((UserObjectItemType)(node.getUserObject())).getUserObject(); 95 96 Class c = ((UserObjectItemType)(node.getUserObject())).getUserObject().getClass(); 97 Method[] m = c.getDeclaredMethods(); 98 String keyValue; 99 String key; 100 ViewItem vi; 101 for (Method n : m) { 102 if(n.getName().startsWith("get")) { 103 keyValue = (String)n.invoke(item, (Object[])null); 104 if (keyValue == null) continue; 105 key = n.getName().substring(3); 106 vi = new ViewItem(); 107 vi.setKey(key); vi.setKeyValue(keyValue); vi.setResType(type); 108 selectedObject.add(vi); 109 } 110 } 111 } catch(Exception e) { 112 e.printStackTrace(); 113 } 84 114 } 85 115 … … 90 120 return tree; 91 121 } 92 public UserObjectItemgetSelectedObject() {122 public ArrayList<ViewItem> getSelectedObject() { 93 123 return selectedObject; 94 124 } 95 public void setSelectedObject( UserObjectItemselectedObject) {125 public void setSelectedObject(ArrayList<ViewItem> selectedObject) { 96 126 this.selectedObject = selectedObject; 97 127 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/TreeNavigation.java
r848 r849 140 140 } 141 141 public DefaultMutableTreeNode addNode(DefaultMutableTreeNode parent, String type, ResourceAttributeType[] ra){ 142 DefaultMutableTreeNode node = new DefaultMutableTreeNode(); 142 143 //DefaultMutableTreeNode node = new DefaultMutableTreeNode(); 143 144 Class subClass; 144 145 Class myClass; … … 146 147 Method[] methods; 147 148 Object o; 148 UserObjectItemType userObject = new UserObjectItemType(node);149 //UserObjectItemType userObject = new UserObjectItemType(node); 149 150 String type2 = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 150 151 String key = null, value = null; … … 152 153 subClass = Class.forName(type2); 153 154 o = subClass.newInstance(); 154 UserObjectItem item = ( UserObjectItem) o;155 item.setResType(type);155 UserObjectItem item = ((UserObjectItemType)parent.getUserObject()).getUserObject(); 156 //item.setResType(type); 156 157 myClass = item.getClass().asSubclass(subClass); 157 158 methods = myClass.getMethods(); 158 159 Method m; 160 Method n; 159 161 Class[] args = new Class[1]; 160 162 args[0] = String.class; 161 /*for (Method m : methods){162 if(m.getName().contains("set" + p)){163 m.invoke(item, title);164 }165 }*/166 163 for(ResourceAttributeType rat : ra){ 167 for (Method n : rat.getClass().getDeclaredMethods()){164 /*for (Method n : rat.getClass().getDeclaredMethods()){ 168 165 if (n.getName().equals("getKey")) { 169 166 key = (String)(n.invoke(rat, (Object[])null)); … … 174 171 } 175 172 176 } 173 }*/ 174 n = (rat.getClass().getMethod("getKey", (Class[])null)); 175 key = (String)n.invoke(rat, (Object[])null); 176 n = (rat.getClass().getMethod("getValue", (Class[])null)); 177 value = (String)n.invoke(rat, (Object[])null); 178 177 179 if(!(key.isEmpty() && value.isEmpty())){ 178 180 key = key.replaceAll(" ", ""); … … 181 183 m = myClass.getMethod(("set"+key), args); 182 184 m.invoke(item, value); 183 if(m.getName().equals("getName") || m.getName().equals("setName")){185 /*if(m.getName().equals("getName") || m.getName().equals("setName")){ 184 186 ((ItemType)o).setValue(key + ": " + value); 185 } 187 }*/ 186 188 187 189 } … … 194 196 195 197 //ItemObjekt erzeugen und an das UserObjekt referenzieren 196 userObject.setUserObjectItem((UserObjectItem)o);198 //userObject.setUserObjectItem((UserObjectItem)o); 197 199 //Eine Referenz auf das UserObjekt wird an das Nodeobjekt übergeben 198 node.setUserObject(userObject);200 //node.setUserObject(userObject); 199 201 //System.out.println(((ItemType)((UserObjectItem)(node.getUserObject()))).getResId()); 200 return node;202 return parent; 201 203 } catch (ClassNotFoundException e1){ 202 204 System.err.println("Itemclass "+ type2 +" must be in the classpath"); -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ViewItem.java
r848 r849 6 6 public class ViewItem extends ItemType implements UserObjectItem { 7 7 private String key; 8 private String value;8 private String keyValue; 9 9 10 10 public ViewItem(){ … … 33 33 } 34 34 35 public String get Value() {36 return value;35 public String getKeyValue() { 36 return keyValue; 37 37 } 38 38 39 public void set Value(String value) {40 this. value = value;39 public void setKeyValue(String keyValue) { 40 this.keyValue = keyValue; 41 41 } 42 42 }
Note:
See TracChangeset
for help on using the changeset viewer.