Example usage for com.vaadin.ui FormLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

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);
    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);/*  w  ww .  j a  v  a 2 s .  c  om*/
    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.KeyPairImportDialog.java

License:Open Source License

public KeyPairImportDialog(final DialogCallback callback) {
    super("Import Key Pair");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();/*from  w  w  w.ja v  a  2  s. co  m*/
    content.setMargin(true);
    content.setSpacing(true);
    content.setWidth("500px");
    content.setHeight("250px");

    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);
    form.setSpacing(true);

    this.nameField = new TextField("Name");
    this.nameField.setWidth("50%");
    this.nameField.setRequired(true);
    this.nameField.setRequiredError("Please enter a name for your key pair");
    form.addComponent(this.nameField);

    this.publicKeyField = new TextArea("Public Key");
    this.publicKeyField.setWidth("100%");
    this.publicKeyField.setRequired(true);
    this.publicKeyField.setRequiredError("Please enter a name for your key pair");
    form.addComponent(this.publicKeyField);

    content.addComponent(form);

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

}

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

License:Open Source License

public SecurityGroupRuleCreationDialog(final List<SecGroupChoice> choices, final DialogCallback callback) {
    super("Add Rule");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);
    content.setWidth("500px");
    content.setHeight("350px");

    this.protocolBox = new ComboBox("IP Protocol");
    this.protocolBox.setRequired(true);
    this.protocolBox.setTextInputAllowed(false);
    this.protocolBox.setNullSelectionAllowed(false);
    this.protocolBox.setImmediate(true);
    this.protocolBox.addItem("TCP");
    this.protocolBox.addItem("UDP");
    this.protocolBox.addItem("ICMP");
    this.protocolBox.setValue("TCP");
    content.addComponent(this.protocolBox);

    this.portField = new TextField("Port range");
    this.portField.setRequired(true);
    this.portField.setWidth("80%");
    this.portField.setRequired(true);
    this.portField.setRequiredError("Please provide a port range");
    this.portField.setImmediate(true);
    content.addComponent(this.portField);

    this.sourceChoice = new OptionGroup("Source");
    this.sourceChoice.addItem("CIDR");
    this.sourceChoice.addItem("Security Group");
    this.sourceChoice.setValue("CIDR");
    this.sourceChoice.setImmediate(true);
    this.sourceChoice.addValueChangeListener(new ValueChangeListener() {

        @Override/*from   w  ww.j a  v a  2 s. c om*/
        public void valueChange(final ValueChangeEvent event) {
            boolean sourceIsCidr = SecurityGroupRuleCreationDialog.this.sourceChoice.getValue().equals("CIDR");
            SecurityGroupRuleCreationDialog.this.sourceIpRangeField.setEnabled(sourceIsCidr);
            SecurityGroupRuleCreationDialog.this.sourceSecGroupBox.setEnabled(!sourceIsCidr);
        }
    });
    content.addComponent(this.sourceChoice);

    this.sourceIpRangeField = new TextField("CIDR");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setWidth("80%");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setRequiredError("Please provide a CIDR");
    this.sourceIpRangeField.setImmediate(true);
    this.sourceIpRangeField.setValue("0.0.0.0/0");
    content.addComponent(this.sourceIpRangeField);

    this.sourceSecGroupBox = new ComboBox("Security Group");
    this.sourceSecGroupBox.setRequired(true);
    this.sourceSecGroupBox.setTextInputAllowed(false);
    this.sourceSecGroupBox.setNullSelectionAllowed(false);
    this.sourceSecGroupBox.setInputPrompt("select machine");
    this.sourceSecGroupBox.setImmediate(true);
    for (SecGroupChoice choice : choices) {
        this.sourceSecGroupBox.addItem(choice.id);
        this.sourceSecGroupBox.setItemCaption(choice.id, choice.name);
    }
    this.sourceSecGroupBox.setValue(choices.get(0).id);
    this.sourceSecGroupBox.setEnabled(false);
    content.addComponent(this.sourceSecGroupBox);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);

    this.errorLabel = new Label("                                       ");
    this.errorLabel.setStyleName("errorMsg");
    this.errorLabel.setWidth("100%");
    buttonLayout.addComponent(this.errorLabel);
    buttonLayout.setExpandRatio(this.errorLabel, 1.0f);

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

}

From source file:org.ow2.sirocco.cloudmanager.util.InputDialog.java

License:Open Source License

private InputDialog(final String title, final String name, final String initialValue, final boolean isPassword,
        final DialogCallback callback) {
    super(title);
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);/*w ww.j av  a 2  s . co  m*/
    verticalLayout.setMargin(true);

    FormLayout content = new FormLayout();
    content.setMargin(true);
    content.setWidth("400px");
    content.setHeight("100px");

    this.textField = isPassword ? new PasswordField(name) : new TextField(name);
    this.textField.setRequired(true);
    this.textField.setWidth("100%");
    this.textField.setRequired(true);
    this.textField.setRequiredError("Please provide a " + name);
    this.textField.setImmediate(true);
    if (initialValue != null) {
        this.textField.setValue(initialValue);
    }
    content.addComponent(this.textField);

    verticalLayout.addComponent(content);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    Label spacer = new Label("");
    buttonLayout.addComponent(spacer);
    spacer.setWidth("100%");
    buttonLayout.setExpandRatio(spacer, 1f);
    this.okButton = new Button("Ok", this);
    this.okButton.setClickShortcut(KeyCode.ENTER, null);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.setClickShortcut(KeyCode.ESCAPE, null);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    // content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    verticalLayout.addComponent(buttonLayout);

    this.setContent(verticalLayout);
}

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);
    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);//from ww  w  .  j av  a  2 s  . com
    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.ozkar.vaadinBootstrapp.login.LoginPage.java

public LoginPage() {

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

    txtUsername.setRequired(true);/*from w  ww  .  j  a v  a2  s. c  o  m*/
    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.");
        }
    });

}

From source file:org.sensorhub.ui.GenericConfigForm.java

License:Mozilla Public License

@Override
public void build(String title, MyBeanItem<? extends Object> beanItem) {
    List<Field<?>> labels = new ArrayList<Field<?>>();
    List<Field<?>> textBoxes = new ArrayList<Field<?>>();
    List<Field<?>> listBoxes = new ArrayList<Field<?>>();
    List<Field<?>> numberBoxes = new ArrayList<Field<?>>();
    List<Field<?>> checkBoxes = new ArrayList<Field<?>>();
    List<Component> otherWidgets = new ArrayList<Component>();

    // prepare header and form layout
    setSpacing(true);//from  w  w  w.j a  va  2  s  .  c  o  m

    // add main form widgets
    FormLayout form = new FormLayout();
    form.setWidth(100.0f, Unit.PERCENTAGE);
    form.setMargin(false);

    if (title != null) {
        Label sectionLabel = new Label(title);
        sectionLabel.addStyleName(STYLE_H3);
        sectionLabel.addStyleName(STYLE_COLORED);
        form.addComponent(sectionLabel);
    }

    // add widget for each visible attribute
    if (beanItem != null) {
        fieldGroup = new FieldGroup(beanItem);
        for (Object propId : fieldGroup.getUnboundPropertyIds()) {
            Property<?> prop = fieldGroup.getItemDataSource().getItemProperty(propId);

            // sub objects with multiplicity > 1
            if (prop instanceof ContainerProperty) {
                Class<?> eltType = ((ContainerProperty) prop).getValue().getBeanType();

                // use simple table for string lists
                if (eltType == String.class) {
                    Component list = buildSimpleTable((String) propId, (ContainerProperty) prop);
                    fieldGroup.bind((Field<?>) list, propId);
                    listBoxes.add((Field<?>) list);
                }

                // else use tab sheet
                else if (!((ContainerProperty) prop).getValue().getItemIds().isEmpty()) {
                    Component subform = buildTabs((String) propId, (ContainerProperty) prop, fieldGroup);
                    otherWidgets.add(subform);
                }
            }

            // sub object
            else if (prop instanceof ComplexProperty) {
                Component subform = buildSubForm((String) propId, (ComplexProperty) prop);
                otherWidgets.add(subform);
            }

            // scalar field
            else {
                Field<?> field = null;

                try {
                    String label = null;
                    if (prop instanceof FieldProperty)
                        label = ((FieldProperty) prop).getLabel();
                    if (label == null)
                        label = DisplayUtils.getPrettyName((String) propId);

                    String desc = null;
                    if (prop instanceof FieldProperty)
                        desc = ((FieldProperty) prop).getDescription();

                    field = buildAndBindField(label, (String) propId, prop);
                    ((AbstractField<?>) field).setDescription(desc);
                } catch (Exception e) {
                    System.err.println("No UI generator for field " + propId);
                    continue;
                }

                // add to one of the widget lists so we can order by widget type
                Class<?> propType = prop.getType();
                if (propType.equals(String.class)) {
                    if (field instanceof Label)
                        labels.add(field);
                    else
                        textBoxes.add(field);
                } else if (Enum.class.isAssignableFrom(propType))
                    numberBoxes.add(field);
                else if (Number.class.isAssignableFrom(propType))
                    numberBoxes.add(field);
                else if (field instanceof CheckBox)
                    checkBoxes.add(field);
                else
                    otherWidgets.add(field);
            }
        }
    }

    // main form
    for (Field<?> w : labels)
        form.addComponent(w);
    for (Field<?> w : textBoxes)
        form.addComponent(w);
    for (Field<?> w : listBoxes)
        form.addComponent(w);
    for (Field<?> w : numberBoxes)
        form.addComponent(w);
    for (Field<?> w : checkBoxes)
        form.addComponent(w);
    addComponent(form);

    // sub forms
    for (Component w : otherWidgets)
        addComponent(w);
}

From source file:pl.adrian.pieper.biuwaw.NewPartyView.java

private AbstractComponent createGiftEditor() {
    final FormLayout formLayout = new FormLayout();
    editedGift.setBuffered(false);//www.  j  a  v  a 2 s.c om
    final Button editButton = new Button("Zatwierd");
    editButton.addClickListener((event) -> {
        try {
            editedGift.commit();
        } catch (FieldGroup.CommitException ex) {
            Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    formLayout.addComponents(new Label("Edytor"), editedGift.buildAndBind("name"), editButton);

    formLayout.setMargin(true);

    return formLayout;
}

From source file:pl.exsio.frameset.vaadin.account.window.view.AccountWindowView.java

License:Open Source License

private FormLayout createForm() {
    this.form = new Form();
    this.form.setFormFieldFactory(new FramesetFieldFactory(UserImpl.class));
    this.form.setItemDataSource(this.item,
            Arrays.asList(FIELD_USERNAME, FIELD_FIRST_NAME, FIELD_lAST_NAME, FIELD_PHONE_NO));
    this.form.setBuffered(true);
    this.form.getField(FIELD_USERNAME)
            .addValidator(new EmailValidator(t("core.management.users.invalid_username")));
    Field passwordField = this.createPasswordField();
    this.form.addField(FIELD_PASSWORD, passwordField);
    Field passwordFieldRepeated = this.createPasswordRepeatedField();
    this.form.addField(FIELD_PASSWORD_REPEATED, passwordFieldRepeated);
    FormLayout formLayout = new FormLayout();
    formLayout.addComponent(this.form);
    formLayout.setMargin(true);
    HorizontalLayout controls = this.createFormControls();
    formLayout.addComponent(controls);/*from  w ww .j  a  va  2 s  . c o  m*/
    return formLayout;
}

From source file:pl.exsio.frameset.vaadin.module.util.usergen.UserGenModule.java

License:Open Source License

private Form getGeneratorForm() {

    Form form = new Form();

    form.addField("usernamePrefix", createUsernamePrefixField());
    form.addField("usernameSuffix", createUsernameSuffixField());
    form.addField("from", createFromField());
    form.addField("to", createToField());
    form.addField("groups", createGroupsField());
    form.addField("roles", createRolesField());

    form.setBuffered(true);/*w ww  . j  av a2  s .  com*/
    FormLayout layout = new FormLayout();
    layout.setMargin(true);
    form.setLayout(layout);
    return form;
}