Example usage for com.vaadin.ui Button setDescription

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

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

From source file:org.opencms.ui.components.CmsAppViewLayout.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsAppUIContext#addPublishButton(org.opencms.ui.I_CmsUpdateListener)
 *//*  w  ww.  j av  a 2 s. c  o m*/
public Button addPublishButton(final I_CmsUpdateListener<String> updateListener) {

    Button publishButton = CmsToolBar.createButton(FontOpenCms.PUBLISH,
            CmsVaadinUtils.getMessageText(Messages.GUI_PUBLISH_BUTTON_TITLE_0));
    if (CmsAppWorkplaceUi.isOnlineProject()) {
        // disable publishing in online project
        publishButton.setEnabled(false);
        publishButton
                .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_TOOLBAR_NOT_AVAILABLE_ONLINE_0));
    }
    publishButton.addClickListener(new ClickListener() {

        /** Serial version id. */
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            CmsAppWorkplaceUi.get().disableGlobalShortcuts();
            CmsGwtDialogExtension extension = new CmsGwtDialogExtension(A_CmsUI.get(), updateListener);
            extension.openPublishDialog(A_CmsUI.getCmsObject().getRequestContext().getCurrentProject());
        }
    });

    addToolbarButton(publishButton);
    return publishButton;
}

From source file:org.opencms.ui.components.CmsRemovableFormRow.java

License:Open Source License

/**
 * Constructor.<p>/*  w  w w.j av a  2 s  .  co  m*/
 *
 * @param input the input field
 * @param removeLabel the remove button label
 */
public CmsRemovableFormRow(T input, String removeLabel) {
    setWidth("100%");
    m_input = input;
    setSpacing(true);
    input.setWidth("100%");
    addComponent(input);
    setExpandRatio(input, 1f);
    Button deleteButton = new Button("");
    deleteButton.setIcon(FontOpenCms.CUT_SMALL);
    deleteButton.addStyleName(OpenCmsTheme.BUTTON_ICON);
    deleteButton.setDescription(removeLabel);
    deleteButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            HasComponents parent = CmsRemovableFormRow.this.getParent();
            if (parent instanceof ComponentContainer) {
                ((ComponentContainer) parent).removeComponent(CmsRemovableFormRow.this);
            }
        }
    });
    addComponent(deleteButton);
}

From source file:org.opencms.ui.components.CmsToolBar.java

License:Open Source License

/**
 * Creates a properly styled toolbar button.<p>
 *
 * @param icon the button icon//w  w w .  ja  v a 2 s  . c om
 * @param title the button title, will be used for the tooltip
 * @param alwaysShow <code>true</code> to prevent the button to be folded into a sub menu for small screens
 *
 * @return the button
 */
public static Button createButton(Resource icon, String title, boolean alwaysShow) {

    Button button = new Button(icon);
    button.setDescription(title);
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button.addStyleName(OpenCmsTheme.TOOLBAR_BUTTON);
    if (alwaysShow) {
        button.addStyleName(OpenCmsTheme.REQUIRED_BUTTON);
    }
    return button;
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Creates the "Add key" button./*from www  .  j av a 2s . c  o  m*/
 * @return the "Add key" button.
 */
private Component createAddKeyButton() {

    // the "+" button
    Button addKeyButton = new Button();
    addKeyButton.addStyleName("icon-only");
    addKeyButton.addStyleName("borderless-colored");
    addKeyButton.setDescription(m_messages.key(Messages.GUI_ADD_KEY_0));
    addKeyButton.setIcon(FontOpenCms.CIRCLE_PLUS, m_messages.key(Messages.GUI_ADD_KEY_0));
    addKeyButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            handleAddKey();

        }
    });
    return addKeyButton;
}

From source file:org.opencms.ui.util.table.CmsTableUtil.java

License:Open Source License

/**
 * Creates an icon button.<p>//from  w w  w .j  a  va  2s. c o  m
 *
 * @param icon the resource for the icon
 * @param caption the caption
 *
 * @return the created button
 */
public static Button createIconButton(Resource icon, String caption) {

    Button button = new Button();

    button.addStyleName(OpenCmsTheme.BUTTON_TABLE_ICON);
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button.setIcon(icon);
    button.setDescription(caption);
    return button;
}

From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java

License:Open Source License

/**
 * Executes one of the dialog actions.<p>
 *
 * @param action the action to perform/*from   w  ww .  ja  v a2 s. c  o  m*/
 */
public void runAction(ActionType action) {

    m_mode = action;
    setActionFlags();
    setCommonParameters();
    m_checkinBean.clearModules();
    for (String moduleName : getSelectedModules()) {
        m_checkinBean.addModuleToExport(moduleName);
    }
    int result = m_checkinBean.checkIn();
    String log = m_checkinBean.getLogText();
    String message = null;
    boolean error = false;
    switch (action) {
    case checkIn:
        String messageToSave = m_checkinBean.getCommitMessage();
        String emailToSave = m_checkinBean.getGitUserEmail();
        String userToSave = m_checkinBean.getGitUserName();
        CmsObject cms = m_checkinBean.getCmsObject();
        CmsUser user = cms.getRequestContext().getCurrentUser();
        setUserInfo(user, ADDINFO_USER, userToSave);
        setUserInfo(user, ADDINFO_EMAIL, emailToSave);
        setUserInfo(user, ADDINFO_MESSAGE, messageToSave);
        try {
            cms.writeUser(user);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }

        List<Button> resetButtons = new ArrayList<Button>();

        Button resetHead = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_HEAD_0));
        resetHead.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_HEAD_DESC_0));
        resetHead.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {

                runAction(ActionType.resetHead);
            }
        });

        Button resetRemoteHead = new Button(
                CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_REMOTE_HEAD_0));
        resetRemoteHead.setDescription(
                CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_REMOTE_HEAD_DESC_0));
        resetRemoteHead.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {

                runAction(ActionType.resetRemoteHead);
            }
        });

        if (result == 0) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_SUCCESSFUL_0);
        } else if (result == 10) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_FAILED_0);
            error = true;
            resetButtons.add(resetRemoteHead);
            resetButtons.add(resetHead);
        } else {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_FAILED_0);
            error = true;
            resetButtons.add(resetRemoteHead);
        }
        CmsGitActionResultPanel panel = new CmsGitActionResultPanel(message, log, error, resetButtons);
        addAsWindow(panel);
        break;
    case checkOut:
        if (result == 0) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_IMPORT_SUCCESSFUL_0);
        } else {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_IMPORT_FAILED_0);
        }
        CmsGitActionResultPanel checkoutResult = new CmsGitActionResultPanel(message, log, error,
                new ArrayList<Button>());
        addAsWindow(checkoutResult);
        break;
    case resetHead:
        if (result == 0) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_SUCCESSFUL_0);
        } else {
            error = true;
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_FAILED_0);
        }
        CmsGitActionResultPanel resetResult = new CmsGitActionResultPanel(message, log, error,
                new ArrayList<Button>());
        addAsWindow(resetResult);
        break;
    case resetRemoteHead:
        if (result == 0) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_SUCCESSFUL_0);
        } else {
            error = true;
            message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_FAILED_0);
        }
        CmsGitActionResultPanel resetRemoteResult = new CmsGitActionResultPanel(message, log, error,
                new ArrayList<Button>());
        addAsWindow(resetRemoteResult);
        break;
    default:
        // Should never happen
    }
}

From source file:org.openeos.services.ui.vaadin.internal.notifications.VaadinNotificationManager.java

License:Apache License

private void refreshLayout(final IUnoVaadinApplication application, HorizontalLayout layout) {
    layout.removeAllComponents();//from   w ww .j ava 2  s  .  c o  m
    for (final Notification notification : resolveAndSortNotifications(application)) {
        VerticalLayout vLayout = new VerticalLayout();
        vLayout.setMargin(false);
        vLayout.setSpacing(false);
        Button button = new Button();
        button.addListener(new Button.ClickListener() {

            private static final long serialVersionUID = 3202745949615598633L;

            @Override
            public void buttonClick(ClickEvent event) {
                notification.onClick(applicationFactory.createApplication(application));
                ;
            }
        });
        button.setStyleName(Reindeer.BUTTON_LINK);
        button.setIcon(createIconResource(application, notification));
        button.setDescription(notification.getText());
        //createOverlay(application, notification, button, layout);
        vLayout.addComponent(button);
        if (notification.getNumber() != null) {
            Label label = new Label(notification.getNumber().toString());
            label.setSizeUndefined();
            vLayout.addComponent(label);
            vLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        }
        layout.addComponent(vLayout);
    }
}

From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java

License:Apache License

private void addToolbarButtons(HorizontalLayout hLayout) {
    HorizontalLayout newLayout = new HorizontalLayout();
    newLayout.setMargin(false);/*  w w  w.j a v a 2  s  . com*/
    Button buttonRefresh = new Button();
    buttonRefresh.setStyleName(Reindeer.BUTTON_LINK);
    buttonRefresh.setIcon(Resources.ICON_32_REFRESH);
    buttonRefresh.setDescription("Refresh");
    buttonRefresh.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            refresh();
        }
    });
    newLayout.addComponent(buttonRefresh);

    Button buttonNew = new Button();
    buttonNew.setStyleName(Reindeer.BUTTON_LINK);
    buttonNew.setIcon(Resources.ICON_32_NEW);
    buttonNew.setDescription("New task");
    buttonNew.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            newTask();
        }
    });
    newLayout.addComponent(buttonNew);

    hLayout.addComponent(newLayout);
}

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

License:Open Source License

private Component createMapLayout() {
    final Property<Double> scale = m_graphContainer.getScaleProperty();

    m_lastUpdatedTimeLabel = new LastUpdatedLabel();
    m_lastUpdatedTimeLabel.setImmediate(true);

    m_zoomLevelLabel.setHeight(20, Unit.PIXELS);
    m_zoomLevelLabel.setWidth(22, Unit.PIXELS);
    m_zoomLevelLabel.addStyleName("center-text");
    m_zoomLevelLabel.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override/* w  w  w  . j a v  a2  s . c o m*/
        public void textChange(FieldEvents.TextChangeEvent event) {
            try {
                int zoomLevel = Integer.parseInt(event.getText());
                setSemanticZoomLevel(zoomLevel);
            } catch (NumberFormatException e) {
                setSemanticZoomLevel(m_graphContainer.getSemanticZoomLevel());
            }

        }
    });

    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);

    final Slider slider = new Slider(0, 1);
    slider.setPropertyDataSource(scale);
    slider.setResolution(1);
    slider.setHeight("200px");
    slider.setOrientation(SliderOrientation.VERTICAL);

    slider.setImmediate(true);

    final NativeButton showFocusVerticesBtn = new NativeButton(FontAwesomeIcons.Icon.eye_open.variant());
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.setHtmlContentAllowed(true);
    showFocusVerticesBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (showFocusVerticesBtn.getCaption().equals(FontAwesomeIcons.Icon.eye_close.variant())) {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_open.variant());
            } else {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_close.variant());
            }
            m_topologyComponent.getState()
                    .setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus());
            m_topologyComponent.updateGraph();
        }
    });

    final NativeButton magnifyBtn = new NativeButton();
    magnifyBtn.setHtmlContentAllowed(true);
    magnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_in.stylename() + "\" ></i>");
    magnifyBtn.setStyleName("icon-button");
    magnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() < 1) {
                slider.setValue(Math.min(1, slider.getValue() + 0.25));
            }
        }
    });

    final NativeButton demagnifyBtn = new NativeButton();
    demagnifyBtn.setHtmlContentAllowed(true);
    demagnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_out.stylename() + "\" ></i>");
    demagnifyBtn.setStyleName("icon-button");
    demagnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() != 0) {
                slider.setValue(Math.max(0, slider.getValue() - 0.25));
            }
        }
    });

    VerticalLayout sliderLayout = new VerticalLayout();
    sliderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    sliderLayout.addComponent(magnifyBtn);
    sliderLayout.addComponent(slider);
    sliderLayout.addComponent(demagnifyBtn);

    m_szlOutBtn = new Button();
    m_szlOutBtn.setHtmlContentAllowed(true);
    m_szlOutBtn.setCaption(FontAwesomeIcons.Icon.arrow_down.variant());
    m_szlOutBtn.setDescription("Collapse Semantic Zoom Level");
    m_szlOutBtn.setEnabled(m_graphContainer.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            if (szl > 0) {
                szl--;
                setSemanticZoomLevel(szl);
                saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setHtmlContentAllowed(true);
    szlInBtn.setCaption(FontAwesomeIcons.Icon.arrow_up.variant());
    szlInBtn.setDescription("Expand Semantic Zoom Level");
    szlInBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            szl++;
            setSemanticZoomLevel(szl);
            saveHistory();
        }
    });

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.setStyleName("toolbar-button down");

    m_selectBtn = new Button();
    m_selectBtn.setIcon(new ThemeResource("images/selection.png"));
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_selectBtn.setStyleName("toolbar-button down");
            m_panBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("select");
        }
    });

    m_panBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_panBtn.setStyleName("toolbar-button down");
            m_selectBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("pan");
        }
    });

    final Button historyBackBtn = new Button(FontAwesomeIcons.Icon.arrow_left.variant());
    historyBackBtn.setHtmlContentAllowed(true);
    historyBackBtn.setDescription("Click to go back");
    historyBackBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.back()");
        }
    });

    final Button historyForwardBtn = new Button(FontAwesomeIcons.Icon.arrow_right.variant());
    historyForwardBtn.setHtmlContentAllowed(true);
    historyForwardBtn.setDescription("Click to go forward");
    historyForwardBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.forward()");
        }
    });

    m_searchBox = new SearchBox(m_serviceManager, new CommandManager.DefaultOperationContext(this,
            m_graphContainer, OperationContext.DisplayLocation.SEARCH));

    //History Button Layout
    HorizontalLayout historyButtonLayout = new HorizontalLayout();
    historyButtonLayout.setSpacing(true);
    historyButtonLayout.addComponent(historyBackBtn);
    historyButtonLayout.addComponent(historyForwardBtn);

    //Semantic Controls Layout
    HorizontalLayout semanticLayout = new HorizontalLayout();
    semanticLayout.setSpacing(true);
    semanticLayout.addComponent(szlInBtn);
    semanticLayout.addComponent(m_zoomLevelLabel);
    semanticLayout.addComponent(m_szlOutBtn);
    semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout historyCtrlLayout = new VerticalLayout();
    historyCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    historyCtrlLayout.addComponent(historyButtonLayout);

    HorizontalLayout controlLayout = new HorizontalLayout();
    controlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    controlLayout.addComponent(m_panBtn);
    controlLayout.addComponent(m_selectBtn);

    VerticalLayout semanticCtrlLayout = new VerticalLayout();
    semanticCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    semanticCtrlLayout.addComponent(semanticLayout);

    HorizontalLayout locationToolLayout = createLocationToolLayout();

    //Vertical Layout for all tools on right side
    VerticalLayout toollayout = new VerticalLayout();
    toollayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    toollayout.setSpacing(true);

    toollayout.addComponent(historyCtrlLayout);
    toollayout.addComponent(locationToolLayout);
    toollayout.addComponent(showFocusVerticesBtn);
    toollayout.addComponent(sliderLayout);
    toollayout.addComponent(controlLayout);
    toollayout.addComponent(semanticCtrlLayout);

    AbsoluteLayout mapLayout = new AbsoluteLayout();
    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(m_lastUpdatedTimeLabel, "top: 5px; right: 10px;");
    mapLayout.addComponent(toollayout, "top: 25px; right: 10px;");
    mapLayout.setSizeFull();

    m_infoPanel = new InfoPanel(m_searchBox, mapLayout);
    return m_infoPanel;
}

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

License:Open Source License

private HorizontalLayout createLocationToolLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/* ww  w  . ja v a2s .  c  om*/
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button showAllMapBtn = new Button(FontAwesomeIcons.Icon.globe.variant());
    showAllMapBtn.setHtmlContentAllowed(true);
    showAllMapBtn.setDescription("Show Entire Map");
    showAllMapBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            m_topologyComponent.showAllMap();
        }
    });

    Button centerSelectionBtn = new Button(FontAwesomeIcons.Icon.location_arrow.variant());
    centerSelectionBtn.setHtmlContentAllowed(true);
    centerSelectionBtn.setDescription("Center On Selection");
    centerSelectionBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            m_topologyComponent.centerMapOnSelection();
        }
    });

    layout.addComponent(centerSelectionBtn);
    layout.addComponent(showAllMapBtn);

    return layout;
}