Package com.vaadin.ui

Examples of com.vaadin.ui.TextField


                return String.valueOf(prop.getValue());
            }

            @Override
            public Component getPopupComponent() {
                return new TextField("Edit foo", prop);
            }
        };

        PopupView pe = new PopupView(content);
        pe.setDescription("Click to edit");
        panelLayout.addComponent(pe);

        // Second test component
        PopupView pe2 = new PopupView("fooLabel", new Label("Foooooooooo..."));
        pe2.setDescription("Click to view");
        panelLayout.addComponent(pe2);

        // Third test component
        final ObjectProperty<StringBuffer> prop2 = new ObjectProperty<StringBuffer>(
                new StringBuffer("Text for button"));

        class myButton extends Button {
            public myButton() {
                super("Reverse the property");
                this.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        StringBuffer getContents = prop2.getValue();
                        getContents.reverse();

                    }
                });
            }
        }

        VerticalLayout panel2Layout = new VerticalLayout();
        panel2Layout.setMargin(true);
        final Panel panel2 = new Panel("Editor with a button", panel2Layout);
        panel2Layout.addComponent(new myButton());
        PopupView.Content content2 = new PopupView.Content() {
            @Override
            public String getMinimizedValueAsHTML() {
                return String.valueOf(prop2.getValue());
            }

            @Override
            public Component getPopupComponent() {
                return panel2;
            }
        };

        PopupView p3 = new PopupView(content2);
        panelLayout.addComponent(p3);

        // Fourth test component
        VerticalLayout panel3Layout = new VerticalLayout();
        panel3Layout.setMargin(true);
        final Panel panel3 = new Panel("Editor popup for a property",
                panel3Layout);
        TextField tf2 = new TextField("TextField for editing a property");
        final ObjectProperty<String> op = new ObjectProperty<String>(
                "This is property text.");
        tf2.setPropertyDataSource(op);
        panel3Layout.addComponent(tf2);
        PopupView.Content content3 = new PopupView.Content() {

            @Override
            public String getMinimizedValueAsHTML() {
                return String.valueOf(op.getValue());
            }

            @Override
            public Component getPopupComponent() {
                return panel3;
            }

        };
        PopupView p4 = new PopupView(content3);
        panelLayout.addComponent(p4);

        // Fifth test component
        Table table = new Table("Table for testing purposes");
        for (int i = 0; i < 5; i++) {
            table.addContainerProperty("" + (i + 1), String.class, "");
        }
        table.addContainerProperty("" + 6, PopupView.class, null);
        table.addContainerProperty("" + 7, PopupView.class, null);
        table.setPageLength(20);
        for (int i = 0; i < 1000; i++) {

            final InlineDateField df = new InlineDateField("", new Date());
            PopupView pp = new PopupView(new PopupView.Content() {
                @Override
                public String getMinimizedValueAsHTML() {
                    return String.valueOf(df.getValue());
                }

                @Override
                public Component getPopupComponent() {
                    return df;
                }
            });
            final int lineNum = i;
            PopupView pp2 = new PopupView(new PopupView.Content() {

                TextField tf = new TextField("Editor for line " + lineNum,

                "Try to edit the contents for this textfield on line "
                        + lineNum
                        + " and see how the overview-version changes.");

                @Override
                public String getMinimizedValueAsHTML() {
                    return "" + String.valueOf(tf.getValue()).length()
                            + " characters of info";
                }

                @Override
                public Component getPopupComponent() {
View Full Code Here


                        + "should still work with margins and spacings");
        main.addComponent(description);

        final GridLayout grid = new GridLayout(4, 1);

        final TextField size = new TextField("Grid width in css unit");
        size.addListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                String width = size.getValue().toString();
                if (width == null || width.equals("")) {
                    grid.setSizeUndefined();
                } else {
                    grid.setWidth(width);
                }
View Full Code Here

        final LegacyWindow main = new LegacyWindow(getClass().getName()
                .substring(getClass().getName().lastIndexOf(".") + 1));
        setMainWindow(main);

        final ObjectProperty<String> prop = new ObjectProperty<String>("");
        final TextField tf1 = new TextField(
                "Buffered TextField bound to ObjectProperty");
        tf1.setBuffered(true);
        tf1.setPropertyDataSource(prop);
        main.addComponent(tf1);
        main.addComponent(new Button(
                "This button does nothing (but flushes queued variable changes)"));
        main.addComponent(new Button("Commit the field to property",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        tf1.commit();
                    }
                }));
        main.addComponent(new Button("Show property value",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        main.showNotification("'" + prop.getValue() + "'");
                    }
                }));
        main.addComponent(new Button("Show field value",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        main.showNotification("'" + tf1.getValue() + "'");
                    }
                }));
    }
View Full Code Here

public class LocaleChangeOnReadOnlyField extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final TextField textField = getReadOnlyTextField();
        addComponent(textField);

        Button changeLocaleButton = addLocaleChangeButton(textField);
        addComponent(changeLocaleButton);
    }
View Full Code Here

        Button changeLocaleButton = addLocaleChangeButton(textField);
        addComponent(changeLocaleButton);
    }

    private TextField getReadOnlyTextField() {
        final TextField textField = new TextField();

        textField.setConverter(BigDecimal.class);
        textField.setLocale(Locale.US);
        textField.setValue("1024000");
        textField.setReadOnly(true);

        return textField;
    }
View Full Code Here

    private final Log log = new Log(5);

    @Override
    public void setup() {
        TextField tf = new TextField();
        tf.setTextChangeEventMode(TextChangeEventMode.TIMEOUT);
        tf.setTextChangeTimeout(500);
        tf.addListener(new TextChangeListener() {
            @Override
            public void textChange(TextChangeEvent event) {
                log.log("TextChangeEvent: " + event.getText());
            }
        });
View Full Code Here

public class TextChangeEventsEternalLoop extends TestBase {
    @Override
    protected void setup() {

        final TextField tf = new TextField("Debug");
        getLayout().addComponent(tf);

        tf.addListener(new TextChangeListener() {
            @Override
            public void textChange(TextChangeEvent event) {
                tf.setValue(event.getText());
            }
        });
    }
View Full Code Here

     * VaadinRequest)
     */
    @Override
    protected void setup(VaadinRequest request) {

        final TextField tf = new TextField();
        tf.setId(FIELD);
        tf.setInputPrompt("input text here");
        tf.setImmediate(true);
        tf.setNullRepresentation("");

        Button button = new Button("Click Me");
        button.setId(BUTTON);
        button.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                String input = tf.getValue();
                Label label = new Label("Your input was: " + input);
                label.setId(LABEL2);
                getLayout().addComponent(label);
            }
        });
        tf.addShortcutListener(new ShortcutListener("Shortcut", KeyCode.ENTER,
                null) {

            @Override
            public void handleAction(Object sender, Object target) {
                String input = tf.getValue();
                Label label = new Label("Your input was: " + input);
                label.setId(LABEL1);
                getLayout().addComponent(label);
            }
        });
View Full Code Here

        setMainWindow(mainWindow);

        final Table table = new Table();
        table.addContainerProperty("column1", Component.class, null);
        VerticalLayout vl = new VerticalLayout();
        final TextField textField = new TextField();
        vl.addComponent(textField);

        table.addItem(new Object[] { vl }, 1);

        table.setSizeFull();
View Full Code Here

public class TextFieldWithProperty extends TestBase {

    @Override
    protected void setup() {

        final TextField tf1 = new TextField();

        final ObjectProperty<String> op = new ObjectProperty<String>("FOO");

        tf1.setPropertyDataSource(op);

        addComponent(tf1);

        Button b = new Button(
                "Set BAR to underlaying property (should propagate to UI)");
View Full Code Here

TOP

Related Classes of com.vaadin.ui.TextField

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.