List of usage examples for com.vaadin.ui VerticalLayout addLayoutClickListener
@Override
public Registration addLayoutClickListener(LayoutClickListener listener)
From source file:de.fatalix.bookery.view.admin.AdminView.java
License:Open Source License
public HorizontalLayout createUserManagement() { userManagementLayout = new HorizontalLayout(); userManagementLayout.addStyleName("wrapping"); userManagementLayout.setSpacing(true); userManagementLayout.setMargin(true); Label label = new Label("Add new user..."); label.setSizeUndefined();/* ww w . ja v a2 s.c om*/ label.addStyleName(ValoTheme.LABEL_LARGE); VerticalLayout emptyLayout = new VerticalLayout(label); emptyLayout.addStyleName("dashed-border"); emptyLayout.setWidth(380, Unit.PIXELS); emptyLayout.setHeight(220, Unit.PIXELS); emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { AppUser appUser = presenter.createNewUser(); AppUserCard appUserCard = appUserCardInstances.get(); appUserCard.loadAppUser(appUser); appUserCard.addAppUserCardListener(AdminView.this); userManagementLayout.addComponent(appUserCard, userManagementLayout.getComponentCount() - 1); } }); userManagementLayout.addComponent(emptyLayout); return userManagementLayout; }
From source file:de.fatalix.bookery.view.admin.BatchJobsLayout.java
private Layout createEmptyLayout() { Label label = new Label("Add new job..."); label.setSizeUndefined();//from w w w . java 2 s . c om label.addStyleName(ValoTheme.LABEL_LARGE); VerticalLayout emptyLayout = new VerticalLayout(label); emptyLayout.addStyleName("dashed-border"); emptyLayout.setWidth(380, Unit.PIXELS); emptyLayout.setHeight(220, Unit.PIXELS); emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { BatchJobConfiguration jobConfig = presenter.createBatchJob(); BatchJobCard batchJobCard = batchJobCardInstances.get(); batchJobCard.load(jobConfig); batchJobCard.addBatchJobCardListener(BatchJobsLayout.this); batchJobLayout.addComponent(batchJobCard, batchJobLayout.getComponentCount() - 1); } }); return emptyLayout; }
From source file:de.fatalix.bookery.view.common.BookSearchLayout.java
License:Open Source License
private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) { Image image = new Image(); image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor()); image.setHeight("200px"); image.setWidth("130px"); image.setImmediate(true);//from w w w . j av a 2s .co m if (bookEntry.getThumbnail() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail()); image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png")); } else if (bookEntry.getCover() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover()); image.setSource(new StreamResource(source, bookEntry.getId() + ".png")); } final MButton watchListButton = new MButton() .withIcon(presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR : FontAwesome.STAR_O) .withStyleName(ValoTheme.BUTTON_LINK); watchListButton.addStyleName("quick-action"); watchListButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { watchListButton.setIcon(presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR : FontAwesome.STAR_O); } }); final MButton likeButton = new MButton().withCaption("" + bookEntry.getLikes()) .withIcon(FontAwesome.THUMBS_O_UP).withStyleName(ValoTheme.BUTTON_LINK); likeButton.addStyleName("quick-action"); likeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { BookEntry updatedBook = presenter.updateLike(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()); bookEntry.setLikes(updatedBook.getLikes()); bookEntry.setLikedby(updatedBook.getLikedby()); likeButton.setCaption("" + bookEntry.getLikes()); } catch (SolrServerException | IOException ex) { java.util.logging.Logger.getLogger(BookSearchLayout.class.getName()).log(Level.SEVERE, null, ex); } } }); final MButton downloadsButton = new MButton().withCaption("" + bookEntry.getDownloads()) .withIcon(FontAwesome.DOWNLOAD).withStyleName(ValoTheme.BUTTON_LINK); downloadsButton.addStyleName("quick-action"); HorizontalLayout quickActionLayout = new HorizontalLayout(watchListButton, likeButton, downloadsButton); quickActionLayout.addStyleName("quick-action-layout"); VerticalLayout result = new VerticalLayout(image, quickActionLayout); //result.setHeight("210px"); //result.setWidth("140px"); result.addStyleName("pointer-cursor"); result.addStyleName("book-card"); result.setComponentAlignment(image, Alignment.MIDDLE_CENTER); result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { bookDetailLayout.loadData(bookEntry); bookDetailLayout.setLayoutVisible(true); //BookDetailDialog dialogInstance = bookDetail.get(); //dialogInstance.loadData(bookEntry); //UI.getCurrent().addWindow(dialogInstance); } }); return result; }
From source file:de.fatalix.bookery.view.common.SuggestLaneLayout.java
License:Open Source License
private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) { Image image = new Image(); image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor()); image.setHeight("200px"); image.setWidth("130px"); image.setImmediate(true);/* w w w.j a va 2 s . co m*/ if (bookEntry.getThumbnail() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail()); image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png")); } else if (bookEntry.getCover() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover()); image.setSource(new StreamResource(source, bookEntry.getId() + ".png")); } VerticalLayout result = new VerticalLayout(image); result.setHeight("210px"); result.addStyleName("pointer-cursor"); result.addStyleName("book-cover"); result.setComponentAlignment(image, Alignment.MIDDLE_CENTER); result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { bookDetailLayout.loadData(bookEntry); bookDetailLayout.setLayoutVisible(true); } }); return result; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTextAreaView.java
License:Apache License
@Override public void showContent(String xhtml) { Label label = new Label(xhtml, ContentMode.HTML); VerticalLayout clickLayout = new VerticalLayout(label); clickLayout.addLayoutClickListener(new LayoutClickListener() { @Override/* www. ja v a 2s .c o m*/ public void layoutClick(LayoutClickEvent event) { if (event.isDoubleClick()) { presenter.contentAreaClicked(); } } }); setCompositionRoot(clickLayout); }
From source file:edu.nps.moves.mmowgli.components.CardLarge.java
License:Open Source License
@SuppressWarnings("serial") @HibernateRead//from w ww .j a va 2s . c om public void initGuiTL() { setWidth(CARDBIG_W); setHeight(CARDBIG_H); MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals(); if (bckgrndResource != null) { bckgrndImg = new Embedded(null, bckgrndResource); addComponent(bckgrndImg, "top:0px;left:0px"); } Card card = Card.getTL(cardId); title.setValue(card.getCardType().getTitle().toUpperCase()); title.setWidth(CARDBIG_TITLE_W); title.setHeight(CARDBIG_TITLE_H); title.setDescription(title_tt); addComponent(title, CARDBIG_TITLE_POS); title.addStyleName("m-cardlarge-title"); title.addStyleName(CardStyler.getCardTextColorOverWhiteStyle(card.getCardType())); User userMe = globs.getUserTL(); if (starGreyResource != null && starRedResource != null) { if (userMe.getFavoriteCards().contains(card)) starButton.setIcon(starRedResource); else starButton.setIcon(starGreyResource); addComponent(starButton, CARDBIG_STAR_POS); starButton.addClickListener(new StarClick()); starButton.addStyleName("borderless"); starButton.setDescription(star_tt); } content.setWidth(CARDBIG_CONTENT_W); content.setHeight("115px");// 130 CARDBIG_CONTENT_H); addComponent(content, CARDBIG_CONTENT_POS); Game g = Game.getTL(); content.setValue(formatText(card.getText(), g, HSess.get())); content.addStyleName("m-cardlarge-content"); if (card.isHidden()) content.addStyleName("m-cardsummary-hidden"); // red "HIDDEN" text background // Removing the tool-tip because: // 1 it doesn't tell us anything new since the text is already visible // 2 new tooltips for inner-links to other ap's and cards conflict //content.setDescription(card.getText()); addComponent(idLab, "top:55px;left:340px"); idLab.setHeight("15px"); idLab.setWidth("70px"); idLab.addStyleName("m-cardlarge-id"); idLab.setValue("" + card.getId()); idLab.setDescription(id_tt); markingPanel = new HorizontalLayout(); markingPanel.setHeight("15px"); markingPanel.setWidth(CARDBIG_CONTENT_W); markingPanel.setSpacing(true); markingPanel.addStyleName("m-cardlarge-markings"); addComponent(markingPanel, "top:220px;left:70px"); showMarking_oob(card); User author = card.getAuthor(); if (author.getAvatar() != null) { Resource avRes = globs.mediaLocator().locate(author.getAvatar().getMedia()); if (avRes != null) { avatarIcon = new Embedded(null, avRes); avatarIcon.setWidth(CARDBIG_ICON_W); avatarIcon.setHeight(CARDBIG_ICON_H); avatarIcon.addStyleName("m-cursor-pointer"); avatarIcon.setDescription(userProfile_tt); addComponent(avatarIcon, CARDBIG_ICON_POS); } } uname.setValue(author.getUserName()); uname.setWidth(CARDBIG_UNAME_W); uname.setHeight(CARDBIG_UNAME_H); uname.addStyleName("m-cardlarge-user"); uname.addStyleName("m-cursor-pointer"); uname.setDescription(userProfile_tt); // This silly wrapper is so we can listen for mouse clicks on the name (should really used a link-style button); listing on this // component as a whole kill the ability to follow url links which are in the card text. VerticalLayout wrapper = new VerticalLayout(); wrapper.addComponent(uname); addComponent(wrapper, CARDBIG_UNAME_POS); dateLab.setValue(dateFormatter.format(card.getCreationDate())); dateLab.setWidth(CARDBIG_DATE_W); dateLab.setHeight(CARDBIG_DATE_H); dateLab.addStyleName("m-cardlarge-user"); dateLab.setDescription(date_tt); addComponent(dateLab, CARDBIG_DATE_POS); long currentMoveId = Move.getCurrentMoveTL().getId(); if (card.getCreatedInMove().getId() != currentMoveId) { moveLab.setValue(card.getCreatedInMove().getName()); moveLab.setWidth("198px"); moveLab.setHeight("20px"); moveLab.addStyleName("m-cardlarge-movelabel"); moveLab.addStyleName("m-cursor-pointer"); moveLab.setDescription("This card was created in a prior round"); addComponent(moveLab, "top:300px;left:300px"); } wrapper.addLayoutClickListener(new LayoutClickListener() { @MmowgliCodeEntry public void layoutClick(LayoutClickEvent event) { Component c = event.getChildComponent(); if (c == uname) goToUserProfilePage(); } }); addLayoutClickListener(new LayoutClickListener() { @MmowgliCodeEntry public void layoutClick(LayoutClickEvent event) { Component c = event.getChildComponent(); if (c == avatarIcon) goToUserProfilePage(); } }); }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static void updateIndicators(final Main main, final Base base, boolean canWrite) { final Database database = main.getDatabase(); List<IndicatorDescription> descs = new ArrayList<IndicatorDescription>(); fillIndicatorDescriptions(main, base, "", descs); boolean isMap = base instanceof Strategiakartta; if (isMap && (!descs.isEmpty() || canWrite)) { HorizontalLayout indiHeader = new HorizontalLayout(); indiHeader.setSpacing(true);/*from w w w.ja v a 2 s .co m*/ Label header = new Label("Indikaattorit (ennuste)"); main.propertyCells.add(Utils.excelRow(header.getValue())); header.setHeight("32px"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); indiHeader.addComponent(header); indiHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editIndicators = new Image(null, new ThemeResource("chart_line_edit.png")); editIndicators.setHeight("24px"); editIndicators.setWidth("24px"); editIndicators.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editIndicators); manageIndicators(main, main.getUIState().currentItem); } }); indiHeader.addComponent(editIndicators); indiHeader.setComponentAlignment(editIndicators, Alignment.BOTTOM_CENTER); } main.properties.addComponent(indiHeader); main.properties.setComponentAlignment(indiHeader, Alignment.MIDDLE_CENTER); VerticalLayout indicators = new VerticalLayout(); boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); Property time = Property.find(database, Property.AIKAVALI); int index = 0; for (final IndicatorDescription desc : descs) { ArrayList<String> excelRow = new ArrayList<String>(); Indicator indicator = desc.indicator; final HorizontalLayout hl = new HorizontalLayout(); hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty"); hl.setSpacing(true); Label l = new Label(desc.caption); excelRow.add(l.getValue().replace("%nbsp", "")); l.setContentMode(ContentMode.HTML); l.setWidth("450px"); l.addStyleName("propertyName"); l.setData(desc); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); String value = updateIndicatorValue(main, hl, base, indicator, canWrite); excelRow.add(value); Label unit = new Label(indicator.getUnit()); unit.setWidth("100px"); hl.addComponent(unit); hl.setComponentAlignment(unit, Alignment.MIDDLE_LEFT); excelRow.add(unit.getValue()); Label comment = new Label(indicator.getValueShortComment()); comment.setWidth("150px"); hl.addComponent(comment); hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT); excelRow.add(comment.getValue()); if (showYears) { HorizontalLayout hl2 = new HorizontalLayout(); hl2.setWidth("70px"); hl2.setHeight("100%"); hl.addComponent(hl2); hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT); String years = time.getPropertyValue(indicator); if (years == null) years = Property.AIKAVALI_KAIKKI; final Label region = new Label(years); region.setWidthUndefined(); excelRow.add(region.getValue()); hl2.addComponent(region); hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER); } final Image wiki = new Image(); wiki.setSource(new ThemeResource("table_edit.png")); wiki.setHeight("24px"); wiki.setWidth("24px"); wiki.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Wiki.openWiki(main, desc.indicator); } }); hl.addComponent(wiki); hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER); indicators.addComponent(hl); indicators.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); main.propertyCells.add(excelRow); } indicators.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 3295743025581923380L; private String extractData(Component c) { if (c instanceof AbstractComponent) { Object data = ((AbstractComponent) c).getData(); if (data instanceof IndicatorDescription) { IndicatorDescription desc = (IndicatorDescription) data; return desc.indicator.getDescription(database); } } return null; } @Override public void layoutClick(LayoutClickEvent event) { String desc = extractData(event.getClickedComponent()); if (desc == null) return; String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">"; content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">" + desc + "</div>"; content += "</div>"; Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE); n.setHtmlContentAllowed(true); n.show(Page.getCurrent()); } }); main.properties.addComponent(indicators); main.properties.setComponentAlignment(indicators, Alignment.MIDDLE_CENTER); } }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void updateMeters(final Main main, boolean canWrite) { if (main.getUIState().currentItem instanceof Strategiakartta) return;//from w w w .j a v a 2s . c om final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; List<MeterDescription> descs = makeMeterDescriptions(main, base, false); if (!descs.isEmpty() || canWrite) { HorizontalLayout meterHeader = new HorizontalLayout(); meterHeader.setSpacing(true); Label header = new Label("Mittarit"); main.propertyCells.add(Utils.excelRow(header.getValue())); header.setHeight("32px"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); meterHeader.addComponent(header); meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png")); editMeters.setHeight("24px"); editMeters.setWidth("24px"); editMeters.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editMeters); manageMeters(main, main.getUIState().currentItem); } }); meterHeader.addComponent(editMeters); meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER); } main.properties.addComponent(meterHeader); main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER); VerticalLayout meters = new VerticalLayout(); boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); Property time = Property.find(database, Property.AIKAVALI); int index = 0; for (final MeterDescription desc : descs) { ArrayList<String> excelRow = new ArrayList<String>(); final Meter meter = desc.meter; final HorizontalLayout hl = new HorizontalLayout(); hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty"); hl.setSpacing(true); Label l = new Label(desc.caption); excelRow.add(l.getValue().replace("%nbsp", "")); l.setContentMode(ContentMode.HTML); l.setWidth("450px"); l.addStyleName("propertyName"); l.setData(desc); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); String value = updateMeterValue(main, hl, base, meter, canWrite); excelRow.add(value); String shortComment = ""; Indicator indicator = meter.getPossibleIndicator(database); if (indicator != null) shortComment = indicator.getValueShortComment(); Label comment = new Label(shortComment); comment.setWidth("150px"); hl.addComponent(comment); hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT); excelRow.add(comment.getValue()); if (showYears) { HorizontalLayout hl2 = new HorizontalLayout(); hl2.setWidth("70px"); hl2.setHeight("100%"); hl.addComponent(hl2); hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT); String years = time.getPropertyValue(meter); if (years == null) years = Property.AIKAVALI_KAIKKI; final Label region = new Label(years); region.setWidthUndefined(); excelRow.add(region.getValue()); hl2.addComponent(region); hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER); } AbsoluteLayout image = new AbsoluteLayout(); image.setWidth("32px"); image.setHeight("32px"); image.addStyleName("meterColor" + index); String color = meter.getTrafficColor(database); Styles styles = Page.getCurrent().getStyles(); styles.add( ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }"); hl.addComponent(image); hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER); hl.setExpandRatio(image, 0.0f); meters.addComponent(hl); meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png") : new ThemeResource("zoom_out.png"); final Image show = new Image(); show.setSource(res); show.setHeight("24px"); show.setWidth("24px"); if (canWrite) { show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa"); show.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { desc.meter.setShowInMap(!desc.meter.showInMap); Updates.update(main, true); } }); } hl.addComponent(show); hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER); final Image wiki = new Image(); wiki.setSource(new ThemeResource("table_edit.png")); wiki.setHeight("24px"); wiki.setWidth("24px"); wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan"); wiki.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Wiki.openWiki(main, desc.meter); } }); hl.addComponent(wiki); hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER); if (canWrite) { final Button principalButton = new Button(); if (meter.isPrincipal) { principalButton.setCaption("Poista kokonaisarvio"); } else { principalButton.setCaption("Aseta kokonaisarvioksi"); } principalButton.setStyleName(ValoTheme.BUTTON_TINY); principalButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 8247560202892661226L; @Override public void buttonClick(ClickEvent event) { if (meter.isPrincipal) { meter.isPrincipal = false; } else { for (Meter m : base.getMeters(database)) m.isPrincipal = false; meter.isPrincipal = true; } Updates.update(main, true); } }); hl.addComponent(principalButton); hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER); } main.propertyCells.add(excelRow); } meters.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 3295743025581923380L; private String extractData(Component c) { if (c instanceof AbstractComponent) { Object data = ((AbstractComponent) c).getData(); if (data instanceof MeterDescription) { MeterDescription desc = (MeterDescription) data; return desc.meter.getDescription(database); } } return null; } @Override public void layoutClick(LayoutClickEvent event) { String desc = extractData(event.getClickedComponent()); if (desc == null) return; String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">"; content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">" + desc + "</div>"; content += "</div>"; Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE); n.setHtmlContentAllowed(true); n.show(Page.getCurrent()); } }); main.properties.addComponent(meters); main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER); } }
From source file:no.uib.probe.csf.pr.touch.view.core.SearchingField.java
/** * Default constructor to initialize the main attributes. */// w ww. ja va 2 s .c om public SearchingField() { this.setSpacing(true); this.setHeightUndefined(); HorizontalLayout searchFieldContainerLayout = new HorizontalLayout(); searchFieldContainerLayout.setWidthUndefined(); searchFieldContainerLayout.setHeight(100, Unit.PERCENTAGE); searchFieldContainerLayout.setSpacing(true); TextField searchField = new TextField(); searchField.setDescription("Search proteins by name or accession"); searchField.setImmediate(true); searchField.setWidth(100, Unit.PIXELS); searchField.setHeight(18, Unit.PIXELS); searchField.setInputPrompt("Search..."); searchFieldContainerLayout.addComponent(searchField); searchField.setTextChangeTimeout(1500); searchField.setStyleName(ValoTheme.TEXTFIELD_SMALL); searchField.addStyleName(ValoTheme.TEXTFIELD_TINY); final Button b = new Button(); searchField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY); searchField.addShortcutListener(new Button.ClickShortcut(b, ShortcutListener.KeyCode.ENTER)); VerticalLayout searchingBtn = new VerticalLayout(); searchingBtn.setWidth(22, Unit.PIXELS); searchingBtn.setHeight(18, Unit.PIXELS); searchingBtn.setStyleName("tablesearchingbtn"); searchFieldContainerLayout.addComponent(searchingBtn); searchFieldContainerLayout.setComponentAlignment(searchingBtn, Alignment.TOP_CENTER); this.addComponent(searchFieldContainerLayout); this.setComponentAlignment(searchFieldContainerLayout, Alignment.TOP_CENTER); searchingCommentLabel = new Label(); searchingCommentLabel.setWidth(100, Unit.PERCENTAGE); searchingCommentLabel.setHeight(23, Unit.PIXELS); searchingCommentLabel.addStyleName(ValoTheme.LABEL_BOLD); searchingCommentLabel.addStyleName(ValoTheme.LABEL_SMALL); searchingCommentLabel.addStyleName(ValoTheme.LABEL_TINY); this.addComponent(searchingCommentLabel); this.setComponentAlignment(searchingCommentLabel, Alignment.TOP_CENTER); searchingBtn.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> { b.click(); }); searchField.addTextChangeListener((FieldEvents.TextChangeEvent event) -> { SearchingField.this.textChanged(event.getText()); }); b.addClickListener((Button.ClickEvent event) -> { SearchingField.this.textChanged(searchField.getValue()); }); }
From source file:no.uib.probe.mnpc_2017.view.ApplicationLayout.java
private VerticalLayout generateMenuBtn(String title, VerticalLayout targetComponent) { VerticalLayout btn = new VerticalLayout(); Label btnLabel = new Label(title); btn.setStyleName("menubtn"); btn.addComponent(btnLabel);/*from www . j a v a 2 s.c o m*/ btn.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> { UI.getCurrent().scrollIntoView(targetComponent); }); return btn; }