Example usage for com.vaadin.ui Component getStyleName

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

Introduction

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

Prototype

public String getStyleName();

Source Link

Document

Gets all user-defined CSS style names of a component.

Usage

From source file:com.esofthead.mycollab.vaadin.ui.VerticalTabsheet.java

License:Open Source License

private void clearTabSelection(boolean setDefaultIcon) {
    Iterator<Component> iterator = navigatorContainer.iterator();
    if (setDefaultIcon) {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
                setDefaulButtonIcon(btn, false);
            }/*from  w w  w .j  a  va  2s . c  om*/
        }
    } else {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
            }
        }
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.VerticalTabsheet.java

License:Open Source License

private void clearTabSelection(boolean setDefaultIcon) {
    Iterator<Component> iterator = navigatorContainer.iterator();
    if (setDefaultIcon) {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
                setDefaultButtonIcon(btn, false);
            }/*from   w  w w. java 2 s .c  om*/
        }
    } else {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
            }
        }
    }
}

From source file:com.mycollab.vaadin.web.ui.VerticalTabsheet.java

License:Open Source License

private void clearTabSelection(boolean setDefaultIcon) {
    Iterator<Component> iterator = navigatorContainer.iterator();
    if (setDefaultIcon) {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
            }/*from  w w  w  . j  a  v  a 2  s.  c  o m*/
        }
    } else {
        while (iterator.hasNext()) {
            Component btn = iterator.next();
            if (btn.getStyleName().contains(TAB_SELECTED_STYLENAME)) {
                btn.removeStyleName(TAB_SELECTED_STYLENAME);
            }
        }
    }
}

From source file:com.profitsoftware.vaadin.query.matcher.MatchExactStyle.java

License:Apache License

public boolean match(Component component) {
    return style.equals(component.getStyleName());
}

From source file:com.profitsoftware.vaadin.query.matcher.MatchStyle.java

License:Apache License

public boolean match(Component component) {
    if (component == null) {
        return false;
    }/*  w  w w  .  j  a  v a 2 s . c  o m*/
    String styleName = component.getStyleName();
    if (styleName == null) {
        return false;
    }
    if (styleName.contains(" ")) {
        StringTokenizer stringTokenizer = new StringTokenizer(styleName, " ");
        while (stringTokenizer.hasMoreElements()) {
            if (style.equals(stringTokenizer.nextElement())) {
                return true;
            }
        }
        return false;
    }
    return styleName.equals(style);
}

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

License:Open Source License

GridLayout getPreviewLayout(String caption) {
    GridLayout grid = new GridLayout(3, 1) {
        @Override//from w  ww.j av  a  2 s .c o  m
        public void addComponent(Component c) {
            super.addComponent(c);
            setComponentAlignment(c, "center middle");
            if (c.getStyleName() != "") {
                ((AbstractComponent) c).setDescription(
                        c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")");
            } else {
                ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()");
            }
        }
    };
    grid.setWidth("100%");
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setCaption(caption);
    grid.setStyleName("preview-grid");
    return grid;
}

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

License:Open Source License

public StyleController(final Component component, String... styles) {
    super();//www  . ja v a 2s.  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.opencms.ui.components.CmsToolBar.java

License:Open Source License

/**
 * Checks whether the given component may be placed into the buttons sub menu.<p>
 *
 * @param comp the component to check/*from   w w w .  j a  v  a 2  s  .  c  om*/
 *
 * @return <code>true</code> in case the component should always be displayed in the toolbar
 */
private boolean isAlwaysShow(Component comp) {

    return ((comp == m_appIndicator) || (comp == m_contextMenu) || (comp == m_userDropDown)
            || (comp == m_quickLaunchDropDown) || comp.getStyleName().contains(OpenCmsTheme.REQUIRED_BUTTON));
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.ToolBarRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    if (!(element instanceof MToolBar)) {
        return;/*  w w w . j a va2s .co  m*/
    }

    MToolBar toolbarModel = (MToolBar) element;
    processContribution(toolbarModel);

    AbstractLayout toolBarWidget;

    if ((MElementContainer<?>) toolbarModel.getParent() instanceof MTrimBar) {
        MTrimBar parentTrimBar = (MTrimBar) (MElementContainer<?>) toolbarModel.getParent();
        int orientation = parentTrimBar.getSide().getValue();

        if (orientation == SideValue.TOP_VALUE || orientation == SideValue.BOTTOM_VALUE) {
            toolBarWidget = new HorizontalLayout() {
                @Override
                public void addComponent(Component c) {
                    if (!c.getStyleName().contains("horizontalseparator"))
                        c.addStyleName("horizontaltoolbarlement");
                    super.addComponent(c);
                }

                @Override
                public void addComponent(Component c, int index) {
                    if (!c.getStyleName().contains("horizontalseparator"))
                        c.addStyleName("horizontaltoolbarlement");
                    super.addComponent(c, index);
                }
            };
            toolBarWidget.addStyleName("horizontaltoolbar");
        } else {
            toolBarWidget = new VerticalLayout() {
                @Override
                public void addComponent(Component c) {
                    if (!c.getStyleName().contains("verticalseparator"))
                        c.addStyleName("verticaltoolbarlement");
                    super.addComponent(c);
                }

                @Override
                public void addComponent(Component c, int index) {
                    if (!c.getStyleName().contains("verticalseparator"))
                        c.addStyleName("verticaltoolbarlement");
                    super.addComponent(c, index);
                }
            };
            toolBarWidget.addStyleName("verticaltoolbar");
        }

        Component separator = GuiUtils.createSeparator(toolbarModel);
        if (separator != null)
            toolBarWidget.addComponent(separator);
    } else
        toolBarWidget = new HorizontalLayout();

    toolBarWidget.setSizeUndefined();
    toolBarWidget.addStyleName("toolbar");

    for (String css : toolbarModel.getTags()) {
        toolBarWidget.addStyleName(css);
    }

    element.setWidget(toolBarWidget);
}

From source file:rs.pupin.jpo.esta_ld.EstaLdComponent.java

private void refresh() {
    contentLayout.removeAllComponents();

    // create left part where the map goes
    // first create a vertical layout for components
    geoLayout = new VerticalLayout();
    geoLayout.setDebugId("l-geo");
    geoLayout.setSizeUndefined();/*ww w. j  ava 2s  . c o  m*/
    //        geoLayout.setWidth(GEO_PART_WIDTH);
    //        geoLayout.setHeight("100%");
    geoLayout.setSizeFull();
    geoLayout.setSpacing(true);
    contentLayout.addComponent(geoLayout);
    getWindow().executeJavaScript("$('div#l-geo').append('<div id=\"esta-map-popup\"><p></p></div>')");
    //        contentLayout.setExpandRatio(geoLayout, 0.0f);
    // create Level and +- controls
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    final Label levelLabel = new Label(LEVEL_LABEL_CONTENT, Label.CONTENT_XHTML);
    hl.addComponent(levelLabel);
    hl.setComponentAlignment(levelLabel, Alignment.MIDDLE_LEFT);
    btnAggregColor = new Button("Aggregated Coloring");
    btnAggregColor.addStyleName("dim-name");
    btnAggregColor.addStyleName("btn-aggreg-coloring");
    btnAggregColor.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            getWindow().executeJavaScript("toggleAggregatedColoring()");
        }
    });
    hl.addComponent(btnAggregColor);
    geoLayout.addComponent(hl);
    geoLayout.setExpandRatio(hl, 0.0f);
    // create a layout for the map
    //        mapLayout = new VerticalLayout();
    mapLayout = new VerticalLayout() {
        @Override
        public void attach() {
            getWindow().executeJavaScript("console.log('Attached the map')");
        }
    };
    mapLayout.addListener(new ComponentAttachListener() {

        public void componentAttachedToContainer(ComponentAttachEvent event) {
            getWindow().executeJavaScript("console.log('ComponentAttachedListener triggered')");
        }
    });
    mapLayout.setSizeUndefined();
    mapLayout.setWidth("100%");
    //        mapLayout.setHeight("620px");
    mapLayout.setHeight("100%");
    mapLayout.setDebugId("map");
    mapLayout.addStyleName("leaflet-container");
    mapLayout.addStyleName("leaflet-fade-anim");
    geoLayout.addComponent(mapLayout);
    geoLayout.setExpandRatio(mapLayout, 2.0f);

    rightLayout = new VerticalLayout();
    rightLayout.setSizeUndefined();
    rightLayout.setWidth("100%");
    rightLayout.setSizeFull();
    rightLayout.setSpacing(true);
    contentLayout.addComponent(rightLayout);
    //        contentLayout.setExpandRatio(rightLayout, 2.0f);
    dimLayout = new GridLayout(6, 1);
    dimLayout.setColumnExpandRatio(0, 0.0f);
    dimLayout.setColumnExpandRatio(1, 0.0f);
    dimLayout.setColumnExpandRatio(2, 2.0f);
    dimLayout.setColumnExpandRatio(3, 0.0f);
    dimLayout.setColumnExpandRatio(4, 0.0f);
    dimLayout.setColumnExpandRatio(5, 2.0f);
    dimLayout.setDebugId("dim-layout");
    //        dimLayout.setSizeFull();
    dimLayout.setWidth("100%");
    dimLayout.setSpacing(true);
    //        rightLayout.addComponent(dimLayout);
    settingsLayout.addComponent(dimLayout);

    dimLayout.addListener(new LayoutEvents.LayoutClickListener() {
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Component btnAggreg = event.getClickedComponent();
            if (!(btnAggreg instanceof Label))
                return;
            if (btnAggreg.getStyleName().contains("selected")) {
                btnAggreg.removeStyleName("selected");
            } else {
                btnAggreg.addStyleName("selected");
            }
            aggregDimensionsChanged();
        }
    });

    refreshDimensions();

    HorizontalLayout chartControlsLayout = new HorizontalLayout();
    chartControlsLayout.setDebugId("l-chart-controls");
    chartControlsLayout.setWidth("100%");
    chartControlsLayout.setSpacing(true);
    rightLayout.addComponent(chartControlsLayout);
    rightLayout.setExpandRatio(chartControlsLayout, 0.0f);
    btnCompare = new Button("Compare");
    btnCompare.setDebugId("btn-compare");
    btnCompare.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            getWindow().executeJavaScript("toggleCompare()");
        }
    });
    chartControlsLayout.addComponent(btnCompare);
    btnSwap = new Button("Swap");
    btnSwap.setDebugId("btn-swap");
    btnSwap.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            getWindow().executeJavaScript("toggleSwap()");
        }
    });
    chartControlsLayout.addComponent(btnSwap);
    btnInvert = new Button("Switch Axes");
    btnInvert.setDebugId("btn-invert");
    btnInvert.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            getWindow().executeJavaScript("toggleInvert()");
        }
    });
    chartControlsLayout.addComponent(btnInvert);
    btnStack = new Button("Stack");
    btnStack.setDebugId("btn-stack");
    btnStack.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            getWindow().executeJavaScript("toggleStacking()");
        }
    });
    chartControlsLayout.addComponent(btnStack);
    Label lblEmpty = new Label(" ");
    chartControlsLayout.addComponentAsFirst(lblEmpty);
    chartControlsLayout.setExpandRatio(lblEmpty, 2.0f);

    chartLayout = new VerticalLayout();
    chartLayout.setSizeFull();
    chartLayout.setDebugId("highchartsbarsingle");
    //        rightLayout.addComponent(chartLayout);
    VerticalLayout chartLayout2 = new VerticalLayout();
    chartLayout2.setSizeFull();
    chartLayout2.setDebugId("highchartsbarmultiple");
    rightLayout.addComponent(chartLayout2);
    rightLayout.setExpandRatio(chartLayout2, 2.0f);

    inspectLayout = new VerticalLayout();
    inspectLayout.setVisible(false);
    inspectLayout.setWidth("100%");
    inspectLayout.setDebugId("l-inspect");
    //        mainLayout.addComponent(inspectLayout);
    //        mainLayout.setExpandRatio(inspectLayout, 2.0f);
}