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:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);/* www  . j a va 2s.  co  m*/
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}

From source file:nl.kpmg.lcm.ui.component.DefinedLabel.java

License:Apache License

public DefinedLabel(String title, String content, String tooltip) {
    // A layout structure used for composition
    Panel panel = new Panel();
    panel.setStyleName("v-panel-borderless");
    panel.setWidth("100%");

    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setMargin(true); // Very useful
    panelContent.setWidth("100%");

    panel.setContent(panelContent);/*w w  w  . jav a2  s  . c o m*/

    // Compose from multiple components
    Label titleLabel = new Label(title);
    titleLabel.setStyleName("v-label-h4");
    panelContent.addComponent(titleLabel);

    Label contentLabel = new Label(content);
    panelContent.addComponent(contentLabel);

    // The composition root MUST be set
    setCompositionRoot(panel);
}

From source file:nl.kpmg.lcm.ui.view.administration.TasksPanel.java

License:Apache License

public TasksPanel() {
    Panel panel = new Panel();
    VerticalLayout root = new VerticalLayout();

    Panel schedulePanel = new Panel();
    VerticalLayout schedulePanelLayout = new VerticalLayout();
    scheduleTable = new Table();
    scheduleTable.setWidth("100%");
    scheduleTable.setHeight("300px");
    scheduleTable.addContainerProperty("Name", String.class, null);
    scheduleTable.addContainerProperty("Cron", String.class, null);
    scheduleTable.addContainerProperty("Job", String.class, null);
    scheduleTable.addContainerProperty("Target", String.class, null);
    Label scheduleLabel = new Label("Schedule");
    scheduleLabel.setStyleName("v-label-h2");
    schedulePanelLayout.addComponent(scheduleLabel);
    schedulePanelLayout.addComponent(scheduleTable);
    schedulePanel.setContent(schedulePanelLayout);

    Panel tasksPanel = new Panel();
    VerticalLayout tasksPanelLayout = new VerticalLayout();
    tasksTable = new Table();
    tasksTable.setWidth("100%");
    tasksTable.addContainerProperty("Job", String.class, null);
    tasksTable.addContainerProperty("Target", String.class, null);
    tasksTable.addContainerProperty("Start", Date.class, null);
    tasksTable.addContainerProperty("End", Date.class, null);
    tasksTable.addContainerProperty("Status", String.class, null);
    Label tasksLabel = new Label("Tasks");
    tasksLabel.setStyleName("v-label-h2");
    tasksPanelLayout.addComponent(tasksLabel);
    tasksPanelLayout.addComponent(tasksTable);
    tasksPanel.setContent(tasksPanelLayout);

    root.addComponent(schedulePanel);/*from   w  ww . ja  va 2 s  .  c o m*/
    root.addComponent(tasksPanel);

    root.setSpacing(true);
    root.setMargin(true);
    root.setWidth("100%");

    panel.setContent(root);

    setCompositionRoot(panel);
}

From source file:org.accelerators.activiti.admin.ui.MainView.java

License:Open Source License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);/*from ww  w.  j a v a 2  s.c  om*/
    setSpacing(false);
    setSizeFull();

    // Add header
    GridLayout header = new GridLayout(2, 1);
    header.setWidth("100%");
    header.setHeight("34px");
    addComponent(header);

    // Add header styles
    header.addStyleName(Consts.HEADER);
    header.addStyleName("header");
    header.setSpacing(true);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    header.addComponent(logoGrid, 0, 0);
    header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("header-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add logout button to header
    GridLayout logoutGrid = new GridLayout(2, 1);
    Label userLabel = new Label("Signed in as: " + app.getUser().toString());
    userLabel.addStyleName("user");
    logout.setStyleName(Reindeer.BUTTON_LINK);
    logout.addStyleName("logout");
    logoutGrid.addComponent(userLabel, 0, 0);
    logoutGrid.addComponent(logout, 1, 0);
    header.addComponent(logoutGrid, 1, 0);
    header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT);

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

From source file:org.activiti.administrator.ui.LoginView.java

License:Apache License

@SuppressWarnings("serial")
public LoginView(AdminApp application) {

    // Set application reference
    this.app = application;

    // Init window caption
    app.getMainWindow().setCaption(app.getMessage(Messages.Title));

    // Set style/*from   ww w.jav a2s .  co  m*/
    setStyleName(Reindeer.LAYOUT_WHITE);

    // Set layout to full size
    setSizeFull();

    // Create main layout
    VerticalLayout mainLayout = new VerticalLayout();

    // Add layout styles
    mainLayout.setStyleName(Reindeer.LAYOUT_WHITE);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    mainLayout.setMargin(false);
    mainLayout.setSpacing(false);

    // Add layout
    addComponent(mainLayout);
    setComponentAlignment(mainLayout, Alignment.TOP_LEFT);

    // Add field and button layout
    VerticalLayout buttonLayout = new VerticalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(true);
    buttonLayout.setWidth("200px");
    buttonLayout.setStyleName("login-form");

    // Add username field
    username = new TextField(app.getMessage(Messages.Username));
    username.setWidth("100%");
    buttonLayout.addComponent(username);

    // Add password field
    password = new PasswordField(app.getMessage(Messages.Password));
    password.setWidth("100%");
    buttonLayout.addComponent(password);

    // Add Login button
    buttonLayout.addComponent(login);
    buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_LEFT);

    // Add button layout
    mainLayout.addComponent(buttonLayout);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    footerText.addStyleName("footer");
    mainLayout.addComponent(footerText);
    mainLayout.setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

    // Set focus to this component
    username.focus();

    // Add shortcut to login button
    login.setClickShortcut(KeyCode.ENTER);

    login.addListener(new Button.ClickListener() {

        public void buttonClick(Button.ClickEvent event) {
            try {

                // Athenticate the user
                authenticate((String) username.getValue(), (String) password.getValue());

                // Switch to the main view
                app.switchView(MainView.class.getName(), new MainView(app));

            } catch (Exception e) {
                getWindow().showNotification(e.toString());
            }
        }
    });

}

From source file:org.activiti.administrator.ui.MainView.java

License:Apache License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);// w w w.  j a v  a 2s .c  o  m
    setSpacing(false);
    setSizeFull();

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    footerText.addStyleName("footer");
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java

License:Apache License

/**
 * Default constructor./*w  w w .ja v a  2s. c  o m*/
 */
public BuildingControlPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Control Panel");
    title.setIcon(getSite().getIcon("inventory"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    elementLayout = new VerticalLayout();
    elementLayout.setSpacing(true);
    elementLayout.setMargin(false);
    layout.addComponent(elementLayout);
    layout.setExpandRatio(elementLayout, 1);

    roomIcon = site.getIcon("room");
    deviceIcon = site.getIcon("device");
    temperatureIcon = site.getIcon("temperature");
    brightnessIcon = site.getIcon("brightness");
    humidityIcon = site.getIcon("humidity");
    eventIcon = site.getIcon("event");

    setCompositionRoot(layout);

    // the Refresher polls automatically
    final Refresher refresher = new Refresher();
    refresher.setRefreshInterval(200);
    refresher.addListener(new Refresher.RefreshListener() {
        @Override
        public void refresh(final Refresher refresher) {
            while (!recordsQueue.isEmpty()) {
                final List<Record> records = recordsQueue.remove();
                if (records.size() > 0) {
                    final Record record = records.get(0);
                    final RecordSet recordSet = record.getRecordSet();
                    final Element element = recordSet.getElement();

                    final GridLayout recordsLayout = recordsLayouts.get(element.getElementId());
                    if (recordsLayout == null) {
                        continue;
                    }

                    final int columnIndex = recordSet.getType().ordinal();
                    final int rowIndex = 0;
                    if (recordsLayout.getComponent(columnIndex, rowIndex) != null) {
                        continue;
                    }

                    final VerticalLayout recordLayout = new VerticalLayout();
                    recordLayout.setSpacing(true);
                    final Resource recordIcon;
                    switch (recordSet.getType()) {
                    case TEMPERATURE:
                        recordIcon = temperatureIcon;
                        break;
                    case BRIGHTNESS:
                        recordIcon = brightnessIcon;
                        break;
                    case HUMIDITY:
                        recordIcon = humidityIcon;
                        break;
                    default:
                        recordIcon = eventIcon;
                        break;
                    }

                    final Embedded embedded = new Embedded(null, recordIcon);
                    recordLayout.addComponent(embedded);
                    recordLayout.setExpandRatio(embedded, 0.1f);
                    embedded.setWidth(32, Unit.PIXELS);
                    embedded.setHeight(32, Unit.PIXELS);

                    final Label label = new Label();
                    recordLayout.addComponent(label);
                    recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);

                    final String recordUnit = recordSet.getUnit();
                    final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(),
                            recordUnit);

                    final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(),
                            recordUnit, displayUnit, record.getValue());

                    final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue);

                    label.setValue(displayValueString + " " + displayUnit);
                    label.setDescription(record.getCreated().toString());

                    recordsLayout.addComponent(recordLayout, columnIndex, rowIndex);
                }
            }
        }
    });
    addExtension(refresher);

}

From source file:org.agocontrol.site.viewlet.dashboard.BuildingSelectPanel.java

License:Apache License

/**
 * Default constructor.//from ww w. j  av  a 2 s .  co m
 */
public BuildingSelectPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);
    buildingIcon = site.getIcon("building");

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Select Building");
    //title.setIcon(getSite().getIcon("inventory"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    layout.addComponent(titleLayout);
    titleLayout.setSpacing(true);
    titleLayout.setSizeFull();

    final Embedded embedded = new Embedded(null, buildingIcon);
    titleLayout.addComponent(embedded);
    titleLayout.setExpandRatio(embedded, 0.1f);
    embedded.setWidth(32, Unit.PIXELS);
    embedded.setHeight(32, Unit.PIXELS);

    buildingComboBox = new ComboBox();
    titleLayout.addComponent(buildingComboBox);
    titleLayout.setComponentAlignment(buildingComboBox, Alignment.MIDDLE_LEFT);
    titleLayout.setExpandRatio(buildingComboBox, 0.9f);
    //buildingComboBox.setWidth(100, Unit.PERCENTAGE);
    buildingComboBox.setNullSelectionAllowed(false);
    buildingComboBox.setNewItemsAllowed(false);
    buildingComboBox.setTextInputAllowed(false);
    buildingComboBox.setImmediate(true);
    buildingComboBox.setBuffered(false);

    buildingComboBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            final Element building = (Element) buildingComboBox.getValue();
            if (building != null && !building.getElementId().equals(selectedBuildingId)) {
                UI.getCurrent().getNavigator().navigateTo("default/" + building.getElementId());
            }
        }
    });

    setCompositionRoot(layout);
}

From source file:org.agocontrol.site.viewlet.dashboard.EventPanel.java

License:Apache License

/**
 * Default constructor which constructs components.
 *//*w  w  w  . j  a  va2 s  .c  o  m*/
public EventPanel() {
    final VerticalLayout layout = new VerticalLayout();
    setCompositionRoot(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Events");
    title.setIcon(getSite().getIcon("event"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields
            .getFieldDescriptors(org.agocontrol.model.Event.class);
    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final Site site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    final EntityManager entityManager = site.getSiteContext().getObject(EntityManager.class);
    container = new LazyEntityContainer<org.agocontrol.model.Event>(entityManager, true, false, false,
            org.agocontrol.model.Event.class, 50, new String[] { "created" }, new boolean[] { false },
            "eventId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final Table table = new FormattingTable();
    grid = new Grid(table, container, false);
    layout.addComponent(grid);
    layout.setExpandRatio(grid, 1);

    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);
    //grid.setSizeUndefined();
    //grid.setSizeUndefined();

    table.setColumnCollapsed("eventId", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("processed", true);
    table.setColumnCollapsed("processingError", true);

    final Company company = site.getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
}

From source file:org.bubblecloud.ilves.comment.CommentListComponent.java

License:Open Source License

public void refresh() {

    final String contextPath = VaadinService.getCurrentRequest().getContextPath();
    final Site site = Site.getCurrent();

    final Company company = site.getSiteContext().getObject(Company.class);
    final EntityManager entityManager = site.getSiteContext().getObject(EntityManager.class);

    final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    final CriteriaQuery<Comment> commentCriteriaQuery = builder.createQuery(Comment.class);
    final Root<Comment> commentRoot = commentCriteriaQuery.from(Comment.class);
    commentCriteriaQuery.where(builder.and(builder.equal(commentRoot.get("owner"), company),
            builder.equal(commentRoot.get("dataId"), contextPath)));
    commentCriteriaQuery.orderBy(builder.asc(commentRoot.get("created")));

    final TypedQuery<Comment> commentTypedQuery = entityManager.createQuery(commentCriteriaQuery);
    final List<Comment> commentList = commentTypedQuery.getResultList();

    final Panel panel = new Panel(site.localize("panel-comments"));
    setCompositionRoot(panel);//from   w w w . j a v a2 s .c om

    final GridLayout gridLayout = new GridLayout(3, commentList.size() + 1);
    panel.setContent(gridLayout);
    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);
    gridLayout.setColumnExpandRatio(0, 0.0f);
    gridLayout.setColumnExpandRatio(1, 0.1f);
    gridLayout.setColumnExpandRatio(2, 0.9f);

    final Label authorHeaderLabel = new Label();
    authorHeaderLabel.setStyleName(ValoTheme.LABEL_BOLD);
    authorHeaderLabel.setValue(site.localize("column-header-author"));
    gridLayout.addComponent(authorHeaderLabel, 0, 0, 1, 0);

    final Label commentHeaderLabel = new Label();
    commentHeaderLabel.setStyleName(ValoTheme.LABEL_BOLD);
    commentHeaderLabel.setValue(site.localize("column-header-comment"));
    gridLayout.addComponent(commentHeaderLabel, 2, 0);

    for (int i = 0; i < commentList.size(); i++) {
        final Comment comment = commentList.get(i);

        final Link authorImageLink = GravatarUtil.getGravatarImageLink(comment.getAuthor().getEmailAddress());
        gridLayout.addComponent(authorImageLink, 0, i + 1);

        final Label authorLabel = new Label();
        final String authorName = comment.getAuthor().getFirstName();
        authorLabel.setValue(authorName);
        gridLayout.addComponent(authorLabel, 1, i + 1);

        final Label messageLabel = new Label();
        messageLabel.setValue(comment.getMessage());
        gridLayout.addComponent(messageLabel, 2, i + 1);
    }

}