Changeset 862 for vanHelsing


Ignore:
Timestamp:
Apr 15, 2010, 3:49:35 PM (14 years ago)
Author:
tobias
Message:

JobScheduleBean as a testcase for refactored tree building with DataTree, UOFactory und ConcreteUserObjectItem.
Helper methods added to Client.

Location:
vanHelsing/trunk/gui
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • vanHelsing/trunk/gui/WebContent/menu.jspx

    r860 r862  
    1818    <ice:outputText style="color:grey; font-size:32px" value="Van Helsing"/>
    1919    <ice:form>
    20     <ice:panelGroup style="float:top">
    21         <ice:commandButton id="newRes"
    22             value="create resource"
    23             actionListener="#{configurationBean.newResourceButtonListener}"/>
    24                 <ice:commandButton id="reloadRes"
    25                         value="reload Tree"
    26                         actionListener="#{configurationBean.reloadResourceButtonListener}" />
    27                 <ice:commandButton id="saveRes"
    28                 value="update resource"
    29                 actionListener="#{configurationBean.saveButtonListener}"/>
    30                 <ice:commandButton id="deleteRes"
    31                         value="delete resource"
    32                         actionListener="#{configurationBean.deleteResourceButtonListener}" />
    33         </ice:panelGroup>
    3420   
    3521        <ice:panelTabSet>
    3622                <ice:panelTab  label="Configuration">
     23                            <ice:panelGroup style="float:top">
     24                                <ice:commandButton id="newRes"
     25                                    value="create resource"
     26                                    actionListener="#{configurationBean.newResourceButtonListener}"/>
     27                                        <ice:commandButton id="reloadRes"
     28                                                value="reload Tree"
     29                                                actionListener="#{configurationBean.reloadResourceButtonListener}" />
     30                                        <ice:commandButton id="saveRes"
     31                                        value="update resource"
     32                                        actionListener="#{configurationBean.saveButtonListener}"/>
     33                                        <ice:commandButton id="deleteRes"
     34                                                value="delete resource"
     35                                                actionListener="#{configurationBean.deleteResourceButtonListener}" />
     36                                </ice:panelGroup>
     37               
    3738                        <ice:panelDivider style="height:600px;width:85%" dividerPosition="30">
    3839                        <f:facet name="first">
     
    106107         
    107108                <ice:panelTab label="Job / Schedule">
     109                        <ice:commandButton id="createNode"
     110                                value="create"
     111                                actionListener="#{jobScheduleBean.createNodeListener}" />
     112
     113                        <ice:commandButton id="updateNode"
     114                                value="update"
     115                                actionListener="#{jobScheduleBean.updateNodeListener}" />
     116
     117                        <ice:commandButton id="deleteNode"
     118                                value="delete"
     119                                actionListener="#{jobScheduleBean.deleteNodeListener}" />
     120                               
     121                        <ice:commandButton id="reloadTree"
     122                                value="reloadTree"
     123                                actionListener="#{jobScheduleBean.reloadTreeListener}" />
     124                       
     125                        <ice:panelDivider style="height:600px;width:85%" dividerPosition="30">
     126                                        <f:facet name="first">
     127                                <ice:tree id="baum2"   
     128                                        value="#{jobScheduleBean.dataTree.tree}"
     129                                        var="item"
     130                                        hideRootNode = "false"
     131                                        hideNavigation ="false"
     132                                        imageDir = "css/images/">
     133                                                        <ice:treeNode id="knoten">
     134                                                                <f:facet name="icon">
     135                                                                <ice:panelGroup style="display: inline" >
     136                                                    <ice:graphicImage
     137                                                         value="/css/images/#{item.userObject.icon}"/>
     138                                                        </ice:panelGroup>
     139                                                                </f:facet>
     140                                                                <f:facet name="content">
     141                                                                        <ice:commandLink actionListener="#{jobScheduleBean.selectNode}">
     142                                                                        <f:param name="userObject.resId" value="#{item.userObject.userObject.resId}"/>
     143                                                                    <ice:outputText id="knoten" value="#{item.userObject.userObject.resName}"/>
     144                                                                                </ice:commandLink>
     145                                                                </f:facet>
     146                                                        </ice:treeNode>
     147                                                </ice:tree>
     148                                        </f:facet>
     149                                        <f:facet name="second">
     150                                               
     151                                        </f:facet>
     152                        </ice:panelDivider>                     
    108153                </ice:panelTab>
    109154         
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/BeanUtil.java

    r858 r862  
    4343                return false;
    4444        }
     45        public static String getDataType(String type, String key){
     46                return getFieldProperty(type, key, 1);
     47        }
    4548        //getRenderer returns rendererType based on properties
    4649        public static String getRenderer(String type, String key){
    47                 return getFieldProperty(type, key, 1);
     50                return getFieldProperty(type, key, 0);
    4851        }
    4952        public static String getFieldProperty(String type, String key, int i){
     
    5861                type = type.toLowerCase();
    5962                key = key.toLowerCase();
     63                key = key.replaceAll(" ", "");
    6064                String result[] = getProperties((daemon+"."+type+"."+key));
    61                 if (i == 1) {
     65                if (i == 0) {
    6266                        if (result[1].equals("boolean")){
    6367                                return "radioGroup";
     
    6973                }
    7074                if (i == 2) return result[2];
     75                if (i == 1) return result[1];
     76                if (i == 3) return result[3];
    7177                return res;
    7278        }
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/Client.java

    r860 r862  
    66
    77public class Client {
    8 
     8        public ResourceInfo[] getListResources(String director, String resource){
     9                ListResourcesType lrt = new ListResourcesType();
     10                lrt.setDirector(director);
     11                lrt.setResourceType(resource);
     12                return getListResources(lrt);
     13        }
    914        public ResourceInfo[] getListResources(ListResourcesType lrt){
    1015                VanHelsingStub stub;
     
    2429                return new ResourceInfo[0];
    2530        }
    26 
     31       
     32        public SimpleResource getSimpleResource(String director, int resId){
     33                GetResourceType grt = new GetResourceType();
     34                grt.setDirector(director);
     35                grt.setResId(resId);
     36                return getSimpleResource(grt);
     37        }
    2738        public SimpleResource getSimpleResource(GetResourceType grt){
    2839                VanHelsingStub stub;
     
    4657                return new SimpleResource(new ResourceInfo(), new ResourceAttributeType[0]);
    4758        }
    48        
     59        public SetSimpleResourceResponse setSimpleResource(){
     60                ResourceInitialization ri = new ResourceInitialization();
     61                return setSimpleResource(ri);
     62        }
    4963        public SetSimpleResourceResponse setSimpleResource(ResourceInitialization ri){
    5064                VanHelsingStub stub;
     
    7488                return stub;
    7589        }       
    76 
    7790        public static void main(String args[]){
    7891                Client c = new Client();
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java

    r860 r862  
    3939
    4040                Client c = new Client();
    41                 String[] nodes = { "Director", "Storage", "Autochanger",
     41                /*String[] nodes = { "Director", "Storage", "Autochanger",
    4242                                "Client", "FileSet", "FDClient", "Schedule", "SDStorage",
    4343                                "Console", "Catalog", "SDDevice", "Job", "JobDefs", "Messages",
    44                                 "Pool" };
     44                                "Pool" }; */
    4545                // String[] nodes = {"Client"};
    46                 setTree(super.createTree(root, nodes, "Configuration"));
     46                setTree(super.createTree(root, BeanUtil.getProperty("nodes").split(","), "Configuration"));
    4747
    4848                // \forall header wird eine ResourceList[] angefragt
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/JobScheduleBean.java

    r832 r862  
    11package 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;
     8
    29/*
    310 * JobSchedule will list all schedules and the jobs which are associated with a given schedule.
    411 */
    5 public class JobScheduleBean extends TreeNavigation {
     12public class JobScheduleBean  {
     13        private DataTree dataTree;
     14        private ConcreteUserObjectItem selectedObject;
    615
     16        public JobScheduleBean(){
     17                init();
     18        }
     19        private void init(){
     20                Client c = new Client();
     21                UserObjectItemFactory UOFactory = new UserObjectItemFactory();
     22               
     23                ResourceInfo riSched[];
     24                ResourceInfo riJobs[];
     25                SimpleResource sr;
     26                DefaultMutableTreeNode parent;
     27               
     28                dataTree = new DataTree();
     29                dataTree.setTree("JobSchedule");
     30
     31               
     32                //TODO: Director auslesen
     33                riSched = c.getListResources("bacula-dir", "Schedule");
     34                for (ResourceInfo rinfo : riSched){
     35                        parent = dataTree.createNode(dataTree.getRoot(),
     36                                        UOFactory.createUserObjectItem(rinfo));
     37
     38                        riJobs = c.getListResources(rinfo.getDirector(), "Job");
     39                        for (ResourceInfo rJobs : riJobs){
     40
     41                                sr = c.getSimpleResource(rJobs.getDirector(), rJobs.getResId());
     42                                for (ResourceAttributeType rat : sr.getResourceAttributeType()){
     43                                        if (rat.getKey().toLowerCase().equals("schedule") &&
     44                                                rat.getValue().equals(rinfo.getResName())){     
     45                                                dataTree.createNode(parent,
     46                                                                UOFactory.createUserObjectItem(rJobs));
     47                                        }
     48                                }
     49                        }
     50                }
     51        }
     52       
     53        public void createNodeListener(ActionEvent ae){
     54                //Methode kann nur mit ausgewählten ParentNode ausgeführt werden
     55                DefaultMutableTreeNode parent = dataTree.getNodeByName("horst");
     56                UserObjectItemFactory UOFactory = new UserObjectItemFactory();
     57               
     58                //UOFactory.createUserObjectItem(new ResourceAttributeType[], )
     59                //dataTree.createNode(parent, userObject);
     60        }
     61        public void updateNodeListener(ActionEvent ae){
     62                BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert");
     63               
     64        }
     65        public void deleteNodeListener(ActionEvent ae){
     66                BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert");
     67               
     68        }
     69        public void reloadTreeListener(ActionEvent ae){
     70                init();
     71        }
     72        public void selectNode(ActionEvent ae){
     73                BeanUtil.setInfoMessage(null, "Die Methode ist noch nicht implementiert");
     74        }
     75
     76        public DataTree getDataTree(){
     77                return dataTree;
     78        }
     79
     80        public void setDataTree(DataTree dataTree){
     81                this.dataTree = dataTree;
     82        }
    783}
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ViewItem.java

    r858 r862  
    66
    77public class ViewItem extends ItemType implements UserObjectItem {
    8         /**
    9          * @uml.property  name="key"
    10          */
    118        private String key;
    12         /**
    13          * @uml.property  name="keyValue"
    14          */
    159        private String keyValue;
    16         /**
    17          * @uml.property  name="inputText"
    18          */
     10        private boolean required;
     11        private String renderer;
     12        private String dataType;
     13        private SelectItem[] keyValueList;
     14
    1915        private String inputText;
    20         /**
    21          * @uml.property  name="selectOneMenu"
    22          */
    2316        private String selectOneMenu;
    24         /**
    25          * @uml.property  name="radioGroup"
    26          */
    2717        private String radioGroup;
    28         /**
    29          * @uml.property  name="required"
    30          */
    31         private boolean required;
    32         /**
    33          * @uml.property  name="renderer"
    34          */
    35         private String renderer;
    36         /**
    37          * @uml.property  name="dataType"
    38          */
    39         private String dataType;
    40         /**
    41          * @uml.property  name="keyValueList"
    42          * @uml.associationEnd  multiplicity="(0 -1)"
    43          */
    44         private SelectItem[] keyValueList;
    45        
     18
    4619        public ViewItem(){
    4720                inputText = null;
    4821                selectOneMenu = null;
     22                radioGroup = null;
    4923        }
    5024       
    51         /**
    52          * @return
    53          * @uml.property  name="required"
    54          */
    5525        public boolean getRequired() {
    5626                return required;
    5727        }
    5828
    59         /**
    60          * @param necessary
    61          * @uml.property  name="required"
    62          */
    6329        public void setRequired(boolean required) {
    6430                this.required = required;
    6531        }
    6632
    67         /**
    68          * @return
    69          * @uml.property  name="renderer"
    70          */
    7133        public String getRenderer() {
    7234                return renderer;
    7335        }
    7436
    75         /**
    76          * @param renderer
    77          * @uml.property  name="renderer"
    78          */
    7937        public void setRenderer(String renderer) {
    8038                this.renderer = renderer;
    8139        }
    8240
    83         /**
    84          * @return
    85          * @uml.property  name="dataType"
    86          */
    8741        public String getDataType() {
    8842                return dataType;
    8943        }
    9044
    91         /**
    92          * @param dataType
    93          * @uml.property  name="dataType"
    94          */
    9545        public void setDataType(String dataType) {
    9646                this.dataType = dataType;
     
    11262        }
    11363        //eigene Felder für die Tabellenspalten
    114         /**
    115          * @param key
    116          * @uml.property  name="key"
    117          */
    11864        public void setKey(String key) {
    11965                this.key = key;
    12066        }
    12167
    122         /**
    123          * @return
    124          * @uml.property  name="key"
    125          */
    12668        public String getKey() {
    12769                return key;
    12870        }
    12971       
    130         /**
    131          * @return
    132          * @uml.property  name="keyValue"
    133          */
    13472        public String getKeyValue() {
    13573                return keyValue;
    13674        }
    13775
    138         /**
    139          * @param keyValue
    140          * @uml.property  name="keyValue"
    141          */
    14276        public void setKeyValue(String keyValue) {
    14377                this.keyValue = keyValue;
    14478        }
    14579
    146         /**
    147          * @param inputText
    148          * @uml.property  name="inputText"
    149          */
    15080        public void setInputText(String inputText) {
    15181                this.inputText = inputText;
    15282        }
    15383
    154         /**
    155          * @return
    156          * @uml.property  name="inputText"
    157          */
    15884        public String getInputText() {
    15985                return inputText;
    16086        }
    16187
    162         /**
    163          * @param selectOneMenu
    164          * @uml.property  name="selectOneMenu"
    165          */
    16688        public void setSelectOneMenu(String selectOneMenu) {
    16789                this.selectOneMenu = selectOneMenu;
    16890        }
    16991
    170         /**
    171          * @return
    172          * @uml.property  name="selectOneMenu"
    173          */
    17492        public String getSelectOneMenu() {
    17593                return selectOneMenu;
    17694        }
    177        
    17895
    17996        public void setRendererFlag(String r){
    18097                if (r.equals("inputText")) {
    18198                        this.inputText = new String("bernd");
    182                         this.selectOneMenu = null;
    183                         this.radioGroup = null;
    18499                }
    185100                if (r.equals("selectOneMenu")){
    186101                        this.selectOneMenu = new String("bernd"); //null;
    187                         this.inputText = null; //new String ("bernd");
    188                         this.radioGroup = null;
    189                         //KeyValuesList erzeugen
    190                         /*keyValueList = new SelectItem[3];
    191                         * keyValueList[0] = new SelectItem("keyBernd","valueBernd");
    192                         * keyValueList[1] = new SelectItem("keyHorst","valueHorst");
    193                         * keyValueList[2] = new SelectItem("keyPeter","valuePeter");
    194                         */     
    195                        
    196102                }
    197103                if (r.equals("radioGroup")){
    198104                        this.radioGroup = new String("bernd");
    199                         this.selectOneMenu = null;
    200                         this.inputText = null;
    201105                }
    202106        }
    203107
    204         /**
    205          * @return
    206          * @uml.property  name="keyValueList"
    207          */
    208108        public SelectItem[] getKeyValueList() {
    209109                return keyValueList;
    210110        }
    211111
    212         /**
    213          * @param keyValueList
    214          * @uml.property  name="keyValueList"
    215          */
    216112        public void setKeyValueList(SelectItem[] keyValueList) {
    217113                this.keyValueList = keyValueList;
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/messages_en.properties

    r859 r862  
     1director = bacula-dir
     2nodes = Director,Storage,Autochanger,Client,FileSet,FDClient,Schedule,SDStorage,Console,Catalog,SDDevice,Job,JobDefs,Messages,Pool
    13director.director.name.ref =  0
    24director.director.name.type = String
Note: See TracChangeset for help on using the changeset viewer.