Example usage for com.vaadin.ui GridLayout setSpacing

List of usage examples for com.vaadin.ui GridLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

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

Component buildRequestForm() {
    GridLayout glayout = new GridLayout(4, 7);
    glayout.setSizeFull();/*  w  ww .ja  v  a  2  s.c  o m*/
    glayout.setSpacing(true);
    glayout.setMargin(true);

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(controlNo, 0, 0);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    glayout.addComponent(dateOfActivity, 1, 0);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    glayout.addComponent(area, 2, 0);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(activity, 0, 1, 1, 1);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(venue, 0, 2, 1, 2);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    glayout.addComponent(requirements, 2, 1, 3, 2);

    Label lodging = new Label("Lodging: ");
    lodging.setWidthUndefined();
    glayout.addComponent(lodging, 0, 3);
    glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER);

    lodgingPax = new TextField("Pax: ");
    lodgingPax.setWidth("100%");
    lodgingPax.setValue("0");
    lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingPax.addStyleName("align-right");
    glayout.addComponent(lodgingPax, 1, 3);

    lodgingAmount = new TextField("Amount: ");
    lodgingAmount.setWidth("100%");
    lodgingAmount.setValue("0.00");
    lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingAmount.addStyleName("align-right");
    lodgingAmount.setEnabled(false);
    lodgingAmount.setImmediate(true);
    glayout.addComponent(lodgingAmount, 3, 3);

    lodgingBudget = new TextField("Budget: ");
    lodgingBudget.setWidth("100%");
    lodgingBudget.setValue("0.00");
    lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingBudget.addStyleName("align-right");
    lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> {
        if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) {
            Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE);
            return;
        }

        if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) {
            Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE);
            return;
        }

        lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim())
                * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim())));
    });
    lodgingBudget.setImmediate(true);
    glayout.addComponent(lodgingBudget, 2, 3);

    Label meals = new Label("Meals: ");
    meals.setWidthUndefined();
    glayout.addComponent(meals, 0, 4);
    glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER);

    mealsPax = new TextField("Pax: ");
    mealsPax.setWidth("100%");
    mealsPax.setValue("0");
    mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsPax.addStyleName("align-right");
    glayout.addComponent(mealsPax, 1, 4);

    mealsAmount = new TextField("Amount: ");
    mealsAmount.setWidth("100%");
    mealsAmount.setValue("0.00");
    mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsAmount.addStyleName("align-right");
    mealsAmount.setEnabled(false);
    mealsAmount.setImmediate(liquidated);
    glayout.addComponent(mealsAmount, 3, 4);

    mealsBudget = new TextField("Budget: ");
    mealsBudget.setWidth("100%");
    mealsBudget.setValue("0.00");
    mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsBudget.addStyleName("align-right");
    mealsBudget.addValueChangeListener((ValueChangeEvent event) -> {
        if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) {
            Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE);
            return;
        }

        if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) {
            Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE);
            return;
        }

        mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim())
                * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim())));
    });
    mealsAmount.setImmediate(true);
    glayout.addComponent(mealsBudget, 2, 4);

    others = new TextArea("Others: ");
    others.setWidth("100%");
    others.setRows(3);
    others.addStyleName(ValoTheme.TEXTAREA_SMALL);
    glayout.addComponent(others, 0, 5, 2, 6);

    othersAmount = new TextField("Amount: ");
    othersAmount.setWidth("100%");
    othersAmount.setValue("0.00");
    othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    othersAmount.addStyleName("align-right");
    glayout.addComponent(othersAmount, 3, 5);
    glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER);

    Button rlButton = new Button();
    rlButton.setCaption("SAVE");
    rlButton.setWidth("100%");
    rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    rlButton.addStyleName(ValoTheme.BUTTON_SMALL);
    rlButton.addClickListener(buttonClickListener);
    glayout.addComponent(rlButton, 3, 6);
    glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER);

    if (getRequestId() != 0) {
        LiquidationForm lf = rls.getRLById(getRequestId());
        controlNo.setValue(String.valueOf(lf.getControlNo()));
        dateOfActivity.setValue(lf.getDateOfActivity());
        area.setValue(lf.getAreaId());
        activity.setValue(lf.getActivity());
        requirements.setValue(lf.getRequirements());
        venue.setValue(lf.getVenue());
        others.setValue(lf.getOthersRemarks());
        othersAmount.setValue(String.valueOf(lf.getOthersAmount()));
        lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount()));
        mealsAmount.setValue(String.valueOf(lf.getMealsAmount()));
        if (getLiquidated() == true) {
            setCaption("LIQUIDATE FROM");
            rlButton.setCaption("LIQUIDATE");
            controlNo.setReadOnly(liquidated);
            dateOfActivity.setReadOnly(liquidated);
            area.setReadOnly(liquidated);
            activity.setReadOnly(liquidated);
            requirements.setReadOnly(liquidated);
            venue.setReadOnly(liquidated);
        } else {
            rlButton.setCaption("EDIT");
            lodgingPax.setValue(String.valueOf(lf.getLodgingPax()));
            lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget()));
            mealsPax.setValue(String.valueOf(lf.getMealsPax()));
            mealsBudget.setValue(String.valueOf(lf.getMealsBudget()));
            rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0);
        }
        //            delete.setVisible(true);
    }

    return glayout;
}

From source file:com.scipionyx.butterflyeffect.frontend.configuration.ui.view.AboutView.java

License:Apache License

/**
 * /*  w  w w  .j a v  a2s  .co  m*/
 * @param workAreaPanel
 */
private GridLayout createClusterInformation(String type, VerticalLayout workAreaPanel) {

    GridLayout layout = new GridLayout(4, 2);
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);

    Label label = new Label("Cluster Information - " + type);
    label.setStyleName(ValoTheme.LABEL_H2);

    Panel panelClusterInformation = new Panel(layout);
    panelClusterInformation.setStyleName(ValoTheme.PANEL_WELL);

    workAreaPanel.addComponents(label, panelClusterInformation);

    return layout;

}

From source file:com.scsb.crpro.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * /*from  w  ww.j  a  v a2s .  co  m*/
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.scsb.vaadin.composite.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //  w  w  w  . jav a 2 s.c o m
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("./images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("./images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("./images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("./images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.skysql.manager.ui.components.ParametersLayout.java

License:Open Source License

/**
 * Display backup info./*from   w  ww.  j  a va  2s  . c om*/
 *
 * @param layout the layout
 * @param record the record
 */
final public void displayBackupInfo(VerticalLayout layout, BackupRecord record) {
    String value;
    String values[] = { (value = record.getNode()) != null ? value : NOT_AVAILABLE,
            (value = record.getLevelAsString()) != null ? value : NOT_AVAILABLE,
            ((record.getLevel() != null) && (record.getLevel().equals(BackupRecord.BACKUP_TYPE_INCREMENTAL))
                    && ((value = record.getParent()) != null)) ? value : "-",
            ((value = record.getState()) != null) && (value = BackupStates.getDescriptions().get(value)) != null
                    ? value
                    : "Invalid",
            (value = record.getSize()) != null ? value : NOT_AVAILABLE };

    GridLayout newBackupInfoGrid = new GridLayout(2, backupLabels.length);
    newBackupInfoGrid.setSpacing(true);

    for (int i = 0; i < backupLabels.length; i++) {
        newBackupInfoGrid.addComponent(new Label(backupLabels[i]), 0, i);
        newBackupInfoGrid.addComponent(new Label(values[i]), 1, i);
    }

    if (backupInfoGrid == null) {
        layout.addComponent(newBackupInfoGrid);
        backupInfoGrid = newBackupInfoGrid;
    } else {
        layout.replaceComponent(backupInfoGrid, newBackupInfoGrid);
        backupInfoGrid = newBackupInfoGrid;
    }

    //      SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
    //      LinkedHashMap<String, String> sysProperties = systemInfo.getCurrentSystem().getProperties();
    //      String EIP = sysProperties.get(SystemInfo.PROPERTY_EIP);
    //      if (EIP != null) {
    //         String url = "http://" + EIP + "/consoleAPI/" + record.getLog();
    //         Link newBackupLogLink = new Link("Backup Log", new ExternalResource(url));
    //         newBackupLogLink.setTargetName("_blank");
    //         newBackupLogLink.setDescription("Open backup log in a new window");
    //         newBackupLogLink.setIcon(new ThemeResource("img/externalLink.png"));
    //         newBackupLogLink.addStyleName("icon-after-caption");
    //         if (backupLogLink == null) {
    //            layout.addComponent(newBackupLogLink);
    //            backupLogLink = newBackupLogLink;
    //         } else {
    //            layout.replaceComponent(backupLogLink, newBackupLogLink);
    //            backupLogLink = newBackupLogLink;
    //         }
    //      }
}

From source file:com.skysql.manager.ui.PanelInfo.java

License:Open Source License

/**
 * Creates the current info./*from w  ww .  j a va2 s  .c  o  m*/
 *
 * @param labels the labels
 * @param values the values
 * @return the component
 */
private Component createCurrentInfo(Label[] labels, String[] values) {
    GridLayout currentGrid = new GridLayout(2, labels.length);
    currentGrid.addStyleName("currentInfo");
    currentGrid.setSpacing(true);
    currentGrid.setMargin(new MarginInfo(false, false, false, true));
    currentGrid.setSizeUndefined();

    for (int i = 0; i < labels.length; i++) {
        Label label = new Label(values[i]);
        label.setSizeUndefined();
        currentGrid.addComponent(label, 0, i);
        labels[i] = new Label("");
        labels[i].setSizeUndefined();
        currentGrid.addComponent(labels[i], 1, i);
    }

    return (currentGrid);
}

From source file:com.wcs.wcslib.vaadin.widget.recaptcha.demo.DummyRegWithReCaptcha.java

License:Apache License

private Layout createForm() {
    RegistrationFields registrationFields = new RegistrationFields();
    fieldGroup.buildAndBindMemberFields(registrationFields);
    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.addComponent(registrationFields.getLogin(), 0, 0);
    layout.addComponent(registrationFields.getPassword(), 0, 1);
    layout.addComponent(registrationFields.getPasswordAgain(), 1, 1);
    registrationFields.login.focus();//from  www.  jav a  2 s .c  om
    return layout;
}

From source file:de.catma.ui.tagger.TagInstanceTree.java

License:Open Source License

private void initComponents() {
    tagInstanceTree = new TreeTable();
    tagInstanceTree.setImmediate(true);/*from  w  ww.ja  v  a2  s . com*/
    tagInstanceTree.setSizeFull();
    tagInstanceTree.setSelectable(true);
    tagInstanceTree.setMultiSelect(true);
    tagInstanceTree.setColumnReorderingAllowed(true);
    tagInstanceTree.setColumnCollapsingAllowed(true);

    tagInstanceTree.setContainerDataSource(new HierarchicalContainer());
    tagInstanceTree.addContainerProperty(TagInstanceTreePropertyName.caption, String.class, null);
    tagInstanceTree.setColumnHeader(TagInstanceTreePropertyName.caption, "Tag Instance");

    tagInstanceTree.addContainerProperty(TagInstanceTreePropertyName.icon, Resource.class, null);

    tagInstanceTree.addContainerProperty(TagInstanceTreePropertyName.path, String.class, null);

    tagInstanceTree.addContainerProperty(TagInstanceTreePropertyName.instanceId, String.class, null);

    tagInstanceTree.addContainerProperty(TagInstanceTreePropertyName.umc, String.class, null);

    tagInstanceTree.setItemCaptionPropertyId(TagInstanceTreePropertyName.caption);
    tagInstanceTree.setItemIconPropertyId(TagInstanceTreePropertyName.icon);

    tagInstanceTree.addGeneratedColumn(TagInstanceTreePropertyName.color,
            new ColorLabelColumnGenerator(new ColorLabelColumnGenerator.TagInstanceTagDefinitionProvider()));

    tagInstanceTree.setVisibleColumns(new Object[] { TagInstanceTreePropertyName.caption,
            TagInstanceTreePropertyName.color, TagInstanceTreePropertyName.path,
            TagInstanceTreePropertyName.instanceId, TagInstanceTreePropertyName.umc });
    tagInstanceTree.setColumnHeader(TagInstanceTreePropertyName.color, "Tag Color");
    tagInstanceTree.setColumnHeader(TagInstanceTreePropertyName.path, "Tag Path");
    tagInstanceTree.setColumnHeader(TagInstanceTreePropertyName.instanceId, "Tag Instance ID");
    tagInstanceTree.setColumnHeader(TagInstanceTreePropertyName.umc, "User Markup Collection");
    addComponent(tagInstanceTree);
    setExpandRatio(tagInstanceTree, 1.0f);

    GridLayout buttonGrid = new GridLayout(1, 2);
    buttonGrid.setMargin(false, true, true, true);
    buttonGrid.setSpacing(true);

    btRemoveTagInstance = new Button("Remove Tag Instance");
    buttonGrid.addComponent(btRemoveTagInstance);

    btEditPropertyValues = new Button("Edit Property values");
    buttonGrid.addComponent(btEditPropertyValues);

    addComponent(buttonGrid);
}

From source file:de.catma.ui.tagmanager.PropertyDefinitionDialog.java

License:Open Source License

private void initComponents(String caption) {
    setMargin(true);/*from w  w  w  .  ja v a 2 s. c  o  m*/
    setSpacing(true);

    GridLayout propPanel = new GridLayout(3, 3);
    propPanel.setSpacing(true);

    nameInput = new TextField("Name");
    nameInput.setRequired(true);
    if (propertyDefinition != null) {
        nameInput.setValue(propertyDefinition.getName());
    }
    propPanel.addComponent(nameInput, 0, 0, 2, 0);

    if (propertyDefinition != null) {
        valueInput = new ListSelect("Possible values",
                propertyDefinition.getPossibleValueList().getPropertyValueList().getValues());
    } else {
        valueInput = new ListSelect("Possible values");
    }
    valueInput.setWidth("100%");
    valueInput.setRequired(true);
    valueInput.setNullSelectionAllowed(false);

    propPanel.addComponent(valueInput, 0, 1, 2, 1);

    newValueInput = new TextField("Add possible value");
    propPanel.addComponent(newValueInput, 0, 2);

    btAdd = new Button("+");
    propPanel.addComponent(btAdd, 1, 2);
    propPanel.setComponentAlignment(btAdd, Alignment.BOTTOM_CENTER);

    btRemove = new Button("-");
    propPanel.addComponent(btRemove, 2, 2);
    propPanel.setComponentAlignment(btRemove, Alignment.BOTTOM_CENTER);

    addComponent(propPanel);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    buttonPanel.setSpacing(true);

    btSave = new Button("Save");
    buttonPanel.addComponent(btSave);
    buttonPanel.setComponentAlignment(btSave, Alignment.MIDDLE_RIGHT);

    btCancel = new Button("Cancel");
    buttonPanel.addComponent(btCancel);
    buttonPanel.setComponentAlignment(btCancel, Alignment.MIDDLE_RIGHT);

    addComponent(buttonPanel);
    setComponentAlignment(buttonPanel, Alignment.MIDDLE_RIGHT);

    window = new Window(caption);
    window.setContent(this);
    window.setWidth("30%");
    window.setHeight("70%");
    window.center();
}

From source file:de.catma.ui.tagmanager.TagsetTree.java

License:Open Source License

private void initComponents() {
    setSizeFull();/*w ww .jav a  2 s.c o  m*/

    tagTree = new EndorsedTreeTable();
    tagTree.setImmediate(true);
    tagTree.setSizeFull();
    tagTree.setSelectable(true);
    tagTree.setMultiSelect(false);

    tagTree.setContainerDataSource(new HierarchicalContainer());

    tagTree.addContainerProperty(TagTreePropertyName.caption, String.class, null);
    tagTree.setColumnHeader(TagTreePropertyName.caption, "Tagsets");

    tagTree.addContainerProperty(TagTreePropertyName.icon, Resource.class, null);

    tagTree.setItemCaptionPropertyId(TagTreePropertyName.caption);
    tagTree.setItemIconPropertyId(TagTreePropertyName.icon);
    tagTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);

    tagTree.setVisibleColumns(new Object[] { TagTreePropertyName.caption });

    if (colorButtonListener != null) {
        tagTree.addGeneratedColumn(TagTreePropertyName.color,
                new ColorButtonColumnGenerator(colorButtonListener));
        tagTree.setColumnReorderingAllowed(true);
    } else {
        tagTree.addGeneratedColumn(TagTreePropertyName.color, new ColorLabelColumnGenerator());
    }
    tagTree.setColumnHeader(TagTreePropertyName.color, "Tag Color");
    addComponent(tagTree);
    setExpandRatio(tagTree, 2);

    GridLayout buttonGrid = new GridLayout(1, 19);
    buttonGrid.setMargin(true);
    buttonGrid.setSpacing(true);

    buttonGrid.addStyleName("taglibrary-action-grid");
    int buttonGridRowCount = 0;

    if (withTagsetButtons) {
        btReload = new Button("");
        btReload.setIcon(new ClassResource("ui/resources/icon-reload.gif", getApplication()));
        btReload.addStyleName("icon-button");
        buttonGrid.addComponent(btReload);
        buttonGrid.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT);
        buttonGridRowCount++;

        Label tagsetLabel = new Label();
        tagsetLabel.setIcon(new ClassResource("ui/tagmanager/resources/grndiamd.gif", application));
        tagsetLabel.setCaption("Tagset");

        buttonGrid.addComponent(tagsetLabel);
        buttonGridRowCount++;

        btInsertTagset = new Button("Create Tagset");
        btInsertTagset.setEnabled(true);
        btInsertTagset.setWidth("100%");
        buttonGrid.addComponent(btInsertTagset);
        buttonGridRowCount++;

        btRemoveTagset = new Button("Remove Tagset");
        btRemoveTagset.setWidth("100%");
        buttonGrid.addComponent(btRemoveTagset);
        buttonGridRowCount++;

        btEditTagset = new Button("Edit Tagset");
        btEditTagset.setWidth("100%");
        buttonGrid.addComponent(btEditTagset);
        buttonGridRowCount++;
    }

    Label tagLabel = new Label();
    tagLabel.setIcon(new ClassResource("ui/tagmanager/resources/reddiamd.gif", application));
    tagLabel.setCaption("Tag");

    buttonGrid.addComponent(tagLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4);
    buttonGridRowCount += 5;

    buttonGrid.setComponentAlignment(tagLabel, Alignment.BOTTOM_LEFT);

    btInsertTag = new Button("Create Tag");
    btInsertTag.setWidth("100%");
    if (withTagsetButtons) {
        btInsertTag.setEnabled(true);
    }
    buttonGrid.addComponent(btInsertTag);
    buttonGridRowCount++;

    btRemoveTag = new Button("Remove Tag");
    btRemoveTag.setWidth("100%");
    buttonGrid.addComponent(btRemoveTag);
    buttonGridRowCount++;

    btEditTag = new Button("Edit Tag");
    btEditTag.setWidth("100%");
    buttonGrid.addComponent(btEditTag);
    buttonGridRowCount++;

    Label propertyLabel = new Label();
    propertyLabel.setIcon(new ClassResource("ui/tagmanager/resources/ylwdiamd.gif", application));
    propertyLabel.setCaption("Property");

    buttonGrid.addComponent(propertyLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4);
    buttonGridRowCount += 5;

    buttonGrid.setComponentAlignment(propertyLabel, Alignment.BOTTOM_LEFT);

    btInsertProperty = new Button("Create Property");
    btInsertProperty.setWidth("100%");
    buttonGrid.addComponent(btInsertProperty);
    buttonGridRowCount++;

    btRemoveProperty = new Button("Remove Property");
    // commented out on purpose: somehow this forces all the other buttons to 
    // show up in natural size...
    //      btRemoveProperty.setWidth("100%");
    buttonGrid.addComponent(btRemoveProperty);
    buttonGridRowCount++;

    btEditProperty = new Button("Edit Property");
    btEditProperty.setWidth("100%");
    buttonGrid.addComponent(btEditProperty);
    buttonGridRowCount++;

    addComponent(buttonGrid);
    setExpandRatio(buttonGrid, 0);

    if (!withButtonPanel) {
        buttonGrid.setVisible(false);
    }

}