Example usage for com.vaadin.ui FormLayout FormLayout

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

Introduction

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

Prototype

public FormLayout() 

Source Link

Usage

From source file:ru.codeinside.gses.webui.components.EmployeeInfo.java

License:Mozilla Public License

public EmployeeInfo(String userLogin, Button button) {

    setCaption("? ? ".concat(userLogin));

    FormLayout layout = new FormLayout();
    for (Component c : AdminServiceProvider.get().withEmployee(userLogin, new CreateInfo())) {
        layout.addComponent(c);/*from w  w w  .ja v a  2s .  c  o m*/
    }
    addComponent(layout);
    addComponent(button);
}

From source file:ru.codeinside.gses.webui.declarant.DeclarantFactory.java

License:Mozilla Public License

public static Component create() {

    // TODO: ??   ??!
    final ServiceQueryDefinition amSQ = new ServiceQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amSC = new LazyQueryContainer(amSQ, new ServiceQueryFactory(false));
    final ProcedureQueryDefinition amPQ = new ProcedureQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amPC = new LazyQueryContainer(amPQ,
            new ProcedureQueryFactory(Flash.login(), false));

    final ProcedureQueryDefinition mmQ = new ProcedureQueryDefinition(ProcedureType.Interdepartmental);
    final LazyQueryContainer mmC = new LazyQueryContainer(mmQ, new ProcedureQueryFactory(Flash.login(), false));

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from www  .j ava2  s  .  co m
    layout.setMargin(true);
    final Label header = new Label(
            " ?  ?? ?? ?");
    header.addStyleName("h1");
    layout.addComponent(header);

    final Select amS = new Select("", amPC);
    String selectWidth = "400px";
    amS.setWidth(selectWidth);
    amS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amS.setItemCaptionPropertyId("name");
    amS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amS.setNullSelectionAllowed(true);
    amS.setNewItemsAllowed(false);
    amS.setImmediate(true);

    final Select amSS = new Select("?", amSC);
    amSS.setWidth(selectWidth);
    amSS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amSS.setItemCaptionPropertyId("name");
    amSS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amSS.setNullSelectionAllowed(true);
    amSS.setNewItemsAllowed(false);
    amSS.setImmediate(true);

    final FormLayout amLayout = new FormLayout();

    final Panel amPanel = new Panel();
    amLayout.addComponent(amSS);
    amLayout.addComponent(amS);
    amPanel.addComponent(amLayout);

    final Select mmS = new Select("", mmC);
    mmS.setFilteringMode(Select.FILTERINGMODE_OFF);
    mmS.setWidth(selectWidth);
    mmS.setItemCaptionPropertyId("name");
    mmS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    mmS.setNullSelectionAllowed(true);
    mmS.setNewItemsAllowed(false);
    mmS.setImmediate(true);

    final FormLayout mmLayout = new FormLayout();
    final Panel mmPanel = new Panel();
    //    mmLayout.addComponent(mmSS);
    mmLayout.addComponent(mmS);
    mmPanel.addComponent(mmLayout);

    final VerticalLayout amWrapper = new VerticalLayout();
    amWrapper.setSizeFull();
    amWrapper.addComponent(amPanel);

    final VerticalLayout imWrapper = new VerticalLayout();
    imWrapper.setSizeFull();
    imWrapper.addComponent(mmPanel);

    final TabSheet typeSheet = new TabSheet();
    typeSheet.setSizeFull();
    typeSheet.addTab(amWrapper, "?? ");
    typeSheet.addTab(imWrapper, "? ");
    layout.addComponent(typeSheet);
    layout.setExpandRatio(typeSheet, 1);

    // 

    amSS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                amPQ.serviceId = -1;
            } else {
                amPQ.serviceId = (Long) amSC.getItem(prop.getValue()).getItemProperty("id").getValue();
            }
            amS.select(null);
            amPC.refresh();
        }
    });

    final ProcedureSelectListener administrativeProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (amWrapper.getComponentCount() > 1) {
                amWrapper.removeComponent(amWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    amWrapper.addComponent(cmp);
                    amWrapper.setExpandRatio(cmp, 1f);
                } else {
                    amS.select(null);
                    amPC.refresh();
                    amSC.refresh();
                }
            }
        }
    };
    final ProcedureSelectListener interdepartamentalProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (imWrapper.getComponentCount() > 1) {
                imWrapper.removeComponent(imWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    imWrapper.addComponent(cmp);
                    imWrapper.setExpandRatio(cmp, 1f);
                }
            }
        }
    };
    amS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) amPC.getItem(itemId).getItemProperty("id").getValue();
            administrativeProcedureSelectListener.selectProcedure(procedureId);
        }
    });
    mmS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) mmC.getItem(itemId).getItemProperty("id").getValue();
            interdepartamentalProcedureSelectListener.selectProcedure(procedureId);
        }
    });

    return layout;
}

From source file:sample.ui.view.PersonEditor.java

License:Apache License

public FormLayout getLayout() {
    //      this.departmentSelector = departmentSelector;
    //      this.person = person;
    this.setClosable(true);

    FormLayout layout = new FormLayout();
    // Form for editing the bean
    final BeanFieldGroup<Person> binder = new BeanFieldGroup<Person>(Person.class);
    binder.setItemDataSource(person);/*from  w  ww  .jav  a  2s. com*/
    binder.setFieldFactory(this);
    layout.addComponent(binder.buildAndBind("Name", "firstName"));
    layout.addComponent(binder.buildAndBind("Last name", "lastName"));
    layout.addComponent(binder.buildAndBind("Street", "street"));
    layout.addComponent(binder.buildAndBind("City", "city"));
    layout.addComponent(binder.buildAndBind("Zip Code", "zipCode"));
    layout.addComponent(binder.buildAndBind("Phone", "phoneNumber"));
    layout.addComponent(binder.buildAndBind("Departman", "department"));

    // Buffer the form content
    binder.setBuffered(true);
    // A button to commit the buffer
    layout.addComponent(new Button("OK", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                binder.commit();
                fireEvent(new Event(PersonEditor.this));
                Notification.show("Thanks!");
            } catch (CommitException e) {
                Notification.show("You fail!");
            }
            close();
        }
    }));

    // A button to discard the buffer
    layout.addComponent(new Button("Discard", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            binder.discard();
            Notification.show("Discarded!");
            close();
        }
    }));

    return layout;
}

From source file:trader.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    setLocale(Locale.ENGLISH);// www . j  a  v a2  s.  c o  m

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();

    loginForm.addComponent(userName = new TextField("Username"));
    loginForm.addComponent(passwordField = new PasswordField("Password"));
    loginForm.addComponent(rememberMe = new CheckBox("Remember me"));
    loginForm.addComponent(login = new Button("Login"));
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        /**
        * 
        */
        private static final long serialVersionUID = 7813011112417170727L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:ui.form.LifetimeForm.java

private void initMain() {
    main = new FormLayout();
    main.setMargin(true);
    main.setImmediate(true);
}

From source file:uk.co.intec.keyDatesApp.components.MainViewFilter.java

License:Apache License

/**
 * Main method to load the filtering fields and valueChangeListeners for
 * those fields.//  w  ww .j  a v  a2  s . c o m
 */
public void loadContent() {
    final FormLayout cust = new FormLayout();
    cust.setMargin(false);
    setCustField(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer()));
    getCustField().setInputPrompt("No Customer Selected");
    getCustField().setFilteringMode(FilteringMode.STARTSWITH);
    getCustField().setImmediate(true);
    getCustField().setInvalidAllowed(false);
    getCustField().setNullSelectionAllowed(true);
    getCustField().setPageLength(5);
    getCustField().setWidth("95%");
    getCustField().setResponsive(true);
    getCustField().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap((String) event.getProperty().getValue(),
                    viewWrapper.getStartDate(), viewWrapper.isSingleCat(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });
    cust.addComponent(getCustField());

    final FormLayout date = new FormLayout();
    date.setMargin(false);
    setDateField(new PopupDateField("Start Date:"));
    getDateField().setValue(new Date());
    getDateField().setResolution(Resolution.DAY);
    getDateField().setLocale(Locale.getDefault());
    getDateField().setResponsive(true);
    getDateField().setTextFieldEnabled(false);
    getDateField().setWidth("95%");
    getDateField().setRequired(true);
    getDateField().setRequiredError("A date is required!");

    getDateField().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(),
                    (Date) event.getProperty().getValue(), viewWrapper.isSingleCat(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });

    date.addComponent(getDateField());

    final FormLayout singleCatLayout = new FormLayout();
    singleCatLayout.setMargin(false);
    singleCatLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    setSingleCatButton(new CheckBox());
    getSingleCatButton().setStyleName(ValoTheme.CHECKBOX_SMALL);
    getSingleCatButton().setResponsive(true);
    getSingleCatButton().setCaption("Restrict to Date");
    getSingleCatButton().setWidth("95%");
    getSingleCatButton().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            final Boolean val = (Boolean) event.getProperty().getValue();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(),
                    viewWrapper.getStartDate(), val.booleanValue(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });
    singleCatLayout.addComponent(getSingleCatButton());

    addComponents(cust, date, singleCatLayout);
    setExpandRatio(cust, 2);
    setExpandRatio(date, 1);
    setExpandRatio(singleCatLayout, 1);
    setComponentAlignment(singleCatLayout, Alignment.MIDDLE_RIGHT);

}

From source file:views.PersonInput.java

License:Open Source License

public PersonInput(List<String> titles, Map<String, Integer> affiliations, List<String> roles,
        AffiliationInput affiInput) {/*from w ww. j a v a2s.c  o m*/
    left = new FormLayout();
    left.setMargin(true);

    affiliationMap = affiliations;
    this.affiInput = affiInput;
    this.affiInput.hideRegisterButton();
    this.affiInput.setVisible(false);

    userName = new TextField("Username");
    // userName.setRequired(true);
    userName.addValidator(new RegexpValidator(Helpers.VALID_USERNAME_REGEX, "Please input a valid username."));
    left.addComponent(Styles.questionize(userName,
            "University Tbingen user name or user name provided by QBiC. If left empty a dummy user name is chosen "
                    + "which cannot be used to log in until a real name is added. Person information can still be added to "
                    + "projects or experiments in that case.",
            "User Name"));

    title = new ComboBox("Title", titles);
    title.setRequired(true);
    title.setStyleName(ValoTheme.COMBOBOX_SMALL);
    title.setNullSelectionAllowed(false);
    left.addComponent(title);

    first = new TextField("First Name");
    first.setRequired(true);
    first.addValidator(new RegexpValidator(Helpers.VALID_NAME_REGEX, "Please input a valid name."));
    left.addComponent(first);

    last = new TextField("Last Name");
    last.setRequired(true);
    last.addValidator(new RegexpValidator(Helpers.VALID_NAME_REGEX, "Please input a valid name."));
    left.addComponent(last);

    eMail = new TextField("E-Mail");
    eMail.setRequired(true);
    eMail.addValidator(
            new RegexpValidator(Helpers.VALID_EMAIL_ADDRESS_REGEX, "Please input a valid e-mail address."));
    left.addComponent(eMail);

    phone = new TextField("Phone");
    left.addComponent(phone);

    affiliation = new ComboBox("Affiliation", affiliations.keySet());
    // affiliation.setNullSelectionAllowed(false);
    affiliation.setRequired(true);
    affiliation.setFilteringMode(FilteringMode.CONTAINS);
    affiliation.setStyleName(ValoTheme.COMBOBOX_SMALL);
    left.addComponent(Styles.questionize(affiliation,
            "Work group or organization this person is part of. If it does not exist in the system "
                    + "a \"New Affiliation\" has to be created first. Additional Affiliations and roles can be set in the next Tab.",
            "Affiliation"));

    newAffiliation = new CheckBox("New Affiliation");
    left.addComponent(newAffiliation);
    newAffiliation.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            enableAffiliationInput(newAffiliation.getValue());
            affiliation.select(affiliation.getNullSelectionItemId());
            affiliation.setEnabled(!newAffiliation.getValue());
        }
    });

    role = new ComboBox("Role", roles);
    role.setRequired(true);
    role.setStyleName(ValoTheme.COMBOBOX_SMALL);
    role.setNullSelectionAllowed(false);
    left.addComponent(role);

    commit = new Button("Save New User");
    left.addComponent(commit);

    addComponent(left);
    addComponent(affiInput);
}

From source file:xyz.iipster.ui.ChangePasswordComponent.java

License:Apache License

@Override
public void attach() {
    super.attach();

    setModal(true);/*  ww  w .j ava2s  .  c  o m*/
    setClosable(false);
    setResizable(false);

    setCaption(i18N.get("iipster.changePassword.title"));

    oldPasswordField.setCaption(i18N.get("iipster.changePassword.oldPassword.label"));
    newPasswordField1.setCaption(i18N.get("iipster.changePassword.newPassword1.label"));
    newPasswordField2.setCaption(i18N.get("iipster.changePassword.newPassword2.label"));

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    vl.setMargin(true);

    if (currentPassword != null) {
        // currentPassowrd is not null, that means we are on login screen and the password is expired
        Label expiredLabel = new Label(i18N.get("iipster.changePassword.expired.text"));
        vl.addComponent(expiredLabel);
    }

    FormLayout fl = new FormLayout();
    fl.setSizeUndefined();
    fl.addComponents(oldPasswordField, newPasswordField1, newPasswordField2);
    vl.addComponent(fl);
    vl.setExpandRatio(fl, 1F);

    okButton.setCaption(i18N.get("iipster.ok"));
    okButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    okButton.addClickListener(e -> {
        try {
            ibmiService.changePassword(
                    securityUtils.getAuthentication() == null ? userName
                            : securityUtils.getAuthentication().getPrincipal().toString(),
                    oldPasswordField.getValue(), newPasswordField1.getValue());
            close();
            eventBus.post(new PasswordChangedEvent(newPasswordField1.getValue()));
        } catch (BadCredentialsException e1) {
            Notification.show(i18N.get("iipster.changePassword.oldPassword.error"),
                    Notification.Type.WARNING_MESSAGE);
            oldPasswordField.focus();
        } catch (IOException e1) {
            Notification.show("Error while changing password", Notification.Type.ERROR_MESSAGE);
        } catch (NewPasswordInvalidException e1) {
            Notification.show(i18N.get(e1.getMessageId()), Notification.Type.WARNING_MESSAGE);
            newPasswordField1.focus();
        }
    });

    cancelButton.setCaption(i18N.get("iipster.cancel"));
    cancelButton.setClickShortcut(ShortcutAction.KeyCode.F12);
    cancelButton.addClickListener(e -> {
        close();
    });

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();
    hl.setSpacing(true);
    hl.addComponents(okButton, cancelButton);

    vl.addComponent(hl);
    vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

    setContent(vl);

    if (currentPassword == null) {
        // currentPassword is null so we are not forced to change password during login
        oldPasswordField.setValue("");
        oldPasswordField.setEnabled(true);

        oldPasswordField.focus();
    } else {
        oldPasswordField.setValue(currentPassword);
        oldPasswordField.setEnabled(false);

        newPasswordField1.focus();
    }

    newPasswordField1.setValue("");
    newPasswordField2.setValue("");
}

From source file:xyz.iipster.ui.DefaultIbmiLoginComponent.java

License:Apache License

@Override
public void attach() {
    super.attach();
    final FormLayout fl = new FormLayout();
    fl.setSizeUndefined();/*from   www.j  a  v  a2 s .c o m*/

    userNameTF.setCaption(i18N.get("iipster.login.username.label"));
    //        userNameTF.setRequired(true);
    userNameTF.addStyleName("upper-case");
    userNameTF.setMaxLength(10);
    passwordPF.setCaption(i18N.get("iipster.login.password.label"));
    //        passwordPF.setRequired(true);

    fl.addComponent(userNameTF);
    fl.addComponent(passwordPF);

    final VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    vl.addComponent(fl);
    vl.setExpandRatio(fl, 1F);
    vl.setComponentAlignment(fl, Alignment.MIDDLE_CENTER);

    final HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();

    loginButton.setCaption(i18N.get("iipster.login.loginButton.label"));
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    loginButton.addClickListener(event -> {
        if (userNameTF.isEmpty()) {
            Notification.show(i18N.get("iipster.login.username.missing"), Notification.Type.WARNING_MESSAGE);
            userNameTF.focus();
            return;
        }
        if (passwordPF.isEmpty()) {
            Notification.show(i18N.get("iipster.login.password.missing"), Notification.Type.WARNING_MESSAGE);
            passwordPF.focus();
            return;
        }

        try {
            Authentication auth = securityUtils.login(userNameTF.getValue(), passwordPF.getValue());
            eventBus.post(new LoginEvent(auth.getPrincipal().toString()));
        } catch (BadCredentialsException e) {
            Notification.show(i18N.get("iipster.login.bad.credential"), Notification.Type.WARNING_MESSAGE);
        } catch (DisabledException e) {
            Notification.show(i18N.get("iipster.login.disabled"), Notification.Type.WARNING_MESSAGE);
        } catch (CredentialsExpiredException e) {
            changePasswordComponent.setUserName(userNameTF.getValue());
            changePasswordComponent.setCurrentPassword(passwordPF.getValue());
            UI.getCurrent().addWindow(changePasswordComponent);
        } catch (Exception e) {
            Notification.show(i18N.get("iipster.login.error"), Notification.Type.WARNING_MESSAGE);
        }
    });
    hl.addComponent(loginButton);
    vl.addComponent(hl);
    vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);
    vl.setSizeUndefined();

    vl.setMargin(true);
    final Panel panel = new Panel(i18N.get("iipster.login.panel.title"), vl);
    panel.setSizeUndefined();

    rootLayout.addComponent(panel);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    setCompositionRoot(rootLayout);
    setSizeFull();
}