Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_RIGHT.

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

From source file:org.investovator.ui.nngaming.QuoteUI.java

License:Open Source License

private void setupUI() {

    //Trade Button
    tradeButton = new Button("Place Order");
    tradeButton.addClickListener(tradeButtonClickListener);
    tradeButton.setWidth("100%");

    //Price Layout
    price = new TextField("Price");
    price.addValueChangeListener(priceValueChangedListener);
    price.setImmediate(true);//  w w  w  .  j  a  va  2  s .  c o m
    price.setWidth("100%");

    amount = new Label();
    amount.setCaption("Amount");
    amount.addStyleName("outlined");
    amount.setWidth("100%");

    stocks = new TextField("Stocks");
    stocks.addValueChangeListener(stocksChangedListener);
    stocks.setImmediate(true);
    stocks.setWidth("100%");

    //Stock Select
    stockSelect = new ComboBox();
    stockSelect.setCaption("Select stock to trade");
    stockSelect.setNullSelectionAllowed(false);
    stockSelect.setImmediate(true);
    stockSelect.setWidth("100%");
    stockSelect.addValueChangeListener(selectSymbolValueChange);

    VerticalLayout column1 = new VerticalLayout();
    column1.setSpacing(true);
    column1.setWidth("100%");
    column1.addComponent(stockSelect);
    column1.setComponentAlignment(stockSelect, Alignment.MIDDLE_LEFT);
    column1.addComponent(price);
    column1.setComponentAlignment(price, Alignment.MIDDLE_LEFT);
    column1.addComponent(amount);
    column1.setComponentAlignment(amount, Alignment.MIDDLE_LEFT);

    //Side Select
    sideSelect = new ComboBox("Select Order Type");
    sideSelect.addItem("Buy Order");
    sideSelect.addItem("Sell Order");
    sideSelect.select("Buy Order");
    isBuy = true;
    sideSelect.setNullSelectionAllowed(false);
    sideSelect.addValueChangeListener(sideSelectValueChangeListener);
    sideSelect.setImmediate(true);
    sideSelect.setWidth("100%");

    VerticalLayout column2 = new VerticalLayout();

    column2.setSpacing(true);
    column2.setWidth("100%");
    column2.addComponent(sideSelect);
    column2.setComponentAlignment(sideSelect, Alignment.MIDDLE_RIGHT);
    column2.addComponent(stocks);
    column2.setComponentAlignment(stocks, Alignment.MIDDLE_RIGHT);
    column2.addComponent(tradeButton);
    column2.setComponentAlignment(tradeButton, Alignment.BOTTOM_RIGHT);

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(column1);
    layout.addComponent(column2);
    layout.setSpacing(true);

    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.MIDDLE_RIGHT);
    this.setSpacing(true);
    this.setMargin(new MarginInfo(false, false, false, true));
    this.setImmediate(true);
    this.setWidth("100%");

}

From source file:org.jpos.qi.login.LoginView.java

License:Open Source License

private HorizontalLayout createButtons() {
    buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth("100%");
    buttonsLayout.setMargin(new MarginInfo(true, false, false, false));

    loginBtn = new Button(app.getMessage("login"), event -> {
        login();/*from   w  w  w. j  av  a  2  s. co  m*/
    });
    loginBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginBtn.addShortcutListener(new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            login();
        }
    });
    buttonsLayout.addComponent(loginBtn);
    buttonsLayout.setComponentAlignment(loginBtn, Alignment.MIDDLE_RIGHT);
    return buttonsLayout;
}

From source file:org.jpos.qi.minigl.AccountsView.java

License:Open Source License

@Override
protected HorizontalLayout createHeader(String title) {
    HorizontalLayout header = super.createHeader(title);
    if (isGeneralView()) {
        Label refDebit = new Label(FontAwesome.SQUARE.getHtml() + " DEBIT accounts");
        Label refCredit = new Label(FontAwesome.SQUARE.getHtml() + " CREDIT accounts");
        refDebit.setContentMode(ContentMode.HTML);
        refCredit.setContentMode(ContentMode.HTML);
        refDebit.setStyleName("debit-color");
        refCredit.setStyleName("credit-color");
        refDebit.addStyleName(ValoTheme.LABEL_SMALL);
        refCredit.addStyleName(ValoTheme.LABEL_SMALL);
        Button collapse = new Button(getApp().getMessage("collapseAll"), event -> {
            ((TreeGrid) getGrid()).collapse(expandedItems.toArray());

        });/* w w w. jav a 2  s.  co m*/
        collapse.setStyleName(ValoTheme.BUTTON_LINK);
        collapse.addStyleName(ValoTheme.BUTTON_SMALL);
        HorizontalLayout l = new HorizontalLayout(refDebit, refCredit, collapse);
        l.setSpacing(true);
        l.setComponentAlignment(refDebit, Alignment.BOTTOM_CENTER);
        l.setComponentAlignment(refCredit, Alignment.BOTTOM_CENTER);
        l.setComponentAlignment(collapse, Alignment.BOTTOM_CENTER);
        header.addComponent(l);
        header.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);
    }
    return header;
}

From source file:org.jpos.qi.minigl.TransactionsView.java

License:Open Source License

private HorizontalLayout createFilters() {
    HorizontalLayout controls = new HorizontalLayout();
    controls.setWidth("100%");
    journals = new JournalsCombo(true);
    journals.setValue(journals.getDataProvider().fetch(new Query<>()).findFirst().orElse(null));
    controls.addComponents(journals, dateRangeComponent);
    controls.setComponentAlignment(dateRangeComponent, Alignment.MIDDLE_LEFT);
    controls.setComponentAlignment(journals, Alignment.MIDDLE_RIGHT);
    controls.setExpandRatio(journals, 0f);
    controls.setExpandRatio(dateRangeComponent, 1f);
    controls.setMargin(new MarginInfo(false, true, true, true));
    controls.setSpacing(true);/* w  w  w .j  ava2s  .c  om*/
    return controls;
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

public Layout createForm(final Object entity, String[] params, boolean isNew) {
    VerticalLayout profileLayout = new VerticalLayout();
    profileLayout.setMargin(true);//from   w w  w  . j  ava 2 s  .c om
    profileLayout.setSpacing(true);

    //Add Back Button
    if (params.length <= 1 || !"profile".equals(params[1])) {
        Button back = new Button(getApp().getMessage("back"));
        back.addStyleName("borderless-colored");
        back.setIcon(VaadinIcons.ARROW_LEFT);
        back.addClickListener(event -> app.getNavigator().navigateTo(getGeneralRoute()));
        profileLayout.addComponent(back);
        profileLayout.setComponentAlignment(back, Alignment.MIDDLE_LEFT);
    }

    binder = new Binder<T>(clazz) {
        @Override
        public void setReadOnly(boolean readOnly) {
            super.setReadOnly(readOnly);
            if (readOnlyFields != null) {
                for (String fieldId : readOnlyFields) {
                    if (binder.getBinding(fieldId).isPresent()) {
                        HasValue field = binder.getBinding(fieldId).get().getField();
                        if ((field != null && !field.isEmpty()) || !field.isRequiredIndicatorVisible()) {
                            field.setReadOnly(true);
                            binder.bind(field, fieldId);
                        }
                    }

                }
            }
        }
    };
    bean = (T) entity;
    final Layout formLayout = createLayout();
    getHelper().setOriginalEntity(bean);
    binder.readBean((T) entity);
    binder.setReadOnly(true);
    profileLayout.addComponent(formLayout);

    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName("footer");
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.setSpacing(true);
    formLayout.addComponent(footer);

    //Add Save, Remove & Cancel Buttons
    editBtn = new Button(app.getMessage("edit"));
    removeBtn = new Button(app.getMessage("remove"));
    saveBtn = new Button(app.getMessage("save"));
    cancelBtn = new Button(app.getMessage("cancel"));

    editBtn.addClickListener(event -> editClick(event, formLayout));
    editBtn.addStyleName("icon-edit");

    saveBtn.addClickListener(event -> saveClick(event, formLayout));
    saveBtn.setVisible(false);
    saveBtn.setStyleName("icon-ok");
    saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    removeBtn.addClickListener(event -> app.addWindow(new ConfirmDialog(app.getMessage("confirmTitle"),
            app.getMessage("removeConfirmationMessage"), confirm -> {
                if (confirm) {
                    removeEntity();
                }
            })));
    removeBtn.addStyleName("icon-trash");

    cancelBtn.addClickListener(event -> {
        if (isNew) {
            app.getNavigator().navigateTo(getGeneralRoute());
        } else {
            cancelClick(event, formLayout);
        }
    });

    cancelBtn.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    cancelBtn.setVisible(false);
    cancelBtn.addStyleName("icon-cancel");

    if (canEdit()) {
        footer.addComponent(editBtn);
        footer.addComponent(saveBtn);
        footer.addComponent(cancelBtn);
        footer.setComponentAlignment(editBtn, Alignment.MIDDLE_RIGHT);
        footer.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        footer.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);
    }
    if (canRemove()) {
        footer.addComponent(removeBtn);
        footer.setComponentAlignment(removeBtn, Alignment.MIDDLE_RIGHT);
    }
    if (isNew) {
        editBtn.click();
    }
    errorLabel = new Label();
    errorLabel.setVisible(false);
    errorLabel.setStyleName(ValoTheme.LABEL_FAILURE);
    profileLayout.addComponent(errorLabel);
    return profileLayout;
}

From source file:org.jumpmind.metl.ui.common.ButtonBar.java

License:Open Source License

public ButtonBar() {
    setWidth(100, Unit.PERCENTAGE);/*w w w.j a v  a2s  .  co m*/
    setMargin(new MarginInfo(true, false, true, false));

    wrapper = new HorizontalLayout();
    wrapper.setWidth(100, Unit.PERCENTAGE);
    wrapper.addStyleName(STYLE);
    wrapper.setMargin(new MarginInfo(false, true, false, false));

    left = new HorizontalLayout();
    wrapper.addComponent(left);
    wrapper.setComponentAlignment(left, Alignment.MIDDLE_RIGHT);

    bar = new HorizontalLayout();

    wrapper.addComponent(bar);
    wrapper.setComponentAlignment(bar, Alignment.MIDDLE_LEFT);

    Label spacer = new Label();
    spacer.addStyleName(STYLE);
    wrapper.addComponent(spacer);
    wrapper.setExpandRatio(spacer, 1);

    right = new HorizontalLayout();
    right.setSpacing(true);
    right.setMargin(false);
    wrapper.addComponent(right);
    wrapper.setComponentAlignment(right, Alignment.MIDDLE_RIGHT);

    addComponent(wrapper);
}

From source file:org.jumpmind.metl.ui.views.manage.ExecutionRunPanel.java

License:Open Source License

public ExecutionRunPanel(String executionId, ApplicationContext context, TabbedPanel parentTabSheet,
        IFlowRunnable flowRunnable) {/* ww w . ja  v  a  2  s .c o  m*/
    this.executionService = context.getExecutionService();
    this.executionId = executionId;
    this.context = context;
    this.parentTabSheet = parentTabSheet;
    this.flowRunnable = flowRunnable;

    Execution execution = executionService.findExecution(executionId);
    this.flow = context.getConfigurationService().findFlow(execution.getFlowId());

    HorizontalLayout topBar = new HorizontalLayout();
    topBar.setMargin(new MarginInfo(true, true, false, true));
    topBar.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout left = new HorizontalLayout();
    topBar.addComponent(left);

    HorizontalLayout right = new HorizontalLayout();
    right.setSpacing(true);
    topBar.addComponent(right);
    topBar.setComponentAlignment(right, Alignment.MIDDLE_RIGHT);

    Label limitLabel = new Label("Max Log Messages To Show :");
    right.addComponent(limitLabel);
    right.setComponentAlignment(limitLabel, Alignment.MIDDLE_RIGHT);
    limitField = new ImmediateUpdateTextField(null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void save(String text) {
            Setting setting = context.getUser().findSetting(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW);
            setting.setValue(Integer.toString(getMaxToShow(text)));
            context.getConfigurationService().save(setting);
        }
    };
    limitField.setWidth("5em");
    limitField.setValue(context.getUser().get(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW, "1000"));
    right.addComponent(limitField);
    right.setComponentAlignment(limitField, Alignment.MIDDLE_RIGHT);

    showDiagramCheckbox = new CheckBox("Show Diagram");
    showDiagramCheckbox.addValueChangeListener((event) -> {
        if (showDiagramCheckbox.getValue()) {
            showDiagram();
        } else {
            showDetails();
        }
    });
    right.addComponent(showDiagramCheckbox);
    right.setComponentAlignment(showDiagramCheckbox, Alignment.MIDDLE_RIGHT);

    addComponent(topBar);

    ButtonBar buttonBar = new ButtonBar();

    rerunButton = buttonBar.addButton("Rerun", Icons.RUN, event -> rerun());
    rerunButton.setVisible(false);
    removeButton = buttonBar.addButton("Remove", Icons.DELETE, event -> remove());
    removeButton.setVisible(false);
    cancelButton = buttonBar.addButton("Cancel", Icons.CANCEL, event -> cancel());

    addComponent(buttonBar);

    HorizontalLayout header1 = new HorizontalLayout();
    header1.addComponent(new Label("<b>Flow:</b>", ContentMode.HTML));
    header1.addComponent(flowLabel);
    header1.addComponent(new Label("<b>Start:</b>", ContentMode.HTML));
    header1.addComponent(startLabel);
    header1.setSpacing(true);
    header1.setMargin(new MarginInfo(false, true, false, true));
    header1.setWidth("100%");
    addComponent(header1);

    HorizontalLayout header2 = new HorizontalLayout();
    header2.addComponent(new Label("<b>Status:</b>", ContentMode.HTML));
    header2.addComponent(statusLabel);
    header2.addComponent(new Label("<b>End:</b>", ContentMode.HTML));
    header2.addComponent(endLabel);
    header2.setSpacing(true);
    header2.setMargin(new MarginInfo(false, true, true, true));
    header2.setWidth("100%");
    addComponent(header2);

    stepContainer.setBeanIdProperty("id");

    diagramLayout = new VerticalLayout();
    diagramLayout.setWidth(10000, Unit.PIXELS);
    diagramLayout.setHeight(10000, Unit.PIXELS);

    flowPanel = new Panel();
    flowPanel.setSizeFull();
    flowPanel.addStyleName(ValoTheme.PANEL_WELL);

    flowPanel.setContent(diagramLayout);

    stepTable.setContainerDataSource(stepContainer);
    stepTable.setSelectable(true);
    stepTable.setMultiSelect(true);
    stepTable.setImmediate(true);
    stepTable.setSizeFull();
    stepTable.setVisibleColumns(
            new Object[] { "componentName", "threadNumber", "status", "payloadReceived", "messagesReceived",
                    "messagesProduced", "payloadProduced", "startTime", "endTime", "handleDurationString" });
    stepTable.setColumnHeaders(new String[] { "Component Name", "Thread", "Status", "Payload Recvd",
            "Msgs Recvd", "Msgs Sent", "Payload Sent", "Start", "End", "Run Duration" });
    stepTable.setColumnWidth("status", 100);
    stepTable.setColumnWidth("messagesReceived", 100);
    stepTable.setColumnWidth("messagesProduced", 100);
    stepTable.setColumnWidth("payloadReceived", 100);
    stepTable.setColumnWidth("payloadProduced", 100);
    stepTable.setColumnWidth("threadNumber", 100);
    stepTable.setColumnWidth("startTime", 170);
    stepTable.setColumnWidth("endTime", 170);
    stepTable.setColumnExpandRatio("handleDurationString", 1);
    stepTable.addValueChangeListener(event -> {
        @SuppressWarnings("unchecked")
        Set<String> executionStepIds = (Set<String>) event.getProperty().getValue();
        logContainer.removeAllItems();
        List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow());
        logContainer.addAll(logs);
    });

    stepTable.addValueChangeListener(event -> {
        @SuppressWarnings("unchecked")
        Set<String> executionStepIds = (Set<String>) event.getProperty().getValue();
        logContainer.removeAllItems();
        List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow());
        logContainer.addAll(logs);
    });

    logTable = new Grid();
    logTable.addColumn("level", String.class).setHeaderCaption("Level").setWidth(110).setMaximumWidth(200);
    logTable.addColumn("createTime", Date.class).setHeaderCaption("Time").setWidth(120).setMaximumWidth(200)
            .setRenderer(new DateRenderer(UiConstants.TIME_FORMAT));
    logTable.addColumn("logText", String.class).setHeaderCaption("Message").setExpandRatio(1);
    logTable.setContainerDataSource(logContainer);
    logTable.setSizeFull();
    logTable.addItemClickListener(event -> logTableCellClicked(logTable, event));
    logTable.addSortListener(event -> {
        lastSortOrder = event.getSortOrder();
    });

    HeaderRow filteringHeader = logTable.appendHeaderRow();
    HeaderCell logTextFilterCell = filteringHeader.getCell("logText");
    TextField filterField = new TextField();
    filterField.setInputPrompt("Filter");
    filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    filterField.setWidth("100%");

    // Update filter When the filter input is changed
    filterField.addTextChangeListener(change -> {
        // Can't modify filters so need to replace
        logContainer.removeContainerFilters("logText");

        // (Re)create the filter if necessary
        if (!change.getText().isEmpty())
            logContainer.addContainerFilter(new SimpleStringFilter("logText", change.getText(), true, false));
    });
    logTextFilterCell.setComponent(filterField);

    HeaderCell levelFilterCell = filteringHeader.getCell("level");
    ComboBox levelFilter = new ComboBox();
    levelFilter.setWidth(8, Unit.EM);
    levelFilter.setNullSelectionAllowed(true);
    LogLevel[] levels = LogLevel.values();
    for (LogLevel logLevel : levels) {
        levelFilter.addItem(logLevel.name());
    }
    levelFilter.addValueChangeListener(change -> {
        logContainer.removeContainerFilters("level");
        String text = (String) levelFilter.getValue();
        if (isNotBlank(text)) {
            logContainer.addContainerFilter(new SimpleStringFilter("level", text, true, false));
        }
    });
    levelFilterCell.setComponent(levelFilter);

    levelFilter.addStyleName(ValoTheme.COMBOBOX_TINY);

    splitPanel = new VerticalSplitPanel();
    splitPanel.setFirstComponent(flowPanel);
    splitPanel.setSecondComponent(logTable);
    splitPanel.setSplitPosition(50f);
    splitPanel.setSizeFull();
    addComponent(splitPanel);
    setExpandRatio(splitPanel, 1.0f);

    showDiagramCheckbox.setValue(context.getUser().getBoolean(UserSetting.SETTING_SHOW_RUN_DIAGRAM, true));
    if (!showDiagramCheckbox.getValue()) {
        showDetails();
    }

    context.getBackgroundRefresherService().register(this);
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TabularResultLayout.java

License:Open Source License

private void createMenuBar() {
    HorizontalLayout resultBar = new HorizontalLayout();
    resultBar.setWidth(100, Unit.PERCENTAGE);
    resultBar.setMargin(new MarginInfo(false, true, false, true));

    HorizontalLayout leftBar = new HorizontalLayout();
    leftBar.setSpacing(true);//from   w ww  . j  a va 2 s  .co  m
    resultLabel = new Label("", ContentMode.HTML);
    leftBar.addComponent(resultLabel);

    final Label sqlLabel = new Label("", ContentMode.TEXT);
    sqlLabel.setWidth(800, Unit.PIXELS);
    leftBar.addComponent(sqlLabel);

    resultBar.addComponent(leftBar);
    resultBar.setComponentAlignment(leftBar, Alignment.MIDDLE_LEFT);
    resultBar.setExpandRatio(leftBar, 1);

    MenuBar rightBar = new MenuBar();
    rightBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    rightBar.addStyleName(ValoTheme.MENUBAR_SMALL);

    MenuBar.MenuItem refreshButton = rightBar.addItem("", new Command() {
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            listener.reExecute(sql);
        }
    });
    refreshButton.setIcon(FontAwesome.REFRESH);

    MenuBar.MenuItem exportButton = rightBar.addItem("", new Command() {
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            new ExportDialog(grid, db.getName(), sql).show();
        }
    });
    exportButton.setIcon(FontAwesome.UPLOAD);

    if (isInQueryGeneralResults) {
        MenuBar.MenuItem keepResultsButton = rightBar.addItem("", new Command() {
            private static final long serialVersionUID = 1L;

            @Override
            public void menuSelected(com.vaadin.ui.MenuBar.MenuItem selectedItem) {
                queryPanel.addResultsTab(refreshWithoutSaveButton(), StringUtils.abbreviate(sql, 20),
                        queryPanel.getGeneralResultsTab().getIcon());
                queryPanel.resetGeneralResultsTab();
            }
        });
        keepResultsButton.setIcon(FontAwesome.CLONE);
        keepResultsButton.setDescription("Save these results to a new tab");
    }

    if (showSql) {
        sqlLabel.setValue(StringUtils.abbreviate(sql, 200));
    }

    resultBar.addComponent(rightBar);
    resultBar.setComponentAlignment(rightBar, Alignment.MIDDLE_RIGHT);

    this.addComponent(resultBar, 0);
}

From source file:org.kani.Application.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);//from w  w  w.jav a2 s . co  m
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("blue");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Dynamic Vaadin OSGi Demo");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright ?? and others.<br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        Button close = new Button("Close", new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, Alignment.MIDDLE_RIGHT);
    }
    return aboutWindow;
}

From source file:org.lunifera.christmastree.control.MobileControlComponent.java

License:Creative Commons License

@SuppressWarnings("deprecation")
protected GridLayout buildContent() {
    // common part: create layout
    contentLayout = new GridLayout();
    contentLayout.setImmediate(false);//w ww. jav a2s. c  o m
    contentLayout.setMargin(false);
    contentLayout.setSpacing(true);
    contentLayout.setColumns(2);
    contentLayout.setRows(5);

    // button_off
    button_off = new Embedded("Off", new ThemeResource("./images/off.png"));
    button_off.setImmediate(true);
    button_off.setWidth("-1px");
    button_off.setHeight("-1px");
    button_off.addClickListener(listener);
    button_off.setStyleName("xmas-button-off");
    contentLayout.addComponent(button_off, 0, 0);
    contentLayout.setComponentAlignment(button_off, Alignment.MIDDLE_LEFT);

    // button_on
    button_on = new Embedded("On", new ThemeResource("./images/on.png"));
    button_on.setImmediate(true);
    button_on.setWidth("-1px");
    button_on.setHeight("-1px");
    button_on.addListener(listener);
    button_on.setStyleName("xmas-button-on");
    contentLayout.addComponent(button_on, 1, 0);
    contentLayout.setComponentAlignment(button_on, Alignment.MIDDLE_RIGHT);

    // button_red
    button_red = new Embedded(null, new ThemeResource("./images/red.png"));
    button_red.setCaption("Red");
    button_red.setImmediate(true);
    button_red.setWidth("-1px");
    button_red.setHeight("-1px");
    button_red.addListener(listener);
    button_red.setStyleName("xmas-button-red");
    contentLayout.addComponent(button_red, 0, 1);
    contentLayout.setComponentAlignment(button_red, Alignment.MIDDLE_LEFT);

    // button_blue
    button_blue = new Embedded(null, new ThemeResource("./images/blue.png"));
    button_blue.setCaption("Blue");
    button_blue.setImmediate(true);
    button_blue.setWidth("-1px");
    button_blue.setHeight("-1px");
    button_blue.setStyleName("xmas-button-blue");
    button_blue.addListener(listener);
    contentLayout.addComponent(button_blue, 1, 1);
    contentLayout.setComponentAlignment(button_blue, Alignment.MIDDLE_RIGHT);

    // button_flash
    button_flash = new Embedded(null, new ThemeResource("./images/flash.png"));
    button_flash.setCaption("Flash");
    button_flash.setImmediate(true);
    button_flash.setWidth("-1px");
    button_flash.setHeight("-1px");
    button_flash.addListener(listener);
    button_flash.setStyleName("xmas-button-flash");
    contentLayout.addComponent(button_flash, 0, 2);
    contentLayout.setComponentAlignment(button_flash, Alignment.MIDDLE_LEFT);

    // button_strobe
    button_strobe = new Embedded(null, new ThemeResource("./images/strobe.png"));
    button_strobe.setCaption("Strobo");
    button_strobe.setImmediate(true);
    button_strobe.setWidth("-1px");
    button_strobe.setHeight("-1px");
    button_strobe.addListener(listener);
    button_strobe.setStyleName("xmas-button-strobe");
    contentLayout.addComponent(button_strobe, 1, 2);
    contentLayout.setComponentAlignment(button_strobe, Alignment.MIDDLE_RIGHT);

    // button_snow
    button_snow = new Embedded(null, new ThemeResource("./images/snowflake.png"));
    button_snow.setCaption("Let it snow");
    button_snow.setImmediate(true);
    button_snow.setWidth("-1px");
    button_snow.setHeight("-1px");
    button_snow.addListener(listener);
    button_snow.setStyleName("xmas-button-snow");
    contentLayout.addComponent(button_snow, 0, 3);
    contentLayout.setComponentAlignment(button_snow, Alignment.MIDDLE_LEFT);

    // button_angel
    button_angel = new Embedded(null, new ThemeResource("./images/angel.png"));
    button_angel.setCaption("Angel");
    button_angel.setImmediate(true);
    button_angel.setWidth("-1px");
    button_angel.setHeight("-1px");
    button_angel.addListener(listener);
    button_angel.setStyleName("xmas-button-angel");
    contentLayout.addComponent(button_angel, 1, 3);
    contentLayout.setComponentAlignment(button_angel, Alignment.MIDDLE_RIGHT);

    // button_star
    button_star = new Embedded(null, new ThemeResource("./images/star.png"));
    button_star.setCaption("Star");
    button_star.setImmediate(true);
    button_star.setWidth("-1px");
    button_star.setHeight("-1px");
    button_star.addListener(listener);
    button_star.setStyleName("xmas-button-star");
    contentLayout.addComponent(button_star, 0, 4);
    contentLayout.setComponentAlignment(button_star, Alignment.MIDDLE_LEFT);

    return contentLayout;
}