Example usage for com.vaadin.ui HorizontalLayout setComponentAlignment

List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:org.accelerators.activiti.admin.ui.UserCreateForm.java

License:Open Source License

public UserCreateForm(AdminApp application) {

    // Set application reference
    this.app = application;

    // Enable buffering so that commit() must be called for the form.
    setWriteThrough(false);/*from   w  ww.  j  a  v  a2  s .c om*/

    // Set the form to act immediately on user input.
    setImmediate(true);

    // Set form size
    setSizeFull();

    // Setup footer layout
    HorizontalLayout footer = new HorizontalLayout();
    footer.setSpacing(true);
    footer.setWidth("100%");
    footer.setVisible(true);

    // Add footer
    setFooter(footer);

    // Init buttons
    create = new Button(app.getMessage(Messages.Create), (ClickListener) this);
    close = new Button(app.getMessage(Messages.Close), (ClickListener) this);
    reset = new Button(app.getMessage(Messages.Reset), this, "discard");

    // Set button grid
    GridLayout grid = new GridLayout(3, 1);
    grid.addComponent(create, 0, 0);
    grid.addComponent(reset, 1, 0);
    grid.addComponent(close, 2, 0);
    grid.setSpacing(true);

    // Add grid to footer
    footer.addComponent(grid);

    // Right align buttons in footer
    footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT);

    // Get all available groups
    groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups());

    // Set column headers
    groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups));
    groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups));

    // Propagate changes directly
    groups.setImmediate(true);

    // Max width
    groups.setWidth("100%");

    // Field factory for over riding how fields are created
    setFormFieldFactory(new DefaultFieldFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {

            Field field = super.createField(item, propertyId, uiContext);

            field.setWidth("100%");

            // field.setVisible(false);

            if (propertyId.equals("id")) {
                TextField tf = (TextField) field;

                tf.setVisible(true);

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field
                tf.setRequired(true);

                // Set validator example, should not be restricted in the
                // admin ui
                // tf.addValidator(new
                // RegexpValidator("^[a-zA-Z0-9_-]{4,20}",
                // app.getMessage(Messages.InvalidUsername)));

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing));

            } else if (propertyId.equals("password")) {
                TextField tf = (TextField) field;

                tf.setVisible(true);

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field
                tf.setRequired(true);

                // Set as secret (todo: use password field instead of text
                // field)
                tf.setSecret(true);

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing));

            } else if (propertyId.equals("email")) {
                TextField tf = (TextField) field;

                tf.setVisible(true);

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field, should not be required by default
                // in the admin ui
                // tf.setRequired(true);

                // Set error message
                // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing));

                /* Add a validator for email and make it required */
                field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError)));

            } else if (propertyId.equals("firstName")) {
                TextField tf = (TextField) field;

                tf.setVisible(true);

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            } else if (propertyId.equals("lastName")) {
                TextField tf = (TextField) field;

                tf.setVisible(true);

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            }

            return field;
        }
    });

}

From source file:org.accelerators.activiti.admin.ui.UserEditForm.java

License:Open Source License

public UserEditForm(AdminApp application) {

    // Set application reference
    this.app = application;

    // Enable buffering so that commit() must be called for the form.
    setWriteThrough(false);//from  w  ww.j av  a  2s  .  co  m

    // Set the form to act immediately on user input.
    setImmediate(true);

    // Set form size
    setSizeFull();

    // Setup footer layout
    HorizontalLayout footer = new HorizontalLayout();
    footer.setSpacing(true);
    footer.setWidth("100%");
    footer.setVisible(true);

    // Add footer
    setFooter(footer);

    // Init buttons
    save = new Button(app.getMessage(Messages.Save), (ClickListener) this);
    close = new Button(app.getMessage(Messages.Close), (ClickListener) this);
    reset = new Button(app.getMessage(Messages.Reset), this, "discard");

    // Set button grid
    GridLayout grid = new GridLayout(3, 1);
    grid.addComponent(save, 0, 0);
    grid.addComponent(reset, 1, 0);
    grid.addComponent(close, 2, 0);
    grid.setSpacing(true);

    // Add grid to footer
    footer.addComponent(grid);

    // Right align buttons in footer
    footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT);

    // Get all available groups
    groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups());

    // Set column headers
    groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups));
    groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups));

    // Propagate changes directly
    groups.setImmediate(true);

    // Max width
    groups.setWidth("100%");

    // Field factory for over riding how fields are created
    setFormFieldFactory(new DefaultFieldFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {

            Field field = super.createField(item, propertyId, uiContext);

            if (propertyId.equals("id")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as read-only. Changing the id will create a new user.
                tf.setReadOnly(true);

                // Set as required field
                //tf.setRequired(true);

                // Set validator example, should not be restricted in the
                // admin ui
                // tf.addValidator(new
                // RegexpValidator("^[a-zA-Z0-9_-]{4,20}",
                // app.getMessage(Messages.InvalidUsername)));

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing));

            } else if (propertyId.equals("password")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field
                tf.setRequired(true);

                // Set as secret (todo: use password field instead of text
                // field)
                tf.setSecret(true);

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing));

            } else if (propertyId.equals("email")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field, should not be required by default
                // in the admin ui
                // tf.setRequired(true);

                // Set error message
                // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing));

                /* Add a validator for email and make it required */
                field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError)));

            } else if (propertyId.equals("firstName")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            } else if (propertyId.equals("lastName")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            }

            field.setWidth("100%");
            return field;
        }
    });

}

From source file:org.activiti.administrator.ui.UserEditForm.java

License:Apache License

public UserEditForm(AdminApp application) {

    // Set application reference
    this.app = application;

    // Enable buffering so that commit() must be called for the form.
    setWriteThrough(false);//w  w  w . j  av a 2 s.co m

    // Set the form to act immediately on user input.
    setImmediate(true);

    // Set form size
    setSizeFull();

    // Setup footer layout
    HorizontalLayout footer = new HorizontalLayout();
    footer.setSpacing(true);
    footer.setWidth("100%");
    footer.setVisible(true);

    // Add footer
    setFooter(footer);

    // Init buttons
    save = new Button(app.getMessage(Messages.Save), (ClickListener) this);
    close = new Button(app.getMessage(Messages.Close), (ClickListener) this);
    reset = new Button(app.getMessage(Messages.Reset), this, "discard");

    // Set button grid
    GridLayout grid = new GridLayout(3, 1);
    grid.addComponent(save, 0, 0);
    grid.addComponent(reset, 1, 0);
    grid.addComponent(close, 2, 0);
    grid.setSpacing(true);

    // Add grid to footer
    footer.addComponent(grid);

    // Right align buttons in footer
    footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT);

    // Get all available groups
    groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups());

    // Set column headers
    groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups));
    groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups));

    // Propagate changes directly
    groups.setImmediate(true);

    // Max width
    groups.setWidth("100%");

    // Field factory for over riding how fields are created
    setFormFieldFactory(new DefaultFieldFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {

            Field field = super.createField(item, propertyId, uiContext);

            if (propertyId.equals("id")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as read-only. Changing the id will create a new user.
                tf.setReadOnly(true);

                // Set as required field
                // tf.setRequired(true);

                // Set validator example, should not be restricted in the
                // admin ui
                // tf.addValidator(new
                // RegexpValidator("^[a-zA-Z0-9_-]{4,20}",
                // app.getMessage(Messages.InvalidUsername)));

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing));

            } else if (propertyId.equals("password")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field
                tf.setRequired(true);

                // Set as secret (todo: use password field instead of text
                // field)
                tf.setSecret(true);

                // Set error message
                tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing));

            } else if (propertyId.equals("email")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

                // Set as required field, should not be required by default
                // in the admin ui
                // tf.setRequired(true);

                // Set error message
                // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing));

                /* Add a validator for email and make it required */
                field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError)));

            } else if (propertyId.equals("firstName")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            } else if (propertyId.equals("lastName")) {
                TextField tf = (TextField) field;

                // Do not display "null" to the user when the field is empty
                tf.setNullRepresentation("");

            }

            field.setWidth("100%");
            return field;
        }
    });

}

From source file:org.activiti.editor.ui.DeployModelPopupWindow.java

License:Apache License

protected void initButtons(I18nManager i18nManager) {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);//w ww  . ja v  a 2  s.co  m
    buttonLayout.setWidth(100, UNITS_PERCENTAGE);
    addComponent(buttonLayout);

    deployButton = new Button(i18nManager.getMessage(Messages.MODEL_DEPLOY_BUTTON_DEPLOY));
    buttonLayout.addComponent(deployButton);
    buttonLayout.setComponentAlignment(deployButton, Alignment.BOTTOM_CENTER);
}

From source file:org.activiti.explorer.ui.custom.SelectUsersPopupWindow.java

License:Apache License

protected void initSelectMyselfButton(HorizontalLayout searchLayout) {
    final LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();
    if (ignoredUserIds == null || !ignoredUserIds.contains(loggedInUser.getId())) {
        Button meButton = new Button(i18nManager.getMessage(Messages.PEOPLE_SELECT_MYSELF));
        meButton.setIcon(Images.USER_16);
        searchLayout.addComponent(meButton);
        searchLayout.setComponentAlignment(meButton, Alignment.MIDDLE_LEFT);

        if (multiSelect) {
            meButton.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectUser(loggedInUser.getId(), loggedInUser.getFullName());
                }//from  w  w  w.j  a v a  2s.  c o  m
            });
        } else {
            meButton.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    addMatchingUser(loggedInUser.getId(), loggedInUser.getFullName());
                    matchingUsersTable.select(loggedInUser.getId());
                    fireEvent(new SubmitEvent(doneButton, SubmitEvent.SUBMITTED));
                    close();
                }
            });
        }
    }
}

From source file:org.activiti.explorer.ui.form.FormPropertiesForm.java

License:Apache License

protected void initButtons() {
    submitFormButton = new Button();
    cancelFormButton = new Button();

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*  www.j a  v a2s  . c o m*/
    buttons.setWidth(100, UNITS_PERCENTAGE);
    buttons.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    buttons.addComponent(submitFormButton);
    buttons.setComponentAlignment(submitFormButton, Alignment.BOTTOM_RIGHT);

    buttons.addComponent(cancelFormButton);
    buttons.setComponentAlignment(cancelFormButton, Alignment.BOTTOM_RIGHT);

    Label buttonSpacer = new Label();
    buttons.addComponent(buttonSpacer);
    buttons.setExpandRatio(buttonSpacer, 1.0f);
    addComponent(buttons);
}

From source file:org.activiti.explorer.ui.management.admin.AdminCompletedInstancesPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);//from   w w w.  j  a v a  2s  .  c  o  m
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded groupImage = new Embedded(null, Images.PROCESS_50);
    layout.addComponent(groupImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.ADMIN_COMPLETED_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.admin.AdminDatabaseSettingsPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);//  w  w  w  . j a v  a2 s . co  m
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.DATABASE_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.admin.AdminRunningInstancesPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);/*from w w  w . j  a va 2s . c o  m*/
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded groupImage = new Embedded(null, Images.PROCESS_50);
    layout.addComponent(groupImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.ADMIN_RUNNING_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}