Example usage for com.vaadin.ui FormLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:org.opencms.ui.dialogs.CmsSiteSelectDialog.java

License:Open Source License

/**
 * Initializes the form component.<p>
 *
 * @return the form component//from  ww w  .ja  v  a 2  s. co  m
 */
private FormLayout initForm() {

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

    IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY);
    m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
    m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot());
    form.addComponent(m_siteComboBox);
    ValueChangeListener changeListener = new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            submit();
        }
    };
    m_siteComboBox.addValueChangeListener(changeListener);
    return form;
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Initializes the lower right component {@link #m_lowerRightComponent}, with all its components, i.e.,
 * the "Add key" input field {@link #m_addKeyInput} and the "Add key" button.
 *//*www.  j  a  v a  2 s  .  c  o m*/
private void initLowerRightComponent() {

    initAddKeyInput();

    Component addKeyButton = createAddKeyButton();
    HorizontalLayout addKeyWrapper = new HorizontalLayout(addKeyButton);
    addKeyWrapper.setComponentAlignment(addKeyButton, Alignment.MIDDLE_CENTER);
    addKeyWrapper.setHeight("100%");
    addKeyWrapper.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX);

    FormLayout inputForm = new FormLayout(m_addKeyInput);
    inputForm.setWidth("100%");
    HorizontalLayout lowerRight = new HorizontalLayout();
    lowerRight.setWidth("100%");
    lowerRight.addComponent(inputForm);
    lowerRight.addComponent(addKeyWrapper);
    lowerRight.setExpandRatio(inputForm, 1f);
    m_lowerRightComponent = lowerRight;

}

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);// ww  w .  ja v  a 2s  . com
    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.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  ww  .ja va2s .  c o 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);//from w  w w  . j ava2 s .  c  o  m
    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
        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. ja va 2s.  c o  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);/*from  w  w w.ja  v  a 2s . 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);

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

}