Example usage for com.vaadin.ui Button setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java

License:Open Source License

/**
 * Creates the west area layout including the
 * accordion and tree views./*from  w w  w  .  j av  a2 s .  c o m*/
 * 
 * @return
 */
@SuppressWarnings("serial")
private Layout createWestLayout() {
    m_tree = createTree();

    final TextField filterField = new TextField("Filter");
    filterField.setTextChangeTimeout(200);

    final Button filterBtn = new Button("Filter");
    filterBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            GCFilterableContainer container = m_tree.getContainerDataSource();
            container.removeAllContainerFilters();

            String filterString = (String) filterField.getValue();
            if (!filterString.equals("") && filterBtn.getCaption().toLowerCase().equals("filter")) {
                container.addContainerFilter(LABEL_PROPERTY, (String) filterField.getValue(), true, false);
                filterBtn.setCaption("Clear");
            } else {
                filterField.setValue("");
                filterBtn.setCaption("Filter");
            }

        }
    });

    HorizontalLayout filterArea = new HorizontalLayout();
    filterArea.addComponent(filterField);
    filterArea.addComponent(filterBtn);
    filterArea.setComponentAlignment(filterBtn, Alignment.BOTTOM_CENTER);

    m_treeAccordion = new Accordion();
    m_treeAccordion.addTab(m_tree, m_tree.getTitle());
    m_treeAccordion.setWidth("100%");
    m_treeAccordion.setHeight("100%");

    AbsoluteLayout absLayout = new AbsoluteLayout();
    absLayout.setWidth("100%");
    absLayout.setHeight("100%");
    absLayout.addComponent(filterArea, "top: 25px; left: 15px;");
    absLayout.addComponent(m_treeAccordion, "top: 75px; left: 15px; right: 15px; bottom:25px;");

    return absLayout;
}

From source file:org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent.java

License:Open Source License

private static Button createButton(GraphContainer container, Breadcrumb breadcrumb) {
    final Button button = new Button();
    final String layerName = getLayerName(container, breadcrumb.getTargetNamespace());
    if (breadcrumb.getSourceVertices().isEmpty()) {
        button.setCaption(layerName);
    } else {/*ww  w.j av a 2s .  c  o m*/
        String sourceLayerName = getLayerName(container, breadcrumb.getSourceVertices().get(0).getNamespace());
        if (breadcrumb.getSourceVertices().size() > 2) {
            button.setCaption("Multiple " + layerName);
            button.setDescription(String.format("Multiple vertices from %s", sourceLayerName));
        } else {
            button.setCaption(breadcrumb.getSourceVertices().stream().map(b -> b.getLabel())
                    .collect(Collectors.joining(", ")));
            button.setDescription(String.format("%s from %s", button.getCaption(), sourceLayerName));
        }
    }
    button.addStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener((event) -> breadcrumb.clicked(container));
    return button;
}

From source file:org.opennms.features.vaadin.jmxconfiggenerator.ui.UIHelper.java

License:Open Source License

public static Button createButton(final String buttonCaption, final String buttonDescription,
        final Resource icon, final ClickListener clickListener) {
    Button button = new Button();
    button.setCaption(buttonCaption);
    button.setIcon(icon);//w  w  w .ja  va  2 s . c o  m
    if (buttonDescription != null)
        button.setDescription(buttonDescription);
    if (clickListener != null)
        button.addClickListener(clickListener);
    return button;
}

From source file:org.openthinclient.web.pkgmngr.ui.InstallationPlanSummaryDialog.java

/**
 * Creates a table with datasource of IndexedContainer
 * @return the Grid for InstallationSummary
 *//*w w w.  ja va2  s  .  c o  m*/
private Grid<InstallationSummary> createTable(GridTypes type) {

    Grid<InstallationSummary> summary = new Grid<>();
    summary.setDataProvider(DataProvider.ofCollection(Collections.EMPTY_LIST));
    summary.setSelectionMode(Grid.SelectionMode.NONE);
    summary.addColumn(InstallationSummary::getPackageName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    summary.addColumn(InstallationSummary::getPackageVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    if (type == GridTypes.INSTALL_UNINSTALL && !packageManagerOperation.hasPackagesToUninstall()) { // license column
        summary.addComponentColumn(is -> {
            if (is.getLicense() != null) {
                Button button = new Button(
                        mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                button.addClickListener(click -> {
                    // licence already clicked, re-set button caption
                    licenceButtons.stream().filter(b -> !b.equals(button)).forEach(b -> {
                        if (b.getCaption().equals(
                                mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_HIDE))) {
                            b.setCaption(
                                    mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                        }
                    });
                    // display licence
                    if (button.getCaption()
                            .equals(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW))) {
                        licenceTextArea.setVisible(true);
                        licenceTextArea.setValue(is.getLicense());
                    } else {
                        licenceTextArea.setVisible(false);
                    }
                    button.setCaption(licenceTextArea.isVisible()
                            ? mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_HIDE)
                            : mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                });
                button.addStyleName("package_install_summary_display_license_button");
                licenceButtons.add(button);
                return button;
            } else {
                return null;
            }
        }).setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE));
    }

    summary.addStyleName(ValoTheme.TABLE_BORDERLESS);
    summary.addStyleName(ValoTheme.TABLE_NO_HEADER);
    summary.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
    summary.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
    summary.setHeightMode(HeightMode.ROW);

    return summary;
}

From source file:org.openthinclient.web.pkgmngr.ui.view.PackageDetailsWindow.java

public PackageDetailsWindow(PackageDetailsPresenter.View target, Component viewComponent) {
    this.target = target;

    final VerticalLayout contents = new VerticalLayout();
    contents.setMargin(true);//from  w ww  .ja v a 2s. c o  m
    contents.addComponent(viewComponent);
    contents.setExpandRatio(viewComponent, 1);
    contents.setSizeFull();

    final HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleNames(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    actionBar = new CssLayout();
    footer.addComponent(actionBar);
    footer.setWidth("100%");
    footer.setExpandRatio(actionBar, 1);
    footer.setComponentAlignment(actionBar, Alignment.TOP_RIGHT);

    final Button closeButton = new Button();
    closeButton.addStyleNames(ValoTheme.BUTTON_QUIET);
    closeButton.setIcon(VaadinIcons.CLOSE);
    closeButton.setCaption("Close");
    closeButton.addClickListener(e -> hide());
    footer.addComponent(closeButton);

    contents.addComponent(footer);

    setContent(contents);
}

From source file:pl.edu.agh.samm.testapp.SAMMTestApplication.java

License:Apache License

private Button createGenerationControlButton() {
    final Button generationControl = new Button(START_WORKLOAD);
    generationControl.addClickListener(new Button.ClickListener() {
        @Override/*  ww w.j av a 2s.  com*/
        public void buttonClick(ClickEvent event) {
            try {
                WorkloadGeneratorFacade workloadGeneratorFacade = WorkloadGeneratorFacade.getInstance();
                if (generationControl.getCaption().equals(START_WORKLOAD)) {
                    publishMessage("Starting expressions generation...");
                    workloadGeneratorFacade
                            .startGenerating(Long.parseLong(expressionsPerMinuteTextField.getValue()));
                    publishMessage("Started expressions generation");
                    generationControl.setCaption(STOP_WORKLOAD);
                } else {
                    publishMessage("Stopping expressions generation...");
                    workloadGeneratorFacade.stopGenerating();
                    publishMessage("Stopped expressions generation");
                    generationControl.setCaption(START_WORKLOAD);
                }
            } catch (InterruptedException e) {
                publishMessage("Error! " + e.getMessage());
                e.printStackTrace();
            }
        }
    });
    return generationControl;
}

From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java

License:Apache License

private void showAlreadyVotedFragment(final ComponentContainer container, final Entity selectedEntity,
        final OpenGroupsApplication app, final UserAction ua, final ActionContext ac) {
    String entityType = selectedEntity.getSimpleType().toLowerCase();
    String currentUserVote = selectedEntity.getUserData().getVote();
    String messageKey = entityType + ".already.voted." + currentUserVote;
    HorizontalLayout hl = new HorizontalLayout();
    hl.addStyleName(OpenGroupsStyles.TOP_RIGHT);
    hl.setSpacing(true);/*from w  ww.  j a v  a  2s  .  c o m*/
    hl.addComponent(new Label(OpenGroupsResources.getMessage(messageKey)));

    final VoteType opposedVote = VoteType.opposteVoteForValue(currentUserVote, entityType);

    Button changeVoteButton = new Button(/*OpenGroupsResources.getMessage("change.vote")*/);
    changeVoteButton.setCaption(opposedVote.getCaption());
    changeVoteButton.setIcon(opposedVote.getIcon());
    changeVoteButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //      container.removeAllComponents();
            //      showVotesFragment(container, selectedEntity, app, ua, ac);
            Map<String, Object> params = ua.getActionParams();
            //      params.put("entityId", selectedEntity.getId());
            params.put("entityLinkId", selectedEntity.getSelectedCause().getLinkId());
            params.put("userId", app.getCurrentUserId());
            params.put("isRecordCreated", selectedEntity.getUserData().isEntityLinkUserRecordCreated());
            params.put("vote", opposedVote.getValue());
            CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params);
            /* refresh the entity only if the user was actually able to vote */
            if (response != null) {
                app.refreshEntity(selectedEntity, ac);
            }
        }
    });
    hl.addComponent(changeVoteButton);

    Button recallVoteButton = new Button(OpenGroupsResources.getMessage("recall.vote"));
    recallVoteButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.CANCEL, OpenGroupsIconsSet.SMALL));
    recallVoteButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            EntityLink selectedCause = selectedEntity.getSelectedCause();

            Map<String, Object> params = ua.getActionParams();

            params.put("entityLinkId", selectedCause.getLinkId());
            params.put("userId", app.getCurrentUserId());
            params.put("isRecordCreated", true);

            CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params);
            /* refresh the entity only if the user was actually able to vote */
            if (response != null) {
                app.refreshEntity(selectedEntity, ac);
            }
        }
    });
    hl.addComponent(recallVoteButton);
    container.addComponent(hl);
}

From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java

License:Apache License

private Button getButtonForVoteType(final VoteType voteType, final ComponentContainer container,
        final Entity selectedEntity, final OpenGroupsApplication app, final UserAction ua,
        final ActionContext ac) {
    Button button = new Button();
    button.setCaption(voteType.getCaption());
    button.setIcon(voteType.getIcon());//from ww  w . j a  v a  2  s.  co m
    //   button.setDescription(voteType.getCaption());
    button.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            Map<String, Object> params = ua.getActionParams();
            //      params.put("entityId", selectedEntity.getId());
            params.put("entityLinkId", selectedEntity.getSelectedCause().getLinkId());
            params.put("userId", app.getCurrentUserId());
            params.put("isRecordCreated", selectedEntity.getUserData().isEntityLinkUserRecordCreated());
            params.put("vote", voteType.getValue());
            CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params);
            /* refresh the entity only if the user was actually able to vote */
            if (response != null) {
                app.refreshEntity(selectedEntity, ac);
            }
        }
    });
    return button;
}

From source file:ro.zg.open_groups.gui.components.CustomTabSheet.java

License:Apache License

public void addTab(final Component tabContent, String caption) {
    Button tab = tabs.get(tabContent);
    if (tab == null) {
        tab = new Button(caption);
        tab.addStyleName(BaseTheme.BUTTON_LINK);
        tabs.put(tabContent, tab);/*from www  . j  a  va2s .  co  m*/
        /* if this is the first tab in this tabsheet select it */
        if (tabs.size() == 1) {
            if (!initialized) {
                /* laizy initialization when the first tab is added */
                initialize();
                initialized = true;
            }
            tabsArea.addComponent(tab);
            selectTab(tabContent, tab);
        } else {
            tabsArea.addComponent(tab);
        }
        /* add click listener for this tab */
        tab.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                selectTab(tabContent, event.getButton());
            }
        });

    } else {
        tab.setCaption(caption);
    }
}

From source file:uk.co.intec.keyDatesApp.components.Pager.java

License:Apache License

/**
 * Load pager sizes buttons/*from   w w  w.j a  v a2  s .  c  om*/
 *
 * @return HorizontalLayout containing the pager sizes buttons
 */
public HorizontalLayout loadPagerSizesButtons() {
    final HorizontalLayout panel = new HorizontalLayout();
    for (final Sizes size : getAvailableSizes()) {
        final Button pageSizeLink = new Button();
        pageSizeLink.setCaption(Integer.toString(size.getValue()));
        pageSizeLink.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
        pageSizeLink.addStyleName(ValoTheme.BUTTON_TINY);
        pageSizeLink.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            /*
             * (non-Javadoc)
             *
             * @see
             * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.
             * Button.ClickEvent)
             */
            @Override
            public void buttonClick(ClickEvent event) {
                getWrappedView().setCount(size.getValue());
                getWrappedView().redrawContents();
                updatePagerSizeButtonStyles();
                loadPagerPagesButtons();
            }
        });
        getPagerSizeButtons().put(size, pageSizeLink);
        panel.addComponents(pageSizeLink);

        if (getAvailableSizes().indexOf(size) < (getAvailableSizes().size() - 1)) {
            final Label spacer = new Label("|");
            panel.addComponent(spacer);
        }
    }
    updatePagerSizeButtonStyles();
    return panel;
}