List of usage examples for com.vaadin.ui Component addStyleName
public void addStyleName(String style);
From source file:org.vaadin.alump.fancylayouts.demo.CssLayoutDemo.java
License:Apache License
public CssLayoutDemo() { setMargin(true);//from www .j a va 2s . com setSpacing(true); setSizeFull(); final FancyCssLayout cssLayout = new FancyCssLayout(); Label todo = new Label("FancyCssLayout adds transitions when you add or remove components from it."); addComponent(todo); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setWidth("100%"); addComponent(hLayout); Button addContent = new Button("Add new content item"); hLayout.addComponent(addContent); CheckBox middleCbox = new CheckBox("add middle"); middleCbox.setImmediate(true); middleCbox.setValue(addCssMiddle); hLayout.addComponent(middleCbox); CheckBox marginCbox = new CheckBox("slide"); marginCbox.setImmediate(true); marginCbox.setValue(cssLayout.isTransitionEnabled(FancyTransition.SLIDE)); hLayout.addComponent(marginCbox); CheckBox styleCbox = new CheckBox("cards"); styleCbox.setImmediate(true); styleCbox.setValue(boxMode); hLayout.addComponent(styleCbox); final Label counterLabel = new Label(getClickCounterCaption()); hLayout.addComponent(counterLabel); cssLayout.setSizeFull(); addComponent(cssLayout); setExpandRatio(cssLayout, 1.0f); for (int i = 0; i < 10; ++i) { addCssLayoutContent(cssLayout); } addContent.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { addCssLayoutContent(cssLayout); } }); middleCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { addCssMiddle = (Boolean) event.getProperty().getValue(); } }); marginCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { cssLayout.setSlideEnabled((Boolean) event.getProperty().getValue()); } }); styleCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); Iterator<Component> iter = cssLayout.iterator(); while (iter.hasNext()) { Component component = iter.next(); if (value) { component.addStyleName("demo-removable-two"); } else { component.removeStyleName("demo-removable-two"); } } boxMode = value; } }); cssLayout.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { ++clickCounter; if (event.getChildComponent() == null) { ++layoutClickCounter; } counterLabel.setValue(getClickCounterCaption()); } }); }
From source file:org.vaadin.melodion.Melodion.java
License:Open Source License
/** * Selects the given component in this melodion. * //from w w w .j av a2 s . co m * @param c * The component to select. */ public void setSelected(Component c) { updateStyles(); if (c instanceof Tab) { Tab t = (Tab) c; t.label.addStyleName("selected"); t.expand(); } else { c.addStyleName("selected"); } }
From source file:org.yukkasource.mvp.spring.integration.initializers.layout.ValoMenuLayout.java
License:Apache License
public void addMenu(Component menu) { logger.trace("adding menu component: {}", menu.getDescription()); menu.addStyleName("valo-menu-part"); menuArea.addComponent(menu);//from ww w .j ava 2 s.c o m }
From source file:pt.ist.vaadinframework.ui.layout.FlowLayout.java
License:Open Source License
private void setStyle(Component c) { c.addStyleName("flow-part"); c.setSizeUndefined(); }
From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { final UserAction ua = actionContext.getUserAction(); final OpenGroupsApplication app = actionContext.getApp(); ComponentContainer targetContainer = actionContext.getTargetContainer(); targetContainer.removeAllComponents(); targetContainer.addStyleName(OpenGroupsStyles.LIST_ACTIONS_CONTAINER); final Entity entity = actionContext.getEntity(); /* reset filters */ entity.resetFilters();/*from ww w. j a v a2 s . co m*/ // Panel listContainer = new Panel(); // ((VerticalLayout)listContainer.getContent()).setMargin(false); CssLayout refreshButtonContainer = new CssLayout(); // refreshButtonContainer.setSizeFull(); // refreshButtonContainer.setWidth("100%"); refreshButtonContainer.addStyleName(OpenGroupsStyles.LIST_REFRESH_BAR); // final VerticalLayout listContainer = new VerticalLayout(); final CssLayout listAndPageControlsContainer = new CssLayout(); // final VerticalLayout listAndPageControlsContainer = new VerticalLayout(); listAndPageControlsContainer.addStyleName("list-container"); // listAndPageControlsContainer.setSizeFull(); // listAndPageControlsContainer.setWidth("100%"); Button refreshButton = new Button(); refreshButton.setDescription(getMessage("refresh.list")); refreshButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.REFRESH, OpenGroupsIconsSet.MEDIUM)); refreshButton.addStyleName(BaseTheme.BUTTON_LINK + " middle-right"); refreshButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { refreshList(entity, ua, app, listAndPageControlsContainer, actionContext); } }); targetContainer.addComponent(refreshButtonContainer); Component searchFilter = getSearchFilter(entity, ua, app, actionContext); searchFilter.addStyleName("middle-left"); refreshButtonContainer.addComponent(searchFilter); refreshButtonContainer.addComponent(refreshButton); ComponentContainer filtersContainer = initFilters(entity, ua, app, actionContext); targetContainer.addComponent(filtersContainer); targetContainer.addComponent(listAndPageControlsContainer); int itemsCount = refreshList(entity, ua, app, listAndPageControlsContainer, actionContext); }
From source file:ro.zg.netcell.vaadin.action.application.LoadMainWindowHandler.java
License:Apache License
private void addUserHeaderActions(final OpenGroupsApplication app, final ActionContext ac) throws ContextAwareException { UserActionList actionList = getGlobalActions(ActionLocations.HEADER); if (actionList == null) { return;//from ww w.jav a2s . c om } Collection<UserAction> userActions = actionList.getActions().values(); OpenGroupsMainWindow window = ac.getWindow(); User user = app.getCurrentUser(); CssLayout header = window.getHeader(); header.removeAllComponents(); if (user != null) { Embedded usericon = new Embedded(null, OpenGroupsResources.getIcon(OpenGroupsIconsSet.USER, OpenGroupsIconsSet.MEDIUM)); usericon.addStyleName("middle-left right-margin-10"); header.addComponent(usericon); Label userInfo = new Label(/*app.getMessage("login.user.info") + ": " +*/ user.getUsername()); userInfo.setSizeUndefined(); header.addComponent(userInfo); userInfo.addStyleName("username-label"); } /* get the current user types */ // List<String> userTypes = UsersManager.getInstance().getCurrentUserTypes(null, app); for (final UserAction ua : userActions) { /* * if the current user is not allowed to read/view the current action then skip it */ // if (!ua.allowRead(userTypes)) { if (!ua.isVisible(ac)) { continue; } Button actButton = new Button(ua.getDisplayName()); actButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { // app.executeAction(ua, null); ua.executeHandler(null, app, null, ac); } }); header.addComponent(actButton); actButton.addStyleName("middle-right left-margin-10"); } Component rootLink = getRootEntityLink(app); Component metaLink = getMetaEntityLink(app); rootLink.setSizeUndefined(); metaLink.setSizeUndefined(); /* add quick links */ header.addComponent(rootLink); header.addComponent(metaLink); rootLink.addStyleName("middle-right left-margin-10"); metaLink.addStyleName("middle-right left-margin-10"); }
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();// w w w . jav a 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); }