Example usage for com.vaadin.ui Button setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:gov.va.ehtac.appsonfhir.ui.HCSLogs.java

private Button getButtonWithIcon(String val) {
    Button rButton = new Button();
    rButton.setStyleName(Runo.LABEL_SMALL);
    Label lbl = new Label();
    rButton.setData(val);
    if (val.contains("Condition")) {
        rButton.setCaption("Condition Bundle");
    } else if (val.contains("Observation")) {
        rButton.setCaption("Observation Bundle");
    } else if (val.contains("MedicationPrescription")) {
        rButton.setCaption("Medication Prescription Bundle");
    } else if (val.contains("Allergy")) {
        rButton.setCaption("Allergy Intolerence Bundle");
    } else if (val.contains("Immunization")) {
        rButton.setCaption("Immunization Bundle");
    } else if (val.contains("Encounter")) {
        rButton.setCaption("Encounter Bundle");
    } else {/*from ww  w  . java  2  s  .c  o m*/
        rButton.setCaption("Unknown Resource Bundle");
    }
    rButton.setIcon(new ThemeResource("../runo/icons/16/document-web.png"));
    rButton.setData(val);

    //        rButton.addListener(new MouseEvents.ClickListener() {
    //
    //            @Override
    //            public void click(MouseEvents.ClickEvent event) {
    //                String data = (String)event.getButton().getData();
    //                String title = (String)event.getButton().getCaption();
    //                Popover p = getPopoverTextArea(data, title);
    //                p.showRelativeTo(getNavigationBar());
    //            }
    //        });

    return rButton;
}

From source file:info.magnolia.configuration.app.problem.toolbar.ProblemToolbarViewImpl.java

License:Open Source License

private void iniSearchField() {
    Button clearSearchBoxButton = new Button();
    clearSearchBoxButton.setStyleName("m-closebutton");
    clearSearchBoxButton.addStyleName("icon-delete-search");
    clearSearchBoxButton.addStyleName("searchbox-clearbutton");
    // Preventing the button to spoil the tab-navigation due to its changing display value.
    clearSearchBoxButton.setTabIndex(-1);
    clearSearchBoxButton.addClickListener(new Button.ClickListener() {

        @Override//from   w w  w .  ja  va  2 s .c o m
        public void buttonClick(Button.ClickEvent event) {
            searchField.setValue("");
        }
    });

    Icon searchIcon = new Icon("search");
    searchIcon.addStyleName("searchbox-icon");

    Icon searchArrow = new Icon("arrow2_s");
    searchArrow.addStyleName("searchbox-arrow");

    searchField = buildSearchField();

    searchLayout.setVisible(true);
    searchLayout.addComponent(searchField);
    searchLayout.addComponent(clearSearchBoxButton);
    searchLayout.addComponent(searchIcon);
    searchLayout.addComponent(searchArrow);
    searchLayout.setStyleName("searchbox");

    VerticalLayout searchLayoutWrapper = new VerticalLayout();
    searchLayoutWrapper.setStyleName("workbench");
    searchLayoutWrapper.addComponent(searchLayout);

    addComponent(searchLayoutWrapper);
}

From source file:info.magnolia.ui.framework.overlay.OverlayPresenter.java

License:Open Source License

/**
 * Convenience method for presenting notification indicator with string content.
 */// w ww  . j  a v a2s.  c o m
@Override
public void openNotification(MessageStyleType type, boolean doesTimeout, String title, String linkText,
        final NotificationCallback callback) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.addComponent(new Label(title, ContentMode.HTML));

    Button button = new Button(linkText, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            callback.onLinkClicked();
        }
    });
    button.setStyleName(BaseTheme.BUTTON_LINK);

    layout.addComponent(button);
    openNotification(type, doesTimeout, new ViewAdapter(layout));
}

From source file:info.magnolia.ui.workbench.contenttool.search.SearchContentToolViewImpl.java

License:Open Source License

@Inject
public SearchContentToolViewImpl(SimpleTranslator i18n) {
    this.i18n = i18n;
    Button clearSearchBoxButton = new Button();
    clearSearchBoxButton.setStyleName("m-closebutton");
    clearSearchBoxButton.addStyleName("icon-delete-search");
    clearSearchBoxButton.addStyleName("searchbox-clearbutton");
    // Preventing the button to spoil the tab-navigation due to its changing display value.
    clearSearchBoxButton.setTabIndex(-1);
    clearSearchBoxButton.addClickListener(new Button.ClickListener() {

        @Override//from   w  ww . j  a  v a2 s .c  om
        public void buttonClick(Button.ClickEvent event) {
            searchField.setValue("");
        }
    });

    Icon searchIcon = new Icon("search");
    searchIcon.addStyleName("searchbox-icon");

    Icon searchArrow = new Icon("arrow2_s");
    searchArrow.addStyleName("searchbox-arrow");

    searchField = buildSearchField();

    setVisible(true);
    addComponent(searchField);
    addComponent(clearSearchBoxButton);
    addComponent(searchIcon);
    addComponent(searchArrow);
    setStyleName("searchbox");
}

From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java

public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker,
        final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes,
        final NodeType nodeType) {
    super("Add New Node");
    setModal(true);//from  w w w  .ja v  a 2  s  .co m

    setWidth(650, Unit.PIXELS);
    setHeight(450, Unit.PIXELS);

    GridLayout content = new GridLayout(1, 3);
    content.setSizeFull();
    content.setMargin(true);
    content.setSpacing(true);

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

    content.addComponent(topContent);
    topContent.addComponent(new Label("Nodes:"));

    final ComboBox hadoopNodes = new ComboBox();
    hadoopNodes.setId("HadoopNodesCb");
    hadoopNodes.setImmediate(true);
    hadoopNodes.setTextInputAllowed(false);
    hadoopNodes.setNullSelectionAllowed(false);
    hadoopNodes.setRequired(true);
    hadoopNodes.setWidth(200, Unit.PIXELS);
    for (EnvironmentContainerHost node : nodes) {
        hadoopNodes.addItem(node);
        hadoopNodes.setItemCaption(node, node.getHostname());
    }

    if (nodes.size() == 0) {
        return;
    }
    hadoopNodes.setValue(nodes.iterator().next());

    topContent.addComponent(hadoopNodes);

    final Button addNodeBtn = new Button("Add");
    addNodeBtn.setId("AddSelectedNode");
    topContent.addComponent(addNodeBtn);

    final Button ok = new Button("Ok");

    addNodeBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addNodeBtn.setEnabled(false);
            ok.setEnabled(false);
            showProgress();
            EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue();
            final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(),
                    containerHost.getHostname(), nodeType);
            executorService.execute(new Runnable() {
                public void run() {
                    while (track) {
                        TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY,
                                trackID);
                        if (po != null) {
                            setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n"
                                    + po.getLog());
                            if (po.getState() != OperationState.RUNNING) {
                                hideProgress();
                                ok.setEnabled(true);
                                break;
                            }
                        } else {
                            setOutput("Product operation not found. Check logs");
                            break;
                        }
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException ex) {
                            break;
                        }
                    }
                }
            });
        }
    });

    outputTxtArea = new TextArea("Operation output");
    outputTxtArea.setId("outputTxtArea");
    outputTxtArea.setRows(13);
    outputTxtArea.setColumns(43);
    outputTxtArea.setImmediate(true);
    outputTxtArea.setWordwrap(true);

    content.addComponent(outputTxtArea);

    indicator = new Label();
    indicator.setId("indicator");
    indicator.setIcon(new ThemeResource("img/spinner.gif"));
    indicator.setContentMode(ContentMode.HTML);
    indicator.setHeight(11, Unit.PIXELS);
    indicator.setWidth(50, Unit.PIXELS);
    indicator.setVisible(false);

    ok.setId("btnOk");
    ok.setStyleName("default");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            //close window
            track = false;
            close();
        }
    });

    HorizontalLayout bottomContent = new HorizontalLayout();
    bottomContent.addComponent(indicator);
    bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT);
    bottomContent.addComponent(ok);

    content.addComponent(bottomContent);
    content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT);

    setContent(content);
}

From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaPagedTable.java

License:Apache License

@Override
public HorizontalLayout createControls() {
    I18nManager I18nManager = get().getI18nManager();
    final PagedTableContainer container = (PagedTableContainer) getContainerDataSource();
    Label itemsPerPageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PER_PAGINA));
    final ComboBox itemsPerPageSelect = new ComboBox();

    itemsPerPageSelect.addItem("3");
    itemsPerPageSelect.addItem("10");
    itemsPerPageSelect.addItem("25");
    itemsPerPageSelect.addItem("50");
    itemsPerPageSelect.setImmediate(true);
    itemsPerPageSelect.setNullSelectionAllowed(false);
    itemsPerPageSelect.setWidth("50px");
    itemsPerPageSelect.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue())));
        }/*w  ww. j ava 2 s  .c o m*/
    });
    itemsPerPageSelect.select(maxRecords + "");
    Label pageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PAG) + "&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    Label separatorLabel = new Label("&nbsp;/&nbsp;", Label.CONTENT_XHTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    HorizontalLayout controlBar = new HorizontalLayout();
    HorizontalLayout pageSize = new HorizontalLayout();
    HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(ClickEvent event) {
            setCurrentPage(0);
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(ClickEvent event) {
            previousPage();
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(ClickEvent event) {
            nextPage();
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    first.setStyleName(Reindeer.BUTTON_LINK);
    previous.setStyleName(Reindeer.BUTTON_LINK);
    next.setStyleName(Reindeer.BUTTON_LINK);
    last.setStyleName(Reindeer.BUTTON_LINK);

    itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption");
    itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox");
    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    itemsPerPageLabel.addStyleName("pagedtable-label");
    itemsPerPageSelect.addStyleName("pagedtable-combobox");
    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.addComponent(itemsPerPageLabel);
    pageSize.addComponent(itemsPerPageSelect);
    pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT);
    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        public void pageChanged(PagedTableChangeEvent event) {
            first.setEnabled(container.getStartIndex() > 0);
            previous.setEnabled(container.getStartIndex() > 0);
            next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
            itemsPerPageSelect.setValue(String.valueOf(getPageLength()));
        }
    });
    controlBar.setStyleName("pagination");
    return controlBar;
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();/*from   w  ww  . j av a2s .c o  m*/

    VerticalLayout header = new VerticalLayout();
    header.setSizeFull();

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

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

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

    buttons.setMargin(true);
    buttons.setSpacing(true);
    buttons.setSizeFull();

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

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

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

From source file:module.contents.presentationTier.component.AddSectionButton.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    final Button button = new Button("+ " + getMessage("label.add.section"));
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addListener(new Button.ClickListener() {
        @Override//  w  w w  .  j  a  v  a 2 s. co  m
        public void buttonClick(ClickEvent event) {
            final ContentEditorWindow editorWindow = new ContentEditorWindow(
                    getMessage("label.add.section.window.title"), "label.save");
            editorWindow.setContentEditorSaveListner(contentEditorSaveListner);
            getWindow().addWindow(editorWindow);
            editorWindow.center();
        }
    });
    setCompositionRoot(button);
}

From source file:module.contents.presentationTier.component.EditSectionButton.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    final String key = plainHtmlEditor ? "label.edit.html" : "label.edit";
    final Button button = new Button(getMessage(key));
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addListener(new Button.ClickListener() {
        @Override/*from   w  w w . j a va2  s.  c o m*/
        public void buttonClick(ClickEvent event) {
            final ContentEditorLayout contentEditorLayout = new ContentEditorLayout("label.save",
                    section.getTitle().getContent(), section.getContents().getContent(), plainHtmlEditor);

            final AbstractComponentContainer parent = (AbstractComponentContainer) container.getParent();
            parent.replaceComponent(container, contentEditorLayout);

            contentEditorLayout.setContentEditorSaveListner(new ContentEditorSaveListner() {
                @Override
                public void save(final String title, final String content) {
                    editSectionSaveListner.save(title, content, contentEditorLayout);
                }
            });

            contentEditorLayout.setContentEditorCloseListner(new ContentEditorCloseListner() {
                @Override
                public void close() {
                    parent.replaceComponent(contentEditorLayout, container);
                }
            });
        }
    });
    setCompositionRoot(button);
}

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

License:Open Source License

private void initView() {
    setCompositionRoot(root);//  www  .j  a v a2  s .c om
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}