Example usage for com.vaadin.ui FormLayout setComponentAlignment

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

Introduction

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

Prototype

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

Source Link

Usage

From source file:com.etest.view.testbank.CellCaseWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);// ww  w . j a v a2  s  .  co m

    subject.setCaption("Subject: ");
    subject.setWidth("50%");
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    form.addComponent(subject);

    topic.setCaption("Topic: ");
    topic.setWidth("80%");
    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(topic);

    caseTopic = new TextArea();
    caseTopic.setCaption("Case: ");
    caseTopic.setWidth("100%");
    caseTopic.setRows(5);
    form.addComponent(caseTopic);

    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setWidth("100%");
    hlayout.setSpacing(true);

    Button save = new Button("SAVE");
    save.setWidth("200px");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button modify = new Button("MODIFY");
    modify.setWidth("200px");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.setEnabled(UserAccess.approve());
    approve.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("200px");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.setEnabled(UserAccess.delete());
    delete.addClickListener(buttonClickListener);

    if (getCellCaseId() != 0) {
        CellCase cc = ccs.getCellCaseById(getCellCaseId());
        subject.setValue(cc.getCurriculumId());
        topic.setValue(cc.getSyllabusId());
        caseTopic.setValue(cc.getCaseTopic());

        approve.setVisible(cc.getApprovalStatus() == 0);
        hlayout.addComponent(approve);
        hlayout.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(modify);
        hlayout.setComponentAlignment(modify, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(delete);
        hlayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);
    } else {
        hlayout.addComponent(save);
        hlayout.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
    }

    form.addComponent(hlayout);
    form.setComponentAlignment(hlayout, Alignment.MIDDLE_RIGHT);

    return form;
}

From source file:com.haulmont.cuba.web.LoginWindow.java

License:Apache License

protected FormLayout createLoginFormLayout(int fieldWidth, boolean localesSelectVisible) {
    FormLayout loginFormLayout = new FormLayout();
    loginFormLayout.setStyleName("cuba-login-form");
    loginFormLayout.setSpacing(true);/*from   www .java  2s .co m*/
    loginFormLayout.setSizeUndefined();

    loginField.setCaption(messages.getMainMessage("loginWindow.loginField", resolvedLocale));
    loginFormLayout.addComponent(loginField);
    loginField.setWidth(fieldWidth + "px");
    loginField.setStyleName("username-field");
    loginFormLayout.setComponentAlignment(loginField, Alignment.MIDDLE_CENTER);

    passwordField.setCaption(messages.getMainMessage("loginWindow.passwordField", resolvedLocale));
    passwordField.setWidth(fieldWidth + "px");
    passwordField.setAutocomplete(true);
    passwordField.setStyleName("password-field");
    loginFormLayout.addComponent(passwordField);
    loginFormLayout.setComponentAlignment(passwordField, Alignment.MIDDLE_CENTER);

    if (localesSelectVisible) {
        localesSelect.setCaption(messages.getMainMessage("loginWindow.localesSelect", resolvedLocale));
        localesSelect.setWidth(fieldWidth + "px");
        localesSelect.setNullSelectionAllowed(false);
        loginFormLayout.addComponent(localesSelect);
        loginFormLayout.setComponentAlignment(localesSelect, Alignment.MIDDLE_CENTER);
    }

    if (rememberMeAllowed) {
        rememberMeCheckBox.setCaption(messages.getMainMessage("loginWindow.rememberMe", resolvedLocale));
        rememberMeCheckBox.setStyleName("remember-me");
        loginFormLayout.addComponent(rememberMeCheckBox);
        loginFormLayout.setComponentAlignment(rememberMeCheckBox, Alignment.MIDDLE_CENTER);
    }

    okButton.setCaption(messages.getMainMessage("loginWindow.okButton", resolvedLocale));
    okButton.addClickListener(submitListener);
    okButton.setStyleName("cuba-login-submit");
    okButton.setIcon(WebComponentsHelper.getIcon("app/images/login-button.png"));

    loginFormLayout.addComponent(okButton);
    loginFormLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    return loginFormLayout;
}

From source file:com.save.employee.request.ViewRLWindow.java

FormLayout buildFormLayout() {
    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);/*from www  . j  a v  a  2 s  . co m*/

    LiquidationForm lf = rls.getRLById(getRequestId());

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    controlNo.setValue(String.valueOf(lf.getControlNo()));
    controlNo.setEnabled(false);
    f.addComponent(controlNo);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    dateOfActivity.setValue(lf.getDateOfActivity());
    dateOfActivity.setEnabled(false);
    f.addComponent(dateOfActivity);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    area.setValue(lf.getAreaId());
    area.setEnabled(false);
    f.addComponent(area);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    activity.setValue(lf.getActivity());
    activity.setEnabled(false);
    f.addComponent(activity);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    venue.setValue(lf.getVenue());
    venue.setEnabled(false);
    f.addComponent(venue);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    requirements.setValue(lf.getRequirements());
    requirements.setEnabled(false);
    f.addComponent(requirements);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");
    h1.setCaption("Request Lodging");
    h1.addStyleName("light");
    //        h1.setReadOnly(true);

    requestLodgingPax = new TextField();
    requestLodgingPax.setWidth("100%");
    requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingPax.addStyleName("align-right");
    requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax()));
    requestLodgingPax.setEnabled(false);
    h1.addComponent(requestLodgingPax);

    requestLodgingBudget = new TextField();
    requestLodgingBudget.setWidth("100%");
    requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingBudget.addStyleName("align-right");
    requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget()));
    requestLodgingBudget.setEnabled(false);
    h1.addComponent(requestLodgingBudget);

    requestLodgingAmount = new TextField();
    requestLodgingAmount.setWidth("100%");
    requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingAmount.addStyleName("align-right");
    requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount()));
    requestLodgingAmount.setEnabled(false);
    h1.addComponent(requestLodgingAmount);

    f.addComponent(h1);
    f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidth("100%");
    h2.setCaption("Request Meals");
    //        h2.setReadOnly(true);

    requestMealsPax = new TextField();
    requestMealsPax.setWidth("100%");
    requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsPax.addStyleName("align-right");
    requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax()));
    requestMealsPax.setEnabled(false);
    h2.addComponent(requestMealsPax);

    requestMealsBudget = new TextField();
    requestMealsBudget.setWidth("100%");
    requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsBudget.addStyleName("align-right");
    requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget()));
    requestMealsBudget.setEnabled(false);
    h2.addComponent(requestMealsBudget);

    requestMealsAmount = new TextField();
    requestMealsAmount.setWidth("100%");
    requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsAmount.addStyleName("align-right");
    requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount()));
    requestMealsAmount.setEnabled(false);
    h2.addComponent(requestMealsAmount);

    f.addComponent(h2);
    f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setWidth("100%");
    h3.setCaption("Liquidated Lodging");
    //        h3.setReadOnly(true);

    liquidateLodgingPax = new TextField();
    liquidateLodgingPax.setWidth("100%");
    liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingPax.addStyleName("align-right");
    liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax()));
    liquidateLodgingPax.setEnabled(false);
    h3.addComponent(liquidateLodgingPax);

    liquidateLodgingBudget = new TextField();
    liquidateLodgingBudget.setWidth("100%");
    liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingBudget.addStyleName("align-right");
    liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget()));
    liquidateLodgingBudget.setEnabled(false);
    h3.addComponent(liquidateLodgingBudget);

    liquidateLodgingAmount = new TextField();
    liquidateLodgingAmount.setWidth("100%");
    liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingAmount.addStyleName("align-right");
    liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount()));
    liquidateLodgingAmount.setEnabled(false);
    h3.addComponent(liquidateLodgingAmount);

    f.addComponent(h3);
    f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setWidth("100%");
    h4.setCaption("Liquidated Meals");
    h4.setReadOnly(true);

    liquidateMealsPax = new TextField();
    liquidateMealsPax.setWidth("100%");
    liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsPax.addStyleName("align-right");
    liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax()));
    liquidateMealsPax.setEnabled(false);
    h4.addComponent(liquidateMealsPax);

    liquidateMealsBudget = new TextField();
    liquidateMealsBudget.setWidth("100%");
    liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsBudget.addStyleName("align-right");
    liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget()));
    liquidateMealsBudget.setEnabled(false);
    h4.addComponent(liquidateMealsBudget);

    liquidateMealsAmount = new TextField();
    liquidateMealsAmount.setWidth("100%");
    liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsAmount.addStyleName("align-right");
    liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount()));
    liquidateMealsAmount.setEnabled(false);
    h4.addComponent(liquidateMealsAmount);

    f.addComponent(h4);
    f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);

    reimbursement = new TextField("Reimbursement: ");
    reimbursement.setWidth("50%");
    reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    reimbursement.setValue(String.valueOf(lf.getReimbursedAmount()));
    reimbursement.setEnabled(false);
    f.addComponent(reimbursement);

    f.addStyleName("light");
    f.setReadOnly(true);

    return f;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.LoginDialog.java

License:Apache License

public void init() {
    //Layout//from ww  w  .j a v a 2s.  c o m
    FormLayout layout = new FormLayout();
    setContent(layout);
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.addComponent(loginButton);
    hlayout.addComponent(cancelButton);
    layout.addComponent(name);
    layout.addComponent(password);
    name.focus();
    name.setWidth(100, Unit.PERCENTAGE);
    StringLengthValidator nameVal = new StringLengthValidator(Lookup.getDefault()
            .lookup(InternationalizationProvider.class).translate("password.length.message"));
    nameVal.setMinLength(5);
    name.addValidator(nameVal);
    name.setImmediate(true);
    StringLengthValidator passVal = new StringLengthValidator(
            Lookup.getDefault().lookup(InternationalizationProvider.class).translate("password.empty.message"));
    passVal.setMinLength(3);
    password.addValidator(passVal);
    password.setImmediate(true);
    password.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(hlayout);
    layout.setComponentAlignment(name, Alignment.TOP_LEFT);
    layout.setComponentAlignment(password, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(hlayout, Alignment.BOTTOM_LEFT);
    layout.setSpacing(true);
    layout.setMargin(true);

    // Keyboard navigation - enter key is a shortcut to login
    addActionHandler(new Handler() {
        @Override
        public Action[] getActions(Object target, Object sender) {
            return new Action[] { enterKey };
        }

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            tryToLogIn();
        }
    });
}

From source file:org.ow2.sirocco.cloudmanager.AddressAssociateDialog.java

License:Open Source License

public AddressAssociateDialog(final List<MachineChoice> choices, final DialogCallback callback) {
    super("Associate Address");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);/*w  ww  .j  a  v a 2  s .c  o m*/
    content.setWidth("400px");
    content.setHeight("150px");

    this.machineBox = new ComboBox("Machine");
    this.machineBox.setRequired(true);
    this.machineBox.setTextInputAllowed(false);
    this.machineBox.setNullSelectionAllowed(false);
    this.machineBox.setInputPrompt("select machine");
    this.machineBox.setImmediate(true);
    content.addComponent(this.machineBox);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

    for (MachineChoice choice : choices) {
        this.machineBox.addItem(choice.id);
        this.machineBox.setItemCaption(choice.id, choice.name);
    }

}

From source file:org.ow2.sirocco.cloudmanager.VolumeAttachDialog.java

License:Open Source License

public VolumeAttachDialog(final List<MachineChoice> choices, final DialogCallback callback) {
    super("Attach Volume");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);/*from   www.j a v a 2s  .  c om*/
    content.setWidth("400px");
    content.setHeight("150px");

    this.machineBox = new ComboBox("Machine");
    this.machineBox.setRequired(true);
    this.machineBox.setTextInputAllowed(false);
    this.machineBox.setNullSelectionAllowed(false);
    this.machineBox.setInputPrompt("select machine");
    this.machineBox.setImmediate(true);
    content.addComponent(this.machineBox);

    this.deviceField = new TextField("Device location");
    this.deviceField.setRequired(true);
    this.deviceField.setWidth("80%");
    this.deviceField.setRequired(true);
    this.deviceField.setRequiredError("Please provide a device location");
    this.deviceField.setImmediate(true);
    content.addComponent(this.deviceField);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

    for (MachineChoice choice : choices) {
        this.machineBox.addItem(choice.id);
        this.machineBox.setItemCaption(choice.id, choice.name);
    }

}