Example usage for com.vaadin.ui GridLayout setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel notifications() {
    Panel p = new Panel("Notifications");
    VerticalLayout content = new VerticalLayout() {
        Notification notification = new Notification("");
        TextField title = new TextField("Title");
        TextArea description = new TextArea("Description");
        MenuBar style = new MenuBar();
        MenuBar type = new MenuBar();
        String typeString = "";
        String styleString = "";
        TextField delay = new TextField();
        {/*from w  w  w.j  ava  2s. co m*/
            setSpacing(true);
            setMargin(true);

            title.setInputPrompt("Title for the notification");
            title.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (title.getValue() == null || title.getValue().length() == 0) {
                        notification.setCaption(null);
                    } else {
                        notification.setCaption(title.getValue());
                    }
                }
            });
            title.setValue("Notification Title");
            title.setWidth("100%");
            addComponent(title);

            description.setInputPrompt("Description for the notification");
            description.addStyleName("small");
            description.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (description.getValue() == null || description.getValue().length() == 0) {
                        notification.setDescription(null);
                    } else {
                        notification.setDescription(description.getValue());
                    }
                }
            });
            description.setValue(
                    "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
            description.setWidth("100%");
            addComponent(description);

            Command typeCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Humanized")) {
                        typeString = "";
                        notification.setStyleName(styleString.trim());
                    } else {
                        typeString = selectedItem.getText().toLowerCase();
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    }
                    for (MenuItem item : type.getItems()) {
                        item.setChecked(false);
                    }
                    selectedItem.setChecked(true);
                }
            };

            type.setCaption("Type");
            MenuItem humanized = type.addItem("Humanized", typeCommand);
            humanized.setCheckable(true);
            humanized.setChecked(true);
            type.addItem("Tray", typeCommand).setCheckable(true);
            type.addItem("Warning", typeCommand).setCheckable(true);
            type.addItem("Error", typeCommand).setCheckable(true);
            type.addItem("System", typeCommand).setCheckable(true);
            addComponent(type);
            type.addStyleName("small");

            Command styleCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    styleString = "";
                    for (MenuItem item : style.getItems()) {
                        if (item.isChecked()) {
                            styleString += " " + item.getText().toLowerCase();
                        }
                    }
                    if (styleString.trim().length() > 0) {
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    } else if (typeString.length() > 0) {
                        notification.setStyleName(typeString.trim());
                    } else {
                        notification.setStyleName(null);
                    }
                }
            };

            style.setCaption("Additional style");
            style.addItem("Dark", styleCommand).setCheckable(true);
            style.addItem("Success", styleCommand).setCheckable(true);
            style.addItem("Failure", styleCommand).setCheckable(true);
            style.addItem("Bar", styleCommand).setCheckable(true);
            style.addItem("Small", styleCommand).setCheckable(true);
            style.addItem("Closable", styleCommand).setCheckable(true);
            addComponent(style);
            style.addStyleName("small");

            CssLayout group = new CssLayout();
            group.setCaption("Fade delay");
            group.addStyleName("v-component-group");
            addComponent(group);

            delay.setInputPrompt("Infinite");
            delay.addStyleName("align-right");
            delay.addStyleName("small");
            delay.setWidth("7em");
            delay.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    try {
                        notification.setDelayMsec(Integer.parseInt(delay.getValue()));
                    } catch (Exception e) {
                        notification.setDelayMsec(-1);
                        delay.setValue("");
                    }

                }
            });
            delay.setValue("1000");
            group.addComponent(delay);

            Button clear = new Button(null, new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    delay.setValue("");
                }
            });
            clear.setIcon(FontAwesome.TIMES_CIRCLE);
            clear.addStyleName("last");
            clear.addStyleName("small");
            clear.addStyleName("icon-only");
            group.addComponent(clear);
            group.addComponent(new Label("  msec", ContentMode.HTML));

            GridLayout grid = new GridLayout(3, 3);
            grid.setCaption("Show in position");
            addComponent(grid);
            grid.setSpacing(true);

            Button pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

        }
    };
    p.setContent(content);

    return p;
}

From source file:com.cms.utils.CommonUtils.java

public static void setBasicAttributeLayout(GridLayout gridLayout, String caption, boolean isCollapseable) {
    gridLayout.setWidth("100%");
    gridLayout.setHeight("-1px");
    gridLayout.setImmediate(true);/*w w  w  .ja  va 2s  .  com*/
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    if (isCollapseable && !DataUtil.isStringNullOrEmpty(caption)) {
        gridLayout.setStyleName("custom-feildset");
        gridLayout.setCaption(MakeURL.makeURLForGrid(caption));
        gridLayout.setCaptionAsHtml(isCollapseable);
    }
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

GridLayout getPreviewLayout(String caption) {
    GridLayout grid = new GridLayout(3, 1) {
        @Override/*from w  w  w. j a  v  a  2  s . c  om*/
        public void addComponent(Component c) {
            super.addComponent(c);
            setComponentAlignment(c, "center middle");
            if (c.getStyleName() != "") {
                ((AbstractComponent) c).setDescription(
                        c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")");
            } else {
                ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()");
            }
        }
    };
    grid.setWidth("100%");
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setCaption(caption);
    grid.setStyleName("preview-grid");
    return grid;
}

From source file:org.apache.ace.target.management.ui.TargetManagementExtension.java

License:Apache License

public Component create(Map<String, Object> context) {
    GridLayout result = new GridLayout(1, 4);
    result.setCaption(CAPTION);

    result.setMargin(true);/*from   www  . j a  v a2  s  . c  o  m*/
    result.setSpacing(true);
    result.setSizeFull();

    final StatefulTargetObject target = getRepositoryObjectFromContext(context);

    final CheckBox registerCB = new CheckBox("Registered?");
    registerCB.setImmediate(true);
    registerCB.setEnabled(!target.isRegistered());
    registerCB.setValue(Boolean.valueOf(target.isRegistered()));

    result.addComponent(registerCB);

    final CheckBox autoApproveCB = new CheckBox("Auto approve?");
    autoApproveCB.setImmediate(true);
    autoApproveCB.setEnabled(target.isRegistered());
    autoApproveCB.setValue(Boolean.valueOf(target.getAutoApprove()));

    result.addComponent(autoApproveCB);

    final Button approveButton = new Button("Approve changes");
    approveButton.setImmediate(true);
    approveButton.setEnabled(getApproveButtonEnabledState(target));

    result.addComponent(approveButton);

    // Add a spacer that fill the remainder of the available space...
    result.addComponent(new Label(" "));
    result.setRowExpandRatio(3, 1.0f);

    // Add all listeners...
    registerCB.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (event.getButton().booleanValue()) {
                target.register();
                registerCB.setEnabled(!target.isRegistered());
                autoApproveCB.setEnabled(target.isRegistered());
            }
        }
    });
    autoApproveCB.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            target.setAutoApprove(event.getButton().booleanValue());
            approveButton.setEnabled(getApproveButtonEnabledState(target));
        }
    });
    approveButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            target.approve();
            approveButton.setEnabled(getApproveButtonEnabledState(target));
        }
    });

    return result;
}

From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java

License:Open Source License

public void setupPanel() {
    //clear everything
    //        content.removeAllComponents();

    //add components only if components have not already been added
    if (content.getComponentCount() == 0) {

        //Main chart
        HorizontalLayout chartContainer = new HorizontalLayout();
        chartContainer.setWidth(95, Unit.PERCENTAGE);
        chartContainer.setMargin(true);//  w  ww .j a  v a 2 s.  c om
        //            chartContainer.setHeight(30,Unit.PERCENTAGE);
        mainChart = buildMainChart();
        chartContainer.addComponent(mainChart);
        chartContainer.setComponentAlignment(mainChart, Alignment.MIDDLE_CENTER);
        chartContainer.setCaption(mainChart.getCaption());
        //            chartContainer.setCaption("Price");
        //            chartContainer.addStyleName("center-caption");

        content.addComponent(chartContainer);
        content.setExpandRatio(chartContainer, 1.3f);
        content.setComponentAlignment(chartContainer, Alignment.MIDDLE_CENTER);

        //Quantity chart
        HorizontalLayout quantityChartContainer = new HorizontalLayout();
        quantityChartContainer.setWidth(95, Unit.PERCENTAGE);
        //            quantityChartContainer.setMargin(true);
        quantityChartContainer.setMargin(new MarginInfo(true, true, false, true));
        //            quantityChartContainer.setHeight(30,Unit.PERCENTAGE);
        quantityChart = buildQuantityChart();
        quantityChartContainer.addComponent(quantityChart);
        quantityChartContainer.setComponentAlignment(quantityChart, Alignment.MIDDLE_CENTER);
        //            quantityChartContainer.setCaption("Quantity");
        //            quantityChartContainer.addStyleName("center-caption");

        content.addComponent(quantityChartContainer);
        content.setExpandRatio(quantityChartContainer, 1.0f);

        content.setComponentAlignment(quantityChartContainer, Alignment.MIDDLE_CENTER);

        //bottom row conatainer
        HorizontalLayout bottowRow = new HorizontalLayout();
        bottowRow.setWidth(100, Unit.PERCENTAGE);
        content.addComponent(bottowRow);
        content.setExpandRatio(bottowRow, 1.0f);

        //Stock price table
        GridLayout stockPriceTableContainer = new GridLayout(1, 2);
        //add a caption to the table
        //            Label tableCaption=new Label("Stock Price Table");
        //            stockPriceTableContainer.addComponent(tableCaption, 0, 0);
        //            stockPriceTableContainer.setComponentAlignment(tableCaption,Alignment.MIDDLE_RIGHT);
        stockPriceTable = setupStockPriceTable();
        stockPriceTableContainer.addComponent(stockPriceTable, 0, 1);
        stockPriceTableContainer.setMargin(new MarginInfo(false, true, true, true));
        stockPriceTableContainer.setCaption("Stock Price Table");
        stockPriceTableContainer.addStyleName("center-caption");

        stockPriceTableContainer.setComponentAlignment(stockPriceTable, Alignment.MIDDLE_CENTER);
        bottowRow.addComponent(stockPriceTableContainer);
        //            bottowRow.setExpandRatio(stockPriceTableContainer,1.0f);

        //buy-sell window
        GridLayout buySellWindowContainer = new GridLayout(1, 2);
        //            //add a caption to the table
        //            Label buySellWindowCaption=new Label("Buy/Sell Stocks");
        //            buySellWindowContainer.addComponent(buySellWindowCaption,0,0);
        //            buySellWindowContainer.setComponentAlignment(buySellWindowCaption,Alignment.MIDDLE_CENTER);
        Component buySellWindow = setupBuySellForm();
        buySellWindowContainer.addComponent(buySellWindow, 0, 1);
        buySellWindowContainer.setMargin(new MarginInfo(false, false, true, false));
        buySellWindowContainer.setCaption("Buy/Sell Stocks");
        buySellWindowContainer.addStyleName("center-caption");

        buySellWindowContainer.setComponentAlignment(buySellWindow, Alignment.MIDDLE_CENTER);
        bottowRow.addComponent(buySellWindowContainer);
        //            bottowRow.setExpandRatio(buySellWindowContainer,1.0f);

        //portfolio data
        //            VerticalLayout myPortfolioLayout=new VerticalLayout();
        //            myPortfolioLayout.setMargin(new MarginInfo(false,true,true,true));
        //            bottowRow.addComponent(myPortfolioLayout);
        //add a caption to the table
        //            Label portfolioCaption=new Label("My Portfolio");
        //            myPortfolioLayout.addComponent(portfolioCaption);
        //            myPortfolioLayout.setComponentAlignment(portfolioCaption,Alignment.MIDDLE_CENTER);

        HorizontalLayout portfolioContainer = new HorizontalLayout();
        portfolioContainer.setMargin(new MarginInfo(false, true, true, true));
        portfolioContainer.setCaption("My Portfolio");
        portfolioContainer.addStyleName("center-caption");
        bottowRow.addComponent(portfolioContainer);
        //            bottowRow.setExpandRatio(portfolioContainer,1.0f);

        //portfolio table
        portfolioTable = setupPortfolioTable();
        portfolioContainer.addComponent(portfolioTable);
        //            portfolioContainer.setExpandRatio(portfolioTable,1.0f);

        //profit chart
        //            HorizontalLayout profitContainer = new HorizontalLayout();
        //            bottowRow.addComponent(profitContainer);

        profitChart = setupProfitChart();
        profitChart.setCaption("Profit Chart");
        profitChart.addStyleName("center-caption");
        bottowRow.addComponent(profitChart);
        bottowRow.setExpandRatio(profitChart, 1.3f);

        //            Component accountInfo=setUpAccountInfoForm();
        //            accountInfo.setCaption("Profit Chart");
        //            accountInfo.addStyleName("center-caption");
        //
        //            bottowRow.addComponent(accountInfo);
        //            bottowRow.setExpandRatio(accountInfo,1.3f);

        this.setContent(content);
    }

}