Changeset 844 for vanHelsing/trunk/gui/src/de
- Timestamp:
- Mar 18, 2010, 6:52:29 PM (15 years ago)
- Location:
- vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui
- Files:
-
- 1 added
- 19 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/Client.java
r841 r844 1 1 package de.dass_it.vanhelsing.gui; 2 3 import org.apache.axis2.*;4 import org.apache.axis2.client.Options;5 import org.apache.axis2.client.ServiceClient;6 import org.apache.axis2.context.ConfigurationContext;7 import org.apache.axis2.context.ConfigurationContextFactory;8 2 9 3 import de.dass_it.www.vanhelsing.*; 10 4 import de.dass_it.www.vanhelsing.VanHelsingCallbackHandler.*; 11 5 import de.dass_it.www.vanhelsing.VanHelsingStub.*; 12 import java.util.*;13 6 14 7 public class Client { 15 public void connect() {16 VanHelsingStub stub;17 try {18 ConfigurationContext cfgCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);19 HashMap<String, Object> params = new HashMap<String, Object>();20 params.put("org.apache.axis2.transport.http.HTTPConstants.CHUNKED", Boolean.FALSE);21 params.put("org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION", "org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10");22 cfgCtx.setProperties(params);23 24 25 stub = new VanHelsingStub(cfgCtx, "http://localhost:8080/");26 27 getResourceList(stub);28 29 } catch (Exception e){30 e.printStackTrace();31 }32 }33 8 34 public void getResourceList(VanHelsingStub stub){35 ListResourcesType arg0 = new ListResourcesType();36 arg0.setDirector("bacula-dir");37 arg0.setResourceType("Job");38 try{39 40 VanHelsingStub.ListResources req = new VanHelsingStub.ListResources();41 req.setListResources(arg0);42 43 VanHelsingStub.ListResourcesResponse res = stub.listResources(req);44 ResourceInfo[] ergebnis = (res.getListResourcesResponse()).getResource();45 46 for (int i = 0; i < ergebnis.length; i++){47 System.err.println(ergebnis[i].getResId());48 System.err.println(ergebnis[i].getResName());49 System.err.println(ergebnis[i].getResType());50 System.err.println(ergebnis[i].getDirector());51 }52 53 //System.err.println("\n\n!!!!res.toString()");54 //System.err.println(res.toString());55 //System.err.println("\n\n");56 57 } catch (Exception e) {58 e.printStackTrace();59 }60 61 }62 63 9 public ResourceInfo[] getListResources(ListResourcesType lrt){ 64 10 VanHelsingStub stub; 65 11 try { 66 //ohne chunked 67 Options options = new Options(); 68 options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.TRUE); 69 70 stub = new VanHelsingStub("http://localhost:8080/"); 12 13 stub = getStub(); 71 14 72 15 VanHelsingStub.ListResources req = new VanHelsingStub.ListResources(); … … 77 20 78 21 } catch (Exception e){ 79 e.printStackTrace();22 System.err.println("getListResources: " + e.toString()); 80 23 } 81 24 return new ResourceInfo[0]; 82 25 } 83 84 /*public ResourceItem[] getListResourceItems(ListResourcesType lrt){26 27 public SimpleResource getSimpleResource(GetResourceType grt){ 85 28 VanHelsingStub stub; 86 29 try { 87 stub = new VanHelsingStub("http://localhost:8080/");30 stub = getStub(); 88 31 89 VanHelsingStub. ListResourceItems req = new VanHelsingStub.ListResourceItems();90 req.set ListResourceItems(lrt);32 VanHelsingStub.GetSimpleResource req = new VanHelsingStub.GetSimpleResource(); 33 req.setGetSimpleResource(grt); 91 34 92 VanHelsingStub.ListResourceItemsResponse res = stub.listResourceItems(req); 93 return (res.getListResourceItemsResponse()).getResourceItemListElement(); 35 VanHelsingStub.GetSimpleResourceResponse res = stub.getSimpleResource(req); 94 36 95 } catch (Exception e){ 96 e.printStackTrace(); 37 SimpleResource sr = new SimpleResource(); 38 sr.setResourceInfo(res.getResInfo()); 39 sr.setResourceAttributeType(res.getResAttribute()); 40 return sr; 41 42 43 } catch(Exception e){ 44 System.err.println("getSimpleResource: " + e.toString()); 97 45 } 98 return new ResourceItem[0]; 99 }*/ 100 46 return new SimpleResource(new ResourceInfo(), new ResourceAttributeType[0]); 47 } 48 49 private VanHelsingStub getStub() throws Exception { 50 String url = new String("http://localhost:8080/"); 51 VanHelsingStub stub = new VanHelsingStub(url); 52 stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); 53 return stub; 54 } 55 101 56 public static void main(String args[]){ 102 57 Client c = new Client(); 103 c.connect(); 104 105 /*ListResourcesType lrt = new ListResourcesType(); 58 ListResourcesType lrt = new ListResourcesType(); 106 59 lrt.setDirector("bacula-dir"); 107 60 lrt.setResourceType("JobDefs"); … … 109 62 ResourceInfo[] rinfo = c.getListResources(lrt); 110 63 111 //ResourceItem[] ritem = c.getListResourceItems(lrt);112 113 64 System.err.println("!!!rinfo!!!"); 114 65 for (int i = 0; i < rinfo.length && rinfo.length > 0; i++){ … … 119 70 } 120 71 121 /*System.err.println("!!!ritem!!!"); 122 for (int i = 0; i < ritem.length && ritem.length > 0; i++){ 123 System.err.println(ritem[i].getDirector()); 124 System.err.println(ritem[i].getResId()); 125 System.err.println(ritem[i].getResKey()); 126 System.err.println(ritem[i].getResName()); 127 System.err.println(ritem[i].getResValue()); 72 GetResourceType grt = new GetResourceType(); 73 grt.setDirector("bacula-dir"); 74 grt.setResId(117); 75 76 SimpleResource sr = new SimpleResource(); 77 sr = c.getSimpleResource(grt); 78 79 System.err.println("!!sr!!"); 80 System.err.println(sr.getResourceInfo().getDirector()); 81 System.err.println(sr.getResourceInfo().getResId()); 82 System.err.println(sr.getResourceInfo().getResName()); 83 System.err.println(sr.getResourceInfo().getResType()); 84 85 for (int i = 0; i < sr.getResourceAttributeType().length; i++){ 86 System.err.print("\nKey: "); 87 System.err.print((sr.getResourceAttributeType())[i].getKey()); 88 System.err.print("\nValue: "); 89 System.err.print((sr.getResourceAttributeType())[i].getValue()); 128 90 } 129 */91 130 92 } 131 93 -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java
r840 r844 1 1 package de.dass_it.vanhelsing.gui; 2 3 4 import java.lang.reflect.Method; 2 5 3 6 import javax.swing.tree.DefaultMutableTreeNode; 4 7 import javax.swing.tree.DefaultTreeModel; 5 8 import de.dass_it.vanhelsing.gui.items.*; 9 import de.dass_it.www.vanhelsing.*; 10 import de.dass_it.www.vanhelsing.VanHelsingCallbackHandler.*; 11 import de.dass_it.www.vanhelsing.VanHelsingStub.*; 6 12 /* 7 13 * List all Bacula configuration components by name 8 14 */ 9 15 public class ConfigurationBean extends TreeNavigation { 16 10 17 private DefaultTreeModel tree; 18 11 19 public ConfigurationBean(){ 12 20 DefaultMutableTreeNode root = new DefaultMutableTreeNode(); 21 DefaultMutableTreeNode header; 22 String type; 23 ListResourcesType lrt; 24 DefaultMutableTreeNode myNode; 25 ResourceInfo[] ri; 26 Client c = new Client(); 13 27 String[] nodes = {"Director", "Client", "FileSet", "Schedule", 14 28 "SDStorage", "Catalog", "SDDevice", "Job", "JobDefs"}; 15 setTree(super.createTree(root, nodes)); 16 29 setTree(super.createTree(root, nodes, "Configuration")); 30 31 //\forall header wird eine ResourceList[] angefragt 32 for(int i = 0; i < tree.getChildCount(root); i++){ 33 header = (DefaultMutableTreeNode)tree.getChild(root, i); 34 type = ((UserObjectItemType)header.getUserObject()).getUserObject().getResType(); 35 lrt = new ListResourcesType(); 36 lrt.setDirector("bacula-dir"); 37 lrt.setResourceType(type); 38 ri = c.getListResources(lrt); 39 if (ri.length == 0) continue; 40 for (int j = 0; j < ri.length; j++){ 41 myNode = null; 42 myNode = addNode(header, type, ri[j]); 43 if (myNode != null){ 44 header.add(myNode); 45 } 46 } 47 } 17 48 } 49 18 50 public void setTree(DefaultTreeModel tree) { 19 51 this.tree = tree; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/TreeNavigation.java
r832 r844 2 2 3 3 //import org.apache.log4j.Logger; 4 import java.lang.reflect.Method; 5 4 6 import javax.swing.tree.DefaultTreeModel; 5 7 import javax.swing.tree.DefaultMutableTreeNode; 6 8 import de.dass_it.vanhelsing.gui.items.*; 7 9 import de.dass_it.www.vanhelsing.*; 10 import de.dass_it.www.vanhelsing.VanHelsingCallbackHandler.*; 11 import de.dass_it.www.vanhelsing.VanHelsingStub.*; 8 12 9 13 /* 10 * Helper class to encapsulate all procedure 11 * sto work with the tree structure.14 * Helper class to encapsulate all procedures 15 * to work with the tree structure. 12 16 */ 13 17 public class TreeNavigation extends BeanUtil { 14 18 private DefaultTreeModel tree; 15 19 //private Logger logger = Logger.getLogger(this.getClass()); 16 public DefaultTreeModel createTree(DefaultMutableTreeNode root, String[] nodes){ 20 public DefaultTreeModel createTree(DefaultMutableTreeNode root, 21 String[] nodes, String title){ 17 22 23 DefaultMutableTreeNode node; 24 DefaultMutableTreeNode myNode; 18 25 tree = new DefaultTreeModel(root); 26 UserObjectItemType item = new UserObjectItemType(root); 27 UserObjectItem uoi = new TreeItem("Configuration"); 28 uoi.setResType("Tree"); 29 item.setUserObjectItem(uoi); 30 root.setUserObject(item); 31 19 32 for(int i = 0; i< nodes.length; i++){ 20 addNode(root, nodes[i]); 33 //root.add(addNode(root, "Tree", nodes[i])); 34 myNode = null; 35 myNode = addNode(root, nodes[i], nodes[i]); 36 if (myNode != null){ 37 root.add(myNode); 38 } 21 39 } 22 23 40 return tree; 24 41 } 25 42 26 public DefaultMutableTreeNode addNode(DefaultMutableTreeNode parent, String type ){43 public DefaultMutableTreeNode addNode(DefaultMutableTreeNode parent, String type, String title){ 27 44 DefaultMutableTreeNode node = new DefaultMutableTreeNode(); 28 node.setParent(parent); 45 Class subClass; 46 Class myClass; 47 Method[] methods; 48 Object o; 29 49 UserObjectItemType userObject = new UserObjectItemType(node); 30 type = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 50 String type2 = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 51 31 52 try { 32 Class myClass = Class.forName(type); 33 UserObjectItem item = (UserObjectItem) myClass.newInstance(); 34 userObject.setUserObjectItem(item); 35 36 } catch (ClassNotFoundException e){ 37 System.err.println("Itemclass "+ type +" must be in the classpath"); 38 } catch (InstantiationException e){ 39 System.err.println("Class"+type+"must be a concrete class, not an interface or an abstract class"); 40 } catch (IllegalAccessException e){ 41 System.err.println("Class" + type + " lacks a no-argument constructor"); 53 subClass = Class.forName(type2); 54 o = subClass.newInstance(); 55 UserObjectItem item = (UserObjectItem) o; 56 item.setResType(type); 57 myClass = item.getClass().asSubclass(subClass); 58 methods = myClass.getMethods(); 59 for (Method m : methods){ 60 System.err.println(m.getName()); 61 if(m.getName().contains("setValue")){ 62 m.invoke(item, title); 63 } 64 } 65 //ItemObjekt erzeugen und an das UserObjekt referenzieren 66 userObject.setUserObjectItem((UserObjectItem)o); 67 //Eine Referenz auf das UserObjekt wird an das Nodeobjekt übergeben 68 node.setUserObject(userObject); 69 return node; 70 } catch (ClassNotFoundException e1){ 71 System.err.println("Itemclass "+ type2 +" must be in the classpath"); 72 } catch (InstantiationException e2){ 73 System.err.println("Class "+type2+" must be a concrete class, not an interface or an abstract class"); 74 } catch (IllegalAccessException e3){ 75 System.err.println("Class " + type2 + " lacks a no-argument constructor"); 76 } catch (Exception e){ 77 System.err.println(e.toString()); 42 78 } 43 44 return n ode;79 80 return null; 45 81 } 82 public DefaultMutableTreeNode addNode(DefaultMutableTreeNode parent, String type, ResourceInfo ri){ 83 DefaultMutableTreeNode node = new DefaultMutableTreeNode(); 84 Class subClass; 85 Class myClass; 86 Method[] riMethods; 87 Method[] methods; 88 Object o; 89 UserObjectItemType userObject = new UserObjectItemType(node); 90 String type2 = "de.dass_it.vanhelsing.gui.items." + type + "Item"; 91 92 try { 93 subClass = Class.forName(type2); 94 o = subClass.newInstance(); 95 UserObjectItem item = (UserObjectItem) o; 96 item.setResType(type); 97 myClass = item.getClass().asSubclass(subClass); 98 methods = myClass.getMethods(); 99 ; 100 /*for (Method m : methods){ 101 if(m.getName().contains("set" + p)){ 102 m.invoke(item, title); 103 } 104 }*/ 105 for (Method n : ri.getClass().getDeclaredMethods()){ 106 if (n.getName().startsWith("get") 107 && !(n.getName().contains("OMElement") || n.getName().contains("PullParser"))){ 108 109 System.err.println("Name: " + n.getName() +" Feld: "+ n.getName().substring(3)); 110 for (Method m : methods){ 111 if (m.getName().equals("set"+n.getName().substring(3))){ 112 m.invoke(item, n.invoke(ri, (Object[])null)); 113 } 114 } 115 116 117 } 118 119 } 120 //ItemObjekt erzeugen und an das UserObjekt referenzieren 121 userObject.setUserObjectItem((UserObjectItem)o); 122 //Eine Referenz auf das UserObjekt wird an das Nodeobjekt übergeben 123 node.setUserObject(userObject); 124 return node; 125 } catch (ClassNotFoundException e1){ 126 System.err.println("Itemclass "+ type2 +" must be in the classpath"); 127 } catch (InstantiationException e2){ 128 System.err.println("Class "+type2+" must be a concrete class, not an interface or an abstract class"); 129 } catch (IllegalAccessException e3){ 130 System.err.println("Class " + type2 + " lacks a no-argument constructor"); 131 } catch (Exception e){ 132 System.err.println(e.toString()); 133 } 134 135 return null; 136 } 137 46 138 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/CatalogItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class CatalogItem extends ItemType {2 public class CatalogItem extends ItemType implements UserObjectItem{ 3 3 4 4 private String name; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/ClientItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class ClientItem extends ItemType {2 public class ClientItem extends ItemType implements UserObjectItem{ 3 3 4 4 private String name; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/ConfigItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class ConfigItem extends ItemType {2 public class ConfigItem extends ItemType implements UserObjectItem{ 3 3 private int id; 4 4 private String ressource; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/ConsoleItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class ConsoleItem extends ItemType {2 public class ConsoleItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String password; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/CounterItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class CounterItem extends ItemType {2 public class CounterItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String minimum; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/FDClientItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class FDClientItem extends ItemType {2 public class FDClientItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String workingDirectory; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/FDDirectorItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class FDDirectorItem extends ItemType {2 public class FDDirectorItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String password; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/ItemType.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 2 3 public abstract class ItemType { 4 private String type; 3 public abstract class ItemType implements UserObjectItem{ 4 private String ResType; 5 private int ResId; 6 private String ResName; 7 private String director; 8 private String value; 5 9 6 public void setType(String type){7 this.type = type;10 public String getTypePage(){ 11 return ("/WEB-INF/" + ResType + ".jspx"); 8 12 } 9 13 10 public String get Type() {11 return type;14 public String getResType() { 15 return ResType; 12 16 } 13 public String getTypePage(){ 14 return ("/WEB-INF/" + type + ".jspx"); 17 18 public void setResType(String resType) { 19 ResType = resType; 15 20 } 21 22 public int getResId() { 23 return ResId; 24 } 25 26 public void setResId(int resId) { 27 ResId = resId; 28 } 29 30 public String getResName() { 31 return ResName; 32 } 33 34 public void setResName(String resName) { 35 ResName = resName; 36 } 37 38 public String getDirector() { 39 return director; 40 } 41 42 public void setDirector(String director) { 43 this.director = director; 44 } 45 46 public String getValue() { 47 return value; 48 } 49 50 public void setValue(String value) { 51 this.value = value; 52 } 53 16 54 } -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/JobItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class Job sItem extends ItemType{2 public class JobItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String enabled; … … 62 62 private String writePartAfterJob; 63 63 64 public Job sItem() {}65 public Job sItem(String name, String client, String type, String level, String fileSet, String schedule,64 public JobItem() {} 65 public JobItem(String name, String client, String type, String level, String fileSet, String schedule, 66 66 String messages, String pool, String storage, String priority, String writeBootstrap){ 67 67 -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/MessagesItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class MessagesItem extends ItemType {2 public class MessagesItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String mailCommand; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/PoolItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class PoolItem extends ItemType {2 public class PoolItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String maximumVolumes; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/SDDeviceItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class SDDeviceItem extends ItemType {2 public class SDDeviceItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String archiveDevice; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/SDStorageItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class SDStorageItem extends ItemType {2 public class SDStorageItem extends ItemType implements UserObjectItem{ 3 3 private String name; 4 4 private String workingDirectory; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/ScheduleItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class ScheduleItem extends ItemType {2 public class ScheduleItem extends ItemType implements UserObjectItem{ 3 3 4 4 private String name; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/StorageItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 public class StorageItem extends ItemType {2 public class StorageItem extends ItemType implements UserObjectItem{ 3 3 4 4 private String name; -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/TreeItem.java
r832 r844 1 1 package de.dass_it.vanhelsing.gui.items; 2 2 3 public class TreeItem extends ItemType {3 public class TreeItem extends ItemType implements UserObjectItem{ 4 4 5 5 private String value; 6 7 public TreeItem(){} 6 8 7 9 public TreeItem(String value) { -
vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/items/UserObjectItem.java
r831 r844 5 5 public interface UserObjectItem { 6 6 7 public String get Type();8 public void set Type(String type);7 public String getResType(); 8 public void setResType(String ResType); 9 9 }
Note:
See TracChangeset
for help on using the changeset viewer.