Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setExpandRatio.

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:com.openhris.payroll.contributions.PhicUI.java

public PhicUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//from w w  w. j  av a 2 s.  com
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE PHIC SHARE");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            phicTable.setContainerDataSource(
                    new PhicDataContainer(corporateId, (1 + c.get(Calendar.MONTH)), c.get(Calendar.YEAR)));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(phicTable, "PHIC Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " PHIC Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-PHIC-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(phicTable);
    setExpandRatio(phicTable, 2);
}

From source file:com.openhris.payroll.contributions.SssUI.java

public SssUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//  w w w .  j av a 2  s  . co m
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE SSS SHARE");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            sssTable.setContainerDataSource(
                    new SssDataContainer(corporateId, (1 + c.get(Calendar.MONTH)), c.get(Calendar.YEAR)));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(sssTable, "SSS Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " SSS Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-SSS-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(sssTable);
    setExpandRatio(sssTable, 2);
}

From source file:com.openhris.payroll.contributions.TaxUI.java

public TaxUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();/*from  w  w  w  .j  av  a2  s  . co m*/
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE WITHHOLDING TAX");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            taxTable.setContainerDataSource(new TaxDataContainer(corporateId,
                    util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()))));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(taxTable, "TAX Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " TAX Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-TAX-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(taxTable);
    setExpandRatio(taxTable, 2);
}

From source file:com.peergreen.webconsole.core.exception.ExceptionView.java

License:Open Source License

public ExceptionView(Exception ex) {

    setSizeFull();//from   w w  w.  jav  a 2 s . c  om
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    addComponent(top);
    final Label title = new Label("Oops ! A problem occurred when drawing this view");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setMargin(new MarginInfo(true, true, false, true));
    row.setSpacing(true);
    addComponent(row);
    setExpandRatio(row, 1.5f);

    Table t = new Table();
    t.setCaption("Stack trace");
    t.addContainerProperty("<p style=\"display:none\">Stack</p>", String.class, null);
    t.setWidth("100%");
    t.setImmediate(true);
    t.addStyleName("plain");
    t.addStyleName("borderless");
    t.setSortEnabled(false);
    t.setImmediate(true);
    t.setSizeFull();

    int i = 1;
    t.addItem(new Object[] { ex.toString() }, i++);
    for (StackTraceElement element : ex.getStackTrace()) {
        t.addItem(new Object[] { element.toString() }, i++);
    }
    CssLayout panel = new CssLayout();
    panel.addStyleName("layout-panel");
    panel.setSizeFull();

    panel.addComponent(t);

    row.addComponent(panel);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.all.AllView.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/*from w w  w . ja va  2s.c  o  m*/
    setSpacing(true);
    setMargin(true);

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

    final TextField filter = new TextField();
    filter.setInputPrompt("Type artifact name or maven dependency");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(AbstractDeployableContainer.DEPLOYABLE_NAME,
            directoryContainer.getContainer(), mavenContainer.getContainer()));
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);
    header.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    TreeTable directoryTable = createDeployableTable(AbstractDeployableContainer.DEPLOYABLE_NAME,
            DIRECTORY_ITEM_ID, directoryContainer.getContainer());
    TreeTable mavenTable = createDeployableTable(AbstractDeployableContainer.DEPLOYABLE_NAME, MAVEN_ITEM_ID,
            mavenContainer.getContainer());
    //mavenTable.addExpandListener(new TreeItemExpandListener(this, mavenRepositoryService));

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, directoryTable, actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    addComponent(directoryTable);
    setExpandRatio(directoryTable, 1.5f);
    addComponent(mavenTable);
    setExpandRatio(mavenTable, 1.5f);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.directory.DirectoryView.java

License:Open Source License

@PostConstruct
public void init() {
    File deploy = new File(System.getProperty("user.dir") + File.separator + "deploy");
    repositoryManager.addRepository(formatUrl(deploy), "Deploy", RepositoryType.DIRECTORY);

    File m2 = new File(
            System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository");
    if (m2.exists()) {
        repositoryManager.addRepository(formatUrl(m2), "Local M2 repository", RepositoryType.DIRECTORY);
    }/*from   w w w.j ava 2s  . c om*/

    File tmp = new File(Constants.STORAGE_DIRECTORY);
    if (!tmp.exists()) {
        tmp.mkdirs();
    }
    repositoryManager.addRepository(formatUrl(tmp), "Temporary directory", RepositoryType.DIRECTORY);

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

    final TextField filter = new TextField();
    filter.setInputPrompt("Filter deployable files");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(DEPLOYABLE_NAME, getContainer()));
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);
    header.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, getTree(), actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    HorizontalLayout repositoryInfo = new HorizontalLayout();
    repositoryInfo.setWidth("100%");
    repositoryInfo.addComponent(getFetching());
    repositoryInfo.setComponentAlignment(getFetching(), Alignment.MIDDLE_LEFT);
    addComponent(repositoryInfo);

    getTree().addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, getTree(), "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    getTree().addExpandListener(new TreeItemExpandListener(this, getRepositoryService(), repositoryManager));

    addComponent(getTree());
    setExpandRatio(getTree(), 1.5f);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.maven.MavenView.java

License:Open Source License

@PostConstruct
public void init() throws URISyntaxException {
    repositoryManager.loadRepositoriesInCache();
    addRootItemToContainer("Peergreen Releases",
            new URI("https://forge.peergreen.com/repository/content/repositories/releases/"));
    addRootItemToContainer("Maven Central", new URI("http://repo1.maven.org/maven2/"));

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);/* w w w  .  j  a v  a  2 s.c  om*/
    header.setMargin(true);

    final TextField filterG = new TextField();
    filterG.setInputPrompt("Filter by group id");
    filterG.addTextChangeListener(new FilterFiles(MVN_GROUP_ID, getContainer()));
    header.addComponent(filterG);
    header.setComponentAlignment(filterG, Alignment.TOP_LEFT);

    final TextField filterA = new TextField();
    filterA.setInputPrompt("Filter by artifact id");
    filterA.addTextChangeListener(new FilterFiles(MVN_ARTIFACT_ID, getContainer()));
    header.addComponent(filterA);
    header.setComponentAlignment(filterA, Alignment.TOP_LEFT);

    //        final TextField filterV = new TextField();
    //        filterV.setInputPrompt("Filter by version");
    //        filterV.addTextChangeListener(new FilterFiles(MVN_VERSION, getContainer()));
    //        header.addComponent(filterV);
    //        header.setComponentAlignment(filterV, Alignment.TOP_LEFT);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.addItem(CLEAR_FILTER);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, getTree(), actionSelection, deploymentViewManager));
    doButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (CLEAR_FILTER.equals(actionSelection.getValue())) {
                getContainer().removeAllContainerFilters();
            }
        }
    });

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    HorizontalLayout repositoryInfo = new HorizontalLayout();
    repositoryInfo.setWidth("100%");
    repositoryInfo.addComponent(getFetching());
    repositoryInfo.setComponentAlignment(getFetching(), Alignment.MIDDLE_LEFT);
    addComponent(repositoryInfo);

    getTree().addExpandListener(new TreeItemExpandListener(this, getRepositoryService(), repositoryManager));
    addComponent(getTree());
    setExpandRatio(getTree(), 1.5f);

    updateTree();
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployed.DeployedPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();//from  w  w w . j a v  a 2 s  .c  o m
    Table table = new Table();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

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

    // Select all deployed artifacts
    CheckBox selectAll = new CheckBox("All");
    selectAll.addValueChangeListener(new SelectAll(table));
    toolBar.addComponent(selectAll);
    toolBar.setExpandRatio(selectAll, 1);

    // Filter
    TextField filter = new TextField();
    filter.setInputPrompt("Filter deployed artifacts");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(TREE_ITEM_ID, container));
    toolBar.addComponent(filter);
    toolBar.setComponentAlignment(filter, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.UNDEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, table, actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    toolBar.addComponent(actionArea);
    toolBar.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    mainContent.addComponent(toolBar);

    VerticalLayout deployedContainer = new VerticalLayout();
    DragAndDropWrapper deployedContainerWrapper = new DragAndDropWrapper(deployedContainer);
    deployedContainerWrapper
            .setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    deployedContainerWrapper.setSizeFull();
    mainContent.addComponent(deployedContainerWrapper);
    mainContent.setExpandRatio(deployedContainerWrapper, 1.5f);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED, deploymentManager));
    table.addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, table, "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    table.setItemDescriptionGenerator(new ItemDescription());
    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                DeployableEntry deployableEntry = (DeployableEntry) event.getItemId();
                try {
                    ArtifactStatusReport report = deploymentManager
                            .getReport(deployableEntry.getUri().toString());
                    event.getComponent().getUI()
                            .addWindow(new DeployableWindow(deployableEntry, report).getWindow());
                } catch (ArtifactStatusReportException e) {
                    LOGGER.warn("Cannot get artifact status report for ''{0}''", deployableEntry.getUri(), e);
                    event.getComponent().getUI().addWindow(new DeployableWindow(deployableEntry).getWindow());
                }
            }
        }
    });
    deployedContainer.addComponent(table);
    deployedContainer.setExpandRatio(table, 1.5f);

    refresh();
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deploymentplan.DeploymentPlanPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();//  w w w .  j  a v  a  2s.  c  o m

    TreeTable table = new TreeTable();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

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

    // Deployment Plan name
    Label deploymentPlanNameLabel = new Label("Plan");
    toolBar.addComponent(deploymentPlanNameLabel);
    toolBar.setExpandRatio(deploymentPlanNameLabel, 1);

    deploymentPlanName = new TextField();
    deploymentPlanName.setInputPrompt(getDefaultName());
    deploymentPlanName.setWidth("100%");
    toolBar.addComponent(deploymentPlanName);
    toolBar.setComponentAlignment(deploymentPlanName, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(deploymentPlanName, 3);

    error = new Label("", ContentMode.HTML);
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    toolBar.addComponent(error);
    toolBar.setComponentAlignment(error, Alignment.TOP_RIGHT);
    toolBar.setExpandRatio(error, 1);
    mainContent.addComponent(toolBar);
    mainContent.setComponentAlignment(toolBar, Alignment.TOP_LEFT);
    mainContent.setExpandRatio(toolBar, 1);

    VerticalLayout deploymentPlanContainer = new VerticalLayout();
    DragAndDropWrapper deploymentPlanContainerWrapper = new DragAndDropWrapper(deploymentPlanContainer);
    DropHandler deploymentPlanDropHandler = new DeploymentDropHandler(deploymentViewManager, this,
            notifierService);
    deploymentPlanContainerWrapper.setDropHandler(deploymentPlanDropHandler);
    deploymentPlanContainerWrapper.setSizeFull();
    mainContent.addComponent(deploymentPlanContainerWrapper);
    mainContent.setExpandRatio(deploymentPlanContainerWrapper, 10);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED));
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setDropHandler(new OrderedContainerDropHandler(table, deploymentPlanDropHandler));
    table.addShortcutListener(new ShortcutListener("Delete", ShortcutAction.KeyCode.DELETE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            Table table = (Table) target;
            Collection<DeployableEntry> deployableEntries = (Collection<DeployableEntry>) table.getValue();
            for (DeployableEntry deployableEntry : deployableEntries) {
                removeDeployable(deployableEntry);
            }
        }
    });
    deploymentPlanContainer.addComponent(table);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setSizeFull();
    footer.setSpacing(true);
    footer.setMargin(true);
    footer.addStyleName("footer");
    footer.setWidth("100%");

    deployIt = new CheckBox("Deploy this deployment plan");
    footer.addComponent(deployIt);
    footer.setComponentAlignment(deployIt, Alignment.TOP_LEFT);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);
    Button cancel = new Button("Cancel");
    cancel.addClickListener(new CancelButtonListener());
    Button create = new Button("Create");
    create.addClickListener(new CreateButtonListener());
    create.addStyleName("wide");
    create.addStyleName("default");
    buttons.addComponent(cancel);
    buttons.addComponent(create);
    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.TOP_RIGHT);

    mainContent.addComponent(footer);
    mainContent.setComponentAlignment(footer, Alignment.BOTTOM_RIGHT);
    mainContent.setExpandRatio(footer, 1);
}

From source file:com.peergreen.webconsole.scope.home.HomeScope.java

License:Open Source License

public HomeScope() {
    setSizeFull();/*from   w w  w.  j  av  a2s .  c  om*/
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    addComponent(top);
    Label title = new Label("Welcome to Peergreen Administration Console");
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row1 = new HorizontalLayout();
    row1.setSizeFull();
    row1.setMargin(new MarginInfo(true, true, true, true));
    row1.setSpacing(true);
    row1.addStyleName("row");
    addComponent(row1);
    setExpandRatio(row1, 4);

    HorizontalLayout row2 = new HorizontalLayout();
    row2.setSizeFull();
    row2.setMargin(new MarginInfo(true, true, true, true));
    row2.setSpacing(true);
    row2.addStyleName("row");
    addComponent(row2);
    setExpandRatio(row2, 4);

    topLeftFrame = new FrameView();
    row1.addComponent(topLeftFrame);

    topRightFrame = new FrameView();
    row1.addComponent(topRightFrame);

    bottomLeftFrame = new FrameView();
    row2.addComponent(bottomLeftFrame);

    bottomRightFrame = new FrameView();
    row2.addComponent(bottomRightFrame);
}