Package smilehouse.gui.html.fieldbased

Examples of smilehouse.gui.html.fieldbased.FieldInfo


                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.
                context.addFieldInfo(fieldInfo);
            }

View Full Code Here


                    };

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

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

                    addField(PASSWORD_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 = ((JDBCConverter) model).getData().getAttribute(
                                CHARSET_ATTR);
                            return value != null ? value : DEFAULT_CHARSET;
                        }

                        public void setModelValue(Object model, Object value)
                                throws FailTransferException, AbortTransferException {
                            ((JDBCConverter) 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);
                }
               
View Full Code Here

                    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);
                }
            } catch(Exception e) {
                Environment.getInstance().log(
View Full Code Here

                    // 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 {
                        ((User) model).setName((String) value);
                    }
                };
                TextEditor editor = new TextEditor();
                editor.setSize(50);

                FieldInfo fieldInfo = new FieldInfo(NAME, NAME, modifier, editor);
                userListFieldInfo.addColumn(fieldInfo);
            }
        } catch(Exception e) {
            throw new ServletException(
                "problem with initialising bean fields. Fields probably incorrectly defined.",
View Full Code Here

                        // 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());
                            m.put(DATA_ID, componentData.getConverterData().getId().toString());
                            return m;

                        }

                        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...

                    ConverterEditButtonEditor editor2 = new ConverterEditButtonEditor();
                       
                    editor2.setHref("EditComponent");
                    List paramNameList = new LinkedList();
                    paramNameList.add(COMPONENT_ID);
                    paramNameList.add(DATA_ID);

                    editor2.setParameterNames(paramNameList);

                    FieldInfo linkFieldInfo = new FieldInfo(id2, label2, modifier2, editor2);
                    converterFieldInfo.addColumn(linkFieldInfo);
                }
            }

        } catch(Exception e) {
View Full Code Here

                    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;
                        }

                        public void setModelValue(Object model, Object value)
                                throws FailTransferException, AbortTransferException {
                            ((IteratingXMLFileSource) 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);
                }
View Full Code Here

   
                    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 {
                            ((WorkspaceHQLOrderSource) model).setNewOrderPaymentStatus((String) value);
                        }
                    };
   
                    TextEditor editor = new TextEditor();
                    editor.setSize(40);
   
                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        NEW_ORDER_PAYMENT_STATUS,
                        NEW_ORDER_PAYMENT_STATUS,
                        modifier,
                        editor);
   
View Full Code Here

                    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 : "";
                        }

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

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

                    //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);
                }
            } catch(Exception e) {
View Full Code Here

                    };

                    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(Iterator i = IMPORT_MODES.keySet().iterator(); i.hasNext();) {
                       
                        Integer optionNumber = (Integer) i.next();
                        String optionName = (String) IMPORT_MODES.get(optionNumber);
                       
                        editor.addOption(new DefaultSelectOption(optionNumber, optionName));
                       
                    }
                   
                    editor.setFormatter(new IntegerFormatter());

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

                    };

                    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);
                }
                addSimpleTextFieldForComponent(FILENAME_START_ATTR, FILENAME_START_ATTR, 20);
                addSimpleTextFieldForComponent(DATE_FORMAT_ATTR, DATE_FORMAT_ATTR, 20);
                addSimpleTextFieldForComponent(FILE_EXTENSION_ATTR, FILE_EXTENSION_ATTR, 5);
                {
                    ModelModifier modifier = new DefaultModelModifier() {
                        public Object getModelValue(Object model) throws FailTransferException, AbortTransferException {
                            return new Integer(((FTPDestination) model).getFileType());
                        }

                        public void setModelValue(Object model, Object value) throws FailTransferException, AbortTransferException {
                            ((FTPDestination) model).setFileType(((Integer) value).intValue());
                        }
                    };

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

                    editor.setFormatter(new IntegerFormatter());
                    //and finally create the configurationObject
                    FieldInfo fieldInfo = new FieldInfo(
                        FILE_TYPE_ATTR,
                        FILE_TYPE_ATTR,
                        modifier,
                        editor);

                    //add the configuration to the context for usage in the http-requests.
                    addField(FILE_TYPE_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 = ((FTPDestination) model).getData().getAttribute(
                                CHARSET_ATTR);
                            return value != null ? value : DEFAULT_CHARSET;
                        }

                        public void setModelValue(Object model, Object value)
                                throws FailTransferException, AbortTransferException {
                            ((FTPDestination) 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);
                }
            } catch(Exception e) {
View Full Code Here

TOP

Related Classes of smilehouse.gui.html.fieldbased.FieldInfo

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.