Package com.vaadin.ui

Examples of com.vaadin.ui.DateField


        return 2813;
    }

    @Override
    protected void setup() {
        @SuppressWarnings("deprecation")
        DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1));
        df.setLocale(new Locale("en", "US"));
        df.setResolution(DateField.RESOLUTION_YEAR);
        df.setResolution(DateField.RESOLUTION_MONTH);
        addComponent(df);

    }
View Full Code Here


        Layout l = getLayout();

        TextField tf = new TextField("TextField");
        l.addComponent(tf);

        DateField df = new DateField("DateField");
        l.addComponent(df);

        ComboBox cb = new ComboBox("ComboBox");
        l.addComponent(cb);

        Button btn = new Button("Button");
        l.addComponent(btn);

        NativeButton nbtn = new NativeButton("NativeButton");
        l.addComponent(nbtn);

        CheckBox chkb = new CheckBox("CheckBox");
        l.addComponent(chkb);

        OptionGroup og = createOptionGroup("OptionGroup");
        og.setMultiSelect(false);
        l.addComponent(og);

        final OptionGroup ogm = createOptionGroup("OptionGroup (multiselect)");
        ogm.setMultiSelect(true);
        l.addComponent(ogm);

        btn.addListener(new ClickListener() {

            private int i;

            @Override
            public void buttonClick(ClickEvent event) {
                ogm.addItem("newItem" + i++);

            }
        });

        tf.addListener(focusListener);
        tf.addListener(blurListener);
        df.addListener(focusListener);
        df.addListener(blurListener);
        cb.addListener(focusListener);
        cb.addListener(blurListener);
        btn.addListener(focusListener);
        btn.addListener(blurListener);
        nbtn.addListener(focusListener);
View Full Code Here

        f.setNullRepresentation("");
        return f;
    }

    private DateField createDateField(String caption) {
        DateField f = new DateField(caption);
        if (useSecondResolution) {
            f.setResolution(Resolution.SECOND);
        } else {
            f.setResolution(Resolution.MINUTE);
        }
        return f;
    }
View Full Code Here

public class DateFieldLocale extends TestBase {

    @Override
    public void setup() {
        final DateField dateField = new DateField("DateField");
        dateField.setLocale(new Locale("fi", "FI"));
        dateField.setCaption(dateField.getLocale().toString());
        dateField.setValue(new Date(2013 - 1900, 7 - 1, 27));
        dateField.setResolution(DateField.RESOLUTION_DAY);

        addComponent(new Button("Change locale", new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                if (dateField.getLocale().getCountry().equalsIgnoreCase("fi")) {
                    dateField.setLocale(new Locale("zh", "CN"));
                } else {
                    dateField.setLocale(new Locale("fi", "FI"));
                }
                dateField.setCaption(dateField.getLocale().toString());
            }
        }));

        addComponent(dateField);
    }
View Full Code Here

        return 6718;
    }

    private DateField makeDateField(boolean isPopup, Locale locale,
            String caption) {
        DateField df = isPopup ? new PopupDateField() : new InlineDateField();
        df.setResolution(DateField.RESOLUTION_DAY);
        df.setValue(date.getTime());
        df.setLocale(locale);
        df.setCaption(caption);
        return df;
    }
View Full Code Here

        final Label dateValue = new Label(initialDateString);
        dateValue.setId("dateValue");

        final TimeZone timezone = TimeZone.getTimeZone("GMT");
        final SimpleDateFormat dateformat = getDateFormat(timezone);
        final DateField dateField = getDateField(timezone, dateformat);

        addComponent(dateValue);
        addComponent(dateField);

        dateField.addValueChangeListener( new Property.ValueChangeListener(){
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                dateValue.setValue(dateformat.format(dateField.getValue()));
            }
        });
    }
View Full Code Here

            }
        });
    }

    private DateField getDateField(TimeZone timezone, SimpleDateFormat dateformat) {
        final DateField dateField = new DateField();
        try {
            Date initialDate = dateformat.parse(initialDateString);
            dateField.setResolution(Resolution.DAY);
            dateField.setTimeZone(timezone);
            dateField.setValue(initialDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dateField;
    }
View Full Code Here

        content.setSpacing(true);
        content.setMargin(true);

        final VerticalLayout pane = new VerticalLayout();
        pane.addComponent(new DateField());

        content.addComponent(pane);

        Button button = new Button("Test");
        button.addClickListener(new Button.ClickListener() {
View Full Code Here

@SuppressWarnings("serial")
public class DefaultHandleUnparsableDateField extends TestBase {

    @Override
    protected void setup() {
        final DateField date = new DateField("Default DateField");
        date.setImmediate(true);
        addComponent(date);
        date.addListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                if (date.isValid()) {
                    getMainWindow()
                            .showNotification(date.getValue().toString());
                }

            }
        });

        final DateField validated = new DateField("Validated Default DateField");
        validated.setImmediate(true);
        validated.addValidator(new NullValidator("Validator: Date is NULL",
                false));
        addComponent(validated);
    }
View Full Code Here

        Calendar cal = Calendar.getInstance();
        cal.set(2010, 1, 1);

        Label serversideValueLabel = new Label();

        DateField df = new DateField();
        df.setResolution(DateField.RESOLUTION_DAY);
        df.setLocale(locale);
        df.setWidth("300px");
        df.setDateFormat(pattern);
        df.setImmediate(true);
        String debugId = pattern.replace('/', 'X');
        // only certain characters are allowed in debug IDs
        debugId = debugId.replaceAll("[^-a-zA-Z .'_]", "X");
        while (usedDebugIds.contains(debugId)) {
            debugId = debugId + "-";
        }
        df.setId(debugId);
        usedDebugIds.add(debugId);

        df.setData(new Data(serversideValueLabel, pattern));
        df.setValue(cal.getTime());
        df.addListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                updateServerSideLabel((DateField) event.getProperty());
            }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.DateField

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.