source: vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/JobScheduleBean.java@ 868

Last change on this file since 868 was 868, checked in by tobias, on May 3, 2010 at 7:12:46 PM

configurationView moved to new DataTree class.
implemented selectOneMenu on DataTree

File size: 4.2 KB
Line 
1package de.dass_it.vanhelsing.gui;
2
3import javax.faces.event.ActionEvent;
4import javax.swing.tree.DefaultMutableTreeNode;
5import javax.swing.tree.DefaultTreeModel;
6import de.dass_it.www.vanhelsing.VanHelsingStub.*;
7import de.dass_it.vanhelsing.gui.items.ConcreteUserObjectItem;
8import javax.faces.context.FacesContext;
9
10/**
11 * JobSchedule will list all schedules and the jobs which are associated
12 * with a given schedule.
13 */
14public class JobScheduleBean implements ViewBean {
15 private DataTree dataTree;
16 private ConcreteUserObjectItem selectedObject;
17 public JobScheduleBean(){
18 init();
19 }
20 /**
21 * creates a data tree for the job / schedule view
22 */
23 private void init(){
24 Client c = new Client();
25 UserObjectItemFactory UOFactory = new UserObjectItemFactory();
26 ResourceInfo riSched[];
27 ResourceInfo riJobs[];
28 SimpleResource sr;
29 DefaultMutableTreeNode parent;
30 dataTree = new DataTree();
31 dataTree.setTree("JobSchedule");
32 riSched = c.getListResources(BeanUtil.getProperty("defaultdirector"), "Schedule");
33 for (ResourceInfo rinfo : riSched){
34 parent = dataTree.createNode(dataTree.getRoot(),
35 UOFactory.createUserObjectItem(rinfo));
36 riJobs = c.getListResources(rinfo.getDirector(), "Job");
37 for (ResourceInfo rJobs : riJobs){
38 sr = c.getSimpleResource(rJobs.getDirector(), rJobs.getResId());
39 for (ResourceAttributeType rat : sr.getResourceAttributeType()){
40 if (rat.getKey().toLowerCase().equals("schedule") &&
41 rat.getValue().equals(rinfo.getResName())){
42 dataTree.createNode(parent,
43 UOFactory.createUserObjectItem(rJobs));
44 }
45 }
46 }
47 }
48 }
49
50 /**
51 * creates a new node in the data tree
52 * @param ae ActionEvent parameter as required by JSF. Not used by this method
53 */
54 public void createNodeButtonListener(ActionEvent ae){
55 //Methode kann nur mit ausgewählten ParentNode ausgeführt werden
56 DefaultMutableTreeNode parent = dataTree.getNodeByName("horst");
57 UserObjectItemFactory UOFactory = new UserObjectItemFactory();
58
59 }
60 /**
61 * updates the selected node of the data tree
62 * @param ae ActionEvent parameter as required by JSF. Not used by this method
63 */
64 public void updateNodeButtonListener(ActionEvent ae){
65 BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert");
66
67 }
68 /**
69 * delete the selected node of the data tree
70 * @param ae
71 */
72 public void deleteNodeButtonListener(ActionEvent ae){
73 DefaultMutableTreeNode node;
74 ae.getComponent().getAttributes();
75
76 String idString = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("UserObject.resId");
77 String name = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("UserObject.resName");
78
79 if (idString == null && name != null && !name.equals("")){
80 node = dataTree.getNodeByName(name);
81 try{
82 node = dataTree.deleteNode(node);
83 }catch (ConstraintViolationException ecv){
84 System.err.println(ecv.toString());
85 }
86 } else if (idString != null) {
87 node = dataTree.getNodeById(new Integer(idString).intValue());
88 try {
89 node = dataTree.deleteNode(node);
90 } catch (ConstraintViolationException ecv) {
91 ecv.printStackTrace();
92 }
93 } else {
94 BeanUtil.setInfoMessage(null, "Knoten kann nicht referenziert werden");
95 }
96 dataTree.getTree().reload();
97 }
98 /**
99 * rebuilds the data tree
100 * @param ae ActionEvent parameter as required by JSF. Not used by this method
101 */
102 public void readNodeButtonListener(ActionEvent ae){
103 init();
104 }
105 public void selectNode(ActionEvent ae){
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
111
112 }
113 /**
114 * getter method for the dataTree attribute
115 * @return dataTree returns the dataTree object. If you want to user Javas tree methods directly
116 */
117 public DataTree getDataTree(){
118 return dataTree;
119 }
120 /**
121 * setter method for the dataTree attribute.
122 * @param dataTree the new dataTree object
123 */
124 public void setDataTree(DataTree dataTree){
125 this.dataTree = dataTree;
126 }
127}
Note: See TracBrowser for help on using the repository browser.