Example usage for com.vaadin.ui Label setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.garyclayburg.vconsole.VConsole.java

License:Open Source License

private void populateExceptionMessage(String message, boolean visible) {
    VerticalLayout windowContent = new VerticalLayout();
    windowContent.setMargin(true);/*  w w w  . j a v a  2  s. com*/

    Label messageLabel = new Label(message, ContentMode.PREFORMATTED);
    messageLabel.setStyleName(Runo.LABEL_SMALL);
    //        messageLabel.setWidth("120em");
    windowContent.addComponent(messageLabel);
    Button closeButton = new Button("Close");
    closeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            exceptionWindow.setVisible(false);
        }
    });

    windowContent.addComponent(closeButton);
    UI ui = exceptionWindow.getUI();
    if (ui != null) {
        VaadinSession session = ui.getSession();
        if (session != null) {
            session.getLockInstance().lock();
            try {
                exceptionWindow.setContent(windowContent);
                exceptionWindow.setVisible(visible);
            } finally {
                session.getLockInstance().unlock();
            }
        } else {
            exceptionWindow.setContent(windowContent);
            exceptionWindow.setVisible(visible);
        }
    } else {
        exceptionWindow.setContent(windowContent);
        exceptionWindow.setVisible(visible);
    }
}

From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java

License:Apache License

/**
 * TODO Document me!//from  www . j  ava  2  s  .com
 * 
 * @return
 */
@SuppressWarnings("serial")
protected Component createHeader() {
    final HorizontalLayout header = new HorizontalLayout();
    header.setMargin(true);
    header.setWidth("100%");

    /*
     * Header label will contain the name and version of the application.
     */
    final Label headerLabel = new Label(
            getApplication().getMessage("app.title", getApplication().getVersion()));
    headerLabel.setStyleName("appHeaderText");
    header.addComponent(headerLabel);
    header.setStyleName("appHeader");
    header.setExpandRatio(headerLabel, 1.0f);
    header.setComponentAlignment(headerLabel, Alignment.MIDDLE_LEFT);

    /*
     * User links contains information about the current user and a button
     * for logging out.
     */
    final HorizontalLayout userLinks = new HorizontalLayout();
    userLinks.setStyleName("appHeaderUserLinks");
    userLinks.setSpacing(true);

    /*
     * The user label contains the name of the current user.
     */
    final Label userLabel = new Label(
            getApplication().getMessage("main.currentlyLoggedIn", getApplication().getUser().getName()),
            Label.CONTENT_XHTML);
    userLinks.addComponent(userLabel);
    userLinks.setComponentAlignment(userLabel, Alignment.MIDDLE_LEFT);
    userLabel.setSizeUndefined();

    /*
     * The logout button closes the application, effectively logging the
     * user out.
     */
    final Button logoutButton = new Button(getApplication().getMessage("main.logout.caption"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    // TODO Add confirmation
                    getApplication().close();
                }
            });
    logoutButton.setDescription(getApplication().getMessage("main.logout.descr"));
    logoutButton.setStyleName("small");
    userLinks.addComponent(logoutButton);
    userLinks.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    header.addComponent(userLinks);
    header.setComponentAlignment(userLinks, Alignment.MIDDLE_RIGHT);
    return header;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.AbstractView.java

License:Apache License

/**
 * Creates the basic layout with panel and footer.
 *
 * @param panelName/*from  www . j  av  a 2  s.c  om*/
 *            the panel name
 */
protected final void createBasicLayoutWithPanelAndFooter(final String panelName) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(100, Unit.PERCENTAGE);

    final VerticalLayout pageModeContent = new VerticalLayout();
    pageModeContent.setMargin(true);
    pageModeContent.setSpacing(true);
    pageModeContent.setWidth(100, Unit.PERCENTAGE);
    pageModeContent.setHeight(100, Unit.PERCENTAGE);

    layout.addComponent(pageModeContent);

    final ThemeResource ciaLogoResource = new ThemeResource("cia-logo.png");

    final Image ciaLogoImage = new Image(null, ciaLogoResource);

    final HorizontalLayout topHeader = new HorizontalLayout();

    topHeader.addComponent(ciaLogoImage);
    ciaLogoImage.setWidth("75px");
    ciaLogoImage.setHeight("75px");
    topHeader.setComponentAlignment(ciaLogoImage, Alignment.MIDDLE_LEFT);
    topHeader.setExpandRatio(ciaLogoImage, ContentRatio.SMALL);

    final HorizontalLayout topTitleHeadertPanel = new HorizontalLayout();

    final Label titleLabel = new Label("Citizen Intelligence Agency");
    titleLabel.setStyleName("Header");
    topTitleHeadertPanel.addComponent(titleLabel);
    topTitleHeadertPanel.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT);

    final Label sloganLabel = new Label("// Tracking politicians like bugs!");
    sloganLabel.setStyleName("HeaderSlogan");
    topTitleHeadertPanel.addComponent(sloganLabel);
    topTitleHeadertPanel.setComponentAlignment(sloganLabel, Alignment.MIDDLE_RIGHT);

    topHeader.addComponent(topTitleHeadertPanel);
    topHeader.setComponentAlignment(topTitleHeadertPanel, Alignment.MIDDLE_LEFT);
    topHeader.setExpandRatio(topTitleHeadertPanel, ContentRatio.GRID);

    topHeaderRightPanel.removeAllComponents();
    topHeader.addComponent(topHeaderRightPanel);
    topHeader.setComponentAlignment(topHeaderRightPanel, Alignment.MIDDLE_RIGHT);
    topHeader.setExpandRatio(topHeaderRightPanel, ContentRatio.LARGE);

    if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN)
            || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) {

        final Link userHomePageLink = pageLinkFactory.createUserHomeViewPageLink();
        topHeaderRightPanel.addComponent(userHomePageLink);
        topHeaderRightPanel.setComponentAlignment(userHomePageLink, Alignment.MIDDLE_RIGHT);

        final Button logoutButton = new Button(LOGOUT, FontAwesome.SIGN_OUT);

        final LogoutRequest logoutRequest = new LogoutRequest();
        logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
        logoutButton.addClickListener(new LogoutClickListener(logoutRequest, applicationManager));

        topHeaderRightPanel.addComponent(logoutButton);
        topHeaderRightPanel.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    } else {
        final Link createRegisterPageLink = pageLinkFactory.createRegisterPageLink();
        topHeaderRightPanel.addComponent(createRegisterPageLink);
        topHeaderRightPanel.setComponentAlignment(createRegisterPageLink, Alignment.MIDDLE_RIGHT);

        final Link createLoginPageLink = pageLinkFactory.createLoginPageLink();
        topHeaderRightPanel.addComponent(createLoginPageLink);
        topHeaderRightPanel.setComponentAlignment(createLoginPageLink, Alignment.MIDDLE_RIGHT);
    }

    topHeaderRightPanel.setWidth("100%");
    topHeaderRightPanel.setHeight("60px");

    topHeader.setWidth("100%");
    topHeader.setHeight("60px");

    pageModeContent.addComponent(topHeader);
    pageModeContent.setComponentAlignment(topHeader, Alignment.TOP_CENTER);

    pageModeContent.addComponent(getBarmenu());
    pageModeContent.setComponentAlignment(getBarmenu(), Alignment.TOP_CENTER);

    panel = new Panel(panelName);

    panel.setSizeFull();
    pageModeContent.addComponent(panel);
    pageModeContent.setExpandRatio(panel, ContentRatio.FULL_SIZE);

    pageModeContent.addComponent(pageLinkFactory.createMainViewPageLink());
    setContent(layout);

    setWidth(100, Unit.PERCENTAGE);
    setHeight(100, Unit.PERCENTAGE);
    setSizeFull();

}

From source file:com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory.java

License:Apache License

/**
 * Creates a new Label object.// w w  w  .j  a va2s  .  c o  m
 *
 * @param panel
 *            the panel
 * @param content
 *            the content
 */
public static void createHeader2Label(final AbstractOrderedLayout panel, final String content) {
    final Label label = new Label(content);
    label.setStyleName("Level2Header");

    panel.addComponent(label);
    panel.setExpandRatio(label, ContentRatio.SMALL);
}

From source file:com.haulmont.cuba.web.AppUI.java

License:Apache License

protected void showCriticalExceptionMessage(Exception exception) {
    String initErrorCaption = messages.getMainMessage("app.initErrorCaption");
    String initErrorMessage = messages.getMainMessage("app.initErrorMessage");

    VerticalLayout content = new VerticalLayout();
    content.setStyleName("c-init-error-view");
    content.setSizeFull();/*from  w w  w  .j  a va2 s .c o m*/

    VerticalLayout errorPanel = new VerticalLayout();
    errorPanel.setStyleName("c-init-error-panel");
    errorPanel.setWidthUndefined();
    errorPanel.setSpacing(true);

    Label captionLabel = new Label(initErrorCaption);
    captionLabel.setWidthUndefined();
    captionLabel.setStyleName("c-init-error-caption");
    captionLabel.addStyleName("h2");
    captionLabel.setValue(initErrorCaption);

    errorPanel.addComponent(captionLabel);

    Label messageLabel = new Label(initErrorCaption);
    messageLabel.setWidthUndefined();
    messageLabel.setStyleName("c-init-error-message");
    messageLabel.setValue(initErrorMessage);

    errorPanel.addComponent(messageLabel);

    Button retryButton = new Button(messages.getMainMessage("app.initRetry"));
    retryButton.setStyleName("c-init-error-retry");
    retryButton.addClickListener(event -> {
        // always restart UI
        String url = ControllerUtils.getLocationWithoutParams() + "?restartApp";
        getPage().open(url, "_self");
    });

    errorPanel.addComponent(retryButton);
    errorPanel.setComponentAlignment(retryButton, Alignment.MIDDLE_CENTER);

    content.addComponent(errorPanel);
    content.setComponentAlignment(errorPanel, Alignment.MIDDLE_CENTER);

    setContent(content);
}

From source file:com.haulmont.cuba.web.gui.components.presentations.TablePresentations.java

License:Apache License

protected void initLayout() {
    setSpacing(true);// w w w . j  av a 2s . c  o  m

    Label titleLabel = new Label(messages.getMainMessage("PresentationsPopup.title"));
    titleLabel.setStyleName("c-table-prefs-title");
    titleLabel.setWidth("-1px");
    addComponent(titleLabel);
    setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    menuBar = new CubaMenuBar();
    menuBar.setStyleName("c-table-prefs-list");
    menuBar.setWidth("100%");
    menuBar.setHeight("-1px");
    menuBar.setVertical(true);
    addComponent(menuBar);

    button = new WebPopupButton();
    button.setCaption(messages.getMainMessage("PresentationsPopup.actions"));
    addComponent(button.<Component>getComponent());
    setComponentAlignment(button.<Component>getComponent(), Alignment.MIDDLE_CENTER);

    textSelectionCheckBox = new CheckBox();
    textSelectionCheckBox.setImmediate(true);
    textSelectionCheckBox.setInvalidCommitted(true);
    textSelectionCheckBox.setCaption(messages.getMainMessage("PresentationsPopup.textSelection"));
    addComponent(textSelectionCheckBox);
    textSelectionCheckBox.setPropertyDataSource(new AbstractProperty() {
        @Override
        public Object getValue() {
            return tableImpl.isTextSelectionEnabled();
        }

        @Override
        public void setValue(Object newValue) throws Property.ReadOnlyException {
            if (newValue instanceof Boolean) {
                tableImpl.setTextSelectionEnabled((Boolean) newValue);
            }
        }

        @Override
        public Class getType() {
            return Boolean.class;
        }
    });
}

From source file:com.haulmont.cuba.web.log.LogWindow.java

License:Apache License

private void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction(
            "closeShortcutAction", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers()));

    addActionHandler(new com.vaadin.event.Action.Handler() {
        @Override//from w ww  . ja v  a2  s  .  co m
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);

    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");

    ((Layout) scrollablePanel.getContent()).addComponent(label);

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();

    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"),
            (Button.ClickListener) event -> label.setValue(writeLog()));

    topLayout.addComponent(refreshBtn);

    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);

    layout.setExpandRatio(scrollablePanel, 1.0f);
}

From source file:com.haulmont.cuba.web.LoginWindow.java

License:Apache License

protected HorizontalLayout createTitleLayout() {
    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setStyleName("cuba-login-title");
    titleLayout.setSpacing(true);/*  w  w  w  .j a  v a 2s. c  o  m*/

    Image logoImage = getLogoImage();
    if (logoImage != null) {
        logoImage.setStyleName("cuba-login-icon");
        titleLayout.addComponent(logoImage);
        titleLayout.setComponentAlignment(logoImage, Alignment.MIDDLE_LEFT);
    }

    String welcomeMsg = messages.getMainMessage("loginWindow.welcomeLabel", resolvedLocale);
    Label label = new Label(welcomeMsg.replace("\n", "<br/>"));
    label.setContentMode(ContentMode.HTML);
    label.setWidthUndefined();
    label.setStyleName("cuba-login-caption");

    if (!StringUtils.isBlank(label.getValue())) {
        titleLayout.addComponent(label);
        titleLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    }
    return titleLayout;
}

From source file:com.haulmont.cuba.web.sys.WindowBreadCrumbs.java

License:Apache License

public void update() {
    AppUI ui = AppUI.getCurrent();/*from www. j a va2  s  . c o m*/
    boolean isTestMode = ui.isTestMode();

    linksLayout.removeAllComponents();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext();) {
        Window window = it.next();
        Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
        button.setSizeUndefined();
        button.setStyleName(BaseTheme.BUTTON_LINK);
        button.setTabIndex(-1);

        if (isTestMode) {
            button.setCubaId("breadCrubms_Button_" + window.getId());
            button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
        }

        btn2win.put(button, window);

        if (it.hasNext()) {
            linksLayout.addComponent(button);

            Label separatorLab = new Label("&nbsp;&gt;&nbsp;");
            separatorLab.setStyleName("c-breadcrumbs-separator");
            separatorLab.setSizeUndefined();
            separatorLab.setContentMode(ContentMode.HTML);
            linksLayout.addComponent(separatorLab);
        } else {
            Label captionLabel = new Label(window.getCaption());
            captionLabel.setStyleName("c-breadcrumbs-win-caption");
            captionLabel.setSizeUndefined();
            linksLayout.addComponent(captionLabel);

            this.label = captionLabel;
        }
    }
}

From source file:com.hivesys.dashboard.view.search.TextualView.java

public void UpdateSearchPane(String searchString) {
    css.removeAllComponents();/* w  ww. ja va2s  .  co m*/

    SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString);
    logResponse(response);
    SearchHits results = response.getHits();

    Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>",
            ContentMode.HTML);
    css.addComponent(labelResultSummary);

    for (SearchHit hit : results) {
        CssLayout cssResult = new CssLayout();
        cssResult.setStyleName("search-result");

        try {
            String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId());
            String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId());

            String highlight = "";
            HighlightField objhighlight = hit.highlightFields().get("file");
            if (objhighlight != null) {
                for (Text fgmt : objhighlight.getFragments()) {
                    highlight += fgmt.string() + "<br>";
                }
            }

            Button lblfileName = new Button(filename);
            lblfileName.addClickListener((Button.ClickEvent event) -> {
                if (boxviewID != null) {
                    String url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                    if (url != null || !url.equals("")) {
                        url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                        BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url));
                        VerticalLayout vlayout = new VerticalLayout(bframe);

                        final Window w = new Window();
                        w.setSizeFull();
                        w.setModal(true);
                        w.setWindowMode(WindowMode.MAXIMIZED);
                        w.setContent(vlayout);
                        vlayout.setSizeFull();
                        vlayout.setMargin(true);
                        w.setResizable(false);
                        w.setDraggable(false);

                        UI.getCurrent().addWindow(w);
                        bframe.setSizeFull();
                        return;
                    }
                    Notification.show("Preview not available for this document!");
                }
            });
            lblfileName.setPrimaryStyleName("filename");

            Label lblHighlight = new Label(highlight, ContentMode.HTML);
            lblHighlight.setStyleName("highlight");

            cssResult.addComponent(lblfileName);
            cssResult.addComponent(lblHighlight);

            css.addComponent(cssResult);
            css.addComponent(new Label("<br>", ContentMode.HTML));

        } catch (SQLException ex) {
        }

    }

}