Changeset 868 for vanHelsing/trunk/gui/src/de/dass_it/vanhelsing
- Timestamp:
- May 3, 2010, 7:12:46 PM (15 years ago)
- Location:
- vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/BeanUtil.java
r867 r868 58 58 public static boolean getRequired(String type, String key) { 59 59 String s = getFieldProperty(type, key, 2); 60 if (s == null) return false; 60 61 if (s.equals("true")) 61 62 return true; … … 104 105 key = key.replaceAll(" ", ""); 105 106 String result[] = getProperties((daemon + "." + type + "." + key)); 107 if (result[0] == null) return null; 106 108 if (i == 0) { 107 109 if (result[1].equals("boolean")) { -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/Client.java
r867 r868 88 88 System.err.println("getSR: " + grt.getResId() + " : " + e.toString()); 89 89 } 90 return n ew SimpleResource(new ResourceInfo(), new ResourceAttributeType[0]);90 return null; 91 91 } 92 92 /** -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java
r867 r868 4 4 import java.util.ArrayList; 5 5 6 import javax.faces.context.FacesContext; 6 7 import javax.faces.event.ActionEvent; 7 8 import javax.faces.event.ValueChangeEvent; … … 17 18 * List all Bacula configuration components by name. 18 19 */ 19 public class ConfigurationBean extends TreeNavigation { 20 21 private DefaultTreeModel tree; 22 private ArrayList<ViewItem> selectedObject; 20 public class ConfigurationBean implements ViewBean{ 21 22 23 private DataTree dataTree; 24 private ConcreteUserObjectItem selectedObject; 25 private boolean createResource; 23 26 private String selectedId; 24 private String selectedName;25 private boolean createResource = false;26 27 27 28 public ConfigurationBean() { … … 34 35 */ 35 36 private void init(){ 36 DefaultMutableTreeNode root = new DefaultMutableTreeNode(); 37 DefaultMutableTreeNode header; 38 DefaultMutableTreeNode leaf; 39 String type; 40 ListResourcesType lrt; 41 GetResourceType grt; 42 DefaultMutableTreeNode myNode; 43 ResourceInfo[] ri; 37 DefaultMutableTreeNode parent; 38 ResourceInfo resItems[]; 44 39 SimpleResource sr; 45 46 40 Client c = new Client(); 47 setTree(super.createTree(root, BeanUtil.getProperty("nodes").split(","), "Configuration")); 48 49 50 for (int i = 0; i < tree.getChildCount(root); i++) { 51 header = (DefaultMutableTreeNode) tree.getChild(root, i); 52 type = ((UserObjectItemType) header.getUserObject()) 53 .getUserObject().getResType(); 54 lrt = new ListResourcesType(); 55 lrt.setDirector("bacula-dir"); 56 lrt.setResourceType(type); 57 ri = c.getListResources(lrt); 58 if (ri == null || ri.length == 0) 59 continue; 60 for (int j = 0; j < ri.length; j++) { 61 myNode = addNode(header, type, ri[j]); 62 grt = new GetResourceType(); 63 grt.setDirector(lrt.getDirector()); 64 grt.setResId(ri[j].getResId()); 65 sr = c.getSimpleResource(grt); 66 myNode = addNode(myNode, type, sr.getResourceAttributeType()); 67 if (myNode != null) { 68 header.add(myNode); 41 UserObjectItemFactory UOFactory = new UserObjectItemFactory(); 42 setDataTree(new DataTree()); 43 dataTree.setTree("Configuration"); 44 for (String name : BeanUtil.getProperty("nodes").split(",")){ 45 parent = dataTree.createNode(dataTree.getRoot(), 46 UOFactory.createUserObjectItem( 47 c.makeResourceInfo(BeanUtil.getProperty("defaultdirector"), -1, name, name) 48 ) 49 ); 50 resItems = c.getListResources(BeanUtil.getProperty("defaultdirector"), name); 51 if (resItems != null){ 52 for (ResourceInfo rinfo : resItems){ 53 sr = c.getSimpleResource(rinfo.getDirector(), rinfo.getResId()); 54 if (sr != null){ 55 //TODO: discard the SimpleResource ResInfo return value and work with the query object 56 dataTree.createNode(parent, 57 UOFactory.createUserObjectItem( 58 sr.getResourceAttributeType(), rinfo)); 59 } 69 60 } 70 61 } 71 } 72 } 73 62 } 63 dataTree.createKeyValueLists(); 64 dataTree.updateUserObjects(); 65 } 66 74 67 /** 75 68 * transfers the selected (by attribute resId) dataobject (resource) into an ArrayList of ViewItems.<br/> … … 79 72 * @param ae ActionEvent which contains relevant information about the component tree. the variable is not used. 80 73 */ 81 public void userObjectItemNodeSelected(ActionEvent ae) { 74 public void renderResource(ActionEvent ae){ 75 DefaultMutableTreeNode node; 76 String id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("userObject.resId"); 77 int numId = new Integer(id); 78 String name = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("userObject.resName"); 79 if (numId > 0){ 80 node = dataTree.getNodeById(numId); 81 selectedObject = (ConcreteUserObjectItem)((UserObjectItemType)(node.getUserObject())).getUserObject(); 82 } else { 83 node = dataTree.getNodeByName(name); 84 selectedObject = (ConcreteUserObjectItem)((UserObjectItemType)(node.getUserObject())).getUserObject(); 85 } 86 } 87 /*public void userObjectItemNodeSelected(ActionEvent ae) { 82 88 DefaultMutableTreeNode node; 83 89 UserObjectItem userObject; 84 selectedObject = new ArrayList<ViewItem>();90 selectedObject.setViewItemList(viewItemList) = new ArrayList<ViewItem>(); 85 91 String Id = BeanUtil.getRequestParameter("userObject.resId"); 86 92 String name = BeanUtil.getRequestParameter("userObject.resName"); … … 147 153 e.printStackTrace(); 148 154 } 149 } 155 }*/ 150 156 /** 151 157 * return an array of nodes of a given resource type … … 156 162 * @return null null object there are no nodes of the requested type 157 163 */ 158 private DefaultMutableTreeNode[] getChildNodes(DefaultTreeModel tree2, String key) {164 /*private DefaultMutableTreeNode[] getChildNodes(DefaultTreeModel tree2, String key) { 159 165 DefaultMutableTreeNode[] dmtn; 160 166 DefaultMutableTreeNode root = (DefaultMutableTreeNode)tree2.getRoot(); … … 171 177 } 172 178 return null; 173 } 179 }*/ 174 180 175 181 /** … … 177 183 * @param ae 178 184 */ 179 public void newClientButtonListener(ActionEvent ae){185 /*public void newClientButtonListener(ActionEvent ae){ 180 186 String type = "client"; 181 187 ArrayList newResource = new ArrayList<ViewItem>(); … … 211 217 212 218 213 } 214 215 public void newResourceButtonListener(ActionEvent ae){219 }*/ 220 221 /*public void newResourceButtonListener(ActionEvent ae){ 216 222 DefaultMutableTreeNode node; 217 223 UserObjectItem userObject; … … 267 273 } 268 274 269 } 275 }*/ 270 276 /** 271 277 * **EXPERIMENTAL** returns type of the selected resource. … … 274 280 * @return viewName name of the resource type of the selected data tree node 275 281 */ 276 public String newResourceListener(ActionEvent ae){282 /*public String newResourceListener(ActionEvent ae){ 277 283 if (selectedObject != null && selectedObject.size() > 0){ 278 284 String resType = selectedObject.get(0).getResType(); … … 281 287 } 282 288 return ""; 283 } 289 }*/ 284 290 285 291 public void userObjectItemOptionSelected(ValueChangeEvent vce){ … … 296 302 BeanUtil.setInfoMessage(null, "Diese Methode ist noch nicht implementiert."); 297 303 } 298 public void saveClientButtonListener(ActionEvent ae){304 /*public void saveClientButtonListener(ActionEvent ae){ 299 305 Client c = new Client(); 300 306 String name = ""; … … 315 321 ); 316 322 System.err.println(newResId); 317 } 323 }*/ 318 324 /** 319 325 * **EXPERIMENTAL** writes the selected resource to the data tree of the web service. … … 321 327 * @param ae ActionEvent contains relevant information 322 328 */ 323 public void saveButtonListener(ActionEvent ae) {329 /*public void saveButtonListener(ActionEvent ae) { 324 330 if (selectedObject == null){ 325 331 BeanUtil.setInfoMessage(null, "bitte eine Resource zum Ändern auswählen"); … … 353 359 if (selectedObject.get(0) != null){ 354 360 selectedObject.get(0).setResId(s2r2.getResId()); 355 } */361 } 356 362 // TODO: write ResId to selectedObject 357 363 // selectedObject.get(0).setResId(grt.getResId()); 358 364 // valueChangeEffect.setFired(false); 359 365 } 360 } 366 }*/ 361 367 /** 362 368 * Setter method for the tree attribute 363 369 * @param tree tree contains the DefaultTreeModel for the data tree 364 370 */ 365 public void set Tree(DefaultTreeModel tree) {366 this. tree = tree;371 public void setDataTree(DataTree dataTree) { 372 this.dataTree = dataTree; 367 373 } 368 374 /** … … 370 376 * @return tree tree contains the DefaultTreeModel for the data tree 371 377 */ 372 public DefaultTreeModel getTree() { 373 return tree; 378 public DataTree getDataTree() { 379 return dataTree; 380 } 381 382 public void createNodeButtonListener(ActionEvent ae) { 383 // TODO Auto-generated method stub 384 385 } 386 387 public void deleteNodeButtonListener(ActionEvent ae) { 388 // TODO Auto-generated method stub 389 390 } 391 392 393 public void readNodeButtonListener(ActionEvent ae) { 394 // TODO Auto-generated method stub 395 396 } 397 398 public void selectNode(ActionEvent ae) { 399 // TODO Auto-generated method stub 400 401 } 402 403 public void updateNodeButtonListener(ActionEvent ae) { 404 // TODO Auto-generated method stub 405 374 406 } 375 407 … … 378 410 * @return selectedObject selectedObject contains the data object of the selected leaf node. 379 411 */ 380 public ArrayList<ViewItem>getSelectedObject() {412 public ConcreteUserObjectItem getSelectedObject() { 381 413 return selectedObject; 382 414 } … … 386 418 * @param selectedObject selectedObject contains the data object of the selected leaf node 387 419 */ 388 public void setSelectedObject( ArrayList<ViewItem>selectedObject) {420 public void setSelectedObject(ConcreteUserObjectItem selectedObject) { 389 421 this.selectedObject = selectedObject; 390 422 } … … 396 428 public int getSelectedId(){ 397 429 if (selectedObject != null){ 398 if (selectedObject.size() > 0){ 399 return selectedObject.get(0).getResId(); 400 } 401 } 430 return selectedObject.getResId(); 431 } 402 432 return -1; 403 433 } 404 public String getSelectedName(){434 /*public String getSelectedName(){ 405 435 if (selectedObject != null){ 406 436 if (selectedObject.size() > 0){ … … 409 439 } 410 440 return ""; 411 } 441 }*/ 412 442 public void setCreateResource(boolean b){ 413 443 this.createResource = b; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/DataTree.java
r867 r868 1 1 package de.dass_it.vanhelsing.gui; 2 2 3 import java.util.ArrayList; 3 4 import java.util.Enumeration; 5 import java.util.HashMap; 6 7 import javax.faces.model.SelectItem; 4 8 import javax.swing.tree.DefaultMutableTreeNode; 5 9 import javax.swing.tree.DefaultTreeModel; … … 15 19 private DefaultTreeModel tree; 16 20 private DefaultMutableTreeNode root; 21 private HashMap<String, SelectItem[]> keyValueList; 17 22 18 23 public DataTree() {} … … 31 36 obj.setResName(name); 32 37 } 38 33 39 /** 34 40 * creates a tree node as a child to the parent node containing the given UserObectItem … … 46 52 return node; 47 53 } 54 48 55 /** 49 56 * replace a tree nodes UserObject … … 54 61 ((UserObjectItemType)node.getUserObject()).setUserObject(userObject); 55 62 } 63 56 64 /** 57 65 * retrieves a node by the value of the UserObjects resId … … 73 81 return null; 74 82 } 83 75 84 /** 76 85 * retrieves a node by the value of the UserObjects resName … … 91 100 return null; 92 101 } 102 93 103 /** 94 104 * deletes the given node from the data tree … … 104 114 } 105 115 116 public void createKeyValueLists(){ 117 DefaultMutableTreeNode parent; 118 DefaultMutableTreeNode node; 119 ConcreteUserObjectItem userObject; 120 SelectItem[] selItems; 121 String key; 122 parent = (DefaultMutableTreeNode)tree.getRoot(); 123 for (int i = 0; i < parent.getChildCount(); i++){ 124 node = (DefaultMutableTreeNode)parent.getChildAt(i); 125 selItems = new SelectItem[node.getChildCount()]; 126 for (int j = 0; j < node.getChildCount(); j++){ 127 userObject = (ConcreteUserObjectItem)((DefaultMutableTreeNode)node.getChildAt(j)).getUserObject(); 128 selItems[j] = new SelectItem(userObject.getResName(), userObject.getResName()); 129 } 130 key = ((ConcreteUserObjectItem)((DefaultMutableTreeNode)node.getChildAt(i)).getUserObject()).getResType(); 131 keyValueList.put(key, selItems); 132 } 133 } 134 public SelectItem[] getSelectItem(String type){ 135 return keyValueList.get(type); 136 } 106 137 public DefaultMutableTreeNode getRoot(){ 107 138 return root; … … 116 147 this.tree = tree; 117 148 } 149 public void updateUserObjects(){ 150 DefaultMutableTreeNode parent; 151 DefaultMutableTreeNode node; 152 parent = (DefaultMutableTreeNode)tree.getRoot(); 153 ArrayList<ViewItem> viList; 154 for(int i = 0; i < parent.getChildCount(); i++){ 155 node = (DefaultMutableTreeNode)parent.getChildAt(i); 156 for (int j = 0; j < node.getChildCount(); j++){ 157 viList = ((ConcreteUserObjectItem)((UserObjectItemType)node.getUserObject()).getUserObject()).getViewItemList(); 158 for (ViewItem vi : viList){ 159 if (vi.getRenderer().equals("selectOneMenu")){ 160 vi.setKeyValueList(keyValueList.get(vi.getResType())); 161 } 162 } 163 } 164 } 165 } 166 167 118 168 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/JobScheduleBean.java
r867 r868 12 12 * with a given schedule. 13 13 */ 14 public class JobScheduleBean {14 public class JobScheduleBean implements ViewBean { 15 15 private DataTree dataTree; 16 16 private ConcreteUserObjectItem selectedObject; … … 52 52 * @param ae ActionEvent parameter as required by JSF. Not used by this method 53 53 */ 54 public void createNode Listener(ActionEvent ae){54 public void createNodeButtonListener(ActionEvent ae){ 55 55 //Methode kann nur mit ausgewählten ParentNode ausgeführt werden 56 56 DefaultMutableTreeNode parent = dataTree.getNodeByName("horst"); … … 62 62 * @param ae ActionEvent parameter as required by JSF. Not used by this method 63 63 */ 64 public void updateNode Listener(ActionEvent ae){64 public void updateNodeButtonListener(ActionEvent ae){ 65 65 BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert"); 66 66 … … 70 70 * @param ae 71 71 */ 72 public void deleteNode Listener(ActionEvent ae){72 public void deleteNodeButtonListener(ActionEvent ae){ 73 73 DefaultMutableTreeNode node; 74 74 ae.getComponent().getAttributes(); … … 100 100 * @param ae ActionEvent parameter as required by JSF. Not used by this method 101 101 */ 102 public void re loadTreeListener(ActionEvent ae){102 public void readNodeButtonListener(ActionEvent ae){ 103 103 init(); 104 104 } 105 105 public void selectNode(ActionEvent ae){ 106 106 //BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert"); 107 String id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("userObject.resId"); 108 String name = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("userObject.resName"); 109 BeanUtil.setInfoMessage(null, ("id: "+id+" name: "+name) ); 110 107 111 108 112 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/UserObjectItemFactory.java
r865 r868 36 36 ArrayList<ViewItem> viewItemList = new ArrayList<ViewItem>(); 37 37 ViewItem vi; 38 String s; 39 boolean b; 38 40 for (ResourceAttributeType attr : ra){ 39 41 vi = new ViewItem(); 40 vi.setDataType(BeanUtil.getDataType(obj.getResType(), attr.getKey())); 41 vi.setRendererFlag(BeanUtil.getRenderer(obj.getResType(), attr.getKey())); 42 vi.setRequired(BeanUtil.getRequired(obj.getResType(), attr.getKey())); 42 43 s = BeanUtil.getDataType(BeanUtil.getAccessType(obj.getResType().toLowerCase()), attr.getKey()); 44 if (s == null){ 45 s = "String"; 46 } 47 vi.setDataType(s); 48 49 s = BeanUtil.getRenderer(BeanUtil.getAccessType(obj.getResType().toLowerCase()), attr.getKey()); 50 if (s == null){ 51 s = "inputType"; 52 } 53 vi.setRendererFlag(s); 54 55 b = false; 56 b = BeanUtil.getRequired(BeanUtil.getAccessType(obj.getResType().toLowerCase()), attr.getKey()); 57 vi.setRequired(b); 58 43 59 vi.setKey(attr.getKey()); 44 60 vi.setKeyValue(attr.getValue()); -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/messages_en.properties
r864 r868 1 1 defaultdirector = bacula-dir 2 nodes = Director,Storage, Autochanger,Client,FileSet,FDClient,Schedule,SDStorage,Console,Catalog,SDDevice,Job,JobDefs,Messages,Pool2 nodes = Director,Storage,Client,FileSet,Schedule,Console,Catalog,Job,JobDefs,Messages,Pool 3 3 director.director.name.ref = 0 4 4 director.director.name.type = String
Note:
See TracChangeset
for help on using the changeset viewer.