Package com.vaadin.ui

Examples of com.vaadin.ui.AbstractField


        return null;
    }

    private <T extends Field> T createDateField(Class<?> type,
            Class<T> fieldType) {
        AbstractField field;

        if (InlineDateField.class.isAssignableFrom(fieldType)) {
            field = new InlineDateField();
        } else if (DateField.class.isAssignableFrom(fieldType)
                || fieldType == Field.class) {
            field = new PopupDateField();
        } else if (AbstractTextField.class.isAssignableFrom(fieldType)) {
            field = createAbstractTextField((Class<? extends AbstractTextField>) fieldType);
        } else {
            return null;
        }

        field.setImmediate(true);
        return (T) field;
    }
View Full Code Here


    }

    private void checkDataBinding(Class<? extends AbstractField> class1) {
        boolean ok = false;
        AbstractField b;
        try {
            b = class1.newInstance();
            b.setCaption("Button of type " + class1.getSimpleName());
            try {
                b.setBuffered(false);
                ObjectProperty<String> prop = new ObjectProperty<String>(
                        "ABC 123");
                /*
                 * This should throw an exception or somehow tell that the
                 * property was invalid (wrong type). See #2223.
                 */
                b.setPropertyDataSource(prop);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e1) {
            e1.printStackTrace();
View Full Code Here

        form2.setFormFieldFactory(new FormFieldFactory() {

            @Override
            public Field createField(Item item, Object propertyId,
                    Component uiContext) {
                AbstractField f = (AbstractField) DefaultFieldFactory.get()
                        .createField(item, propertyId, uiContext);
                if (propertyId.equals("age")) {
                    f.setPropertyDataSource(new PropertyFormatter() {

                        @Override
                        public Object parse(String formattedValue)
                                throws Exception {
                            String str = formattedValue.replaceAll("[^0-9.]",
                                    "");
                            if (formattedValue.toLowerCase().contains("months")) {
                                return Double.parseDouble(str) / 12;
                            }
                            return Double.parseDouble(str);
                        }

                        @Override
                        public String format(Object value) {
                            Double dValue = (Double) value;
                            if (dValue < 1) {
                                return ((int) (dValue * 12)) + " months";
                            }
                            return dValue + " years";
                        }
                    });
                    f.setImmediate(true);
                }
                return f;
            }
        });
        form2.setItemDataSource(createItem());
View Full Code Here

        return null;
    }

    @Override
    public void valueChange(ValueChangeEvent event) {
        AbstractField field = (AbstractField) event.getProperty();
        // if (field == localeSelect) {
        // return;
        // }

        Object newValue = field.getValue();
        if (newValue != null) {
            newValue = newValue + " (" + newValue.getClass().getName() + ")";
        }

        String message = "Value of " + field.getCaption() + " changed to "
                + newValue + ".";
        if (field.getPropertyDataSource() != null) {
            Object dataSourceValue = field.getPropertyDataSource().getValue();
            message += "Data model value is " + dataSourceValue;
            message += " (" + field.getPropertyDataSource().getType().getName()
                    + ")";
        }
        log.log(message);

    }
View Full Code Here

        return null;
    }

    private <T extends Field> T createDateField(Class<?> type,
            Class<T> fieldType) {
        AbstractField field;

        if (InlineDateField.class.isAssignableFrom(fieldType)) {
            field = new InlineDateField();
        } else if (DateField.class.isAssignableFrom(fieldType)
                || fieldType == Field.class) {
            field = new PopupDateField();
        } else if (AbstractTextField.class.isAssignableFrom(fieldType)) {
            field = createAbstractTextField((Class<? extends AbstractTextField>) fieldType);
        } else {
            return null;
        }

        field.setImmediate(true);
        return (T) field;
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.AbstractField

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.