Index: vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java
===================================================================
--- vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java	(revision 868)
+++ vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java	(revision 871)
@@ -18,5 +18,5 @@
  * List all Bacula configuration components by name.
  */
-public class ConfigurationBean implements ViewBean{
+public class ConfigurationBean implements IViewBean{
 	
 	
@@ -63,4 +63,6 @@
 		dataTree.createKeyValueLists();
 		dataTree.updateUserObjects();
+		createResource = false;
+		selectedObject = null;
 	}
 	
@@ -84,210 +86,31 @@
 			selectedObject = (ConcreteUserObjectItem)((UserObjectItemType)(node.getUserObject())).getUserObject();
 		}
-	}
-	/*public void userObjectItemNodeSelected(ActionEvent ae) {
-		DefaultMutableTreeNode node;
-		UserObjectItem userObject;
-		selectedObject.setViewItemList(viewItemList) = new ArrayList<ViewItem>();
-		String Id = BeanUtil.getRequestParameter("userObject.resId");
-		String name = BeanUtil.getRequestParameter("userObject.resName");
-		String selected = BeanUtil.getRequestParameter("ice.event.shift");
-		node = getNode(Id, tree);
-		if (selected.equals("true")){
-			((UserObjectItemType)node.getUserObject()).switchSelected();
-		}
-		String type = ((UserObjectItem) ((UserObjectItemType) node
-				.getUserObject()).getUserObject()).getResType();
-		String resName = ((ItemType)((UserObjectItem) ((UserObjectItemType) node
-				.getUserObject()).getUserObject())).getResName();
-		String director = ((ItemType)((UserObjectItem) ((UserObjectItemType) node
-				.getUserObject()).getUserObject())).getDirector();
-		String classType = "de.dass_it.vanhelsing.gui.items." + type + "Item";
-		String accessType = BeanUtil.getAccessType(type.toLowerCase());
-		try {
-			UserObjectItem item = ((UserObjectItemType) (node.getUserObject()))
-					.getUserObject();
-			Class c = ((UserObjectItemType) (node.getUserObject()))
-					.getUserObject().getClass();
-			Method[] m = c.getDeclaredMethods();
-			String keyValue;
-			String key;
-			ViewItem vi;
-			for (Method n : m) {
-				if (n.getName().startsWith("get")) {
-					keyValue = (String) n.invoke(item, (Object[]) null);
-					if (keyValue == null)
-						continue;
-					key = n.getName().substring(3);
-					vi = new ViewItem();
-					vi.setResId(new Integer(Id));
-					vi.setKey(key);
-					vi.setKeyValue(keyValue);
-					vi.setResType(type);
-					vi.setResName(resName);
-					vi.setDirector(director);
-					vi.setRendererFlag(BeanUtil.getRenderer(accessType, key));
-					vi.setRequired(BeanUtil.getRequired(accessType, key));
-					if (vi.getSelectOneMenu() != null){
-						DefaultMutableTreeNode[] dmtn = getChildNodes(tree, vi.getKey());
-						if (dmtn != null) {
-							SelectItem[] si = new SelectItem[dmtn.length];
-							String objectType;
-							for (int i = 0; i < dmtn.length; i++){
-								UserObjectItem nodeObject = ((UserObjectItemType)dmtn[i].getUserObject()).getUserObject();
-								objectType = "de.dass_it.vanhelsing.gui.items." + vi.getKey() +"Item";
-								Class subClass = Class.forName(objectType);
-								Class myClass = nodeObject.getClass().asSubclass(subClass);
-								Method o = myClass.getMethod("getName", (Class[])null);
-								si[i] = new SelectItem((String)o.invoke(nodeObject, (Object[])null),
-										(String)o.invoke(nodeObject, (Object[])null));
-								
-							}
-							vi.setKeyValueList(si);
-						}
-					}
-					selectedObject.add(vi);
-				}
-				selectedObject.trimToSize();
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}*/
-	/**
-	 * return an array of nodes of a given resource type
-	 * 
-	 * @param tree2		copy of the data tree
-	 * @param key		name of the requested resource type
-	 * @return dmtn		array of nodes of a given resource type
-	 * @return null		null object there are no nodes of the requested type
-	 */
-	/*private DefaultMutableTreeNode[] getChildNodes(DefaultTreeModel tree2, String key) {
-		DefaultMutableTreeNode[] dmtn;
-		DefaultMutableTreeNode root = (DefaultMutableTreeNode)tree2.getRoot();
-		DefaultMutableTreeNode node;
-		for (int i = 0; i< root.getChildCount(); i++){
-			node = (DefaultMutableTreeNode)root.getChildAt(i);
-			if (((UserObjectItemType)(node.getUserObject())).getUserObject().getResType().equals(key)){
-				dmtn = new DefaultMutableTreeNode[node.getChildCount()];
-				for (int j = 0; j < node.getChildCount(); j++){
-					dmtn[j] = (DefaultMutableTreeNode)node.getChildAt(j);
-				}
-				return dmtn;
-			}
-		}
-		return null;
-	}*/
-	
-	/**
-	 * 
+		createResource = false;
+	}
+
+	/**
+	 * reads the properties of a given resource to create a resource object
 	 * @param ae
 	 */
-	/*public void newClientButtonListener(ActionEvent ae){
-		String type = "client";
-		ArrayList newResource = new ArrayList<ViewItem>();
-		ResourceInfo[] ri;
-		int i;
-		String s;
-		selectedObject = BeanUtil.getTypeProperties(type);
-		for (ViewItem vi : selectedObject){
-			vi.setRendererFlag(vi.getRenderer());
-			if (vi.getRenderer().equals("selectOneMenu")){
-				SelectItem[] keyValueList;
-				//TODO: implement getter for list of node types
-				Client c = new Client();
-				s = vi.getKey().replaceFirst(new Character(vi.getKey().charAt(0)).toString(),
-						new Character(Character.toUpperCase(vi.getKey().charAt(0))).toString());
-				
-				ri = c.getListResources("bacula-dir", s);
-				if (ri != null){
-					keyValueList = new SelectItem[ri.length];
-					i = 0;
-					for (ResourceInfo rinfo : ri){
-						keyValueList[i] = new SelectItem();
-						keyValueList[i].setValue(rinfo.getResName());
-						keyValueList[i].setLabel(rinfo.getResName());
-						i++;
-					}
-					vi.setKeyValueList(keyValueList);
-				}
-			
-			}
-			createResource = true;
-		}
-		
-		
-	}*/
-	
-	/*public void newResourceButtonListener(ActionEvent ae){
-		DefaultMutableTreeNode node;
-		UserObjectItem userObject;
-		String Id = BeanUtil.getRequestParameter("userObject.ResId");
-		String value = BeanUtil.getRequestParameter("userObject.resName");
-		String shift = BeanUtil.getRequestParameter("ice.event.shift");
-		selectedObject = new ArrayList<ViewItem>();
-		System.out.println("value: "+value+" id: "+Id);
-		
-		if (value.equals("")){
-			return;
-		}
-		//node = getNode(Id, tree);
-		node = getNodeByName(value, tree);
-		String type = ((UserObjectItem) ((UserObjectItemType) node
-				.getUserObject()).getUserObject()).getResType();
-		ViewItem vi;
-		String[] val;
-		try{
-			//value contains the header of the subtree
-			String type2 = "de.dass_it.vanhelsing.gui.items." +  value + "Item";
-			Class newClass = Class.forName(type2);
-			for (Method m : newClass.getDeclaredMethods()){
-				if (m.getName().startsWith("get")) {
-					vi = new ViewItem();
-					vi.setKey(m.getName().substring(3));
-					vi.setRendererFlag(BeanUtil.getRenderer(type, vi.getKey()));
-					if (vi.getSelectOneMenu() != null){
-						DefaultMutableTreeNode[] dmtn = getChildNodes(tree, vi.getKey());
-						if (dmtn != null) {
-							SelectItem[] si = new SelectItem[dmtn.length];
-							String objectType;
-							for (int i = 0; i < dmtn.length; i++){
-								UserObjectItem nodeObject = ((UserObjectItemType)dmtn[i].getUserObject()).getUserObject();
-								objectType = "de.dass_it.vanhelsing.gui.items." + vi.getKey() +"Item";
-								Class subClass = Class.forName(objectType);
-								Class myClass = nodeObject.getClass().asSubclass(subClass);
-								Method o = myClass.getMethod("getName", (Class[])null);
-								si[i] = new SelectItem((String)o.invoke(nodeObject, (Object[])null),
-										(String)o.invoke(nodeObject, (Object[])null));
-								
-							}
-							vi.setKeyValueList(si);
-						}
-					}
-					if (vi.getInputText() != null){
-						vi.setValue(BeanUtil.getProperty("director."+type+"."+vi.getKey()+".def"));
-					}
-				}
-			}
-		} catch (Exception e){
-			e.printStackTrace();
-		}
-		
-	}*/
-	/**
-	 * **EXPERIMENTAL** returns type of the selected resource.
-	 * The method is used for an evaluation about dynamic navigation.
-	 * @param ae	ActionEvent contains relevant information about the jsf component tree.
-	 * @return viewName	name of the resource type of the selected data tree node	
-	 */
-	/*public String newResourceListener(ActionEvent ae){
-		if (selectedObject != null && selectedObject.size() > 0){
-			String resType = selectedObject.get(0).getResType();
-			String viewName = BeanUtil.getAccessType(resType);
-			return viewName;
-		}
-		return "";
-	}*/
-	
+	public void newResourceButtonListener(ActionEvent ae){
+		String type = "Client";
+		UserObjectItemFactory UOFactory = new UserObjectItemFactory();
+		selectedObject = (ConcreteUserObjectItem)UOFactory.createUserObjectItem(type);
+		for (ViewItem vi : selectedObject.getViewItemList()){
+			if(vi.getSelectOneMenu()){
+				vi.setKeyValueList(dataTree.getKeyValueList().get(vi.getKey()));
+			}
+			if (vi.getRadioGroup()){
+				vi.setKeyValueList(dataTree.getKeyValueList().get("trueFalse"));
+			}
+		}
+		createResource = true;
+	}
+
+	public void newClientButtonListener(ActionEvent ae){
+		newResourceButtonListener(ae);
+	}
 	public void userObjectItemOptionSelected(ValueChangeEvent vce){
+		System.err.println("vce.oldValue: " +vce.getOldValue()+" vce.newValue: "+vce.getNewValue());
 		
 	}
@@ -302,67 +125,36 @@
 		BeanUtil.setInfoMessage(null, "Diese Methode ist noch nicht implementiert.");
 	}
-	/*public void saveClientButtonListener(ActionEvent ae){
-		Client c = new Client();
-		String name = "";
-		ResourceAttributeType[] rat = new ResourceAttributeType[selectedObject.size()];
-		int i =0;
-		for (ViewItem vi : selectedObject){
-			rat[i] = new ResourceAttributeType();
-			rat[i].setKey(vi.getKey());
-			rat[i].setValue(vi.getKeyValue());
-			i++;
-			if (vi.getKey().equals("name")){
-				name = vi.getKeyValue();
-			}
-
-		}
-		int newResId = c.createSimpleResource(rat, 
-				c.makeResourceInfo("bacula-dir", 0, name, "Client") 
-				);
-		System.err.println(newResId);
-	}*/
-	/**
-	 * **EXPERIMENTAL** writes the selected resource to the data tree of the web service.
-	 * 
-	 * @param ae	ActionEvent contains relevant information 
-	 */
-	/*public void saveButtonListener(ActionEvent ae) {
-		if (selectedObject == null){
-			BeanUtil.setInfoMessage(null, "bitte eine Resource zum Ändern auswählen");
-		} else {
+	/**
+	 * save the currently selected object
+	 * @param ae
+	 */
+	public void saveClientButtonListener(ActionEvent ae){
+		if (createResource){
 			Client c = new Client();
-			ResourceInfo ri = new ResourceInfo();
-			SetSimpleResourceResponse s2r2;
-			ri.setDirector( selectedObject.get(0).getDirector() );
-			ri.setResId( selectedObject.get(0).getResId() );
-			ri.setResName( selectedObject.get(0).getResName() );
-			ri.setResType( selectedObject.get(0).getResType() );
-			// ResourceAttribute
-			String key, value;
-			ResourceAttributeType[] ra = new ResourceAttributeType[selectedObject.size()];
-			for (int i = 0; i < selectedObject.size(); i++) {
-				key = selectedObject.get(i).getKey();
-				value = selectedObject.get(i).getKeyValue();
-				ra[i] = new ResourceAttributeType();
-				ra[i].setKey(key);
-				ra[i].setValue(value);
-			}
-			ResourceInitialization rinit = new ResourceInitialization();
-			rinit.setResInfo(ri);
-			rinit.setResAttribute(ra);
-			rinit.setReplace(true);
-			s2r2 = c.setSimpleResource(rinit);
-			System.err.println("Status setSimpleRes: "+s2r2.getStatus());
-			BeanUtil.setErrorMessage(null, "Status setSimpleRessource: "+s2r2.getStatus());
-			
-			/*String status = s2r2.getStatus();
-			if (selectedObject.get(0) != null){
-				selectedObject.get(0).setResId(s2r2.getResId());
-			}
-			// TODO: write ResId to selectedObject
-			// selectedObject.get(0).setResId(grt.getResId());
-			// valueChangeEffect.setFired(false);
-		}
-	}*/
+			SimpleResource sr;
+			UserObjectItemFactory UOFactory = new UserObjectItemFactory();
+			for (ViewItem vi : selectedObject.getViewItemList()){
+				if(vi.getKey().equals("name")){
+					selectedObject.setResName(vi.getKeyValue());
+				}
+			}
+			int newResId = 
+				c.createSimpleResource(c.makeResAttrTypeArray(selectedObject.getViewItemList()),
+					c.makeResourceInfo(selectedObject.getDirector(), selectedObject.getResId(),
+							selectedObject.getResName(), selectedObject.getResType()));
+			BeanUtil.setInfoMessage(null, "Neue Resource erzeugt (Id: "+newResId+")");
+			//neue Resource einlesen und in den Baum eintragen
+			//sr = c.getSimpleResource(selectedObject.getDirector(), newResId);
+			sr = new SimpleResource();
+			sr.setResourceAttributeType(c.makeResAttrTypeArray(selectedObject.getViewItemList()));
+			sr.setResourceInfo(c.makeResourceInfo(selectedObject.getDirector(), selectedObject.getResId(),
+					selectedObject.getResName(), selectedObject.getResType()));
+			dataTree.createNode(dataTree.getNodeByName("Client"),
+					UOFactory.createUserObjectItem(sr.getResourceAttributeType(),
+							sr.getResourceInfo()));
+			dataTree.updateUserObjects();
+		}
+	}
+
 	/**
 	 * Setter method for the tree attribute
