Example usage for com.vaadin.ui VerticalLayout setStyleName

List of usage examples for com.vaadin.ui VerticalLayout setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:se.natusoft.osgi.aps.apsadminweb.app.gui.vaadin.TabPanel.java

License:Open Source License

/**
 * Recreates all tabs./*  w  ww  . jav a 2s.  c  om*/
 */
public void refreshTabs() {
    List<AdminWebReg> currentAdminWebs = this.adminWebService.getRegisteredAdminWebs();

    // Remove old
    removeAllComponents();

    VerticalLayout aboutTabLayout = new VerticalLayout();
    aboutTabLayout.setStyleName("aps-tabsheet-tab");
    aboutTabLayout.setMargin(true);
    aboutTabLayout.setSizeFull();
    Label aboutText = new HTMLFileLabel("/html/about-admin-web.html", APSTheme.THEME,
            getClass().getClassLoader());
    aboutTabLayout.addComponent(aboutText);
    addTab(aboutTabLayout, "About", null).setDescription("Information about APS Admin Web tool.");

    // Add new
    for (AdminWebReg adminWebReg : currentAdminWebs) {
        VerticalLayout tabLayout = new VerticalLayout();
        tabLayout.setStyleName("aps-tabsheet-tab");
        tabLayout.setSizeFull();
        tabLayout.setMargin(false);
        tabLayout.setSpacing(false);
        Embedded adminWeb = new Embedded("", new ExternalResource(adminWebReg.getUrl() + "?adminRefresh"));
        adminWeb.setType(Embedded.TYPE_BROWSER);
        adminWeb.setSizeFull();
        tabLayout.addComponent(adminWeb);
        tabLayout.setData(adminWebReg);

        Tab tab = addTab(tabLayout, adminWebReg.getName(), null);
        tab.setDescription(adminWebReg.getDescription() + "<br/>[" + adminWebReg.getName() + ":"
                + adminWebReg.getVersion() + "]");
    }
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.configeditor.NodeSelector.java

License:Open Source License

/**
 * Creates a new NodeSelector.//from  w  w  w .  ja  v  a  2s  . c o  m
 */
public NodeSelector() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setStyleName(CSS.APS_CONFIG_NODE_SELECTOR);

    setContent(verticalLayout);

    this.configNodeTree = new Tree();
    this.configNodeTree.setImmediate(true);
    this.configNodeTree.setSelectable(true);
    this.configNodeTree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    this.configNodeTree.setItemCaptionPropertyId(HierarchicalModel.getDefaultCaption());
    this.configNodeTree.setItemDescriptionGenerator(this); // For tooltips.
    this.configNodeTree.setHeight("100%");
    this.configNodeTree.setWidth(null);

    this.itemSelectListener = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            itemSelected((ID) event.getProperty().getValue());
        }
    };

    this.configNodeTree.addListener(this.itemSelectListener);

    verticalLayout.addComponent(this.configNodeTree);
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEditor.java

License:Open Source License

/**
 * Builds the gui of this component./*w ww  .  j ava 2  s .co  m*/
 * <p/>
 * The code in this method builds the base gui, the static parts that is only created once. It ends by calling
 * loadCurrentNodeData() to do a first time load of the root node of the ConfigNavigator.
 */
private void setupGUI() {
    this.setStyleName(CSS.APS_CONFIGID_LABEL);
    setSizeFull();

    VerticalLayout mainLayout = new VerticalLayout();
    {
        mainLayout.setSpacing(true);
        mainLayout.setMargin(true);
        mainLayout.setStyleName(CSS.APS_CONTENT_PANEL);
        mainLayout.setSizeFull();

        this.editForConfigEnvSelect = new ConfigEnvSelector();
        this.editForConfigEnvSelect.setDataSource(this.configAdminService.getConfigEnvAdmin());
        this.editForConfigEnvSelect.addListener(new ConfigEnvChangeListener() {
            @Override
            public void configEnvironmentChanged(ConfigEnvChangeEvent event) {
                handleChangedConfigEnv(event.getSelectedConfigEnvironment());
            }
        });
        mainLayout.addComponent(this.editForConfigEnvSelect);
        mainLayout.setExpandRatio(this.editForConfigEnvSelect, 1.0f);

        HorizontalLine hr = new HorizontalLine();
        mainLayout.addComponent(hr);
        mainLayout.setExpandRatio(hr, 1.0f);

        HorizontalLayout contentLayout = new HorizontalLayout();
        {
            contentLayout.setSpacing(true);
            contentLayout.setSizeFull();

            ConfigNode configNode = new ConfigNode(this.editedConfigAdmin.getConfigModel());
            if (!configNode.getNodeChildren().isEmpty()) {

                VerticalLayout nodesAndButtonsLayout = new VerticalLayout();
                {
                    nodesAndButtonsLayout.setWidth(null);
                    nodesAndButtonsLayout.setHeight("100%");
                    nodesAndButtonsLayout.setMargin(false);
                    nodesAndButtonsLayout.setSpacing(false);

                    this.nodeSelector = new NodeSelector();
                    this.nodeSelector.setHeight("100%");
                    this.nodeSelector.setWidth(null);
                    this.nodeSelector.setScrollable(true);
                    this.nodeSelector.setDataSource(this.nodeSelectorDataSource);
                    this.nodeSelector.addListener(new NodeSelectionListener() {
                        @Override
                        public void nodeSelected(NodeSelectedEvent event) {
                            selectCurrentNode(event.getSelectedModel(), event.getIndex());
                        }
                    });
                    nodesAndButtonsLayout.addComponent(this.nodeSelector);
                    nodesAndButtonsLayout.setExpandRatio(this.nodeSelector, 92.0f); // This works for iPad screen
                                                                                    // size and upp.
                    HorizontalLayout buttonsLayout = new HorizontalLayout();
                    {
                        buttonsLayout.setMargin(false);
                        buttonsLayout.setSpacing(false);
                        buttonsLayout.setHeight("100%");

                        this.addNodeButton = new Button(" + ");
                        this.addNodeButton.setEnabled(false);
                        this.addNodeButton.addListener(new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                addNodeInstance();
                            }
                        });
                        buttonsLayout.addComponent(this.addNodeButton);

                        this.removeNodeButton = new Button(" - ");
                        this.removeNodeButton.setEnabled(false);
                        this.removeNodeButton.addListener(new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                removeNodeInstance();
                            }
                        });
                        buttonsLayout.addComponent(this.removeNodeButton);
                    }
                    nodesAndButtonsLayout.addComponent(buttonsLayout);
                    nodesAndButtonsLayout.setExpandRatio(buttonsLayout, 8.0f);

                }
                contentLayout.addComponent(nodesAndButtonsLayout);
                contentLayout.setExpandRatio(nodesAndButtonsLayout, 1.0f);
            }

            this.configNodeValuesEditor = new ConfigNodeValuesEditor();
            {
                this.configNodeValuesEditor.setScrollable(true);
                this.configNodeValuesEditor.setWidth("100%");
                this.configNodeValuesEditor.setHeight("100%");

                this.configNodeValuesEditor.setDataSource(this.configNodeValueEditorDataSource);
            }
            contentLayout.addComponent(this.configNodeValuesEditor);
            contentLayout.setExpandRatio(this.configNodeValuesEditor, 99.0f);
        }
        mainLayout.addComponent(contentLayout);
        mainLayout.setExpandRatio(contentLayout, 96.0f);

        hr = new HorizontalLine();
        mainLayout.addComponent(hr);
        mainLayout.setExpandRatio(hr, 1.0f);

        HorizontalLayout saveCancelButtonsLayout = new HorizontalLayout();
        {
            saveCancelButtonsLayout.setSpacing(true);

            Button saveButton = new Button("Save");
            saveButton.addListener(new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    saveEdit();
                }
            });
            saveCancelButtonsLayout.addComponent(saveButton);

            Button cancelButton = new Button("Cancel");
            cancelButton.addListener(new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    cancelEdit();
                }
            });
            saveCancelButtonsLayout.addComponent(cancelButton);
        }
        mainLayout.addComponent(saveCancelButtonsLayout);
        mainLayout.setExpandRatio(saveCancelButtonsLayout, 1.0f);
    }

    setContent(mainLayout);

    refresh();
    if (this.nodeSelector != null) {
        this.nodeSelector.refreshData();
    }
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEnvEditor.java

License:Open Source License

/**
 * Setup for editing.//from  w  ww  . j  a  v  a 2 s. com
 */
private void initForEdit() {
    if (this.configEnv == null) {
        setCaption("Creating new config environment");
    } else {
        this.origName = this.configEnv.getName();
        setCaption("Editing config environment '" + this.configEnv.getName() + "'");
    }
    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    this.nameTextField = new TextField("Config environment name");
    if (configEnv != null) {
        this.nameTextField.setValue(this.configEnv.getName());
    }
    this.nameTextField.setColumns(30);
    this.nameTextField.setImmediate(true);
    this.nameTextField.setEnabled(
            configEnv != null && configEnv.equals(this.configEnvAdmin.getActiveConfigEnvironment()) ? false
                    : true);

    verticalLayout.addComponent(this.nameTextField);

    this.descriptionTextArea = new TextArea("Description of config environment.");
    this.descriptionTextArea.setRows(3);
    this.descriptionTextArea.setColumns(60);
    this.descriptionTextArea.setImmediate(true);
    if (configEnv != null) {
        this.descriptionTextArea.setValue(this.configEnv.getDescription());
    }
    verticalLayout.addComponent(this.descriptionTextArea);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    verticalLayout.addComponent(horizontalLayout);
    horizontalLayout.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            saveConfigEnv();
        }
    });
    horizontalLayout.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            cancel();
        }
    });
    horizontalLayout.addComponent(cancelButton);

    setContent(verticalLayout);

}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEnvEditor.java

License:Open Source License

/**
 * Setup for deleting.//www .j  a v  a  2 s  . c o m
 */
private void initForDelete() {
    setCaption("Deleting config environment '" + this.configEnv.getName() + "'");
    setStyleName("aps-editing-text");

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    Label nameLabel = new Label("Config environment name:");
    verticalLayout.addComponent(nameLabel);
    Panel confNamePanel = new Panel();
    Label nameValue = new Label(this.configEnv.getName());
    confNamePanel.addComponent(nameValue);
    verticalLayout.addComponent(confNamePanel);

    Label descLabel = new Label("Description of config environment:");
    verticalLayout.addComponent(descLabel);
    Panel confNameDescPanel = new Panel();
    Label descValue = new Label(this.configEnv.getDescription());
    confNameDescPanel.addComponent(descValue);
    verticalLayout.addComponent(confNameDescPanel);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setMargin(false);
    horizontalLayout.setSpacing(true);
    verticalLayout.addComponent(horizontalLayout);

    Button deleteButton = new Button("Delete");
    deleteButton.addListener(new ClickListener() {
        /** click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            deleteConfigEnv();
        }
    });
    if (this.configEnv.equals(this.configEnvAdmin.getActiveConfigEnvironment())) {
        deleteButton.setEnabled(false);
    }
    horizontalLayout.addComponent(deleteButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            cancel();
        }
    });
    horizontalLayout.addComponent(cancelButton);

    setContent(verticalLayout);

}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.LeftBar.java

License:Open Source License

public LeftBar() {
    VerticalLayout vl = new VerticalLayout();
    vl.setStyleName(CSS.APS_LEFTBAR);
    vl.setMargin(true);
    setContent(vl);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.RoleDeleteEditor.java

License:Open Source License

/**
 * Creates a new RoleDeleteEditor instance.
 *
 * @param userServiceAdmin The user admin service for editing the role.
 *//*from w  w w.  j a va 2s  .c o m*/
public RoleDeleteEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;
    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    this.idPanel = new Panel();
    this.idPanel.setCaption("Role id");
    this.idLabel = new Label("");
    this.idPanel.addComponent(this.idLabel);
    verticalLayout.addComponent(idPanel);

    this.descriptionPanel = new Panel();
    this.descriptionPanel.setCaption("Description");
    this.descriptionLabel = new Label("");
    this.descriptionPanel.addComponent(this.descriptionLabel);
    verticalLayout.addComponent(this.descriptionPanel);

    this.subRolesPanel = new Panel();
    this.subRolesPanel.setCaption("Sub roles");
    this.subRolesLabel = new Label("");
    this.subRolesPanel.addComponent(this.subRolesLabel);
    verticalLayout.addComponent(this.subRolesPanel);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    verticalLayout.addComponent(horizontalLayout);
    horizontalLayout.setSpacing(true);

    Button deleteButton = new Button("Delete");
    deleteButton.addListener(new Button.ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(Button.ClickEvent event) {
            delete();
        }
    });
    horizontalLayout.addComponent(deleteButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.addListener(new Button.ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(Button.ClickEvent event) {
            cancel();
        }
    });
    horizontalLayout.addComponent(cancelButton);

    setContent(verticalLayout);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.RoleEditor.java

License:Open Source License

/**
 * Creates a new RoleEditor instance.// w  w w .jav  a  2  s . c  o m
 *
 * @param userServiceAdmin The user admin service for editing the role.
 */
public RoleEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;

    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    // Role id, master and description.
    {
        HorizontalLayout horizLayout = new HorizontalLayout();
        horizLayout.setSpacing(true);

        this.idTextField = new TextField("Role id");
        this.idTextField.setColumns(30);
        this.idTextField.setImmediate(false);
        this.idTextField.setEnabled(true);
        horizLayout.addComponent(this.idTextField);

        this.masterRole = new CheckBox("Master Role");
        this.masterRole.setImmediate(false);
        this.masterRole.setEnabled(true);
        horizLayout.addComponent(this.masterRole);

        verticalLayout.addComponent(horizLayout);

        this.descriptionTextArea = new TextArea("Description of role");
        this.descriptionTextArea.setRows(3);
        this.descriptionTextArea.setColumns(60);
        this.descriptionTextArea.setImmediate(false);
        this.descriptionTextArea.setEnabled(true);
        verticalLayout.addComponent(this.descriptionTextArea);
    }

    // Roles
    {
        HorizontalLayout rolesLayout = new HorizontalLayout();
        rolesLayout.setSizeFull();

        // Available
        this.availableRoles = new Table("Available roles");
        this.availableRoles.setImmediate(true);
        this.availableRoles.setPageLength(10);
        this.availableRoles.setSortAscending(true);
        this.availableRoles.setSizeFull();
        this.availableRoles.setDragMode(Table.TableDragMode.ROW);
        this.availableRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                removeSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.availableRoles);
            }
        });
        VerticalLayout availableRolesFrame = new VerticalLayout();
        availableRolesFrame.setMargin(false, true, false, false);
        availableRolesFrame.addComponent(this.availableRoles);
        rolesLayout.addComponent(availableRolesFrame);

        // Selected
        this.selectedRoles = new Table("Selected sub roles of the role");
        this.selectedRoles.setImmediate(true);
        this.selectedRoles.setPageLength(10);
        this.selectedRoles.setSortAscending(true);
        this.selectedRoles.setSizeFull();
        this.selectedRoles.setDragMode(Table.TableDragMode.ROW);
        this.selectedRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                addSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.selectedRoles);
            }
        });
        VerticalLayout selectedRolesFrame = new VerticalLayout();
        selectedRolesFrame.setMargin(false, false, false, true);
        selectedRolesFrame.addComponent(this.selectedRoles);
        rolesLayout.addComponent(selectedRolesFrame);

        rolesLayout.setExpandRatio(availableRolesFrame, 0.5f);
        rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f);

        verticalLayout.addComponent(rolesLayout);

        /* Help text for the role tables. */
        HelpText roleHelptext = new HelpText(
                "Drag and drop roles back and forth to set or remove a role. Also note that it is fully possible to "
                        + "create circular role dependencies. Don't!");
        verticalLayout.addComponent(roleHelptext);
    }

    // Save / Cancel
    {
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        verticalLayout.addComponent(horizontalLayout);
        horizontalLayout.setSpacing(true);

        Button saveButton = new Button("Save");
        saveButton.addListener(new Button.ClickListener() {
            /** Click handling. */
            @Override
            public void buttonClick(Button.ClickEvent event) {
                save();
            }
        });
        horizontalLayout.addComponent(saveButton);

        Button cancelButton = new Button("Cancel");
        cancelButton.addListener(new Button.ClickListener() {
            /** Click handling. */
            @Override
            public void buttonClick(Button.ClickEvent event) {
                cancel();
            }
        });
        horizontalLayout.addComponent(cancelButton);
    }

    setContent(verticalLayout);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.UserEditor.java

License:Open Source License

/**
 * Creates a new UserEditor instance.//  w w  w  .  j  av  a2s. c  o  m
 *
 * @param userServiceAdmin The user admin service for editing the user.
 */
public UserEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;

    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    // User id & Auth
    {
        HorizontalLayout firstRowLayout = new HorizontalLayout();
        firstRowLayout.setSpacing(true);

        this.userId = new TextField("User id");
        this.userId.setColumns(30);
        this.userId.setImmediate(true);
        this.userId.setEnabled(true);

        firstRowLayout.addComponent(this.userId);

        this.authCurrent = new PasswordField("Current auth");
        this.authCurrent.setColumns(30);
        this.authCurrent.setImmediate(true);
        this.authCurrent.setEnabled(true);

        firstRowLayout.addComponent(this.authCurrent);

        verticalLayout.addComponent(firstRowLayout);

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

        this.authNewOne = new PasswordField("New auth");
        this.authNewOne.setColumns(30);
        this.authNewOne.setImmediate(true);
        this.authNewOne.setEnabled(true);

        secondRowLayout.addComponent(this.authNewOne);

        this.authNewTwo = new PasswordField("New auth confirm");
        this.authNewTwo.setColumns(30);
        this.authNewTwo.setImmediate(true);
        this.authNewTwo.setEnabled(true);

        secondRowLayout.addComponent(this.authNewTwo);

        verticalLayout.addComponent(secondRowLayout);
    }

    // User Properties
    {
        this.propertiesEditor = new Table();
        this.propertiesEditor.setSelectable(true);
        this.propertiesEditor.setCaption("User properties");
        this.propertiesEditor.setPageLength(8);
        this.propertiesEditor.setEditable(true);
        this.propertiesEditor.setSizeFull();
        this.propertiesEditor.setColumnExpandRatio(USER_PROPS_KEY, 0.3f);
        this.propertiesEditor.setColumnExpandRatio(USER_PROPS_VALUE, 0.7f);
        this.propertiesEditor.setTableFieldFactory(new EditFieldFactory());
        this.propertiesEditor.addListener(new ItemClickEvent.ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                selectDeselectProperty(event.getItemId());
            }
        });
        verticalLayout.addComponent(this.propertiesEditor);

        // Buttons + info row
        {
            HorizontalLayout plusMinusRow = new HorizontalLayout();
            plusMinusRow.setSpacing(true);

            this.plusButton = new Button("+");
            this.plusButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    addProperty();
                }
            });
            plusMinusRow.addComponent(this.plusButton);

            this.minusButton = new Button("-");
            this.minusButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    deleteProperty();
                }
            });
            this.minusButton.setEnabled(false);
            plusMinusRow.addComponent(this.minusButton);

            this.propsHelpText = new HelpText(
                    "Press + to add new property, select property and press - to delete.");
            plusMinusRow.addComponent(this.propsHelpText);

            verticalLayout.addComponent(plusMinusRow);
        }
    }

    // Roles
    {
        HorizontalLayout rolesLayout = new HorizontalLayout();
        rolesLayout.setSizeFull();

        // Available
        this.availableRoles = new Table("Available roles");
        this.availableRoles.setImmediate(true);
        this.availableRoles.setPageLength(10);
        this.availableRoles.setSortAscending(true);
        this.availableRoles.setSizeFull();
        this.availableRoles.setDragMode(Table.TableDragMode.ROW);
        this.availableRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                removeRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(UserEditor.this.availableRoles);
            }
        });
        VerticalLayout availableRolesFrame = new VerticalLayout();
        availableRolesFrame.setMargin(false, true, false, false);
        availableRolesFrame.addComponent(this.availableRoles);
        rolesLayout.addComponent(availableRolesFrame);

        // Selected
        this.selectedRoles = new Table("Selected roles");
        this.selectedRoles.setImmediate(true);
        this.selectedRoles.setPageLength(10);
        this.selectedRoles.setSortAscending(true);
        this.selectedRoles.setSizeFull();
        this.selectedRoles.setDragMode(Table.TableDragMode.ROW);
        this.selectedRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                addRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(UserEditor.this.selectedRoles);
            }
        });
        VerticalLayout selectedRolesFrame = new VerticalLayout();
        selectedRolesFrame.setMargin(false, false, false, true);
        selectedRolesFrame.addComponent(this.selectedRoles);
        rolesLayout.addComponent(selectedRolesFrame);

        rolesLayout.setExpandRatio(availableRolesFrame, 0.5f);
        rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f);

        verticalLayout.addComponent(rolesLayout);

        this.roleHelptext = new HelpText("Drag and drop roles back and forth to set or remove a role.");
        verticalLayout.addComponent(this.roleHelptext);
    }

    // Save & Cancel
    {
        HorizontalLayout saveCancelLayout = new HorizontalLayout();
        saveCancelLayout.setSpacing(true);

        this.saveButton = new Button("Save");
        this.saveButton.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                save();
            }
        });
        saveCancelLayout.addComponent(saveButton);

        Button cancelButton = new Button("Cancel");
        cancelButton.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                cancel();
            }
        });
        saveCancelLayout.addComponent(cancelButton);

        verticalLayout.addComponent(saveCancelLayout);
    }

    setContent(verticalLayout);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.LeftBar.java

License:Open Source License

/**
 * Creates a new LeftBar setting up some style.
 *//*from  ww  w .ja v a 2 s. co  m*/
public LeftBar() {
    VerticalLayout vl = new VerticalLayout();
    vl.setStyleName(CSS.APS_LEFTBAR);
    vl.setMargin(true);
    setContent(vl);
}