List of usage examples for com.vaadin.ui CssLayout addLayoutClickListener
@Override
public Registration addLayoutClickListener(LayoutClickListener listener)
From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initDescription(HorizontalLayout layout) { final CssLayout descriptionLayout = new CssLayout(); descriptionLayout.setWidth(100, Unit.PERCENTAGE); layout.addComponent(descriptionLayout); layout.setExpandRatio(descriptionLayout, 1.0f); layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT); String descriptionText = null; if (task.getDescription() != null && !"".equals(task.getDescription())) { descriptionText = task.getDescription(); } else {//?? descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION); }//from w w w . j ava 2s. c o m final Label descriptionLabel = new Label(descriptionText); descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE); descriptionLayout.addComponent(descriptionLabel); descriptionLayout.addLayoutClickListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // layout for textarea + ok button final VerticalLayout editLayout = new VerticalLayout(); editLayout.setSpacing(true); // textarea final TextArea descriptionTextArea = new TextArea(); // descriptionTextArea.setNullRepresentation(""); descriptionTextArea.setWidth(100, Unit.PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace descriptionLayout.replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); descriptionLayout.replaceComponent(editLayout, descriptionLabel); } }); } } }); }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * This method builds audio library for current filter. * /*from w ww .j a v a 2 s . c o m*/ * @param grid * The object to locate the audio covers. * @param filter * The filter to extract need music files. */ private void buildAudioLibrary(GridLayout grid, String filter) { AudioCollection audio = new AudioCollection(); for (final AudioFile audioFile : audio.getAudioCollection(filter)) { CssLayout select = new CssLayout(); select.addStyleName(Runo.CSSLAYOUT_SELECTABLE); CssLayout musicFile = new CssLayout(); musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW); musicFile.addComponent(createImageCover(audioFile.getCover())); select.addComponent(musicFile); musicFile.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 5789650754220216969L; @Override public void layoutClick(LayoutClickEvent event) { buildInformationPanel(audioFile); } }); grid.addComponent(select); grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER); } Label text = new Label("Note: This track are on Crative Common license."); text.addStyleName(Runo.LABEL_SMALL); text.setWidth("90%"); grid.addComponent(text); grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER); }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.navigation.NavigationViewImpl.java
License:Open Source License
public NavigationViewImpl() { for (ViewType type : ViewType.values()) { CssLayout navigationControl = new CssLayout(); navigationControl.addStyleName("navigationControl"); navigationControl.addStyleName(type.getNavigationStyle()); navigationControls.put(type, navigationControl); addComponent(navigationControl); navigationControl.addLayoutClickListener(navigationClickListener); }/*from w ww.j av a 2s .com*/ }
From source file:com.peergreen.webconsole.vaadin.tabs.DefaultTab.java
License:Open Source License
/** * Add extension shortcut to the default tab content * * @param extension extension object * @param extensionName extension name//from ww w . ja va 2s. c o m * @param extensionIcon extension icon */ public void addExtension(Component extension, final String extensionName, Resource extensionIcon) { Image moduleIcon = new Image(extensionName, extensionIcon); final CssLayout frame = new CssLayout(); frame.addComponent(moduleIcon); frame.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { Component moduleComponent = modulesComponents.get(extensionName); if (tabs.getTab(moduleComponent) == null) { tabs.addComponent(moduleComponent); tabs.getTab(moduleComponent).setCaption(extensionName); tabs.getTab(moduleComponent).setClosable(true); tabs.setSelectedTab(moduleComponent); } else { tabs.setSelectedTab(moduleComponent); } } }); if (ui != null) { ui.access(new Runnable() { @Override public void run() { addComponent(frame); } }); } else { addComponent(frame); } modulesComponents.put(extensionName, extension); modulesFrames.put(extensionName, frame); }
From source file:de.symeda.sormas.ui.SubMenu.java
License:Open Source License
public void addView(final String name, String caption, LayoutClickListener onClick) { CssLayout tabItemCell = new CssLayout(); tabItemCell.setSizeUndefined();/*from w w w .j a v a2s. co m*/ tabItemCell.setPrimaryStyleName("v-tabsheet-tabitemcell"); CssLayout tabItem = new CssLayout(); tabItem.setSizeUndefined(); tabItem.setPrimaryStyleName("v-tabsheet-tabitem"); tabItemCell.addComponent(tabItem); Link link = new Link(caption, null); link.addStyleName("v-caption"); tabItem.addComponent(link); tabItem.addLayoutClickListener(onClick); tabItem.addLayoutClickListener((e) -> { this.setActiveView(name); }); menuItemsLayout.addComponent(tabItemCell); viewMenuItemMap.put(name, tabItem); }
From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesForm.java
License:Open Source License
private void init() { addStyleName("favorites-form"); final VerticalLayout favoriteForm = new VerticalLayout(); favoriteEntryForm = new InternalFavoriteEntryForm(); favoriteGroupForm = new InternalFavoriteGroupForm(); tabsheet = new TabSheet(); tabsheet.addStyleName("favorites-tabs"); tabsheet.addTab(favoriteEntryForm, i18n.translate("favorites.form.favorite.add")); tabsheet.addTab(favoriteGroupForm, i18n.translate("favorites.form.group.add")); tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override/* www .j a v a2 s. c o m*/ public void selectedTabChange(SelectedTabChangeEvent event) { if (event.getTabSheet().getSelectedTab() instanceof InternalFavoriteEntryForm) { favoriteGroupForm.removeEnterKeyShortcutListener(); favoriteEntryForm.addEnterKeyShortcutListener(); } else { favoriteEntryForm.removeEnterKeyShortcutListener(); favoriteGroupForm.addEnterKeyShortcutListener(); } } }); final CssLayout header = new CssLayout(); header.addStyleName("dialog-header"); header.setSizeFull(); header.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { // change the visibility of the group- and favorite-items if (event.getClickedComponent() == editIcon || event.getChildComponent() == editLabel) { if (!listener.hasItems() || listener.itemsAreEditable()) { listener.setToInitialState(); } else { listener.setItemsEditable(true); } } else { // just open || close the FavoritesForm if (isOpen()) { close(); } else { open(); } } } }); // add final Label addNewIcon = new Label(); addNewIcon.setSizeUndefined(); addNewIcon.addStyleName("icon"); addNewIcon.addStyleName("icon-add-fav"); final Label addNewLabel = new Label(i18n.translate("favorites.form.add")); addNewLabel.setSizeUndefined(); addNewLabel.addStyleName("title"); // edit editIcon = new Label(); editIcon.setSizeUndefined(); editIcon.addStyleName(EDIT_ACTION_STYLENAME); editIcon.addStyleName("icon"); editIcon.addStyleName("icon-edit"); editLabel = new Label(i18n.translate("favorites.form.favorite.edit")); editLabel.setSizeUndefined(); editLabel.addStyleName("title"); editLabel.addStyleName(EDIT_ACTION_STYLENAME); // arrow arrowIcon = new Label(); arrowIcon.setSizeUndefined(); arrowIcon.addStyleName("icon"); arrowIcon.addStyleName("arrow"); arrowIcon.addStyleName("icon-arrow2_n"); // assemble header.addComponent(addNewIcon); header.addComponent(addNewLabel); header.addComponent(editIcon); header.addComponent(editLabel); header.addComponent(arrowIcon); favoriteForm.addComponent(header); favoriteForm.addComponent(tabsheet); // form is closed initially close(); setCompositionRoot(favoriteForm); }
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);//from w ww. j ava 2s . co m 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); }