Package smilehouse.gui.html.fieldbased.model

Examples of smilehouse.gui.html.fieldbased.model.ModelModifier


       
        try {

            // Well, here goes for nothing...

            ModelModifier modifier = new DefaultModelModifier() {
                public Object getModelValue(Object model) throws Exception {
                    return ((ListModel) model).getList();
                }

                public void setModelValue(Object model, Object value) throws Exception {
                    ((ListModel) model).setList((RecallingList) value);
                }
            };
            HighlightingContainerEditor hlContainerEditor = new HighlightingContainerEditor();
            hlContainerEditor.enableDelete("delete", "confirm_delete_pipe");
            hlContainerEditor.enableClone(Pipe.class,"clone");
            hlContainerEditor.enableAdd(Pipe.class, "add");
            hlContainerEditor.setActivePipes(pipeSet);
           
            pipeListFieldInfo = new ContainerFieldInfo("list", "pipes", modifier, hlContainerEditor);
            {
                // Editor for Pipe name
                String id1 = "name";
                String label1 = "name";
                String property1 = "name";
                PropertySetter propertySetter1 = new IntrospectionPropertySetter(Pipe.class);
                ModelModifier modifier1 = new PropertyBasedModelModifier(property1, propertySetter1);
                TextEditor editor1 = new TextEditor();
                editor1.setSize(50);
                FieldInfo fieldInfo1 = new FieldInfo(id1, label1, modifier1, editor1);
                pipeListFieldInfo.addColumn(fieldInfo1);
               
            }
            {
                // -----------------
                // Start time
                // -----------------
                String id3 = "starttime";
                String label3 = "starttimelist";
                ModelModifier modifier3 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                      Date start =((Pipe) model).getStartTime();
                      if(start==null){
                        return "";
                      }
                        return dateFormat.format(start);
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    }
                };
                UneditingEditor editor3=new UneditingEditor();
               
                FieldInfo linkFieldInfo = new FieldInfo(id3, label3, modifier3, editor3);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
            {
                // -----------------
                // Finish time
                // -----------------
                String id4 = "endtime";
                String label4 = "endtimelist";
                ModelModifier modifier4 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                      Date end=((Pipe) model).getEndTime();
                        if(end==null||(pipeSet!=null&&pipeSet.contains((Pipe)model))){
                        return "";
                      }
                        return dateFormat.format(end);
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    }
                };
                UneditingEditor editor4=new UneditingEditor();
               
                FieldInfo linkFieldInfo = new FieldInfo(id4, label4, modifier4, editor4);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
            {
                // -----------------
                // Duration of pipe execution
                // -----------------
                String id4 = "duration";
                String label4 = "duration";
                ModelModifier modifier4 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                      Long duration=((Pipe)model).getDuration();
                      if(duration==0)
                        return "";
                      else if(pipeSet!=null&&pipeSet.contains((Pipe)model))
                        return environment.getLabel(PIPE_RUNNING, language );
                      else
                        return DurationFormatUtils.formatDuration(duration,DURATION_FORMAT);
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    }
                };
                UneditingEditor editor4=new UneditingEditor();
               
                FieldInfo linkFieldInfo = new FieldInfo(id4, label4, modifier4, editor4);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
           
            {
                // -----------------
                // Last status
                // -----------------
                String id4 = "status";
                String label4 = "laststatus";
                ModelModifier modifier4 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                      String status=((Pipe) model).getLastStatus();
                      if(status!=null && (pipeSet==null||!pipeSet.contains((Pipe)model)))
                        return status;
                      return "";
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    }
                };
                UneditingEditor editor4=new UneditingEditor();
               
                FieldInfo linkFieldInfo = new FieldInfo(id4, label4, modifier4, editor4);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
            {
                // -----------------
                // Last user
                // -----------------
                String id6 = "lastuser";
                String label6 = "lastuser";
                ModelModifier modifier6 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                      String user=((Pipe) model).getUser();
                      if(user!=null && (pipeSet==null||!pipeSet.contains((Pipe)model)))
                        return user;
                      return "";
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    }
                };
                UneditingEditor editor6=new UneditingEditor();
               
                FieldInfo linkFieldInfo = new FieldInfo(id6, label6, modifier6, editor6);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
           
           
            {
                // -----------------
                // Edit button field
                // -----------------
                String id2 = "edit";
                String label2 = "edit";
                ModelModifier modifier2 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getId();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    // We don't want to change it, we just want too see it
                    }
                };
                // Just want to show it...
                LinkButtonEditor editor2 = new LinkButtonEditor();
                editor2.setHref("EditPipe");
                editor2.setParameterName(PIPE_ID);
                editor2.setTarget("_self");
                FieldInfo linkFieldInfo = new FieldInfo(id2, label2, modifier2, editor2);
                pipeListFieldInfo.addColumn(linkFieldInfo);
            }
            {
                // -----------------
                // Start button field
                // -----------------
                String id5 = "start";
                String label5 = "start";
                ModelModifier modifier5 = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getId();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
View Full Code Here


                addSimpleTextFieldForComponent(DATABASE_ATTR, DATABASE_ATTR, 20);
                // USer
                addSimpleTextFieldForComponent(USER_ATTR, USER_ATTR, 20);
                // Password
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return "";
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            String valueStr = (String) value;
                            if(valueStr != null && valueStr.length() > 0)
                                ((DestinationIF) model).getData().setAttribute(PASSWORD_ATTR, valueStr);
                        }
                    };

                    PasswordEditor editor = new PasswordEditor();
                    editor.setSize(10);

                    FieldInfo fieldInfo = new FieldInfo(
                        PASSWORD_ATTR,
                        PASSWORD_ATTR,
                        modifier,
                        editor);

                    //add the configuration to the context for usage in the http-requests.
                    addField(PASSWORD_ATTR, fieldInfo);
                }
                // Import type
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            Integer value = ((DestinationIF) model)
                                .getData().getIntegerAttribute(IMPORT_MODE_ATTR);
                            return value != null ? value : new Integer(0);
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            int intValue = value != null ? ((Integer) value).intValue() : 0;
                            ((DestinationIF) model).getData().setAttribute(IMPORT_MODE_ATTR, intValue);
                        }
                    };

                    SelectEditor editor = new SelectEditor();
                    for(int i = 0; i < IMPORT_MODE_LABELS.length; i++)
                        editor.addOption(new DefaultSelectOption(
                            new Integer(i),
                            IMPORT_MODE_LABELS[i]));

                    editor.setFormatter(new IntegerFormatter());

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        IMPORT_MODE_ATTR,
                        IMPORT_MODE_ATTR,
                        modifier,
                        editor);

                    //add the configuration to the context for usage in the http-requests.
                    addField(IMPORT_MODE_ATTR, fieldInfo);
                }
                // Create customer groups
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            Boolean value = ((DestinationIF) model)
                                .getData().getBooleanAttribute(CREATE_GROUPS_ATTR);
                            if(value == null)
                                value = Boolean.FALSE;
View Full Code Here

            // First, the simple cases...
            // --------------------------
            for(int i = 0; i < SIMPLE_CASES.length; i++) {
                String attr = (String) SIMPLE_CASES[i][0];
                int size = ((Integer) SIMPLE_CASES[i][1]).intValue();
                ModelModifier modifier = new ComponentAttributeModifier(attr);
                TextEditor editor = new TextEditor();
                editor.setSize(size);
                FieldInfo fieldInfo = new FieldInfo(attr, attr, modifier, editor);
                context.addFieldInfo(fieldInfo);
            }

            // ---------------------------------
            // A couple more complicated ones...
            // ---------------------------------
            {
                // ----------------
                // Sum greater than
                // ----------------
                String id = OrderSource.SUM_GREATER_THAN_ATTR;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((OrderSource) model).getSumGreaterThan();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((OrderSource) model).setSumGreaterThan((Double) value);
                    }
                };
                DoubleFormatter formatter = new DoubleFormatter();
                formatter.setAcceptEmptyValues(true);
                TextEditor editor = new TextEditor();
                editor.setSize(10);
                editor.setFormatter(formatter);

                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
                context.addFieldInfo(fieldInfo);
            }
            {
                // -------------
                // Sum less than
                // -------------
                String id = OrderSource.SUM_LESS_THAN_ATTR;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((OrderSource) model).getSumLessThan();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((OrderSource) model).setSumLessThan((Double) value);
                    }
                };
                DoubleFormatter formatter = new DoubleFormatter();
                formatter.setAcceptEmptyValues(true);
                TextEditor editor = new TextEditor();
                editor.setSize(10);
                editor.setFormatter(formatter);

                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
                context.addFieldInfo(fieldInfo);
            }
            {
                // ----------
                // Date after
                // ----------
                String id = "dateAfter";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((OrderSource) model).getDateAfter();
                        if(date != null)
                            return OrderSource.dateFormat.format(date);
                        else
                            return "";
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        String valueStr = (String) value;
                        Date date = null;
                        if(valueStr != null && valueStr.length() != 0) {
                            try {
                                date = OrderSource.dateFormat.parse(valueStr);
                            } catch(ParseException pe) { /* Ignore invalid dates */ }
                        }
                        ((OrderSource) model).setDateAfter(date);
                    }
                };

                TextEditor editor = new TextEditor();
                editor.setSize(50);

                //and finally create the configurationObject
                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                //add the configuration to the context for usage in the http-requests.
                context.addFieldInfo(fieldInfo);
            }
            {
                // -----------
                // Date before
                // -----------
                String id = "dateBefore";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((OrderSource) model).getDateBefore();
                        if(date != null)
                            return OrderSource.dateFormat.format(date);
                        else
View Full Code Here

            // First, the simple cases...
            // --------------------------
            for(int i = 0; i < SIMPLE_CASES.length; i++) {
                String attr = (String) SIMPLE_CASES[i][0];
                int size = ((Integer) SIMPLE_CASES[i][1]).intValue();
                ModelModifier modifier = new ComponentAttributeModifier(attr);
                TextEditor editor = new TextEditor();
                editor.setSize(size);
                FieldInfo fieldInfo = new FieldInfo(attr, attr, modifier, editor);
                context.addFieldInfo(fieldInfo);
            }

            // ---------------------------------
            // A couple more complicated ones...
            // ---------------------------------
       
            {
                // ----------
                // Date created after
                // ----------
               String id = "dateCreatedAfter";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((CustomerSource) model).getDateCreatedAfter();
                        if(date != null)
                            return CustomerSource.dateFormat.format(date);
                        else
                            return "";
                    }

           
                    public void setModelValue(Object model, Object value) throws Exception {
                        String valueStr = (String) value;
                        Date date = null;
                        if(valueStr != null && valueStr.length() != 0) {
                            try {
                                date = CustomerSource.dateFormat.parse(valueStr);
                            } catch(ParseException pe) {
                            /* Ignore invalid dates */
                    }
                        }
                        ((CustomerSource) model).setDateCreatedAfter(date);
                    }
                };

                TextEditor editor = new TextEditor();
                editor.setSize(50);

                //and finally create the configurationObject
                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                //add the configuration to the context for usage in the http-requests.
                context.addFieldInfo(fieldInfo);
            }

            {
                // -----------
                // Date created before
                // -----------
                String id = "dateCreatedBefore";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((CustomerSource) model).getDateCreatedBefore();
                        if(date != null)
                            return CustomerSource.dateFormat.format(date);
                        else
                            return "";
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        String valueStr = (String) value;
                        Date date = null;
                        if(valueStr != null && valueStr.length() != 0) {
                            try {
                                date = CustomerSource.dateFormat.parse(valueStr);
                            } catch(ParseException pe) {
                             /* Ignore invalid dates */
            }
                        }
                        ((CustomerSource) model).setDateCreatedBefore(date);
                    }
                };

                TextEditor editor = new TextEditor();
                editor.setSize(50);

                //and finally create the configurationObject
                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                //add the configuration to the context for usage in the http-requests.
                context.addFieldInfo(fieldInfo);
            }
           
            {
                // ----------
                // Date last visit after
                // ----------
               String id = "dateLastVisitAfter";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((CustomerSource) model).getDateLastVisitAfter();
                        if(date != null)
                            return CustomerSource.dateFormat.format(date);
                        else
                            return "";
                    }

           
                    public void setModelValue(Object model, Object value) throws Exception {
                        String valueStr = (String) value;
                        Date date = null;
                        if(valueStr != null && valueStr.length() != 0) {
                            try {
                                date = CustomerSource.dateFormat.parse(valueStr);
                            } catch(ParseException pe) {
                            /* Ignore invalid dates */
                    }
                        }
                        ((CustomerSource) model).setDateLastVisitAfter(date);
                    }
                };

                TextEditor editor = new TextEditor();
                editor.setSize(50);

                //and finally create the configurationObject
                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                //add the configuration to the context for usage in the http-requests.
                context.addFieldInfo(fieldInfo);
            }

            {
                // -----------
                // Date last visit before
                // -----------
                String id = "dateLastVisitBefore";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        Date date = ((CustomerSource) model).getDateLastVisitBefore();
                        if(date != null)
                            return CustomerSource.dateFormat.format(date);
                        else
                            return "";
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        String valueStr = (String) value;
                        Date date = null;
                        if(valueStr != null && valueStr.length() != 0) {
                            try {
                                date = CustomerSource.dateFormat.parse(valueStr);
                            } catch(ParseException pe) {
                             /* Ignore invalid dates */
                            }
                        }
                        ((CustomerSource) model).setDateLastVisitBefore(date);
                    }
                };

                TextEditor editor = new TextEditor();
                editor.setSize(50);

                //and finally create the configurationObject
                FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                //add the configuration to the context for usage in the http-requests.
                context.addFieldInfo(fieldInfo);
            }
           
           
            {
              // -----------
                // Datebox, customer modified before
                // -----------
               String id = "customerModifiedBefore";
              
               ModelModifier modifier = new DefaultModelModifier() {
                     public Object getModelValue(Object model) throws Exception {
                         Date date = ((CustomerSource) model).getDateCustModifiedBefore();
                         if(date != null)
                             return CustomerSource.dateFormat.format(date);
                         else
                             return "";
                     }

                     public void setModelValue(Object model, Object value) throws Exception {
                         String valueStr = (String) value;
                         Date date = null;
                         if(valueStr != null && valueStr.length() != 0) {
                             try {
                                 date = CustomerSource.dateFormat.parse(valueStr);
                             } catch(ParseException pe) {
                              /* Ignore invalid dates */
                             }
                         }
                         ((CustomerSource) model).setDateCustModifiedBefore(date);
                     }
                 };
              
                 TextEditor editor = new TextEditor();
                 editor.setSize(40);
             
              FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
             
              context.addFieldInfo(fieldInfo);
             
            }
            {
              // -----------
                // Datebox customer modified after
                // -----------
               String id = "customerModifiedAfter";
              
               ModelModifier modifier = new DefaultModelModifier() {
                     public Object getModelValue(Object model) throws Exception {
                         Date date = ((CustomerSource) model).getDateCustModifiedAfter();
                         if(date != null)
                             return CustomerSource.dateFormat.format(date);
                         else
                             return "";
                     }

                     public void setModelValue(Object model, Object value) throws Exception {
                         String valueStr = (String) value;
                         Date date = null;
                         if(valueStr != null && valueStr.length() != 0) {
                             try {
                                 date = CustomerSource.dateFormat.parse(valueStr);
                             } catch(ParseException pe) {
                              /* Ignore invalid dates */
                             }
                         }
                         ((CustomerSource) model).setDateCustModifiedAfter(date);
                     }
                 };
              
              TextEditor editor = new TextEditor();
              editor.setSize(40);
             
              FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
             
              context.addFieldInfo(fieldInfo);
             
            }
            {
//              // -----------
                // Datebox admin modified before
                // -----------
               String id = "adminModifiedBefore";
              
               ModelModifier modifier = new DefaultModelModifier() {
                     public Object getModelValue(Object model) throws Exception {
                         Date date = ((CustomerSource) model).getDateAdminModifiedBefore();
                         if(date != null)
                             return CustomerSource.dateFormat.format(date);
                         else
                             return "";
                     }

                     public void setModelValue(Object model, Object value) throws Exception {
                         String valueStr = (String) value;
                         Date date = null;
                         if(valueStr != null && valueStr.length() != 0) {
                             try {
                                 date = CustomerSource.dateFormat.parse(valueStr);
                             } catch(ParseException pe) {
                              /* Ignore invalid dates */
                             }
                         }
                         ((CustomerSource) model).setDateAdminModifiedBefore(date);
                     }
                 };
              
                 TextEditor editor = new TextEditor();
                 editor.setSize(40);
             
              FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
             
              context.addFieldInfo(fieldInfo);
             
            }
            {
//              // -----------
                // Datebox admin modified after
                // -----------
               String id = "adminModifiedAfter";
              
               ModelModifier modifier = new DefaultModelModifier() {
                     public Object getModelValue(Object model) throws Exception {
                         Date date = ((CustomerSource) model).getDateAdminModifiedAfter();
                         if(date != null)
                             return CustomerSource.dateFormat.format(date);
                         else
                             return "";
                     }

                     public void setModelValue(Object model, Object value) throws Exception {
                         String valueStr = (String) value;
                         Date date = null;
                         if(valueStr != null && valueStr.length() != 0) {
                             try {
                                 date = CustomerSource.dateFormat.parse(valueStr);
                             } catch(ParseException pe) {
                              /* Ignore invalid dates */
                             }
                         }
                         ((CustomerSource) model).setDateAdminModifiedAfter(date);
                     }
                 };
              
                 TextEditor editor = new TextEditor();
                 editor.setSize(40);
             
              FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
             
              context.addFieldInfo(fieldInfo);
             
            }
           
            {
              // -----------
                // what rule to apply (customer / admin / both)
                // -----------
              //set unique id and description labelkey
                String id = "modifyOperation";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws FailTransferException,
                            AbortTransferException {
                      String value = ((CustomerSource)model).getModifyOperation();
                     
                      if(value != null){
View Full Code Here

                addSimpleTextFieldForComponent(ESCAPE_CHAR_ATTR, ESCAPE_CHAR_ATTR, 2);
                {
                    // --------------
                    // Iteration size
                    // --------------
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return new Integer( ((IteratingFileSource) model).getBlockSize() );
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((IteratingFileSource) model).setBlockSize( ((Integer) value).intValue() );
                        }
                    };

                    TextEditor editor = new TextEditor();
                    IntegerFormatter formatter = new IntegerFormatter();
                    formatter.acceptOnlyStrictlyPositive("invalid_block_size");
                    editor.setFormatter(formatter);
                    editor.setSize(5);
                   
                    FieldInfo fieldInfo = new FieldInfo(
                        BLOCK_SIZE_ATTR,
                        BLOCK_SIZE_ATTR,
                        modifier,
                        editor);

                    addField(BLOCK_SIZE_ATTR, fieldInfo);
                }
                {
                    // --------------
                    // Charset select
                    // --------------
                    String id = CHARSET_ATTR;
                   
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((IteratingFileSource) model).getCharset();
                        }
                       
                        public void setModelValue(Object model, Object value) throws Exception {
View Full Code Here

     * GUIContext ant the testobject instance variables.
     */
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {
            ModelModifier userListModifier = new DefaultModelModifier() {
                public Object getModelValue(Object model) throws Exception {
                    return ((ListModel) model).getList();
                }

                public void setModelValue(Object model, Object value) throws Exception {
                    ((ListModel) model).setList((RecallingList) value);
                }
            };
            ContainerEditor userListEditor = new ContainerEditor();
            userListEditor.enableDelete("delete");
            //containerEditor.enableAdd(Pipe.class, "add");
            userListFieldInfo = new ContainerFieldInfo(
                "list",
                "users",
                userListModifier,
                userListEditor);
            {
                // -----
                // Login
                // -----
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((User) model).getLogin();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                    // We won't set it here...
                    }
                };
                UneditingEditor editor = new UneditingEditor();

                FieldInfo fieldInfo = new FieldInfo(LOGIN, LOGIN, modifier, editor);
                userListFieldInfo.addColumn(fieldInfo);

            }
            {
                // --------
                // Password
                // --------
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ""; // We won't show it
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        String strValue = (String) value;
                        if(strValue != null && strValue.length() > 0)
                            ((User) model).setPassword(strValue);
                    }
                };
                PasswordEditor editor = new PasswordEditor();
                editor.setSize(20);

                FieldInfo fieldInfo = new FieldInfo(PASSWORD, PASSWORD, modifier, editor);
                userListFieldInfo.addColumn(fieldInfo);
            }
            {
                // ----
                // Name
                // ----
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((User) model).getName();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
View Full Code Here

                // instead of PipeComponentIFs so that Hibernate doesn't get confused...
                // (Hibernate don't know anything about the PipeComponentIF interface)
                // --------------------------------------------------------------------
                String id = "converters";

                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getConverterList();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setConverterList((List) value);
                    }
                };
                ContainerEditor containerEditor = new ContainerEditor();
                containerEditor.enableDelete("delete", "confirm_delete_component2");
                containerEditor.enableMove("move", "pics/arrow_up_button.gif",
                    "move", "pics/arrow_down_button.gif", "move");

                converterFieldInfo = new ContainerFieldInfo(id, id, modifier, containerEditor);
                {
                    // ---------------------------------------------------
                    // Field for displaying the converter component's type
                    // ---------------------------------------------------
                    String id1 = "type";
                    String label1 = "converter_type";
                    ModelModifier modifier1 = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            //PipeComponentData componentData = (PipeComponentData) model;
                            ConverterListItem componentImpl = (ConverterListItem) model;
                            //if(!componentData.getImplementation().implementationExists()) {

                            // Assume component implementation exists
                            /*if(!componentImpl.implementationExists()) {
                             // If implementation is not there, show error...
                             return "!!! Class not found: "
                             + componentImpl.getClassName() + " !!!";
                             } else {
                             */
                            //PipeComponentIF impl = componentImpl.getInstance();
                            //return impl.getName();
                            return componentImpl.getConverter().getName();
                            //}
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                        // We don't want to change it, we just want to see it
                        }
                    };
                    // Just want to show it...
                    UneditingEditor editor1 = new UneditingEditor();
                    FieldInfo typeFieldInfo = new FieldInfo(id1, label1, modifier1, editor1);
                    converterFieldInfo.addColumn(typeFieldInfo);
                }

                // TODO: Converter component's Edit button should be disabled if the Converter does not
                //       implement GUIConfigurationIF
                {
                    // ---------------
                    // Edit link field
                    // ---------------
                    String id2 = "edit";
                    String label2 = "edit";
                    ModelModifier modifier2 = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            ConverterListItem componentData = (ConverterListItem) model;

                            HashMap m = new HashMap();
                            m.put(COMPONENT_ID, componentData.getConverter().getID());
View Full Code Here

                addSimpleTextFieldForComponent(EXTENSION_ATTR, EXTENSION_ATTR, 10);
                {
                    // ----------
                    // Block size
                    // ----------
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return new Integer( ((IteratingXMLFileSource) model).getBlockSize() );
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((IteratingXMLFileSource) model).setBlockSize( ((Integer) value).intValue() );
                        }
                    };

                    TextEditor editor = new TextEditor();
                    IntegerFormatter formatter = new IntegerFormatter();
                    formatter.acceptOnlyStrictlyPositive("invalid_block_size");
                    editor.setFormatter(formatter);
                    editor.setSize(5);
                   
                    FieldInfo fieldInfo = new FieldInfo(
                        BLOCK_SIZE_ATTR,
                        BLOCK_SIZE_ATTR,
                        modifier,
                        editor);

                    addField(BLOCK_SIZE_ATTR, fieldInfo);
                }
                {
                    // ----------
                    // Chop depth
                    // ----------
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return new Integer( ((IteratingXMLFileSource) model).getChopDepth() );
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((IteratingXMLFileSource) model).setChopDepth( ((Integer) value).intValue() );
                        }
                    };

                    TextEditor editor = new TextEditor();
                    IntegerFormatter formatter = new IntegerFormatter();
                    formatter.acceptOnlyPositive("invalid_chop_depth");
                    editor.setFormatter(formatter);
                    editor.setSize(5);
                   
                    FieldInfo fieldInfo = new FieldInfo(
                        CHOP_DEPTH_ATTR,
                        CHOP_DEPTH_ATTR,
                        modifier,
                        editor);

                    addField(CHOP_DEPTH_ATTR, fieldInfo);
                }
                {
                    //set unique id and description labelkey
                    String id = CHARSET_ATTR;

                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws FailTransferException,
                                AbortTransferException {
                            String value = ((IteratingXMLFileSource) model).getData().getAttribute(
                                CHARSET_ATTR);
                            return value != null ? value : DEFAULT_CHARSET;
View Full Code Here

            super();
           
            // Add WorkspaceHQLOrderSource specific fields to GUI
            try {
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLOrderSource) model).getNewOrderHandlingStatus();
                        }
   
                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLOrderSource) model).setNewOrderHandlingStatus((String) value);
                        }
                    };
   
                    TextEditor editor = new TextEditor();
                    editor.setSize(40);
   
                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        NEW_ORDER_HANDLING_STATUS,
                        NEW_ORDER_HANDLING_STATUS,
                        modifier,
                        editor);
   
                    //add the configuration to the context for usage in the http-requests.
                    addField(NEW_ORDER_HANDLING_STATUS, fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLOrderSource) model).getNewOrderPaymentStatus();
                        }
   
                        public void setModelValue(Object model, Object value) throws Exception {
View Full Code Here

                addField(CHARSET_ATTR, LocalFileDestination.gui.getField(CHARSET_ATTR));
                {
                    //set unique id and description labelkey
                    String id = PREFIX_ATTR;

                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((TimestampFileDestination) model)
                                .data.getAttribute(PREFIX_ATTR);
                            return value != null ? value : "";
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((TimestampFileDestination) model).data.setAttribute(
                                PREFIX_ATTR,
                                (String) value);
                        }
                    };

                    TextEditor editor = new TextEditor();
                    editor.setSize(30);

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                    //add the configuration to the context for usage in the http-requests.
                    addField(id, fieldInfo);
                }
                {
                    //set unique id and description labelkey
                    String id = DATEFORMAT_ATTR;

                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((TimestampFileDestination) model)
                                .data.getAttribute(DATEFORMAT_ATTR);
                            return value != null ? value : DEFAULT_DATEFORMAT;
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((TimestampFileDestination) model).data.setAttribute(
                                DATEFORMAT_ATTR,
                                (String) value);
                        }
                    };

                    TextEditor editor = new TextEditor();
                    editor.setSize(20);

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);

                    //add the configuration to the context for usage in the http-requests.
                    addField(id, fieldInfo);
                }
                {
                    //set unique id and description labelkey
                    String id = EXTENSION_ATTR;

                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((TimestampFileDestination) model)
                                .data.getAttribute(EXTENSION_ATTR);
                            return value != null ? value : "";
                        }
View Full Code Here

TOP

Related Classes of smilehouse.gui.html.fieldbased.model.ModelModifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.