Example usage for com.vaadin.ui Component addStyleName

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

Introduction

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

Prototype

public void addStyleName(String style);

Source Link

Document

Adds one or more style names to this component.

Usage

From source file:lv.polarisit.demosidemenu.ValoThemeUI.java

License:Apache License

@Override
protected void init(final VaadinRequest request) {
    if (request.getParameter("test") != null) {
        testMode = true;/*from  ww w.  j  av a  2  s  . co m*/

        if (browserCantRenderFontsConsistently()) {
            getPage().getStyles().add(".v-app.v-app.v-app {font-family: Sans-Serif;}");
        }
    }

    if (getPage().getWebBrowser().isIE() && getPage().getWebBrowser().getBrowserMajorVersion() == 9) {
        menu.setWidth("320px");
    }
    // Show .v-app-loading valo-menu-badge
    // try {
    // Thread.sleep(2000);
    // } catch (InterruptedException e) {
    // e.printStackTrace();
    // }

    if (!testMode) {
        Responsive.makeResponsive(this);
    }

    getPage().setTitle("Valo Theme Test");
    setContent(root);
    root.setWidth("100%");

    root.addMenu(buildMenu());

    navigator = new Navigator(this, viewDisplay);
    navigator.addView("MessageView", MessageView.class);
    navigator.addView("MessageView1", MessageView1.class);

    /*
    navigator.addView("labels", Labels.class);
    navigator.addView("buttons-and-links", ButtonsAndLinks.class);
    navigator.addView("textfields", TextFields.class);
    navigator.addView("datefields", DateFields.class);
    navigator.addView("comboboxes", ComboBoxes.class);
    navigator.addView("checkboxes", CheckBoxes.class);
    navigator.addView("sliders", Sliders.class);
    navigator.addView("menubars", MenuBars.class);
    navigator.addView("panels", Panels.class);
    navigator.addView("trees", Trees.class);
    navigator.addView("tables", Tables.class);
    navigator.addView("splitpanels", SplitPanels.class);
    navigator.addView("tabs", Tabsheets.class);
    navigator.addView("accordions", Accordions.class);
    navigator.addView("colorpickers", ColorPickers.class);
    navigator.addView("selects", NativeSelects.class);
    navigator.addView("calendar", CalendarTest.class);
    navigator.addView("forms", Forms.class);
    navigator.addView("popupviews", PopupViews.class);
    navigator.addView("dragging", Dragging.class);
    */
    final String f = Page.getCurrent().getUriFragment();
    if (f == null || f.equals("")) {
        navigator.navigateTo("MessageView");
    }

    //navigator.setErrorView(CommonParts.class);

    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(final ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(final ViewChangeEvent event) {
            for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                it.next().removeStyleName("selected");
            }
            for (final Entry<String, String> item : menuItems.entrySet()) {
                if (event.getViewName().equals(item.getKey())) {
                    for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                        final Component c = it.next();
                        if (c.getCaption() != null && c.getCaption().startsWith(item.getValue())) {
                            c.addStyleName("selected");
                            break;
                        }
                    }
                    break;
                }
            }
            menu.removeStyleName("valo-menu-visible");
        }
    });

}

From source file:me.uni.emuseo.view.menu.MenuView.java

License:Open Source License

public void setNavigator(final Navigator navigator) {
    this.navigator = navigator;
    final ViewChangeListener viewChangeListener = new ViewChangeListener() {
        private static final long serialVersionUID = -4564885643037277448L;

        @Override//from   w  w  w . j a v a  2  s  .c  om
        public boolean beforeViewChange(final ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(final ViewChangeEvent event) {
            for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                it.next().removeStyleName("selected");
            }
            String fullViewName = event.getViewName() + '/' + event.getParameters();
            for (final Entry<String, String> item : menuItems.entrySet()) {
                if (fullViewName.equals(item.getKey())) {
                    for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                        final Component c = it.next();
                        if (c.getCaption() != null && c.getCaption().startsWith(item.getValue())) {
                            c.addStyleName("selected");
                            break;
                        }
                    }
                    break;
                }
            }
            menu.removeStyleName("valo-menu-visible");
        }
    };
    navigator.addViewChangeListener(viewChangeListener);
    addDetachListener(new DetachListener() {
        private static final long serialVersionUID = -8082565032894897397L;

        @Override
        public void detach(DetachEvent event) {
            navigator.removeViewChangeListener(viewChangeListener);
        }
    });
}

From source file:module.pandabox.presentation.StyleController.java

License:Open Source License

public StyleController(final Component component, String... styles) {
    super();/*from w  w  w.  ja v a2  s  .c  o  m*/
    setCaption("Style");
    setSpacing(true);

    OptionGroup options = new OptionGroup();
    addComponent(options);
    options.setImmediate(true);
    options.setMultiSelect(true);
    for (String style : styles) {
        options.addItem(style);
    }
    options.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Set<String> value = (Set<String>) event.getProperty().getValue();
            List<String> current = Arrays.asList(component.getStyleName().split(" "));
            for (String style : value) {
                if (!current.contains(style)) {
                    component.addStyleName(style);
                }
            }
            for (String style : current) {
                if (!value.contains(style)) {
                    component.removeStyleName(style);
                }
            }
        }
    });

    HorizontalLayout custom = new HorizontalLayout();
    addComponent(custom);
    custom.setSpacing(true);
    final TextField txtStyle = new TextField();
    custom.addComponent(txtStyle);
    Button btApplyStyle = new Button("Apply Style", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            final String value = (String) txtStyle.getValue();
            if (value != null) {
                component.addStyleName(value);
            }
        }
    });
    custom.addComponent(btApplyStyle);
}

From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java

License:Apache License

protected void loadPicture() {
    Component pictureComponent = null;
    final Picture userPicture = identityService.getUserPicture(user.getId());
    if (userPicture != null) {
        StreamResource imageresource = new StreamResource(new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                return userPicture.getInputStream();
            }//from w w w  .  j ava2s .c  o  m
        }, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()),
                ExplorerApp.get());
        pictureComponent = new Embedded(null, imageresource);
    } else {
        pictureComponent = new Label("");
    }
    pictureComponent.setHeight("200px");
    pictureComponent.setWidth("200px");
    pictureComponent.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
    userDetailsLayout.addComponent(pictureComponent);
    userDetailsLayout.setComponentAlignment(pictureComponent, Alignment.MIDDLE_CENTER);
}

From source file:org.eclipse.hawkbit.ui.menu.DashboardMenu.java

License:Open Source License

/**
 * Creates the wrapper which contains the menu item and the adjacent label
 * for displaying the occurred events//from  w ww .  ja  v  a2 s  .  c  om
 * 
 * @param menuItemButton
 *            the menu item
 * @param notificationLabel
 *            the label for displaying the occurred events
 * @return Component of type CssLayout
 */
private static Component buildLabelWrapper(final ValoMenuItemButton menuItemButton,
        final Component notificationLabel) {
    final CssLayout dashboardWrapper = new CssLayout(menuItemButton);
    dashboardWrapper.addStyleName("labelwrapper");
    dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM);
    notificationLabel.addStyleName(ValoTheme.MENU_BADGE);
    notificationLabel.setWidthUndefined();
    notificationLabel.setVisible(false);
    notificationLabel
            .setId(UIComponentIdProvider.NOTIFICATION_MENU_ID + menuItemButton.getCaption().toLowerCase());
    dashboardWrapper.addComponent(notificationLabel);
    return dashboardWrapper;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectTeamBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_TEAM_INFOBOX);
    layout.setSizeFull();// w  w w  . jav  a 2  s.c o  m
    PeopleExtension ext = project.getExtension(PeopleExtension.class);
    if (ext != null) {
        if (ext.getLeads().size() > 0) {
            Label projectLeadHeaderLabel = new Label("Project Lead");
            projectLeadHeaderLabel.addStyleName(STYLE_TEAMLABEL);
            layout.addComponent(projectLeadHeaderLabel);
            Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(ext.getLeads());
            peopleComponent.addStyleName(InformationBox.STYLE);
            layout.addComponent(peopleComponent);
        }

        if (ext.getMembers().size() > 0) {
            Label projectTeamHeaderLabel = new Label("Project Team/Committers");
            projectTeamHeaderLabel.addStyleName(STYLE_TEAMLABEL);
            layout.addComponent(projectTeamHeaderLabel);

            Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(ext.getMembers());
            peopleComponent.addStyleName(InformationBox.STYLE);
            layout.addComponent(peopleComponent);
        }

        String mailToTeamHtml = new MailToTeam(ext).composeMailToTeamLabel();
        createLabel(layout, mailToTeamHtml);
    }
    return layout;
}

From source file:org.escidoc.browser.ui.mainpage.HeaderContainer.java

License:Open Source License

public void setUser(final CurrentUser user) {
    Component name;
    if (user.getLoginName().equals(ViewConstants.GUEST)) {
        name = new Label(ViewConstants.GUEST);
    } else {/*from w  ww. ja  v a2s  .co  m*/
        name = new Button(user.getRealName());
        name.setStyleName(BaseTheme.BUTTON_LINK);
        name.addStyleName("paddingright10");

        ((Button) name).addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                ResourceProxy userProxy;
                try {
                    userProxy = repositories.user().findById(user.getUserId());
                    UserAccountController controller = new UserAccountController(repositories, router,
                            userProxy);
                    router.openControllerView(controller, Boolean.FALSE);
                } catch (EscidocClientException e) {
                    LOG.error("Can not find user " + e.getMessage());
                    router.getMainWindow().showNotification(ViewConstants.ERROR + "Can not find user ",
                            e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
                }
            }
        });
    }

    Label lblCurrentUser = new Label("<b>" + ViewConstants.CURRENT_USER + "</b>", Label.CONTENT_XHTML);
    lblCurrentUser.addStyleName("paddingright10");
    hl.addComponent(lblCurrentUser);
    hl.setComponentAlignment(lblCurrentUser, Alignment.MIDDLE_RIGHT);

    name.addStyleName("paddingright10");
    hl.addComponent(name);
    hl.addComponent(new Label(" &nbsp;", Label.CONTENT_RAW));
    hl.setComponentAlignment(name, Alignment.MIDDLE_RIGHT);

    if (user.isGuest()) {
        hl.removeComponent(logout);
        hl.addComponent(login);
        hl.setComponentAlignment(login, Alignment.MIDDLE_RIGHT);

    } else {
        logout.addStyleName("paddingright10");
        hl.addComponent(logout);
        hl.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);

    }
}

From source file:org.ikasan.dashboard.ui.framework.panel.LandingViewPanel.java

License:BSD License

private Component buildDashboard(Component component) {
    Component contentWrapper = createContentWrapper(component);
    contentWrapper.addStyleName("top10-revenue");
    return contentWrapper;
}

From source file:org.ikasan.dashboard.ui.framework.panel.LandingViewPanel.java

License:BSD License

private Component buildDashboardChart() {
    this.dashboardChart = new DashboardChart();
    this.dashboardChart.setHcjs("var options = {        chart: {            type: 'pie'        },        "
            + "title: {            text: 'Browser market shares. January, 2015 to May, 2015'        },        "
            + "subtitle: {            text: 'Click the slices to view versions. Source: netmarketshare.com.'        },        "
            + "plotOptions: {            series: {                dataLabels: {                    enabled: true,                    "
            + "format: '{point.name}: {point.y:.1f}%'                }            }        },        "
            + "tooltip: {            headerFormat: '<span style=\"font-size:11px\">{series.name}</span><br>',            "
            + "pointFormat: '<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'        },        "
            + "series: [{            name: \"Brands\",            colorByPoint: true,            "
            + "data: [{                name: \"Microsoft Internet Explorer\",                y: 56.33,                "
            + "drilldown: \"Microsoft Internet Explorer\"            }, "
            + "{                name: \"Chrome\",                y: 24.03,                drilldown: \"Chrome\"            },"
            + "{                name: \"Firefox\",                y: 10.38,                drilldown: \"Firefox\"            }, "
            + "{                name: \"Safari\",                y: 4.77,                drilldown: \"Safari\"            }, "
            + "{                name: \"Opera\",                y: 0.91,                drilldown: \"Opera\"            }, "
            + "{                name: \"Proprietary or Undetectable\",                y: 0.2,                drilldown: null            }]        }],        "
            + "drilldown: {            series: [{                name: \"Microsoft Internet Explorer\",                id: \"Microsoft Internet Explorer\",                data: [                    [\"v11.0\", 24.13],                    [\"v8.0\", 17.2],                    [\"v9.0\", 8.11],                    [\"v10.0\", 5.33],                    [\"v6.0\", 1.06],                    [\"v7.0\", 0.5]                ]            }, "
            + "{                name: \"Chrome\",                id: \"Chrome\",                data: [                    [\"v40.0\", 5],                    [\"v41.0\", 4.32],                    [\"v42.0\", 3.68],                    [\"v39.0\", 2.96],                    [\"v36.0\", 2.53],                    [\"v43.0\", 1.45],                    [\"v31.0\", 1.24],                    [\"v35.0\", 0.85],                    [\"v38.0\", 0.6],                    [\"v32.0\", 0.55],                    [\"v37.0\", 0.38],                    [\"v33.0\", 0.19],                    [\"v34.0\", 0.14],                    [\"v30.0\", 0.14]                ]            }, "
            + "{                name: \"Firefox\",                id: \"Firefox\",                data: [                    [\"v35\", 2.76],                    [\"v36\", 2.32],                    [\"v37\", 2.31],                    [\"v34\", 1.27],                    [\"v38\", 1.02],                    [\"v31\", 0.33],                    [\"v33\", 0.22],                    [\"v32\", 0.15]                ]            }, "
            + "{                name: \"Safari\",                id: \"Safari\",                data: [                    [\"v8.0\", 2.56],                    [\"v7.1\", 0.77],                    [\"v5.1\", 0.42],                    [\"v5.0\", 0.3],                    [\"v6.1\", 0.29],                    [\"v7.0\", 0.26],                    [\"v6.2\", 0.17]                ]            }, "
            + "{                name: \"Opera\",                id: \"Opera\",                data: [                    [\"v12.x\", 0.34],                    [\"v28\", 0.24],                    [\"v27\", 0.17],                    [\"v29\", 0.16]                ]            }]        }    }");

    //       this.dashboardChart.setHcjs("var options = { chart: {            type: 'column'        },        title: {            text: 'Browser market shares. January, 2015 to May, 2015'        }," +
    //       "        subtitle: {            text: 'Click the columns to view versions. Source: <a href=\"http://netmarketshare.com\">netmarketshare.com</a>.'" +
    //       "        },        xAxis: {            type: 'category'        },        yAxis: {            title: {                text: 'Total percent market share'  " +
    //       "          }        },        legend: {            enabled: false        },        plotOptions: {            series: {                borderWidth: 0,    " +
    //       "            dataLabels: {                    enabled: true,                    format: '{point.y:.1f}%'                }            }        },  " +
    //       "      tooltip: {            headerFormat: '<span style=\"font-size:11px\">{series.name}</span><br>',            pointFormat: '<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'" +
    //             "        },        series: [{            name: \"Brands\",            colorByPoint: true,            data: [{                name: \"Microsoft Internet Explorer\"," +
    //                   "                y: 56.33,                drilldown: \"Microsoft Internet Explorer\"            }, {                name: \"Chrome\",                " +
    //                   "y: 24.03,                drilldown: \"Chrome\"            }, {                name: \"Firefox\",                y: 10.38,                drilldown: \"Firefox\"   " +
    //                   "         }, {                name: \"Safari\",                y: 4.77,                drilldown: \"Safari\"            }, {   " +
    //                   "             name: \"Opera\",                y: 0.91,                drilldown: \"Opera\"            }, {                name: \"Proprietary or Undetectable\",  " +
    //                   "              y: 0.2,                drilldown: null            }]        }],        drilldown: {            series: [{                name: \"Microsoft Internet Explorer\",   " +
    //                   "             id: \"Microsoft Internet Explorer\",                data: [                    [                        \"v11.0\",   " +
    //                   "                     24.13                    ],                    [                        \"v8.0\",                        17.2     " +
    //                   "               ],                    [                       \"v9.0\",                        8.11                    ],                    [                        \"v10.0\", " +
    //                   "                       5.33                    ],                    [                        \"v6.0\",                        1.06                    ],                    [                        \"v7.0\",      " +
    //                   "                  0.5                    ]                ]            }, {                name: \"Chrome\",                id: \"Chrome\",                " +
    //                   "data: [                    [                        \"v40.0\",                        5                    ],                    [                        \"v41.0\"," +
    //                   "                        4.32                    ],                    [                        \"v42.0\",                        3.68                    ],     " +
    //                   "               [                        \"v39.0\",                        2.96                    ],                    [                        \"v36.0\", " +
    //                   "                       2.53                    ],                    [                        \"v43.0\",                        1.45                    ],                    [                       " +
    //                   " \"v31.0\",                        1.24                    ],                    [                        \"v35.0\",                  " +
    //                   "      0.85                    ],                    [                        \"v38.0\",                        0.6                    ],  " +
    //                   "                  [                        \"v32.0\",                        0.55                    ],                    [                        \"v37.0\",  " +
    //                   "                      0.38                    ],                    [                        \"v33.0\",                        0.19                    ],    " +
    //                   "                [                        \"v34.0\",                        0.14                    ],                    [                        \"v30.0\",      " +
    //                   "                  0.14                    ]                ]            }, {                name: \"Firefox\",                id: \"Firefox\",                " +
    //                   "data: [                    [                        \"v35\",                        2.76                    ],                    [                        \"v36\", " +
    //                   "                       2.32                    ],                    [                        \"v37\",                        2.31                    ],  " +
    //                   "                  [                        \"v34\",                        1.27                    ],                    [                        \"v38\",  " +
    //                   "                      1.02                    ],                    [                        \"v31\",                        0.33                    ],      " +
    //                   "              [                        \"v33\",                        0.22                    ],                    [                        \"v32\",   " +
    //                   "                     0.15                    ]                ]            }, {                name: \"Safari\",                id: \"Safari\",                data: [                    [                     " +
    //                   "   \"v8.0\",                        2.56                    ],                    [                        \"v7.1\",                        0.77                    ],                    [                        \"v5.1\",      " +
    //                   "                  0.42                    ],                    [                        \"v5.0\",                        0.3                    ],                    [                        \"v6.1\",                        0.29                    ],  " +
    //                   "                  [                        \"v7.0\",                        0.26                    ],                    [                        \"v6.2\",    " +
    //                   "                    0.17                    ]                ]            }, {                name: \"Opera\",                id: \"Opera\",                data: [                    [                        \"v12.x\",    " +
    //                   "                    0.34                    ],                    [                        \"v28\",                        0.24                    ],                    [                        \"v27\",                        0.17                    ],      " +
    //                   "              [                        \"v29\",                        0.16                    ]                ]            }]        }");

    Component contentWrapper = createContentWrapper(this.dashboardChart);
    contentWrapper.addStyleName("top10-revenue");
    return contentWrapper;
}

From source file:org.ikasan.dashboard.ui.framework.panel.LandingViewPanel.java

License:BSD License

private Component buildAnotherChart() {
    DashboardChart anotherChart = new DashboardChart();

    anotherChart.setHcjs(/*from  w  w  w.  j a va 2 s.  c o m*/
            "var options = {        chart: {            type: 'area'        },        title: {            text: 'Historic and Estimated Worldwide Population Growth by Region'        },        subtitle: {            text: 'Source: Wikipedia.org'        },        xAxis: {            categories: ['1750', '1800', '1850', '1900', '1950', '1999', '2050'],            tickmarkPlacement: 'on',            title: {                enabled: false            }        },        yAxis: {            title: {                text: 'Billions'            },            labels: {                formatter: function () {                    return this.value / 1000;                }            }        },        tooltip: {            shared: true,            valueSuffix: ' millions'        },        plotOptions: {            area: {                stacking: 'normal',                lineColor: '#666666',                lineWidth: 1,                marker: {                    lineWidth: 1,                    lineColor: '#666666'                }            }        },        series: [{            name: 'Asia',            data: [502, 635, 809, 947, 1402, 3634, 5268]        }, {            name: 'Africa',            data: [106, 107, 111, 133, 221, 767, 1766]        }, {            name: 'Europe',            data: [163, 203, 276, 408, 547, 729, 628]        }, {            name: 'America',            data: [18, 31, 54, 156, 339, 818, 1201]        }, {            name: 'Oceania',            data: [2, 2, 2, 6, 13, 30, 46]        }]    }");
    Component contentWrapper = createContentWrapper(anotherChart);
    contentWrapper.addStyleName("top10-revenue");
    return contentWrapper;
}