Ignore:
Timestamp:
Apr 26, 2010, 6:20:44 PM (14 years ago)
Author:
tobias
Message:

create Client function added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ConfigurationBean.java

    r864 r867  
    2222        private ArrayList<ViewItem> selectedObject;
    2323        private String selectedId;
     24        private String selectedName;
     25        private boolean createResource = false;
    2426
    2527        public ConfigurationBean() {
     
    8284                selectedObject = new ArrayList<ViewItem>();
    8385                String Id = BeanUtil.getRequestParameter("userObject.resId");
     86                String name = BeanUtil.getRequestParameter("userObject.resName");
    8487                String selected = BeanUtil.getRequestParameter("ice.event.shift");
    8588                node = getNode(Id, tree);
     
    169172                return null;
    170173        }
     174       
    171175        /**
    172176         *
    173177         * @param ae
    174178         */
     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       
    175215        public void newResourceButtonListener(ActionEvent ae){
    176216                DefaultMutableTreeNode node;
    177217                UserObjectItem userObject;
     218                String Id = BeanUtil.getRequestParameter("userObject.ResId");
     219                String value = BeanUtil.getRequestParameter("userObject.resName");
     220                String shift = BeanUtil.getRequestParameter("ice.event.shift");
    178221                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("")){
    183225                        return;
    184226                }
    185                 node = getNode(Id, tree);
     227                //node = getNode(Id, tree);
     228                node = getNodeByName(value, tree);
    186229                String type = ((UserObjectItem) ((UserObjectItemType) node
    187230                                .getUserObject()).getUserObject()).getResType();
     
    189232                String[] val;
    190233                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";
    192236                        Class newClass = Class.forName(type2);
    193237                        for (Method m : newClass.getDeclaredMethods()){
     
    252296                BeanUtil.setInfoMessage(null, "Diese Methode ist noch nicht implementiert.");
    253297        }
     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        }
    254318        /**
    255319         * **EXPERIMENTAL** writes the selected resource to the data tree of the web service.
     
    338402                return -1;
    339403        }
     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        }
    340418
    341419}
Note: See TracChangeset for help on using the changeset viewer.