Example usage for com.vaadin.ui FormLayout setSizeUndefined

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

Introduction

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

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:gq.vaccum121.ui.LoginScreen.java

License:Apache License

private void initLayout() {
    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();
    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    login = new Button("Login");
    loginForm.addComponent(userName);/*w w  w . j  a  v a 2 s . c  om*/
    loginForm.addComponent(passwordField);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

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

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

    loggedOutLabel = new Label("Good bye!");
    loginLayout.addComponent(loggedOutLabel);
    loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    loggedOutLabel.setSizeUndefined();
    loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
    loggedOutLabel.setVisible(false);

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

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

From source file:info.magnolia.ui.form.field.component.AbstractBaseItemContentPreviewComponent.java

License:Open Source License

@Override
public Component refreshContentDetail(Item item) {
    FormLayout fileInfo = new FormLayout();
    fileInfo.setSizeUndefined();
    fileInfo.addStyleName("file-details");
    try {//from  w ww . ja  va 2  s. c  om
        List<Component> res = createFieldDetail(item);
        fileInfo.addComponents(res.toArray(new Component[res.size()]));
    } catch (RepositoryException e) {
        log.warn("Could not get the related File node", e);
    }
    return fileInfo;
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Initialize a Component displaying some File Informations.
 * Override getFileDetail...() in order to display custom info's you may want to display.
 *
 * @return A file Info Component. Generally a {@link FormLayout}.
 *//*from   w  w  w.  j  a v  a 2  s .c o  m*/
private Component createFileInfoComponent() {
    FormLayout fileInfo = new FormLayout();
    fileInfo.setSizeUndefined();
    fileInfo.addStyleName("file-details");
    fileInfo.addComponent(getFileDetailHeader());
    fileInfo.addComponent(getFileDetailFileName());
    fileInfo.addComponent(getFileDetailSize());
    fileInfo.addComponent(getFileDetailFileFormat());
    return fileInfo;
}

From source file:local.ikram.assesment.web.SimpleFormComponent.java

private void initForm() {

    employeeId = new TextField("Employee Id: ");
    employeeId.setIcon(FontAwesome.FILE_PICTURE_O);
    employeeId.setRequired(true);//from w ww  . j a  va2 s  .c  o  m
    employeeId.addValidator(new StringLengthValidator("Must be btw 7 and 9 characters", 7, 9, false));

    firstName = new TextField("First Name: ");
    firstName.setIcon(FontAwesome.USER);
    firstName.setRequired(true);
    firstName.addValidator(new NullValidator("Cannot be empty", false));

    lastName = new TextField("Last Name: ");
    lastName.setIcon(FontAwesome.USER);
    lastName.setRequired(true);
    lastName.addValidator(new NullValidator("Cannot be empty", false));

    phoneNumber = new TextField("Phone Number: ");
    phoneNumber.setIcon(FontAwesome.PHONE_SQUARE);
    phoneNumber.setRequired(true);
    phoneNumber.addValidator(new NullValidator("Cannot be empty", false));

    department = new TextField("Department: ");
    department.setIcon(FontAwesome.DESKTOP);
    department.setRequired(true);
    department.addValidator(new NullValidator("Cannot be empty", false));

    saveBtn = new Button("Save", FontAwesome.SAVE);
    saveBtn.addStyleName("save-btn");
    saveBtn.addClickListener((Button.ClickEvent e) -> {
        try {
            employeeId.validate();
            firstName.validate();
            lastName.validate();
            phoneNumber.validate();
            department.validate();
            update(getEmployee());
        } catch (Validator.InvalidValueException ex) {
            Logger.getLogger(SimpleFormComponent.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(),
                    ex);
        }
    });
    deleteBtn = new Button("Delete", FontAwesome.RECYCLE);
    deleteBtn.addStyleName("delete-btn");
    deleteBtn.addClickListener((Button.ClickEvent e) -> {
        delete(getEmployee());
    });
    addBtn = new Button("Add Employee", FontAwesome.PLUS_SQUARE);
    addBtn.addStyleName("add-btn");
    addBtn.addClickListener((Button.ClickEvent e) -> {
        clear();
    });

    final HorizontalLayout buttonLayout = new HorizontalLayout(saveBtn, deleteBtn);
    buttonLayout.setSpacing(true);

    final FormLayout formLayout = new FormLayout();
    formLayout.setSizeUndefined();
    formLayout.setMargin(true);
    formLayout.setData(this);
    formLayout.addComponents(employeeId, firstName, lastName, phoneNumber, department, buttonLayout);
    setCompositionRoot(formLayout);

    setEmployee(new Employee());
    BeanFieldGroup.bindFieldsUnbuffered(employee, this);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminLoginView.java

License:Open Source License

public AdminLoginView() {

    actAdmin.setActorUI(UI.getCurrent());
    env.setActAdministrator(actAdmin.getName(), actAdmin);
    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctAdmin, actAdmin);

    log.debug("CHECK: ADMIN UI is " + actAdmin.getActorUI());

    welcomeText = new Label("Please login to access iCrash Administrator Console");
    hintText = new Label("(icrashadmin/7WXC1359)");
    welcomeText.setSizeUndefined();//  ww  w  .j av  a  2  s  .co m
    hintText.setSizeUndefined();

    // create the username input field
    username = new TextField("Login:");
    username.setWidth("120px");
    username.setInputPrompt("Admin login");
    username.setImmediate(true);

    // create the password input field
    password = new PasswordField("Password:");
    password.setWidth("120px");
    password.setValue("");
    password.setNullRepresentation("");
    password.setImmediate(true);

    // create the login button
    loginButton = new Button("Login", this);
    loginButton.setClickShortcut(KeyCode.ENTER);
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setImmediate(true);

    /*********************************************************************************************/
    Table adminMessagesTable = new Table();
    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());
    adminMessagesTable.setCaption("Administrator messages");
    //   adminMessagesTable.setVisibleColumns("inputEvent", "message");
    /*********************************************************************************************/

    FormLayout FL = new FormLayout(username, password, loginButton);

    VerticalLayout welcomeLayout = new VerticalLayout(welcomeText, /*hintText,*/ FL);
    VerticalLayout leftVL = new VerticalLayout(welcomeLayout);
    VerticalLayout rightVL = new VerticalLayout(adminMessagesTable);

    welcomeLayout.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);
    // welcomeLayout.setComponentAlignment(hintText, Alignment.MIDDLE_CENTER);
    welcomeLayout.setComponentAlignment(FL, Alignment.MIDDLE_CENTER);

    setSizeFull();
    FL.setSizeUndefined();
    welcomeLayout.setSizeUndefined();
    leftVL.setSizeFull();
    rightVL.setSizeFull();

    leftVL.setComponentAlignment(welcomeLayout, Alignment.MIDDLE_CENTER);
    rightVL.setComponentAlignment(adminMessagesTable, Alignment.MIDDLE_CENTER);

    addComponent(leftVL);
    addComponent(rightVL);

    setMargin(true);
    setExpandRatio(leftVL, 6);
    setExpandRatio(rightVL, 4);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileLoginView.java

License:Open Source License

public CoordMobileLoginView(String CoordID) {
    CtCoordinator ctCoordinator = (CtCoordinator) sys
            .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID)));
    ActCoordinator actCoordinator = env.getActCoordinator(ctCoordinator.login);

    actCoordinator.setActorUI(UI.getCurrent());

    env.setActCoordinator(actCoordinator.getName(), actCoordinator);

    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
    IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);

    setCaption("Login to Coord " + ctCoordinator.login.toString());

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);//w  ww  . ja v  a2 s . c  o  m

    VerticalComponentGroup group = new VerticalComponentGroup();
    layout.addComponent(group);

    VerticalLayout loginExtLayout = new VerticalLayout();
    loginExtLayout.setSizeFull();
    group.addComponent(loginExtLayout);

    FormLayout loginIntLayout = new FormLayout();
    loginIntLayout.setSizeUndefined();
    loginExtLayout.addComponent(loginIntLayout);

    loginExtLayout.setComponentAlignment(loginIntLayout, Alignment.MIDDLE_CENTER);

    login.setInputPrompt("Coord login");
    pwd.setValue("");
    pwd.setNullRepresentation("");

    loginBtn.setClickShortcut(KeyCode.ENTER);

    loginIntLayout.addComponents(login, pwd, loginBtn);

    ///////////////////////////////////////////////////////////////////////////////////

    Grid messagesTable = new Grid();
    messagesTable.setContainerDataSource(actCoordinator.getMessagesDataSource());
    messagesTable.setSizeUndefined();

    VerticalLayout tableLayout = new VerticalLayout();
    tableLayout.setSizeFull();

    group.addComponent(tableLayout);
    tableLayout.addComponent(messagesTable);

    tableLayout.setComponentAlignment(messagesTable, Alignment.MIDDLE_CENTER);

    ///////////////////////////////////////////////////////////////////////////////////

    loginBtn.addClickListener(event -> {
        PtBoolean res;
        try {
            res = actCoordinator.oeLogin(new DtLogin(new PtString(login.getValue())),
                    new DtPassword(new PtString(pwd.getValue())));
            log.info("oeLogin returned " + res.getValue());

            if (res.getValue()) {
                log.debug("After actCoordinator.oeLogin: JUST LOGGED IN, so Coord's vpIsLogged = "
                        + ctCoordinator.vpIsLogged.getValue());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        // refreshing this view forces redirection of the user
        // to the view, where he should go now, be it CoordLoginView or CoordAuthView
        Page.getCurrent().reload();

        actCoordinator.setActorUI(UI.getCurrent());
        env.setActCoordinator(actCoordinator.getName(), actCoordinator);

        IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
        IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);
    });
}

From source file:org.jpos.qi.login.LoginView.java

License:Open Source License

private FormLayout createForm() {
    FormLayout formLayout = new FormLayout();
    formLayout.setMargin(false);/*  ww  w .j a  va2s  . c o m*/
    formLayout.setSizeUndefined();

    binder = new Binder<>(String.class);
    username = new TextField(app.getMessage("login.username"));
    username.setMaxLength(60);

    binder.forField(username)
            .withValidator(new RegexpValidator(
                    app.getMessage("errorMessage.invalidField", username.getCaption()), USERNAME_PATTERN))
            .bind(string -> string, null);
    binder.setBean("");
    username.focus();
    username.setReadOnly(false);
    password = new PasswordField();
    password.setCaption(app.getMessage("login.password"));
    password.setMaxLength(64);
    binder.forField(password).asRequired(app.getMessage("errorMessage.req", password.getCaption()))
            .withValidator(new RegexpValidator(
                    app.getMessage("errorMessage.invalidField", password.getCaption()), PASSWORD_PATTERN))
            .bind(string -> string, null);
    password.setReadOnly(false);

    rememberMe = new CheckBox(app.getMessage("login.remember"));
    rememberMe.setDescription(app.getMessage("login.rememberDesc"));

    formLayout.addComponent(username);
    formLayout.addComponent(password);
    if (helper.isRememberEnabled())
        formLayout.addComponent(rememberMe);
    return formLayout;
}

From source file:org.opennms.netmgt.vaadin.core.KeyValueInputDialogWindow.java

License:Open Source License

/**
 * Constructor responsible for creating new instances of this class
 *
 * @param caption   the window's title//w w  w .  j av  a  2 s  .  c o  m
 * @param keyName   the title of the key input field
 * @param valueName the title of the value input field
 */
public KeyValueInputDialogWindow(String caption, String keyName, String valueName) {
    super(caption);

    /**
     * set window properties
     */
    setModal(true);
    setClosable(false);
    setResizable(false);

    /**
     * create the main layout
     */
    VerticalLayout verticalLayout = new VerticalLayout();

    /**
     * add the key input field
     */
    m_keyInputField = new TextField(keyName);

    m_keyInputField.setValue("");
    m_keyInputField.setId("keyField");
    m_keyInputField.selectAll();
    m_keyInputField.setImmediate(true);
    m_keyInputField.focus();

    /**
     * add the value input field
     */
    m_valueInputField = new TextField(valueName);

    m_valueInputField.setValue("");
    m_valueInputField.setId("valueField");
    m_valueInputField.selectAll();
    m_valueInputField.setImmediate(true);

    /**
     * create nested FormLayout instance
     */
    FormLayout formLayout = new FormLayout();
    formLayout.setSizeUndefined();
    formLayout.setMargin(true);
    formLayout.addComponent(m_keyInputField);
    formLayout.addComponent(m_valueInputField);

    /**
     * add the buttons in a horizontal layout
     */
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    horizontalLayout.setWidth("100%");

    /**
     * create cancel button
     */
    m_cancelButton = new Button("Cancel");
    m_cancelButton.setId("cancelBtn");
    m_cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    m_cancelButton.addClickListener(this);

    horizontalLayout.addComponent(m_cancelButton);
    horizontalLayout.setExpandRatio(m_cancelButton, 1);
    horizontalLayout.setComponentAlignment(m_cancelButton, Alignment.TOP_RIGHT);

    /**
     * create ok button
     */
    m_okButton = new Button("OK");
    m_okButton.setId("okBtn");
    m_okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    m_okButton.addClickListener(this);

    horizontalLayout.addComponent(m_okButton);
    formLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(formLayout);

    addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent event) {
            if (m_focusKey) {
                m_keyInputField.focus();
            } else {
                m_valueInputField.focus();
            }
        }
    });

    /**
     * the close listener
     */
    addCloseListener(this);

    /**
     * set the content
     */
    setContent(verticalLayout);
}

From source file:org.opennms.netmgt.vaadin.core.StringInputDialogWindow.java

License:Open Source License

/**
 * Constructor responsible for creating new instances of this class
 *
 * @param caption   the window's title// ww w.ja  va  2  s .co  m
 * @param fieldName the title of the input field
 */
public StringInputDialogWindow(String caption, String fieldName) {
    super(caption);

    /**
     * set window properties
     */
    setModal(true);
    setClosable(false);
    setResizable(false);

    /**
     * create the main layout
     */
    VerticalLayout verticalLayout = new VerticalLayout();

    /**
     * add the input field
     */
    m_inputField = new TextField(fieldName);

    m_inputField.setValue("");
    m_inputField.focus();
    m_inputField.selectAll();
    m_inputField.setImmediate(true);

    /**
     * create nested FormLayout instance
     */
    FormLayout formLayout = new FormLayout();
    formLayout.setSizeUndefined();
    formLayout.setMargin(true);
    formLayout.addComponent(m_inputField);

    /**
     * add the buttons in a horizontal layout
     */
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    horizontalLayout.setWidth("100%");

    /**
     * create cancel button
     */
    m_cancelButton = new Button("Cancel");
    m_cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    m_cancelButton.addClickListener(this);

    horizontalLayout.addComponent(m_cancelButton);
    horizontalLayout.setExpandRatio(m_cancelButton, 1);
    horizontalLayout.setComponentAlignment(m_cancelButton, Alignment.TOP_RIGHT);

    /**
     * create ok button
     */
    m_okButton = new Button("OK");
    m_okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    m_okButton.addClickListener(this);

    horizontalLayout.addComponent(m_okButton);
    formLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(formLayout);

    /**
     * the close listener
     */
    addCloseListener(this);

    /**
     * set the content
     */
    setContent(verticalLayout);
}

From source file:org.ozkar.vaadinBootstrapp.login.LoginPage.java

public LoginPage() {

    final VerticalLayout root = new VerticalLayout();
    final FormLayout loginForm = new FormLayout();

    txtUsername.setRequired(true);/*from  ww w.java 2s .c  om*/
    txtPassword.setRequired(true);
    btnOk.setClickShortcut(KeyCode.ENTER);

    root.addComponent(loginForm);
    root.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
    root.setSizeFull();

    loginForm.addComponent(txtUsername);
    loginForm.addComponent(txtPassword);
    loginForm.addComponent(btnOk);

    loginForm.setSpacing(true);
    loginForm.setMargin(new MarginInfo(true, true, true, false));
    loginForm.setCaption(":::LOGIN:::");
    loginForm.setSizeUndefined();

    this.setSizeFull();
    this.setCompositionRoot(root);

    /* Event Handling */
    btnOk.addClickListener((Button.ClickEvent event) -> {

        User user = User.getUser(txtUsername.getValue());

        if (AuthUtils.validUser(user, txtPassword.getValue())) {
            Notification.show("Bienvenido...");
            AuthUtils.logIn(getUI(), user);
            getUI().getNavigator().navigateTo(HomePage.URL);
        } else {
            Notification.show("Usuario o Contrasea Incorrecto.");
        }
    });

}