Changeset 867 for vanHelsing/trunk
- Timestamp:
- Apr 26, 2010, 6:20:44 PM (15 years ago)
- Location:
- vanHelsing/trunk/gui
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/gui/WebContent/menu.jspx
r864 r867 22 22 <ice:panelTab label="Configuration"> 23 23 <ice:panelGroup style="float:top"> 24 <ice:commandButton id="newClient" 25 value="create client" 26 actionListener="#{configurationBean.newClientButtonListener}" /> 27 24 28 <ice:commandButton id="newRes" 25 29 value="create resource" 26 actionListener="#{configurationBean.newResourceListener}"/> 30 actionListener="#{configurationBean.newResourceButtonListener}"> 31 </ice:commandButton> 32 27 33 <ice:commandButton id="reloadRes" 28 34 value="reload Tree" 29 35 actionListener="#{configurationBean.reloadResourceButtonListener}" /> 36 30 37 <ice:commandButton id="saveRes" 31 38 value="update resource" 32 39 actionListener="#{configurationBean.saveButtonListener}"/> 40 33 41 <ice:commandButton id="deleteRes" 34 42 value="delete resource" … … 58 66 <ice:commandLink actionListener="#{configurationBean.userObjectItemNodeSelected}"> 59 67 <f:param name="userObject.resId" value="#{item.userObject.userObject.resId}"/> 60 <ice:outputText id="knoten" value="#{item.userObject.userObject.value}"/> 61 </ice:commandLink> 68 <f:param name="userObject.resName" value="#{item.userObject.userObject.value}" /> 69 <ice:outputText id="knoten" value="#{item.userObject.userObject.value}"/> 70 </ice:commandLink> 62 71 </ice:panelGroup> 63 72 </f:facet> … … 101 110 </ice:column> 102 111 </ice:dataTable> 112 <ice:commandButton id="createResource" 113 value="save" 114 rendered="#{configurationBean.createResource eq true}" 115 actionListener="#{configurationBean.saveClientButtonListener}" /> 103 116 </ice:panelGrid> 104 117 </f:facet> -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/BeanUtil.java
r865 r867 5 5 import javax.faces.context.FacesContext; 6 6 import javax.faces.model.SelectItem; 7 8 import edu.emory.mathcs.backport.java.util.Collections; 9 10 import java.util.ArrayList; 7 11 import java.util.ResourceBundle; 8 12 import java.util.Locale; … … 175 179 return type; 176 180 } 177 181 /** 182 * 183 * @param key resource name 184 * @return newRes ArrayList of ViewItem 185 */ 186 public static ArrayList<ViewItem> getTypeProperties(String key){ 187 ArrayList<ViewItem> newRes = new ArrayList<ViewItem>(); 188 ArrayList<ViewItem> newOptRes = new ArrayList<ViewItem>(); 189 ArrayList<String> properties = PropertyBundle.getTypeAttributes("director."+key); 190 191 System.err.println(properties.size()); 192 ViewItem vi; 193 for (String s : properties){ 194 vi = new ViewItem(); 195 vi.setRequired(BeanUtil.getRequired(key, s)); 196 vi.setDataType(BeanUtil.getDataType(key, s)); 197 vi.setKey(s); 198 vi.setRenderer(BeanUtil.getRenderer(key, s)); 199 vi.setKeyValue(BeanUtil.getFieldProperty(key, s, 3)); 200 if (vi.getRequired()){ 201 newRes.add(vi); 202 } else { 203 newOptRes.add(vi); 204 } 205 } 206 newRes.addAll(newOptRes); 207 return newRes; 208 } 178 209 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/Client.java
r865 r867 9 9 * Client wraps access methods and data structure of the axis client 10 10 * @author tgoecke 11 *12 11 */ 13 12 public class Client { … … 275 274 /** 276 275 * creates a simple resource object at Van Helsing 277 * @param replace th e object will be replaced if this parameter is set to true, otherwise the changed values will be updated276 * @param replace this parameter is part of the ResourceInitialization object but will not be used by the create method 278 277 * @param rat list of key value pairs of type ResourceAttributeType[] 279 278 * @param rinfo ResourceInfo object containing identification information of the object 280 279 * @return Id of the created simple resource 281 280 */ 282 public int createSimpleResource( boolean replace,ResourceAttributeType[] rat, ResourceInfo rinfo){281 public int createSimpleResource(ResourceAttributeType[] rat, ResourceInfo rinfo){ 283 282 284 283 ResourceInitialization ri = new ResourceInitialization(); 285 ri.setReplace( replace);284 ri.setReplace(false); 286 285 ri.setResInfo(rinfo); 287 286 ri.setResAttribute(rat); -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java
r864 r867 22 22 private ArrayList<ViewItem> selectedObject; 23 23 private String selectedId; 24 private String selectedName; 25 private boolean createResource = false; 24 26 25 27 public ConfigurationBean() { … … 82 84 selectedObject = new ArrayList<ViewItem>(); 83 85 String Id = BeanUtil.getRequestParameter("userObject.resId"); 86 String name = BeanUtil.getRequestParameter("userObject.resName"); 84 87 String selected = BeanUtil.getRequestParameter("ice.event.shift"); 85 88 node = getNode(Id, tree); … … 169 172 return null; 170 173 } 174 171 175 /** 172 176 * 173 177 * @param ae 174 178 */ 179 public void newClientButtonListener(ActionEvent ae){ 180 String type = "client"; 181 ArrayList newResource = new ArrayList<ViewItem>(); 182 ResourceInfo[] ri; 183 int i; 184 String s; 185 selectedObject = BeanUtil.getTypeProperties(type); 186 for (ViewItem vi : selectedObject){ 187 vi.setRendererFlag(vi.getRenderer()); 188 if (vi.getRenderer().equals("selectOneMenu")){ 189 SelectItem[] keyValueList; 190 //TODO: implement getter for list of node types 191 Client c = new Client(); 192 s = vi.getKey().replaceFirst(new Character(vi.getKey().charAt(0)).toString(), 193 new Character(Character.toUpperCase(vi.getKey().charAt(0))).toString()); 194 195 ri = c.getListResources("bacula-dir", s); 196 if (ri != null){ 197 keyValueList = new SelectItem[ri.length]; 198 i = 0; 199 for (ResourceInfo rinfo : ri){ 200 keyValueList[i] = new SelectItem(); 201 keyValueList[i].setValue(rinfo.getResName()); 202 keyValueList[i].setLabel(rinfo.getResName()); 203 i++; 204 } 205 vi.setKeyValueList(keyValueList); 206 } 207 208 } 209 createResource = true; 210 } 211 212 213 } 214 175 215 public void newResourceButtonListener(ActionEvent ae){ 176 216 DefaultMutableTreeNode node; 177 217 UserObjectItem userObject; 218 String Id = BeanUtil.getRequestParameter("userObject.ResId"); 219 String value = BeanUtil.getRequestParameter("userObject.resName"); 220 String shift = BeanUtil.getRequestParameter("ice.event.shift"); 178 221 selectedObject = new ArrayList<ViewItem>(); 179 String Id = BeanUtil.getRequestParameter("userObject.ResId"); 180 String shift = BeanUtil.getRequestParameter("ice.event.shift"); 181 System.err.println(shift); 182 if (Id == null){ 222 System.out.println("value: "+value+" id: "+Id); 223 224 if (value.equals("")){ 183 225 return; 184 226 } 185 node = getNode(Id, tree); 227 //node = getNode(Id, tree); 228 node = getNodeByName(value, tree); 186 229 String type = ((UserObjectItem) ((UserObjectItemType) node 187 230 .getUserObject()).getUserObject()).getResType(); … … 189 232 String[] val; 190 233 try{ 191 String type2 = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 234 //value contains the header of the subtree 235 String type2 = "de.dass_it.vanhelsing.gui.items." + value + "Item"; 192 236 Class newClass = Class.forName(type2); 193 237 for (Method m : newClass.getDeclaredMethods()){ … … 252 296 BeanUtil.setInfoMessage(null, "Diese Methode ist noch nicht implementiert."); 253 297 } 298 public void saveClientButtonListener(ActionEvent ae){ 299 Client c = new Client(); 300 String name = ""; 301 ResourceAttributeType[] rat = new ResourceAttributeType[selectedObject.size()]; 302 int i =0; 303 for (ViewItem vi : selectedObject){ 304 rat[i] = new ResourceAttributeType(); 305 rat[i].setKey(vi.getKey()); 306 rat[i].setValue(vi.getKeyValue()); 307 i++; 308 if (vi.getKey().equals("name")){ 309 name = vi.getKeyValue(); 310 } 311 312 } 313 int newResId = c.createSimpleResource(rat, 314 c.makeResourceInfo("bacula-dir", 0, name, "Client") 315 ); 316 System.err.println(newResId); 317 } 254 318 /** 255 319 * **EXPERIMENTAL** writes the selected resource to the data tree of the web service. … … 338 402 return -1; 339 403 } 404 public String getSelectedName(){ 405 if (selectedObject != null){ 406 if (selectedObject.size() > 0){ 407 return selectedObject.get(0).getResName(); 408 } 409 } 410 return ""; 411 } 412 public void setCreateResource(boolean b){ 413 this.createResource = b; 414 } 415 public boolean getCreateResource(){ 416 return createResource; 417 } 340 418 341 419 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/DataTree.java
r865 r867 11 11 * @author tgoecke 12 12 */ 13 //TODO: labeling schema for header nodes 13 14 public class DataTree { 14 15 private DefaultTreeModel tree; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/JobScheduleBean.java
r865 r867 57 57 UserObjectItemFactory UOFactory = new UserObjectItemFactory(); 58 58 59 //UOFactory.createUserObjectItem(new ResourceAttributeType[], )60 //dataTree.createNode(parent, userObject);61 59 } 62 60 /** -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/PropertyBundle.java
r865 r867 58 58 key = keySet.nextElement(); 59 59 if (key.startsWith(partialKey)){ 60 result.add(getProperty(key));60 result.add(getProperty(key)); 61 61 } 62 62 } … … 65 65 return result.toArray(new String[0]); 66 66 } 67 public static ArrayList<String> getTypeAttributes(String partialKey){ 68 Enumeration<String> keySet = properties.getKeys(); 69 String key; 70 ArrayList<String> result = new ArrayList<String>(); 71 String [] keyComponents; 72 while(keySet.hasMoreElements()){ 73 key = keySet.nextElement(); 74 if (key.startsWith(partialKey)){ 75 if (key.contains("type")){ 76 keyComponents = key.split("\\."); 77 result.add(keyComponents[2]); 78 } 79 } 80 } 81 result.trimToSize(); 82 return result; 83 } 67 84 } 68 85 -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/TreeNavigation.java
r865 r867 263 263 return null; 264 264 } 265 266 public DefaultMutableTreeNode getNodeByName(String value, DefaultTreeModel tree){ 267 DefaultMutableTreeNode root; 268 DefaultMutableTreeNode node; 269 270 root = (DefaultMutableTreeNode)tree.getRoot(); 271 Enumeration<DefaultMutableTreeNode> e = root.depthFirstEnumeration(); 272 273 while (e.hasMoreElements()){ 274 node = e.nextElement(); 275 if (value.equals( ((ItemType)(((UserObjectItemType)node.getUserObject()).getUserObject())).getValue() )){ 276 return node; 277 } 278 } 279 return null; 280 } 281 265 282 /** 266 283 * returns the UserObject of a node whose resId attribute matches id
Note:
See TracChangeset
for help on using the changeset viewer.