List of usage examples for com.vaadin.ui CssLayout setStyleName
@Override public void setStyleName(String style)
From source file:org.eclipse.skalli.view.component.MultiTextField.java
License:Open Source License
private void renderTextFields() { int size = textFieldEntries.size(); int last = size - 1; for (int i = 0; i <= last; ++i) { TextFieldEntry textFieldEntry = textFieldEntries.get(i); CssLayout css = new CssLayout(); css.setStyleName(STYLE_LINE_LAYOUT); textFieldEntry.textField.setReadOnly(readOnly); css.addComponent(textFieldEntry.textField); if (!readOnly) { if (size > 1) { Button b = createRemoveButton(); textFieldEntry.removeButton = b; css.addComponent(b);/*from w w w . ja v a 2 s . co m*/ } if (size < maxSize && i == last) { css.addComponent(createAddButton()); } } layout.addComponent(css); } }
From source file:org.eclipse.skalli.view.component.Tray.java
License:Open Source License
private ComponentContainer createContent(String caption, String description, ThemeResource icon, boolean isRequired) { CssLayout layout = new CssLayout(); layout.setStyleName(STYLE_TRAY); layout.setMargin(true);/* w w w .j a v a 2 s .c om*/ HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true); header.setStyleName(STYLE_TRAY_HEADER); header.setWidth("100%"); this.icon = icon; trayIcon = new Embedded(null, icon); trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON); header.addComponent(trayIcon); header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT); header.setExpandRatio(trayIcon, 0); Label captionLabel = new Label(StringEscapeUtils.escapeHtml(caption), Label.CONTENT_XHTML); captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL); header.addComponent(captionLabel); header.setExpandRatio(captionLabel, 1); header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT); this.isRequired = isRequired; if (!isRequired) { activator = new NativeButton("", new ToggleEnabledListener()); header.addComponent(activator); header.setExpandRatio(activator, 0); header.setComponentAlignment(activator, Alignment.MIDDLE_RIGHT); } opener = new NativeButton("", new ToggleVisibleListener()); header.addComponent(opener); header.setExpandRatio(opener, 0); header.setComponentAlignment(opener, Alignment.MIDDLE_RIGHT); layout.addComponent(header); CssLayout content = new CssLayout(); Label descriptionLabel = new Label(HtmlUtils.clean(description), Label.CONTENT_XHTML); descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION); content.addComponent(descriptionLabel); layout.addComponent(content); setCompositionRoot(layout); return content; }
From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanelEntry.java
License:Open Source License
@SuppressWarnings("serial") private ComponentContainer createTray() { CssLayout layout = new CssLayout(); layout.setStyleName(STYLE_TRAY); layout.setMargin(true);//ww w.j ava 2s . c o m HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true); header.setStyleName(STYLE_TRAY_HEADER); header.setWidth("100%"); //$NON-NLS-1$ trayIcon = new Embedded(); trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON); final String icon = formService.getIconPath(); if (StringUtils.isNotBlank(icon)) { trayIcon.setSource(new StreamResource(new ExtensionStreamSource(formService.getClass(), icon), FilenameUtils.getName(icon), application)); } header.addComponent(trayIcon); header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT); header.setExpandRatio(trayIcon, 0); Label captionLabel = new Label(getCaptionWithAnchor(), Label.CONTENT_XHTML); captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL); header.addComponent(captionLabel); header.setExpandRatio(captionLabel, 1); header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT); editButton = new Button(); layoutLinkButton(editButton, header, new ClickListener() { @Override public void buttonClick(ClickEvent event) { switch (state) { case DISABLED: setState(TrayState.EDITABLE_VISIBLE); break; case INHERITED_VISIBLE: setState(TrayState.EDITABLE_VISIBLE); break; case INHERITED_INVISIBLE: setState(TrayState.EDITABLE_VISIBLE); break; } } }); inheritButton = new Button(); layoutLinkButton(inheritButton, header, new ClickListener() { @Override public void buttonClick(ClickEvent event) { form.commit(); switch (state) { case DISABLED: setState(TrayState.INHERITED_VISIBLE); break; case EDITABLE_VISIBLE: setState(TrayState.INHERITED_VISIBLE); break; case EDITABLE_INVISIBLE: setState(TrayState.INHERITED_VISIBLE); break; } } }); disableButton = new Button(); layoutLinkButton(disableButton, header, new ClickListener() { @Override public void buttonClick(ClickEvent event) { form.commit(); switch (state) { case EDITABLE_INVISIBLE: setState(TrayState.DISABLED); break; case EDITABLE_VISIBLE: setState(TrayState.DISABLED); break; case INHERITED_INVISIBLE: setState(TrayState.DISABLED); break; case INHERITED_VISIBLE: setState(TrayState.DISABLED); break; } } }); visibleButton = new NativeButton(); layoutIconButton(visibleButton, header, new ClickListener() { @Override public void buttonClick(ClickEvent event) { switch (state) { case EDITABLE_INVISIBLE: setState(TrayState.EDITABLE_VISIBLE); break; case EDITABLE_VISIBLE: setState(TrayState.EDITABLE_INVISIBLE); break; case INHERITED_INVISIBLE: setState(TrayState.INHERITED_VISIBLE); break; case INHERITED_VISIBLE: setState(TrayState.INHERITED_INVISIBLE); break; } } }); layout.addComponent(header); CssLayout content = new CssLayout(); Label descriptionLabel = new Label(extensionService.getDescription(), Label.CONTENT_XHTML); descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION); content.addComponent(descriptionLabel); layout.addComponent(content); return layout; }
From source file:org.lucidj.ui.gauss.GaussUI.java
License:Apache License
private void initToolbarArea() { hToolbarArea.setStyleName("ui-toolbar-area"); hToolbarArea.setSizeUndefined();//w w w .j av a2s . co m hToolbarArea.setWidth("100%"); CssLayout home_buttons = new CssLayout(); home_buttons.setStyleName("ui-toolbar-area-home"); home_buttons.setWidth(get_default_left_panel_width(), Sizeable.Unit.PIXELS); home_buttons.setId("_home_buttons"); final Button toggle_menu = new Button(); toggle_menu.setWidth(3, Unit.EM); toggle_menu.setIcon(FontAwesome.CHEVRON_DOWN); toggle_menu.addStyleName("tiny"); toggle_menu.addStyleName("link"); toggle_menu.addStyleName("ui-toolbar-spacer"); toggle_menu.addStyleName("ui-toggle-button"); toggle_menu.setId("_toggle_menu"); home_buttons.addComponent(toggle_menu); toggle_menu.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (!hsMenuContents.isLocked()) { default_left_panel_width_px = (int) hsMenuContents.getSplitPosition(); acMenu.setVisible(false); hsMenuContents.setMinSplitPosition(0, Unit.PIXELS); hsMenuContents.setSplitPosition(0, Sizeable.Unit.PIXELS); toggle_menu.setIcon(FontAwesome.CHEVRON_RIGHT); hsMenuContents.setLocked(true); } else { hsMenuContents.setLocked(false); acMenu.setVisible(true); hsMenuContents.setMinSplitPosition(MIN_LEFT_PANEL_WIDTH_PX, Unit.PIXELS); hsMenuContents.setSplitPosition(get_default_left_panel_width(), Unit.PIXELS); toggle_menu.setIcon(FontAwesome.CHEVRON_DOWN); } } }); final Button home = new Button("Home"); home.setIcon(FontAwesome.HOME); home.addStyleName("tiny"); home.addStyleName("ui-toolbar-spacer"); home.addStyleName("ui-toggle-button"); home.setId("_home"); home_buttons.addComponent(home); home.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { navigator.navigateTo("home"); } }); final Button new_button = new Button("New"); new_button.setIcon(FontAwesome.EDIT); new_button.addStyleName("tiny"); new_button.addStyleName("primary"); new_button.addStyleName("ui-toggle-button"); new_button.setId("_new"); home_buttons.addComponent(new_button); new_button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { navigator.navigateTo("new"); } }); hToolbarArea.addComponent(home_buttons); hToolbarPlaceholder = new CssLayout(); hToolbarPlaceholder.setSizeFull(); hToolbarArea.addComponent(hToolbarPlaceholder); hToolbarArea.setExpandRatio(hToolbarPlaceholder, 1.0f); final Button eject_view = new Button(); eject_view.setIcon(FontAwesome.EXTERNAL_LINK); eject_view.addStyleName("tiny"); eject_view.addStyleName("link"); eject_view.addStyleName("ui-toggle-button"); eject_view.setId("_eject_view"); hToolbarArea.addComponent(eject_view); eject_view.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Notification.show("Not implemented", Notification.Type.HUMANIZED_MESSAGE); } }); toggle_sidebar = new Button(); toggle_sidebar.setWidth(3, Unit.EM); toggle_sidebar.addStyleName("tiny"); toggle_sidebar.addStyleName("link"); toggle_sidebar.addStyleName("ui-toolbar-spacer"); toggle_sidebar.addStyleName("ui-toggle-button"); toggle_sidebar.setId("_toggle_sidebar"); hToolbarArea.addComponent(toggle_sidebar); toggle_sidebar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { show_sidebar(!sidebar_visible()); } }); }
From source file:org.semanticsoft.vaaclipse.presentation.renderers.PartRenderer.java
License:Open Source License
@Override public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) { VerticalLayout pane = new VerticalLayout(); pane.setSizeFull();// www . j a v a2 s. c o m final MPart part = (MPart) element; CssLayout toolbarArea = new CssLayout(); toolbarArea.setStyleName("mparttoolbararea"); toolbarArea.setSizeUndefined(); toolbarArea.setWidth("100%"); pane.addComponent(toolbarArea); //create toolbar MToolBar toolbar = part.getToolbar(); if (toolbar != null && toolbar.isToBeRendered()) { Component toolbarWidget = (Component) renderingEngine.createGui(toolbar); ((AbstractLayout) toolbarWidget).setSizeUndefined(); toolbarWidget.setStyleName("mparttoolbar"); toolbarArea.addComponent(toolbarWidget); } VerticalLayout contributionArea = new VerticalLayout(); contributionArea.setSizeFull(); pane.addComponent(contributionArea); pane.setExpandRatio(contributionArea, 100); pane.setStyleName("part"); element.setWidget(pane); IEclipseContext localContext = part.getContext(); localContext.set(Component.class, contributionArea); localContext.set(ComponentContainer.class, contributionArea); localContext.set(VerticalLayout.class, contributionArea); localContext.set(MPart.class, part); SavePromptSetup savePromptProvider = new SavePromptSetup(); savePrompts.put(part, savePromptProvider); localContext.set(SavePromptSetup.class, savePromptProvider); if (part instanceof MInputPart) localContext.set(MInputPart.class, (MInputPart) part); IContributionFactory contributionFactory = (IContributionFactory) localContext .get(IContributionFactory.class.getName()); Object newPart = contributionFactory.create(part.getContributionURI(), localContext); part.setObject(newPart); }
From source file:org.vaadin.addon.twitter.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { Responsive.makeResponsive(this); CssLayout info = new CssLayout(); info.setStyleName("tw-docs"); info.addComponent(markdown.get(0));/*from ww w .j ava 2 s. c o m*/ TabSheet tabSheet = new TabSheet(); tabSheet.setStyleName("tw-demo-tab"); tabSheet.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS); tabSheet.setSizeFull(); tabSheet.addTab(new TimelineDemo()).setCaption("Timeline"); tabSheet.addTab(new TweetDemo()).setCaption("Single Tweet"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Follow)).setCaption("Follow Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Share)).setCaption("Share Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Hashtag)).setCaption("Hashtag Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Mention)).setCaption("Mention Button"); tabSheet.addSelectedTabChangeListener(event -> { Component old = info.getComponent(0); Component newComp = markdown.get(tabSheet.getTabPosition(tabSheet.getTab(tabSheet.getSelectedTab()))); info.replaceComponent(old, newComp); }); final MHorizontalLayout layout = new MHorizontalLayout(info, tabSheet).withExpand(info, 4) .withExpand(tabSheet, 6).withFullWidth().withFullHeight().withMargin(false).withSpacing(true); setContent(new MPanel(layout).withFullWidth().withFullHeight().withStyleName(ValoTheme.PANEL_WELL, "root-container")); }
From source file:org.vaadin.alump.fancylayouts.FancyPanel.java
License:Apache License
/** * Build default content container/* w ww . j a v a2 s. c om*/ * * @return Default content container */ protected ComponentContainer createDefaultContent() { if (placeHolderComponent == null) { CssLayout layout = new CssLayout(); layout.setStyleName("fancypanel-default-layout"); layout.setSizeFull(); placeHolderComponent = layout; } return placeHolderComponent; }
From source file:org.vaadin.alump.scaleimage.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(true);//ww w . j av a 2 s . com layout.setSpacing(true); setContent(layout); // Big image that will scale to match with your page width, will // show the center of given picture. See SCSS file. ScaleImage bigCenterImage = new ScaleImage(); bigCenterImage.setWidth("100%"); bigCenterImage.setHeight("200px"); bigCenterImage.setStyleName("big-center-image"); bigCenterImage.setSource(new ThemeResource("images/big-center-image.jpg")); bigCenterImage.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent clickEvent) { Notification.show("Big center image clicked!"); } }); layout.addComponent(bigCenterImage); // Tile with image, where images will be scaled to match with tile size. // tileimage will cover space of tile and indicator image will be at // top left corner. // Uses absolute left/right/top/down positioning. See SCSS file. final CssLayout tile = new CssLayout(); tile.setStyleName("tile"); tile.setWidth(100, Unit.PIXELS); tile.setHeight(100, Unit.PIXELS); layout.addComponent(tile); tile.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { int size = (int) Math.round(100.0 + Math.random() * 100.0); tile.setWidth(size, Unit.PIXELS); tile.setHeight(size, Unit.PIXELS); } }); ScaleImage tileImage = new ScaleImage(); tileImage.setSource(new ThemeResource("images/tile-image.jpg")); tileImage.setStyleName("tile-image"); tile.addComponent(tileImage); ScaleImage indicatorImage = new ScaleImage(); indicatorImage.setSource(new ThemeResource("images/tile-indicator.png")); indicatorImage.setStyleName("tile-indicator"); tile.addComponent(indicatorImage); Label tileLabel = new Label("Click tile to scale it."); tile.addComponent(tileLabel); extendedImage = new ExtendedScaleImage(); extendedImage.setSource(new ThemeResource("images/tile-indicator.png")); extendedImage.setWidth("200px"); extendedImage.setHeight("400px"); extendedImage.setStyleName("extended-image"); layout.addComponent(extendedImage); Button moveButton = new Button("Move background", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Boolean val = extendedImage.getPosition(); if (val == null) { val = true; } extendedImage.setPosition(!val.booleanValue()); } }); layout.addComponent(moveButton); // Test how well scale image behaves inside alignment layout HorizontalLayout alignLayout = new HorizontalLayout(); alignLayout.setSpacing(true); alignLayout.setWidth("200px"); layout.addComponent(alignLayout); Label label = new Label("Alignment test:"); label.addStyleName("align-label"); alignLayout.addComponent(label); alignLayout.setExpandRatio(label, 1.0f); alignLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); ScaleImage alignImage = new ScaleImage(); alignImage.setSource(new ThemeResource("images/tile-image.jpg")); alignImage.setWidth("20px"); alignImage.setHeight("20px"); alignLayout.addComponent(alignImage); alignLayout.setComponentAlignment(alignImage, Alignment.BOTTOM_CENTER); }
From source file:org.vaadin.notifique.Notifique.java
License:Apache License
/** * Create a new item into the queue. It is not visible until added with *///from w w w .j a va 2s.co m protected Message createMessage(final Component component, String style) { final Message m = new Message(); // Wrap to a CssLayout (this is needed for styling and sizing correctly) CssLayout css = new CssLayout(); css.setWidth("100%"); css.setStyleName(Notifique.STYLE_ITEM); css.addStyleName(style != null ? style : Styles.MESSAGE); css.addComponent(component); // Wrap component into an animator m.component = component; m.animatedContent = css; return m; }
From source file:ro.zg.opengroups.views.UserNotificationRuleView.java
License:Apache License
private void displayDeleteRuleButton(final MultitypeNotificationRule rule) { final Button button = new Button(); button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.delete.rule")); button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.CANCEL, OpenGroupsIconsSet.SMALL)); CssLayout cell = addToContainer(button); cell.setStyleName("notification-rules-list-row-cell-delete-rule"); button.addListener(new ClickListener() { @Override// ww w .j a v a 2s. com public void buttonClick(ClickEvent event) { rule.delete(); } }); }