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:org.ripla.web.util.HelpButton.java

License:Open Source License

private Button createLinkButton(final String inCaption, final URL inHelpContent, final int inWidth,
        final int inHeight) {
    final Button outLink = new Button(inCaption);
    outLink.setStyleName(BaseTheme.BUTTON_LINK);
    outLink.addClickListener(new Button.ClickListener() {
        @Override//www .  j  a  v  a2  s  .  c o  m
        public void buttonClick(final ClickEvent inEvent) {
            final HelpWindow lHelpWindow = new HelpWindow(
                    Activator.getMessages().getMessage("help.window.title"), //$NON-NLS-1$
                    getHelpText(inHelpContent), inWidth, inHeight);
            if (lHelpWindow.getParent() == null) {
                UI.getCurrent().addWindow(lHelpWindow);
            }
            lHelpWindow.setPosition(50, 50);
        }
    });
    return outLink;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.ImpactAnalysisFormLayout.java

License:Mozilla Public License

private void createPagebar(final List<Set> dependentInstances, final Panel searchResultPanel,
        final int resultSize) {
    int numPages = resultSize / PAGE_SIZE;
    if (resultSize % PAGE_SIZE > 0) {
        numPages++;/*from  w w w .  ja v  a2  s  .com*/
    }
    final HorizontalLayout hl = new HorizontalLayout();
    for (int n = 0; n < numPages; n++) {
        final Button linkBtn = new Button("" + (n + 1));
        linkBtn.setData(n);
        linkBtn.setStyleName("link");
        linkBtn.setWidth("10px");
        linkBtn.addListener(new Button.ClickListener() {
            public void buttonClick(final Button.ClickEvent event) {
                //reset pageIndex
                pageIndex = (Integer) linkBtn.getData();
                //rebuild page
                rebuildPage(dependentInstances, searchResultPanel, pageIndex);
            }
        });
        hl.addComponent(linkBtn);
    }
    searchResultPanel.addComponent(hl);
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java

License:Mozilla Public License

private void createPagebar(final Panel searchResultPanel, final int resultSize) {
    int numPages = resultSize / PAGE_SIZE;
    if (resultSize % PAGE_SIZE > 0) {
        numPages++;/*from  ww  w  . j a  va2 s  .c o  m*/
    }
    final HorizontalLayout hl = new HorizontalLayout();
    for (int n = 0; n < numPages; n++) {
        final Button linkBtn = new Button("" + (n + 1));
        linkBtn.setData(n);
        linkBtn.setStyleName("link");
        linkBtn.setWidth("15px");
        linkBtn.addListener(new Button.ClickListener() {
            public void buttonClick(final Button.ClickEvent event) {
                //reset pageIndex
                pageIndex = (Integer) linkBtn.getData();
                //rebuild page
                rebuildPage(searchResultPanel, pageIndex);
            }
        });
        hl.addComponent(linkBtn);
    }
    searchResultPanel.addComponent(hl);
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.HorizontalNavigationViewlet.java

License:Apache License

public void refresh() {
    final CssLayout navigationLayout = new CssLayout();
    //navigationLayout.setSpacing(true);
    //navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }//from   w  w  w  .  ja va2 s  . c  o m
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        itemLayout.setStyleName("horizontal-navigation-" + pageName);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setStyleName("horizontal-navigation-logout");
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.VerticalNavigationViewlet.java

License:Apache License

public void refresh() {
    final VerticalLayout navigationLayout = new VerticalLayout();
    navigationLayout.setSpacing(true);//from w w w.j a  v  a  2s  .c  om
    navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    //final ViewDescriptor page = getPageWindow().getViewDescriptor();
    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(32, UNITS_PIXELS);
            embedded.setHeight(32, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(32, UNITS_PIXELS);
            embedded.setHeight(32, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}

From source file:org.vaadin.notifique.Notifique.java

License:Apache License

/**
 * Create a close button for a message.//  w  w  w  .  j  ava  2s  .  c o  m
 */
protected Button createCloseButtonFor(final Message i) {
    Button b = new Button();
    b.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -1932127150282887613L;

        public void buttonClick(ClickEvent event) {
            i.hide();

        }
    });
    b.setStyleName(Reindeer.BUTTON_LINK);
    b.addStyleName(STYLE_CLOSE);
    return b;
}

From source file:pl.exsio.ca.module.terrain.evidence.FilesDataTable.java

License:Open Source License

protected void addDownloadButtonColumn() {
    dataComponent.addGeneratedColumn("", new Table.ColumnGenerator() {

        @Override/* w  w  w . jav  a2s  . c  om*/
        public Component generateCell(final Table source, final Object itemId, final Object columnId) {

            final Button download = new Button("", FontAwesome.DOWNLOAD);
            final TerrainFile terrainFile = ((EntityItem<TerrainFile>) dataComponent.getItem(itemId))
                    .getEntity();
            Resource res = new StreamResource(new StreamSource() {

                @Override
                public InputStream getStream() {
                    return new ByteArrayInputStream(terrainFile.getData());
                }
            }, terrainFile.getName());
            FileDownloader fd = new FileDownloader(res);
            fd.extend(download);
            download.setImmediate(true);
            download.setStyleName("link");
            return download;
        }
    });
}

From source file:pl.exsio.frameset.vaadin.account.menu.presenter.AccountMenuPresenterImpl.java

License:Open Source License

protected Button getSettingsButton(final User user) {
    final AccountWindowPresenter.AccountEditionListener listener = this;
    Button accountSettings = new NativeButton(t("core.account.settings"));
    accountSettings.setIconAlternateText(t("core.account.settings"));
    accountSettings.setIcon(FontAwesome.COG);
    accountSettings.setStyleName("account-settings");
    accountSettings.addClickListener(new Button.ClickListener() {

        @Override/*  w ww  .  j a va2 s  .co m*/
        public void buttonClick(Button.ClickEvent event) {
            AccountWindowPresenter window = ctx.getBean(AccountWindowPresenter.class);
            window.addAccountEditionListener(listener);
            window.show();
        }
    });

    return accountSettings;
}

From source file:pl.exsio.frameset.vaadin.account.menu.presenter.AccountMenuPresenterImpl.java

License:Open Source License

protected Button getLogoutButton() {
    Button logout = new NativeButton(t("core.logout"));
    logout.setIconAlternateText(t("core.logout"));
    logout.setIcon(FontAwesome.TIMES);//  w w  w .ja  v a 2s .  c o m
    logout.setStyleName("logout");
    logout.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ConfirmationDialog.show(t("core.logout.confirm"), new ConfirmationDialog.Handler() {

                @Override
                public void handle(Button.ClickEvent event) {
                    UI.getCurrent().getSession().close();
                    UI.getCurrent().getPage().setLocation(logoutPath);
                }
            }, null);

        }
    });

    return logout;
}