Example usage for com.vaadin.ui FormLayout addComponent

List of usage examples for com.vaadin.ui FormLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui FormLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:fi.jasoft.remoteconnection.ServerExampleUI.java

License:Apache License

private void buildUI() {
    FormLayout vl = new FormLayout();
    setContent(vl);/*from  w w w  . j  av  a  2  s.  com*/

    // Our id
    myId = new Label("Connecting...");
    myId.setCaption("My id:");
    vl.addComponent(myId);

    // Remote id
    final TextField remoteId = new TextField();
    remoteId.setWidth("100%");
    NativeButton connectToRemote = new NativeButton("Connect", new Button.ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final RemoteChannel channel = peer.openChannel(remoteId.getValue());
            channel.addConnectedListener(new ConnectedListener() {

                @Override
                public void connected(String channelId) {
                    remoteId.setReadOnly(true);
                    event.getButton().setVisible(false);
                    Notification.show("Connected to " + channelId, Type.TRAY_NOTIFICATION);
                }
            });
        }
    });

    HorizontalLayout hl = new HorizontalLayout(remoteId, connectToRemote);
    hl.setExpandRatio(remoteId, 1);
    hl.setWidth("100%");
    hl.setCaption("Remote id: ");
    vl.addComponent(hl);

    // Message display where messages are displayed
    messages = new TextArea();
    messages.setWidth("100%");
    vl.addComponent(messages);

    // Message field
    final TextField message = new TextField();
    message.setWidth("100%");
    NativeButton send = new NativeButton("Send", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            // Show message in message window
            messages.setValue(
                    messages.getValue() + peer.getConfiguration().getId() + " >> " + message.getValue() + "\n");

            // Broadcast the message to all connected peers
            peer.broadcast(message.getValue());

            message.setValue("");
        }
    });

    hl = new HorizontalLayout(message, send);
    hl.setExpandRatio(message, 1);
    hl.setWidth("100%");
    hl.setCaption("Send message: ");
    vl.addComponent(hl);
}

From source file:fi.racetrace.adminpanel.ui.CustomerForm.java

License:Open Source License

public CustomerForm(Item customer) {

    FormLayout layout = new FormLayout();
    layout.addComponent(name);
    layout.addComponent(descriptionField);

    final FieldGroup binder = new FieldGroup(customer);
    binder.bindMemberFields(this);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    layout.addComponent(buttonPanel);//from  ww w  .  j a  v  a  2  s  .c o m

    buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            binder.discard();
            Notification.show("Discarded!");
        }
    }));
    buttonPanel.addComponent(new Button("Save", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                binder.commit();
                Notification.show("Changes saved!");
            } catch (CommitException e) {
                Notification.show("An error occurred!");
            }
        }
    }));

    setContent(layout);
}

From source file:fi.racetrace.adminpanel.ui.EventForm.java

License:Open Source License

public EventForm(fi.racetrace.adminpanel.data.Event event) {

    FormLayout layout = new FormLayout();
    layout.addComponent(name);
    layout.addComponent(descriptionField);
    layout.addComponent(start);/*  w ww  . ja  va  2  s.co  m*/
    layout.addComponent(end);

    final FieldGroup binder = new FieldGroup(new BeanItem<fi.racetrace.adminpanel.data.Event>(event));
    binder.bindMemberFields(this);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    layout.addComponent(buttonPanel);

    buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            binder.discard();
            Notification.show("Discarded!");
        }
    }));
    buttonPanel.addComponent(new Button("Save", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                binder.commit();
                Notification.show("Changes saved!");
            } catch (CommitException e) {
                Notification.show("An error occurred!");
            }
        }
    }));

    setContent(layout);
}

From source file:fi.racetrace.adminpanel.ui.SessionForm.java

License:Open Source License

public SessionForm(Session session) {

    latLogPicker = new VolLatLngPicker(session.getCenterLon(), session.getCenterLat());

    FormLayout layout = new FormLayout();
    layout.addComponent(name);
    layout.addComponent(descriptionField);
    layout.addComponent(start);//from  w  ww .j av  a  2s  .co  m
    layout.addComponent(end);
    layout.addComponent(zoom);
    layout.addComponent(centerLat);
    layout.addComponent(centerLon);
    layout.addComponent(latLogPicker);

    latLogPicker.setLatField(centerLat);
    latLogPicker.setLonField(centerLon);

    final FieldGroup binder = new FieldGroup(new BeanItem<Session>(session));
    binder.bindMemberFields(this);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    layout.addComponent(buttonPanel);

    buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            binder.discard();
            Notification.show("Discarded!");
        }
    }));
    buttonPanel.addComponent(new Button("Save", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                binder.commit();
                Notification.show("Changes saved!");
            } catch (CommitException e) {
                Notification.show("An error occurred!");
            }
        }
    }));

    setContent(layout);
}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void modifyAccount(final Main main) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();//w  w w .j a  v  a 2  s  . co m

    final Label l = new Label(main.account.getId(database));
    l.setCaption("Kyttjn nimi:");
    l.setWidth("100%");
    content.addComponent(l);

    final TextField tf = new TextField();
    tf.setWidth("100%");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf.setCaption("Kyttjn nimi:");
    tf.setId("loginUsernameField");
    tf.setValue(main.account.getText(database));
    content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setWidth("100%");
    tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf2.setCaption("Shkpostiosoite:");
    tf2.setId("loginUsernameField");
    tf2.setValue(main.account.getEmail());
    content.addComponent(tf2);

    final PasswordField pf = new PasswordField();
    pf.setCaption("Vanha salasana:");
    pf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf.setWidth("100%");
    pf.setId("loginPasswordField");
    content.addComponent(pf);

    final PasswordField pf2 = new PasswordField();
    pf2.setCaption("Uusi salasana:");
    pf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf2.setWidth("100%");
    pf2.setId("loginPasswordField");
    content.addComponent(pf2);

    final PasswordField pf3 = new PasswordField();
    pf3.setCaption("Uusi salasana uudestaan:");
    pf3.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf3.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf3.setWidth("100%");
    pf3.setId("loginPasswordField");
    content.addComponent(pf3);

    final Label err = new Label("Vr kyttjtunnus tai salasana");
    err.addStyleName(ValoTheme.LABEL_FAILURE);
    err.addStyleName(ValoTheme.LABEL_TINY);
    err.setVisible(false);
    content.addComponent(err);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button apply = new Button("Tee muutokset");

    buttons.addComponent(apply);

    final Window dialog = Dialogs.makeDialog(main, "450px", "480px", "Kyttjtilin asetukset", "Poistu",
            content, buttons);
    apply.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {

            String valueHash = Utils.hash(pf.getValue());
            if (!valueHash.equals(main.account.getHash())) {
                err.setValue("Vr salasana");
                err.setVisible(true);
                return;
            }

            if (pf2.isEmpty()) {
                err.setValue("Tyhj salasana ei kelpaa");
                err.setVisible(true);
                return;
            }

            if (!pf2.getValue().equals(pf3.getValue())) {
                err.setValue("Uudet salasanat eivt tsm");
                err.setVisible(true);
                return;
            }

            main.account.text = tf.getValue();
            main.account.email = tf2.getValue();
            main.account.hash = Utils.hash(pf2.getValue());

            Updates.update(main, true);

            main.removeWindow(dialog);

        }

    });

}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void addMap(final Main main, final Strategiakartta parent) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();/*from   w  w w. j  a  v  a 2  s. com*/

    //      final TextField tf = new TextField();
    //      tf.setCaption("Kartan tunniste:");
    //      tf.setValue("tunniste");
    //      tf.setWidth("100%");
    //      content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setCaption("Kartan nimi:");
    tf2.setValue("Uusi kartta");
    tf2.setWidth("100%");
    content.addComponent(tf2);

    final ComboBox combo = new ComboBox();
    combo.setCaption("Kartan tyyppi:");
    combo.setNullSelectionAllowed(false);
    combo.setWidth("100%");
    content.addComponent(combo);

    Collection<Base> subs = Strategiakartta.availableLevels(database);
    for (Base b : subs) {
        combo.addItem(b.uuid);
        combo.setItemCaption(b.uuid, b.getText(database));
        combo.select(b.uuid);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    Button ok = new Button("Lis");
    buttons.addComponent(ok);

    final Window dialog = Dialogs.makeDialog(main, "450px", "340px", "Lis alatason kartta", "Peruuta",
            content, buttons);
    ok.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1422158448876521843L;

        public void buttonClick(ClickEvent event) {

            String name = tf2.getValue();
            String typeUUID = (String) combo.getValue();
            Base type = database.find(typeUUID);

            database.newMap(main, parent, "", name, type);
            Updates.updateJS(main, true);
            main.removeWindow(dialog);

        }
    });

}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void addImplementationMap(final Main main, final Tavoite goal) {

    final Database database = main.getDatabase();

    try {/* ww  w.ja  va2  s  . c o  m*/
        Base subType = goal.getPossibleSubmapType(database);
        if (subType != null) {
            goal.ensureImplementationMap(main);
            Updates.updateJS(main, true);
            return;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    FormLayout content = new FormLayout();
    content.setSizeFull();

    final ComboBox combo = new ComboBox();
    combo.setCaption("Kartan tyyppi:");
    combo.setNullSelectionAllowed(false);
    combo.setWidth("100%");
    content.addComponent(combo);

    Collection<Base> subs = Strategiakartta.availableLevels(database);
    for (Base b : subs) {
        combo.addItem(b.uuid);
        combo.setItemCaption(b.uuid, b.getText(database));
        combo.select(b.uuid);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    Button ok = new Button("Lis");
    buttons.addComponent(ok);

    final Window dialog = Dialogs.makeDialog(main, "450px", "340px", "Lis alatason kartta", "Peruuta",
            content, buttons);
    ok.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1422158448876521843L;

        public void buttonClick(ClickEvent event) {

            String typeUUID = (String) combo.getValue();
            Base type = database.find(typeUUID);

            Strategiakartta parent = database.getMap(goal);

            Strategiakartta newMap = database.newMap(main, parent, "", "", type);
            newMap.addRelation(Relation.find(database, Relation.IMPLEMENTS), goal);

            for (Painopiste pp : goal.painopisteet) {
                Tavoite.createCopy(main, newMap, pp);
            }

            Updates.updateJS(main, true);
            main.removeWindow(dialog);

        }
    });

}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void insertRootMap(final Main main, final Strategiakartta currentRoot) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();//from  w  w w .  java 2s.c  o m

    final TextField tf = new TextField();
    tf.setCaption("Kartan tunniste:");
    tf.setValue("tunniste");
    tf.setWidth("100%");
    content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setCaption("Kartan nimi:");
    tf2.setValue("Uusi kartta");
    tf2.setWidth("100%");
    content.addComponent(tf2);

    final ComboBox combo = new ComboBox();
    combo.setCaption("Kartan tyyppi:");
    combo.setNullSelectionAllowed(false);
    combo.setWidth("100%");
    content.addComponent(combo);

    Collection<Base> subs = Strategiakartta.availableLevels(database);
    for (Base b : subs) {
        combo.addItem(b.uuid);
        combo.setItemCaption(b.uuid, b.getText(database));
        combo.select(b.uuid);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    Button ok = new Button("Lis");
    buttons.addComponent(ok);

    final Window dialog = Dialogs.makeDialog(main, "450px", "340px", "Lis alatason kartta", "Peruuta",
            content, buttons);
    ok.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1422158448876521843L;

        public void buttonClick(ClickEvent event) {

            String id = tf.getValue();
            String name = tf2.getValue();
            String typeUUID = (String) combo.getValue();
            Base type = database.find(typeUUID);

            Strategiakartta uusi = database.newMap(main, null, id, name, type);
            uusi.addAlikartta(currentRoot);
            Updates.updateJS(main, true);
            main.removeWindow(dialog);

        }
    });

}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void addView(final Main main, final Strategiakartta map) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();// w  w w  .jav  a 2  s .  c o m

    final TextField tf = new TextField();
    tf.setCaption("Nkymn tunniste:");
    tf.setValue("tunniste");
    tf.setWidth("100%");
    content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setCaption("Nkymn nimi:");
    tf2.setValue("Uusi nkym");
    tf2.setWidth("100%");
    content.addComponent(tf2);

    final ComboBox combo = new ComboBox();
    combo.setCaption("Kartan tyyppi:");
    combo.setNullSelectionAllowed(false);
    combo.setWidth("100%");
    content.addComponent(combo);

    Property levelProperty = Property.find(database, Property.LEVEL);
    ObjectType level = database.find((String) levelProperty.getPropertyValue(map));

    Collection<Base> subs = Strategiakartta.availableLevels(database);
    for (Base b : subs) {
        combo.addItem(b.uuid);
        combo.setItemCaption(b.uuid, b.getText(database));
        combo.select(b.uuid);
    }

    final ComboBox combo2 = new ComboBox();
    combo2.setCaption("Aihetunniste:");
    combo2.setNullSelectionAllowed(false);
    combo2.setWidth("100%");
    content.addComponent(combo2);

    for (Tag t : Tag.enumerate(database)) {
        combo2.addItem(t.uuid);
        combo2.setItemCaption(t.uuid, t.getId(database));
        combo2.select(t.uuid);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    Button ok = new Button("Lis");
    buttons.addComponent(ok);

    final Window dialog = Dialogs.makeDialog(main, "450px", "380px", "Lis nkym", "Peruuta", content,
            buttons);
    ok.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1422158448876521843L;

        public void buttonClick(ClickEvent event) {

            String id = tf.getValue();
            String name = tf2.getValue();
            String typeUUID = (String) combo.getValue();
            Base type = database.find(typeUUID);

            String tagUUID = (String) combo2.getValue();
            Tag tag = (Tag) database.find(tagUUID);

            Strategiakartta newMap = database.newMap(main, main.uiState.current, id, name + " (nkym)", type);
            newMap.generators.add(tag);

            Updates.updateJS(main, true);
            main.removeWindow(dialog);

        }

    });

}

From source file:fr.amapj.view.views.compte.MonCompteView.java

License:Open Source License

private TextField addTextField(String lib, FormLayout form) {
    TextField name = new TextField(lib);
    name.addStyleName(TEXTFIELD_COMPTEINPUT);
    name.setWidth("100%");
    name.setNullRepresentation("");
    name.setReadOnly(true);/*from  w w w .  ja  v  a 2 s .c  o m*/
    form.addComponent(name);

    return name;
}