Package smilehouse.gui.html.fieldbased.editor

Examples of smilehouse.gui.html.fieldbased.editor.TextEditor


                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setOpenInterfaceHost((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    addField(OPEN_INTERFACE_HOST_ATTR, fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLSource) model).getDatabase();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setDatabase((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    addField(DATABASE_ATTR, fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLSource) model).getUsername();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setUsername((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    addField(USERNAME_ATTR, fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLSource) model).getPassword();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setPassword((String) value);
                        }
                    };

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

                    //and finally create the configurationObject
                    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);
                }
               
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((WorkspaceHQLSource) model).getHQLQuery();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setHQLQuery((String) value);
                        }
                    };

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

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

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

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

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setSessionTimeout((String) value);
                        }
                    };

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

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

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

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

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((WorkspaceHQLSource) model).setResultsPerIteration((String) value);
                        }
                    };

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

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        RESULTS_PER_ITERATION_ATTR,
                        RESULTS_PER_ITERATION_ATTR,
View Full Code Here


                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteOrderSource) model).setOpenInterfaceHost((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteOrderSource) model).getDatabase();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteOrderSource) model).setDatabase((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteOrderSource) model).getUsername();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteOrderSource) model).setUsername((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteOrderSource) model).getPassword();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteOrderSource) model).setPassword((String) value);
                        }
                    };

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

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        PASSWORD_ATTR,
                        PASSWORD_ATTR,
View Full Code Here

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteCustomerSource) model).setOpenInterfaceHost((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteCustomerSource) model).getDatabase();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteCustomerSource) model).setDatabase((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteCustomerSource) model).getUsername();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteCustomerSource) model).setUsername((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    context.addFieldInfo(fieldInfo);
                }
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            return ((RemoteCustomerSource) model).getPassword();
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((RemoteCustomerSource) model).setPassword((String) value);
                        }
                    };

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

                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        PASSWORD_ATTR,
                        PASSWORD_ATTR,
View Full Code Here

    }

    protected void addSimpleTextFieldForComponent(String attributeName, String label, int fieldSize)
            throws Exception {
        ModelModifier modifier = new ComponentAttributeModifier(attributeName);
        TextEditor editor = new TextEditor();
        editor.setSize(fieldSize);

        FieldInfo fieldInfo = new FieldInfo(attributeName, label, modifier, editor);

        addField(attributeName, fieldInfo);
    }
View Full Code Here

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((LocalFileDestination) model).setFileName((String) value);
                        }
                    };

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

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

                    //add the configuration to the context for usage in the http-requests.
                    addField(FILENAME_ATTR, fieldInfo);
                }
                {

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

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((LocalFileDestination) model).setAppend((Boolean) value);
                        }
                    };

                    BooleanEditor editor = new BooleanEditor();

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

                    //add the configuration to the context for usage in the http-requests.
                    addField(APPEND_ATTR, fieldInfo);
                }
                addSimpleTextFieldForComponent(DIRECTORY_ATTR, DIRECTORY_ATTR, 70);

                {
                    //set unique id and description labelkey
                    String id = CHARSET_ATTR;

                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((LocalFileDestination) model).getData().getAttribute(
                                CHARSET_ATTR);
                            return value != null ? value : DEFAULT_CHARSET;
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((LocalFileDestination) model).getData().setAttribute(
                                CHARSET_ATTR,
                                (String) value);
                        }
                    };

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

                    //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);
                }
                {
                    String id = STARTSTRING_ATTR;
                   
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((LocalFileDestination) model).getData().getAttribute(
                                STARTSTRING_ATTR);
                            return value != null ? value : "";
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((LocalFileDestination) model).getData().setAttribute(
                                STARTSTRING_ATTR,
                                (String) value);
                       
                    };
                    TextAreaEditor editor = new TextAreaEditor();
                    editor.setCols(40);
                    editor.setRows(2);

                    //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);
                }
                {
                    String id = ENDSTRING_ATTR;
                   
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws Exception {
                            String value = ((LocalFileDestination) model).getData().getAttribute(
                                ENDSTRING_ATTR);
                            return value != null ? value : "";
                        }

                        public void setModelValue(Object model, Object value) throws Exception {
                            ((LocalFileDestination) model).getData().setAttribute(
                                ENDSTRING_ATTR,
                                (String) value);
                       
                    };
                    TextAreaEditor editor = new TextAreaEditor();
                    editor.setCols(40);
                    editor.setRows(2);

                    //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.
View Full Code Here

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setName((String) value);
                    }
                };
                TextEditor editor = new TextEditor();
                editor.setSize(75);
                editor.setFormatter(new NullHidingFormatter());
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }
            {
                // --------------
                // Password field
                // --------------
                String id = START_PASSWORD;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getStartPassword();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setStartPassword((String) value);
                    }
                };
                PasswordEditor editor = new PasswordEditor();
                editor.setSize(20);
                editor.setFormatter(new NullHidingFormatter());
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }
/*
            {
                // ----------------------
                // Enable RPC start field
                // ----------------------
                String id = ENABLE_RPC_START;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return new Boolean(((Pipe) model).isRpcStartEnabled());
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setRpcStartEnabled(((Boolean) value).booleanValue());
                    }
                };
                BooleanEditor editor = new BooleanEditor();
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }
*/
            {
                // ----------------------
                // Enable HTTP start field
                // ----------------------
                String id = ENABLE_HTTP_START;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return new Boolean(((Pipe) model).isHttpStartEnabled());
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setHttpStartEnabled(((Boolean) value).booleanValue());
                    }
                };
                BooleanEditor editor = new BooleanEditor();
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }
            {
                // -------------------------
                // Verbosity level drop down
                // -------------------------
                String id = VERBOSITY_LEVEL;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return new Integer(((Pipe) model).getLoggingVerbosityLevel());
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setLoggingVerbosityLevel(((Integer) value).intValue());
                    }
                };
                SelectEditor editor = new SelectEditor();
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.LOG_ERROR),
                    "log_errors"));
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.LOG_WARNING),
                    "log_warnings"));
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.LOG_DEBUG),
                    "log_debug"));
                editor.addOption(new DefaultSelectOption(
                        new Integer(MessageLogger.LOG_DYNAMIC),
                        "log_dynamic"));
                editor.setFormatter(new IntegerFormatter());

                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }
            {
                // -------------------------
                // Transfer log notification level drop down
                // -------------------------
                String id = NOTIFICATION_LEVEL;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return new Integer(((Pipe) model).getTransferLogNotificationLevel());
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setTransferLogNotificationLevel(((Integer) value).intValue());
                    }
                };
                SelectEditor editor = new SelectEditor();
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.MAIL_ERROR),
                    "log_errors"));
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.MAIL_WARNING),
                    "log_warnings"));
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.MAIL_DEBUG),
                    "log_debug"));
                editor.addOption(new DefaultSelectOption(
                    new Integer(MessageLogger.MAIL_NONE),
                  "mail_none"));
                editor.setFormatter(new IntegerFormatter());

                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }{
                // ----------
                // Mail server field
                // ----------
                String id = MAIL_HOST;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getMailHost();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setMailHost((String) value);
                    }
                };
                TextEditor editor = new TextEditor();
                editor.setSize(25);
                editor.setFormatter(new NullHidingFormatter());
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }{
                // ----------
                // Recipient name field
                // ----------
                String id = RECIPIENT;
                ModelModifier modifier = new DefaultModelModifier() {
                    public Object getModelValue(Object model) throws Exception {
                        return ((Pipe) model).getRecipientAddress();
                    }

                    public void setModelValue(Object model, Object value) throws Exception {
                        ((Pipe) model).setRecipientAddress((String) value);
                    }
                };
                TextEditor editor = new TextEditor();
                editor.setSize(25);
                editor.setFormatter(new NullHidingFormatter());
                generalFieldsContext.addFieldInfo(new FieldInfo(id, id, modifier, editor));
            }{
                // ----------
                // Send-mail-when-pipe-aborts checkbox
                // ----------
View Full Code Here

                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);
               
            }
            {
View Full Code Here

            // --------------------------
            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
                            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).setDateBefore(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.
View Full Code Here

            // --------------------------
            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){
                       
                        return value;
                      }
                      else{
                        value = "OR";
                        return value;
                      }
                    }

                    public void setModelValue(Object model, Object value)
                            throws FailTransferException, AbortTransferException {
                     
                      ((CustomerSource)model).setModifyOperation((String)value);
                    }
                };
               
              SelectEditor editor = new SelectEditor();
              editor.addOption(new DefaultSelectOption("OR","OR"));
              editor.addOption(new DefaultSelectOption("AND","AND"));
             
              FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
             
              context.addFieldInfo(fieldInfo);
             
View Full Code Here

                        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 {
                            ((IteratingFileSource) model).getData().setAttribute(
                                CHARSET_ATTR,
                                (String) value);
                        }
                    };
                   
                    SelectEditor editor = new SelectEditor();
                    for(int i = 0; i < CHARSETS.length; i++)
                        editor.addOption(new DefaultSelectOption(CHARSETS[i], CHARSETS[i]));
                   
                    FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
                   
                    addField(id, fieldInfo);
                }
View Full Code Here

TOP

Related Classes of smilehouse.gui.html.fieldbased.editor.TextEditor

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.