Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPostPaginator.java

/**
 * Add buttons, based on number of pages
 *
 * @param numberOfPages number Of Pages/*from   www . ja va2 s.co  m*/
 */
public void addButtons(int numberOfPages) {
    this.removeAllComponents();
    buttonList.clear();
    for (int i = 0; i <= numberOfPages; i++) {
        Button b = new Button("" + i);
        b.setData(i);
        b.setStyleName("button-paginator button-label-simple");
        b.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                int page = (int) event.getButton().getData();
                if (curentPage != page) {
                    filterReference.setPageAndReload(page);
                    removeActiveStyle();
                    curentPage = page;
                    buttonList.get(curentPage).addStyleName("paginator-active");
                }
            }

        });
        if (i == 0) {
            b.addStyleName("paginator-active");
        }
        buttonList.add(b);
        this.addComponent(b);
    }

}

From source file:de.catma.ui.CatmaApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    backgroundService = new UIBackgroundService(true);

    storeParameters(request.getParameterMap());

    Page.getCurrent().setTitle("CATMA 5.0 " + MINORVERSION);

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();/*from w ww . ja v  a 2s  .co  m*/

    menuPanel = new Panel();
    menuPanel.addStyleName("menuPanel");
    mainLayout.addComponent(menuPanel);

    contentPanel = new Panel();
    contentPanel.setHeight("100%");
    contentPanel.addStyleName("contentPanel");

    defaultContentPanelLabel = new Label("Please log in to get started");
    defaultContentPanelLabel.addStyleName("defaultContentPanelLabel");
    contentPanel.setContent(defaultContentPanelLabel);

    mainLayout.addComponent(contentPanel);
    mainLayout.setExpandRatio(contentPanel, 1.0f);

    menuLayout = new HorizontalLayout();
    menuLayout.setMargin(true);
    menuLayout.setSpacing(true);

    logoResource = new ThemeResource("catma-logo.png");
    Link logoImage = new Link(null, new ExternalResource("http://www.catma.de"));
    logoImage.setIcon(logoResource);
    logoImage.setTargetName("_blank");
    menuLayout.addComponent(logoImage);

    MenuFactory menuFactory = new MenuFactory();
    try {

        initTempDirectory();
        tagManager = new TagManager();

        repositoryManagerView = new RepositoryManagerView(
                new RepositoryManager(this, tagManager, RepositoryProperties.INSTANCE.getProperties()));

        tagManagerView = new TagManagerView(tagManager);

        taggerManagerView = new TaggerManagerView();

        analyzerManagerView = new AnalyzerManagerView();

        visualizationManagerView = new VisualizationManagerView();

        menu = menuFactory.createMenu(menuLayout, contentPanel,
                new MenuFactory.MenuEntryDefinition("Repository Manager", repositoryManagerView),
                new MenuFactory.MenuEntryDefinition("Tag Type Manager", tagManagerView),
                new MenuFactory.MenuEntryDefinition("Tagger", taggerManagerView),
                new MenuFactory.MenuEntryDefinition("Analyzer", analyzerManagerView),
                new MenuFactory.MenuEntryDefinition("Visualizer", visualizationManagerView));
        addPropertyChangeListener(CatmaApplicationEvent.userChange, menu.userChangeListener);

        Link latestFeaturesLink = new Link("Latest Features",
                new ExternalResource("http://www.catma.de/latestfeatures"));
        latestFeaturesLink.setTargetName("_blank");
        menuLayout.addComponent(latestFeaturesLink);
        menuLayout.setComponentAlignment(latestFeaturesLink, Alignment.TOP_RIGHT);
        menuLayout.setExpandRatio(latestFeaturesLink, 1.0f);

        Link aboutLink = new Link("About", new ExternalResource("http://www.catma.de"));
        aboutLink.setTargetName("_blank");
        menuLayout.addComponent(aboutLink);
        menuLayout.setComponentAlignment(aboutLink, Alignment.TOP_RIGHT);

        Link termsOfUseLink = new Link("Terms of Use", new ExternalResource("http://www.catma.de/termsofuse"));
        termsOfUseLink.setTargetName("_blank");
        menuLayout.addComponent(termsOfUseLink);
        menuLayout.setComponentAlignment(termsOfUseLink, Alignment.TOP_RIGHT);

        Link manualLink = new Link("Manual", new ExternalResource(request.getContextPath() + "/manual/"));
        manualLink.setTargetName("_blank");
        menuLayout.addComponent(manualLink);
        menuLayout.setComponentAlignment(manualLink, Alignment.TOP_RIGHT);

        Link helpLink = new Link("Helpdesk", new ExternalResource("http://www.catma.de/helpdesk/"));
        helpLink.setTargetName("_blank");
        menuLayout.addComponent(helpLink);
        menuLayout.setComponentAlignment(helpLink, Alignment.TOP_RIGHT);
        helpLink.setVisible(false);

        btHelp = new Button(FontAwesome.QUESTION_CIRCLE);
        btHelp.addStyleName("help-button");
        btHelp.addStyleName("application-help-button");

        menuLayout.addComponent(btHelp);

        btHelp.addClickListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {

                if (uiHelpWindow.getParent() == null) {
                    UI.getCurrent().addWindow(uiHelpWindow);
                } else {
                    UI.getCurrent().removeWindow(uiHelpWindow);
                }

            }
        });

        LoginLogoutCommand loginLogoutCommand = new LoginLogoutCommand(menu, repositoryManagerView);
        Button btloginLogout = new Button("Sign in", event -> loginLogoutCommand.menuSelected(null));
        btloginLogout.setStyleName(BaseTheme.BUTTON_LINK);
        btloginLogout.addStyleName("application-loginlink");

        loginLogoutCommand.setLoginLogoutButton(btloginLogout);

        menuLayout.addComponent(btloginLogout);
        menuLayout.setComponentAlignment(btloginLogout, Alignment.TOP_RIGHT);
        menuLayout.setWidth("100%");

        menuPanel.setContent(menuLayout);

        setContent(mainLayout);

        if (getParameter(Parameter.USER_IDENTIFIER) != null) {
            btloginLogout.click();
        }

        setPollInterval(10000);

        if ((getParameter(Parameter.AUTOLOGIN) != null) && (getUser() == null)) {
            getPage().setLocation(repositoryManagerView.createAuthenticationDialog().createLogInClick(this,
                    RepositoryPropertyKey.CATMA_oauthAuthorizationCodeRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthAccessTokenRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientId.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientSecret.getValue(), URLEncoder.encode("/", "UTF-8")));
        }

    } catch (Exception e) {
        showAndLogError("The system could not be initialized!", e);
    }

}

From source file:de.escidoc.admintool.view.EscidocPagedTable.java

License:Open Source License

public HorizontalLayout createControls() {
    // final Label itemsPerPageLabel = new Label("Items per page:");
    final Label pageLabel = new Label("Page:&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    final 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(final com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                @SuppressWarnings("boxing")
                final int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);/*from   w ww . j ava2s.co m*/
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

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

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(0);
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(final ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(BaseTheme.BUTTON_LINK);
    previous.setStyleName(BaseTheme.BUTTON_LINK);
    next.setStyleName(BaseTheme.BUTTON_LINK);
    last.setStyleName(BaseTheme.BUTTON_LINK);

    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");

    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.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() {
        @SuppressWarnings("boxing")
        public void pageChanged(final PagedTableChangeEvent event) {
            previous.setEnabled(true);
            next.setEnabled(true);
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
        }
    });
    return controlBar;
}

From source file:de.fatalix.bookery.AppHeader.java

License:Open Source License

private MHorizontalLayout createSearchBar() {
    Label header = new Label("Bookery");
    header.addStyleName(ValoTheme.LABEL_BOLD);
    header.setSizeUndefined();/*ww  w . ja  v  a2  s  . c om*/
    header.addStyleName(ValoTheme.LABEL_H3);

    searchText = new TextField();
    searchText.setIcon(FontAwesome.SEARCH);
    searchText.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    searchText.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    searchText.setWidth(100, Unit.PERCENTAGE);
    searchText.setInputPrompt("hier einfach suchen..");
    Button searchButton = new Button("such!", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Navigator navigator = ((App) UI.getCurrent()).getNavigator();
            if (navigator.getState().contains("search")) {
                navigator.navigateTo(navigator.getState());
            } else {
                navigator.navigateTo(SearchView.id);
            }

        }
    });
    searchButton.addStyleName(ValoTheme.BUTTON_LARGE);
    searchText.addShortcutListener(new Button.ClickShortcut(searchButton, ShortcutAction.KeyCode.ENTER));

    MHorizontalLayout layout = new MHorizontalLayout(header, searchText, searchButton);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setExpandRatio(searchText, 1.0f);
    return layout;
}

From source file:de.fatalix.bookery.AppHeader.java

License:Open Source License

private MHorizontalLayout createSmallNavBar() {
    Button homeButton = new Button("Home", new Button.ClickListener() {
        @Override/* w w w.ja  v a 2  s  .c o  m*/
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(HomeView.id);
            //bookMenuLayout.setLayoutVisible(true);
        }
    });
    homeButton.addStyleName(ValoTheme.BUTTON_TINY);
    Button plainSearchButton = new Button("einfach stbern", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/author");
        }
    });
    plainSearchButton.addStyleName(ValoTheme.BUTTON_TINY);
    Button newBooks = new Button("neue Bcher", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/author/true");
        }
    });
    newBooks.addStyleName(ValoTheme.BUTTON_TINY);
    Button bestBooks = new Button("Die besten Bcher", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/likes");
        }
    });
    bestBooks.addStyleName(ValoTheme.BUTTON_TINY);

    logoutButton = new Button("Hallo", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).logout();
        }
    });
    logoutButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    logoutButton.addStyleName(ValoTheme.BUTTON_SMALL);

    VerticalLayout buttonLayout = new VerticalLayout(logoutButton);
    buttonLayout.setMargin(false);
    buttonLayout.setSpacing(false);
    buttonLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    MHorizontalLayout layout = new MHorizontalLayout(homeButton, plainSearchButton, newBooks, bestBooks,
            buttonLayout);
    layout.expand(buttonLayout);

    return layout;
}

From source file:de.fatalix.bookery.view.admin.AdminView.java

License:Open Source License

public VerticalLayout createServerSettings() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from   ww w  .j  a v a2 s. c  o  m*/
    Label titleLabel = new Label("General Settings");
    titleLabel.addStyleName(ValoTheme.LABEL_H2);

    //layout.addComponent(titleLabel);
    layout.addComponent(serverSettingsLayout);
    Button resetIndex = new Button("reset Index", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {

            try {
                presenter.resetIndex();
                Notification.show("Succesfully reset Index", Notification.Type.HUMANIZED_MESSAGE);
            } catch (IOException | SolrServerException ex) {
                Notification.show(ex.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    resetIndex.addStyleName(ValoTheme.BUTTON_DANGER);

    final TextField eMailAdress = new TextField(null, "felix.husse@medavis.de");
    eMailAdress.setColumns(35);
    Button testMail = new Button("Test Mail", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.sendEmail(eMailAdress.getValue());
                Notification.show("Mail succesfully sent!", Notification.Type.HUMANIZED_MESSAGE);
            } catch (MessagingException ex) {
                Notification.show("Mail failed!" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    testMail.setEnabled(true);

    Button resetBatchJobs = new Button("reset BatchJobs", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            presenter.resetBatchJobs();
            Notification.show("Succesfully reset Batchjobs", Notification.Type.HUMANIZED_MESSAGE);

        }
    });
    resetBatchJobs.addStyleName(ValoTheme.BUTTON_DANGER);

    HorizontalLayout mailLayout = new HorizontalLayout(eMailAdress, testMail, resetBatchJobs);
    layout.addComponents(resetIndex, mailLayout);

    return layout;
}

From source file:de.fatalix.bookery.view.admin.AppUserCard.java

License:Open Source License

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.user");
    Button deleteUser = new Button(null, new Button.ClickListener() {

        @Override//from w w  w . ja v a  2  s.c  o m
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteUser(appUser);
            for (Listener listener : listeners) {
                listener.userDeleted(AppUserCard.this);
            }
        }
    });
    deleteUser.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteUser.addStyleName("borderless");
    deleteUser.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteUser);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.fatalix.bookery.view.admin.BatchJobCard.java

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.batchjob");

    Button deleteBatchJob = new Button(null, new Button.ClickListener() {

        @Override//from   w  w  w  . ja  v  a  2 s.c  o m
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteBatchJob(jobConfig);
            for (BatchJobCard.Listener listener : listeners) {
                listener.jobDeleted(BatchJobCard.this);
            }
        }
    });
    deleteBatchJob.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteBatchJob.addStyleName("borderless");
    deleteBatchJob.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteBatchJob);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.fatalix.bookery.view.admin.BatchJobCard.java

private FormLayout createContent() {
    batchJobTypeCombo = new ComboBox("Batch Type");
    for (BatchJobType type : BatchJobType.values()) {
        batchJobTypeCombo.addItem(type);
    }//from   w w  w.  j av  a  2 s . c  o m
    batchJobTypeCombo.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (!noUpdate) {
                BatchJobType newType = ((BatchJobType) batchJobTypeCombo.getValue());

                batchJobConfiguration.setValue(newType.getDefaultConfig());

                updateBean();
                setFields();
            }
        }
    });

    description = new Label("description");
    nextRuntime = new Label("---");
    batchJobActive = new CheckBox("active", false);
    cronjobExpression = new TextField("Cronjob", "*******");
    status = new TextField("Status", "-");
    batchJobConfiguration = new TextArea("Configuration");

    Button updateButton = new Button("update", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateBean();
            jobConfig = presenter.updateBatchJob(jobConfig);
            setFields();
            logger.debug("Updated Batch Job...");
        }
    });
    updateButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    FormLayout batchJobCardContent = new FormLayout(batchJobTypeCombo, description, cronjobExpression,
            batchJobActive, batchJobConfiguration, nextRuntime, status, updateButton);
    batchJobCardContent.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    batchJobCardContent.setMargin(true);
    return batchJobCardContent;
}

From source file:de.fatalix.bookery.view.admin.ServerSettingsLayout.java

License:Open Source License

@PostConstruct
private void postInit() {
    addStyleName("bookery-content");
    formLayout = new FormLayout();
    formLayout.addStyleName("light");
    formLayout.addComponents(generateFields());
    formLayout.addComponents(generateStatusFields());

    Button checkSolr = new Button("check", new Button.ClickListener() {

        @Override//from w  w w.j  a  v  a  2s  .  c  o  m
        public void buttonClick(Button.ClickEvent event) {
            checkSolr();
        }
    });
    checkSolr.addStyleName(ValoTheme.BUTTON_SMALL);
    checkSolr.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    formLayout.addComponent(checkSolr);

    Label titleLabel = new Label("General Settings");
    titleLabel.addStyleName(ValoTheme.LABEL_H2);
    addComponents(titleLabel, formLayout);
}