Example usage for com.vaadin.ui FormLayout setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:ch.bfh.ti.soed.hs16.srs.black.view.loginView.LoginView.java

License:Open Source License

public LoginView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    loginButton = new Button("Login");
    loginButton.setWidth(5, Unit.EM);/*w w w  .j a v  a  2 s.c  om*/
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signUpButton = new Button("Sign Up");
    signUpButton.setWidth(6, Unit.EM);

    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout layoutButtons = new HorizontalLayout(loginButton, signUpButton);
    layoutButtons.setSpacing(true);
    Panel panel = new Panel("Login - Smart ReservationEntity System");
    panel.setSizeUndefined();
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, layoutButtons);
    content.setSizeFull();
    content.setMargin(true);
    panel.setContent(content);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}

From source file:com.concur.ui.WebApp.java

License:Apache License

private Window createWindow() {
    FormLayout fl = new FormLayout();

    //        final SessionGuard sg = new SessionGuard();
    //        sg.setKeepalive(true);
    //        fl.addComponent(sg);

    fl.setSizeFull();
    fl.setMargin(true);/*from  ww  w  .ja v a2s  .  c  om*/
    fl.addComponent(new Label("<h2>ATS Tuple Store -- Demo App<h2/>", Label.CONTENT_XML));

    actionField = new NativeSelect("Action:");
    actionField.addItem("Authenticate");
    actionField.addItem("GetTuple");
    actionField.addItem("PutTuple");
    actionField.addItem("GetConfigurations");
    actionField.select("Authenticate");
    fl.addComponent(actionField);

    tokenField = new TextField("Authentication Token:");
    tokenField.setColumns(40);
    fl.addComponent(tokenField);

    tupleKeyField = new TextField("TupleKey:");
    tupleKeyField.setColumns(40);
    fl.addComponent(tupleKeyField);

    tupleDataArea = new TextArea("TupleData:");
    tupleDataArea.setColumns(40);
    tupleDataArea.setRows(5);
    fl.addComponent(tupleDataArea);

    Button b = new Button("Send Request");
    b.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            submit();
        }
    });

    fl.addComponent(b);

    final Window w = new Window("ATS Tuple Store -- DEMO");
    w.setContent(fl);
    return w;
}

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

public Component getFirstStage() {
    Label header = new Label(Language.get(Word.RSS));
    header.addStyleName(ValoTheme.LABEL_H1);

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

    TextField rssField = new TextField(Language.get(Word.RSS));
    rssField.setWidth("750px");
    forms.addComponents(rssField);//from w  w w . ja v  a  2 s .com

    Runnable cancel = () -> close();
    Runnable next = () -> validateFirstStage(rssField.getValue());

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, forms, getFooter(cancel, next));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

/**
 * If no value present, choose a empty string
 *
 * @param title/* w  w w  .  j a v a 2s.co  m*/
 * @param link
 * @param description
 * @param language
 * @param imageUrl
 * @return
 */
private Component getSecondStage(Source s) {
    Label header = new Label(Language.get(Word.SOURCE));
    header.addStyleName(ValoTheme.LABEL_H1);

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

    TextField textFieldId = new TextField(Language.get(Word.ID));
    textFieldId.setEnabled(false);
    textFieldId.setValue(s.getId());
    textFieldId.setWidth("750px");

    TextField textFieldName = new TextField(Language.get(Word.NAME));
    textFieldName.setValue(s.getName());
    textFieldName.setWidth("750px");

    TextField textFieldDescription = new TextField(Language.get(Word.DESCRIPTION));
    textFieldDescription.setValue(s.getDescription());
    textFieldDescription.setWidth("750px");

    TextField textFieldURL = new TextField(Language.get(Word.URL));
    if (s.getUrl() != null) {
        textFieldURL.setValue(s.getUrl().toExternalForm());
    }
    textFieldURL.setWidth("750px");

    ComboBox<Category> comboBoxCategories = new ComboBox<>(Language.get(Word.CATEGORY),
            EnumSet.allOf(Category.class));
    comboBoxCategories.setItemCaptionGenerator(c -> c.getName());
    comboBoxCategories.setItemIconGenerator(c -> c.getIcon());
    comboBoxCategories.setEmptySelectionAllowed(false);
    comboBoxCategories.setTextInputAllowed(false);
    comboBoxCategories.setWidth("375px");
    if (s.getCategory() != null) {
        comboBoxCategories.setSelectedItem(s.getCategory());
    }

    ComboBox<Locale> comboBoxLanguage = new ComboBox<>(Language.get(Word.LANGUAGE), getLanguages());
    comboBoxLanguage.setItemCaptionGenerator(l -> l.getDisplayLanguage(VaadinSession.getCurrent().getLocale()));
    comboBoxLanguage.setEmptySelectionAllowed(false);
    comboBoxLanguage.setWidth("375px");
    if (!s.getLanguage().isEmpty()) {
        Locale selected = new Locale(s.getLanguage());
        comboBoxLanguage.setSelectedItem(selected);
    }

    Locale loc = VaadinSession.getCurrent().getLocale();

    Map<String, Locale> countries = getCountries();
    List<Locale> locales = countries.values().parallelStream()
            .sorted((l1, l2) -> l1.getDisplayCountry(loc).compareTo(l2.getDisplayCountry(loc)))
            .collect(Collectors.toList());
    ComboBox<Locale> comboBoxCountry = new ComboBox<>(Language.get(Word.COUNTRY), locales);
    comboBoxCountry.setItemCaptionGenerator(l -> l.getDisplayCountry(VaadinSession.getCurrent().getLocale()));
    comboBoxCountry.setItemIconGenerator(l -> FamFamFlags.fromLocale(l));
    comboBoxCountry.setEmptySelectionAllowed(false);
    comboBoxCountry.setWidth("375px");
    if (!s.getCountry().isEmpty()) {
        comboBoxCountry.setSelectedItem(countries.getOrDefault(s.getCountry(), Locale.ROOT));
    }

    Image imageLogo = new Image(Language.get(Word.LOGO));

    TextField textFieldLogo = new TextField(Language.get(Word.LOGO_URL));
    if (s.getLogo() != null) {
        textFieldLogo.setValue(s.getLogo().toExternalForm());
        imageLogo.setSource(new ExternalResource(s.getLogo()));
    }
    textFieldLogo.addValueChangeListener(ce -> imageLogo.setSource(new ExternalResource(ce.getValue())));
    textFieldLogo.setWidth("750px");

    if (imageLogo.getHeight() > 125) {
        imageLogo.setHeight("125px");
    }

    forms.addComponents(textFieldId, textFieldName, textFieldDescription, textFieldURL, comboBoxCategories,
            comboBoxLanguage, comboBoxCountry, textFieldLogo, imageLogo);

    Runnable cancel = () -> close();
    Runnable next = () -> validateSecondStage(s, textFieldId.getValue(), textFieldName.getValue(),
            textFieldURL.getValue(), textFieldDescription.getValue(),
            comboBoxCategories.getSelectedItem().orElse(null),
            comboBoxLanguage.getSelectedItem().orElse(Locale.ROOT),
            comboBoxCountry.getSelectedItem().orElse(Locale.ROOT), textFieldLogo.getValue());

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, forms, getFooter(cancel, next));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    return windowLayout;
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.EditAwardTypeDialog.java

License:Open Source License

@SuppressWarnings("serial")
private EditAwardTypeDialog(AwardType awt, EditAwardResultListener lis) {
    Object sessKey = HSess.checkInit();
    listener = lis;/*w  w w .ja va2  s .  co m*/
    awardType = awt;

    setCaption("Edit Award Type");
    setModal(true);
    setWidth("450px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.addStyleName("m-greybackground");

    FormLayout formLay;
    vLay.addComponent(formLay = new FormLayout());
    formLay.setSizeFull();

    formLay.addComponent(
            nameTF = new MTextField("Award Title").withFullWidth().withNullRepresentation("required field"));
    nameTF.setRequired(true);
    nameTF.setRequiredError("Required field");
    nameTF.setSizeFull();

    formLay.addComponent(
            descTF = new MTextField("Description").withFullWidth().withNullRepresentation("required field"));
    descTF.setRequired(true);
    descTF.setRequiredError("Required field");

    Label sp;

    formLay.addComponent(hLay55 = new HorizontalLayout());
    hLay55.setWidth("100%");
    hLay55.setCaption("55x55 pixel icon");
    hLay55.setSpacing(true);
    hLay55.addComponent(lab55 = new HtmlLabel("<i>image name</i>"));
    hLay55.setComponentAlignment(lab55, Alignment.MIDDLE_CENTER);
    hLay55.addComponent(butt55 = new NativeButton("Choose 55x55 image"));
    hLay55.setComponentAlignment(butt55, Alignment.MIDDLE_CENTER);
    hLay55.addComponent(sp = new Label());
    hLay55.setExpandRatio(sp, 1.0f);
    hLay55.addComponent(image55 = new Image(null));
    image55.setWidth("55px");
    image55.setHeight("55px");
    image55.addStyleName("m-greyborder3");

    formLay.addComponent(hLay300 = new HorizontalLayout());
    hLay300.setWidth("100%");
    hLay300.setCaption("300x300 pixel icon");
    hLay300.setSpacing(true);
    hLay300.addComponent(lab300 = new HtmlLabel("<i>image name</i>"));
    hLay300.setComponentAlignment(lab300, Alignment.MIDDLE_CENTER);
    hLay300.addComponent(butt300 = new NativeButton("Choose 300x300 image"));
    hLay300.setComponentAlignment(butt300, Alignment.MIDDLE_CENTER);
    hLay300.addComponent(sp = new Label());
    hLay300.setExpandRatio(sp, 1.0f);
    hLay300.addComponent(image300 = new Image(null));
    image300.setWidth("55px");
    image300.setHeight("55px");
    image300.addStyleName("m-greyborder3");

    ClickListener chooseIconListener = new ClickListener() {
        boolean is55 = false;

        @Override
        public void buttonClick(ClickEvent event) {
            is55 = (event.getButton() == butt55);
            String txt = (is55 ? pix55text : pix300text);
            InstallImageResultListener lis = new InstallImageResultListener() {
                @Override
                public void doneTL(MediaImage mimg) {
                    Media m = null;
                    if (mimg != null)
                        m = mimg.media;

                    if (m != null) {
                        MediaLocator mediaLoc = Mmowgli2UI.getGlobals().getMediaLocator();
                        String handle = m.getHandle();
                        if (handle != null && handle.trim().length() <= 0)
                            handle = null;
                        if (is55) {
                            media55 = m;
                            if (handle == null) {
                                m.setHandle("55x55");
                                Media.updateTL(m);
                            }
                            lab55.setValue(m.getUrl());
                            image55.setSource(mediaLoc.locate(m));
                        } else {
                            media300 = m;
                            if (handle == null) {
                                m.setHandle("300x300");
                                Media.updateTL(m);
                            }
                            lab300.setValue(m.getUrl());
                            image300.setSource(mediaLoc.locate(m));
                        }
                    }
                }
            };
            InstallImageDialog.show(txt, lis, is55 ? pix55filter : pix300filter);
        }
    };

    butt55.addClickListener(chooseIconListener);
    butt300.addClickListener(chooseIconListener);

    HorizontalLayout buttHL = new HorizontalLayout();
    vLay.addComponent(buttHL);
    buttHL.setWidth("100%");

    buttHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    buttHL.setExpandRatio(sp, 1.0f);

    buttHL.addComponent(new NativeButton("Cancel", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            awardType = null;
            doneHereTL();
        }
    }));

    buttHL.addComponent(new NativeButton("Close", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String title = nameTF.getValue().trim();
            String description = descTF.getValue().trim();
            if (title.length() <= 0 || description.length() <= 0 || media300 == null || media55 == null) {
                Notification.show("All fields must be completed", Notification.Type.ERROR_MESSAGE);
                return;
            }

            HSess.init();

            boolean save = false;
            if (awardType == null) {
                awardType = new AwardType();
                save = true;
            }

            awardType.setName(nameTF.getValue().trim());
            awardType.setDescription(descTF.getValue().trim());
            awardType.setIcon300x300(media300);
            awardType.setIcon55x55(media55);

            if (save)
                HSess.get().save(awardType);
            else
                HSess.get().update(awardType);

            doneHereTL();
            HSess.close();
        }
    }));

    HSess.checkClose(sessKey);
}

From source file:eu.hurion.hello.vaadin.shiro.application.LoginScreen.java

License:Apache License

public LoginScreen(final HerokuShiroApplication app) {
    setSizeFull();//from  w w w . j a v a  2s.com

    final Panel loginPanel = new Panel("Login");
    loginPanel.setWidth("300px");
    final FormLayout content = new FormLayout();
    content.setSizeFull();
    user = new TextField("User");
    content.addComponent(user);
    password = new PasswordField("Password");
    content.addComponent(password);
    final Button loginButton = new Button("Log in");
    content.setHeight("150px");
    loginButton.addClickListener(new ShiroLoginListener(app));
    content.addComponent(loginButton);
    loginPanel.setContent(content);

    addComponent(loginPanel);
    setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);

    final HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    addComponent(footer);
}

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();

    final Label l = new Label(main.account.getId(database));
    l.setCaption("Kyttjn nimi:");
    l.setWidth("100%");
    content.addComponent(l);/*from w ww .ja  v a 2  s.com*/

    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();

    //      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);// ww  w .  j  ava 2  s. co m

    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 {//from   ww  w .  j  av  a  2  s  . co 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();

    final TextField tf = new TextField();
    tf.setCaption("Kartan tunniste:");
    tf.setValue("tunniste");
    tf.setWidth("100%");
    content.addComponent(tf);//  w w w .java  2  s. c om

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

        }
    });

}