List of usage examples for com.vaadin.ui Image setDescription
public void setDescription(String description)
From source file:com.esofthead.mycollab.vaadin.ui.AttachmentDisplayComponent.java
License:Open Source License
public static Component constructAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }//w w w . j av a2 s. co m final AbsoluteLayout attachmentLayout = new AbsoluteLayout(); attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT); attachmentLayout.setStyleName("attachment-block"); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setSizeFull(); thumbnailWrap.setStyleName("thumbnail-wrap"); Image thumbnail = new Image(null); if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) { thumbnail.setSource(DEFAULT_SOURCE); } else { thumbnail.setSource(VaadinResourceManager.getResourceManager() .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE)); } thumbnail.setDescription(docName); thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;"); if (MimeTypesUtil.isImageType(docName)) { thumbnail.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = -2853211588120500523L; @Override public void click(MouseEvents.ClickEvent event) { Resource previewResource = VaadinResourceManager.getResourceManager() .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE); UI.getCurrent().addWindow(new AttachmentPreviewWindow(previewResource)); } }); } CssLayout attachmentNameWrap = new CssLayout(); attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentNameWrap.setStyleName("attachment-name-wrap"); Label attachmentName = new Label(StringUtils.trim(docName, 60, true)); attachmentName.setStyleName("attachment-name"); attachmentNameWrap.addComponent(attachmentName); attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;"); Button trashBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ResourceService attachmentService = ApplicationContextUtil .getSpringBean(ResourceService.class); attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(), AppContext.getAccountId()); ((ComponentContainer) attachmentLayout.getParent()) .removeComponent(attachmentLayout); } } }); } }); trashBtn.setIcon(FontAwesome.TRASH_O); trashBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;"); Button downloadBtn = new Button(); FileDownloader fileDownloader = new FileDownloader( VaadinResourceManager.getResourceManager().getStreamResource(attachment.getPath())); fileDownloader.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;"); return attachmentLayout; }
From source file:com.esofthead.mycollab.vaadin.ui.UserAvatarControlFactory.java
License:Open Source License
public static Image createUserAvatarEmbeddedComponent(String avatarId, int size, String tooltip) { Image embedded = new Image(null, createAvatarResource(avatarId, size)); embedded.setDescription(tooltip); return embedded; }
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);/*ww w . j a v a 2s.c o 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);//from ww w . j a v a2 s . c om 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:edu.nps.moves.mmowgli.AppMaster.java
License:Open Source License
private void createQrImageTL() throws WriterException, IOException { Image imgObj = new Image(MOBILE_QR_IMAGE_NAME, MOBILE_QR_IMAGE_MIMETYPE); QRCodeWriter writer = new QRCodeWriter(); HashMap<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); hints.put(EncodeHintType.MARGIN, 4); String url = MmowgliMobileVaadinServlet.getBaseMobileUrl().toExternalForm(); BitMatrix bm = writer.encode(url, BarcodeFormat.QR_CODE, 550, 550, hints); BufferedImage bi = MatrixToImageWriter.toBufferedImage(bm); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(bi, MOBILE_QR_IMAGE_FILETYPE, baos); baos.flush();/*from www. j a v a2s . com*/ imgObj.setBytes(baos.toByteArray()); imgObj.setDescription(url); Image.saveTL(imgObj); @SuppressWarnings("unchecked") List<Media> lis = HSess.get().createCriteria(Media.class) .add(Restrictions.eq("source", Media.Source.DATABASE)).add(Restrictions.eq("url", imgObj.getName())) .list(); if (lis != null) { for (Media m : lis) Media.deleteTL(m); } Media media = new Media(); media.setDescription(imgObj.getName() + " in db"); media.setSource(Media.Source.DATABASE); media.setUrl(imgObj.getName()); media.setType(Media.MediaType.IMAGE); Media.saveTL(media); }
From source file:fi.semantum.strategia.Updates.java
License:Open Source License
public static void updateTags(final Main main) { final Database database = main.getDatabase(); main.tags.removeAllComponents();/*from w ww . j a va 2 s. co m*/ main.tags.setMargin(true); ArrayList<Tag> sorted = new ArrayList<Tag>(Tag.enumerate(database)); Collections.sort(sorted, new Comparator<Tag>() { @Override public int compare(Tag arg0, Tag arg1) { return arg0.getId(database).compareTo(arg1.getId(database)); } }); for (final Tag t : sorted) { final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label l = new Label(t.getId(database)); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_HUGE); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.BOTTOM_LEFT); final Image select = new Image("", new ThemeResource("cursor.png")); select.setHeight("24px"); select.setWidth("24px"); select.setDescription("Valitse"); select.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 3734678948272593793L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { main.setCurrentItem(t, main.getUIState().currentPosition); Utils.loseFocus(select); } }); hl.addComponent(select); hl.setComponentAlignment(select, Alignment.BOTTOM_LEFT); final Image edit = new Image("", new ThemeResource("table_edit.png")); edit.setHeight("24px"); edit.setWidth("24px"); edit.setDescription("Muokkaa"); edit.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = -3792353723974454702L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.editTextAndId(main, "Muokkaa aihetunnistetta", t); updateTags(main); } }); hl.addComponent(edit); hl.setComponentAlignment(edit, Alignment.BOTTOM_LEFT); main.tags.addComponent(hl); main.tags.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); Label l2 = new Label(t.getText(database)); l2.addStyleName(ValoTheme.LABEL_LIGHT); l2.setSizeUndefined(); main.tags.addComponent(l2); main.tags.setComponentAlignment(l2, 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;/*w w w.ja v a2 s .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:org.opencms.ui.components.CmsResourceTable.java
License:Open Source License
/** * Static helper method to initialize the 'standard' properties of a data item from a given resource.<p> * @param resourceItem the resource item to fill * @param cms the CMS context/*from w ww . jav a 2 s . c o m*/ * @param resource the resource * @param messages the message bundle * @param locale the locale */ public static void fillItemDefault(Item resourceItem, CmsObject cms, CmsResource resource, CmsMessages messages, Locale locale) { if (resource == null) { LOG.error("Error rendering item for 'null' resource"); return; } if (resourceItem == null) { LOG.error("Error rendering 'null' item for resource " + resource.getRootPath()); return; } if (cms == null) { cms = A_CmsUI.getCmsObject(); LOG.warn("CmsObject was 'null', using thread local CmsObject"); } CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource); Map<String, CmsProperty> resourceProps = null; try { List<CmsProperty> props = cms.readPropertyObjects(resource, false); resourceProps = new HashMap<String, CmsProperty>(); for (CmsProperty prop : props) { resourceProps.put(prop.getName(), prop); } } catch (CmsException e1) { LOG.debug("Unable to read properties for resource '" + resource.getRootPath() + "'.", e1); } I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); if (resourceItem.getItemProperty(PROPERTY_TYPE_ICON) != null) { resourceItem.getItemProperty(PROPERTY_TYPE_ICON) .setValue(new CmsResourceIcon(resUtil, resource.getState(), true)); } if (resourceItem.getItemProperty(PROPERTY_PROJECT) != null) { Image projectFlag = null; switch (resUtil.getProjectState().getMode()) { case 1: projectFlag = new Image(resUtil.getLockedInProjectName(), new ThemeResource(OpenCmsTheme.PROJECT_CURRENT_PATH)); break; case 2: projectFlag = new Image(resUtil.getLockedInProjectName(), new ThemeResource(OpenCmsTheme.PROJECT_OTHER_PATH)); break; case 5: projectFlag = new Image(resUtil.getLockedInProjectName(), new ThemeResource(OpenCmsTheme.PROJECT_PUBLISH_PATH)); break; default: } if (projectFlag != null) { projectFlag.setDescription(resUtil.getLockedInProjectName()); } resourceItem.getItemProperty(PROPERTY_PROJECT).setValue(projectFlag); } if (resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT) != null) { resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT) .setValue(Boolean.valueOf(resUtil.isInsideProject())); } if (resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED) != null) { resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED) .setValue(Boolean.valueOf(resUtil.isReleasedAndNotExpired())); } if (resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME) != null) { resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME).setValue(resource.getName()); } if (resourceItem.getItemProperty(PROPERTY_SITE_PATH) != null) { resourceItem.getItemProperty(PROPERTY_SITE_PATH).setValue(cms.getSitePath(resource)); } if ((resourceItem.getItemProperty(PROPERTY_TITLE) != null) && (resourceProps != null)) { resourceItem.getItemProperty(PROPERTY_TITLE) .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_TITLE) ? resourceProps.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue() : ""); } boolean inNavigation = false; if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT) != null) && (resourceProps != null)) { resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT) .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT) ? resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVTEXT).getValue() : ""); inNavigation = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT); } if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION) != null) && (resourceProps != null)) { try { Float navPos = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVPOS) ? Float.valueOf(resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVPOS).getValue()) : (inNavigation ? Float.valueOf(Float.MAX_VALUE) : null); resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION).setValue(navPos); inNavigation = navPos != null; } catch (Exception e) { LOG.debug("Error evaluating navPos property", e); } } if (resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION) != null) { if (inNavigation && (resourceProps != null) && resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVINFO) && CmsClientSitemapEntry.HIDDEN_NAVIGATION_ENTRY .equals(resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVINFO).getValue())) { inNavigation = false; } resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION).setValue(Boolean.valueOf(inNavigation)); } if ((resourceItem.getItemProperty(PROPERTY_COPYRIGHT) != null) && (resourceProps != null)) { resourceItem.getItemProperty(PROPERTY_COPYRIGHT) .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_COPYRIGHT) ? resourceProps.get(CmsPropertyDefinition.PROPERTY_COPYRIGHT).getValue() : ""); } if ((resourceItem.getItemProperty(PROPERTY_CACHE) != null) && (resourceProps != null)) { resourceItem.getItemProperty(PROPERTY_CACHE) .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_CACHE) ? resourceProps.get(CmsPropertyDefinition.PROPERTY_CACHE).getValue() : ""); } if (resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE) != null) { resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE) .setValue(CmsWorkplaceMessages.getResourceTypeName(locale, type.getTypeName())); } if (resourceItem.getItemProperty(PROPERTY_IS_FOLDER) != null) { resourceItem.getItemProperty(PROPERTY_IS_FOLDER).setValue(Boolean.valueOf(resource.isFolder())); } if (resourceItem.getItemProperty(PROPERTY_SIZE) != null) { if (resource.isFile()) { resourceItem.getItemProperty(PROPERTY_SIZE).setValue(Integer.valueOf(resource.getLength())); } } if (resourceItem.getItemProperty(PROPERTY_PERMISSIONS) != null) { resourceItem.getItemProperty(PROPERTY_PERMISSIONS).setValue(resUtil.getPermissionString()); } if (resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED) != null) { resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED) .setValue(Long.valueOf(resource.getDateLastModified())); } if (resourceItem.getItemProperty(PROPERTY_USER_MODIFIED) != null) { resourceItem.getItemProperty(PROPERTY_USER_MODIFIED).setValue(resUtil.getUserLastModified()); } if (resourceItem.getItemProperty(PROPERTY_DATE_CREATED) != null) { resourceItem.getItemProperty(PROPERTY_DATE_CREATED).setValue(Long.valueOf(resource.getDateCreated())); } if (resourceItem.getItemProperty(PROPERTY_USER_CREATED) != null) { resourceItem.getItemProperty(PROPERTY_USER_CREATED).setValue(resUtil.getUserCreated()); } if (resourceItem.getItemProperty(PROPERTY_DATE_RELEASED) != null) { long release = resource.getDateReleased(); if (release != CmsResource.DATE_RELEASED_DEFAULT) { resourceItem.getItemProperty(PROPERTY_DATE_RELEASED).setValue(Long.valueOf(release)); } } if (resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED) != null) { long expire = resource.getDateExpired(); if (expire != CmsResource.DATE_EXPIRED_DEFAULT) { resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED).setValue(Long.valueOf(expire)); } } if (resourceItem.getItemProperty(PROPERTY_STATE_NAME) != null) { resourceItem.getItemProperty(PROPERTY_STATE_NAME).setValue(resUtil.getStateName()); } if (resourceItem.getItemProperty(PROPERTY_STATE) != null) { resourceItem.getItemProperty(PROPERTY_STATE).setValue(resource.getState()); } if (resourceItem.getItemProperty(PROPERTY_USER_LOCKED) != null) { resourceItem.getItemProperty(PROPERTY_USER_LOCKED).setValue(resUtil.getLockedByName()); } }
From source file:org.vaadin.alump.offlinebuilder.demo.DemoUI.java
License:Open Source License
@Override protected void init(VaadinRequest vaadinRequest) { OfflineUIExtension offlineExtension = OfflineUIExtension.get(this); // As Panel is half legacy component, using OfflineCssLayout to make content scrollable OfflineCssLayout panel = new OfflineCssLayout(); panel.addStyleName("scrollable-wrapper"); panel.setSizeFull();//from ww w .jav a 2s . c o m setContent(panel); offlineExtension.setOfflineRoot(panel); VerticalLayout layout = new OfflineVerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.addStyleName("main-layout"); panel.addComponent(layout); Label header = new OfflineLabel("OfflineBuilder"); header.addStyleName("header-label"); layout.addComponent(header); Label info = new OfflineLabel("OfflineBuilder allows to define offline UI without need of writing GWT" + " code. Add-on offers offline extended versions of basic Vaadin UI components and layouts. This way" + " your server defined UI can be used on offline mode too."); info.addStyleName("info-label"); layout.addComponent(info); info = new OfflineLabel( "To test offline functionality. Turn on flight mode on your device or just disconnect" + " from your network connection. Offline UI should look identical with online UI."); info.addStyleName("info-label"); layout.addComponent(info); Image image = new OfflineImage(); image.setWidth("300px"); image.addStyleName("extra-stylename-image"); image.setSource(new ThemeResource("img/offline.png")); image.setDescription("Example image"); layout.addComponent(image); HorizontalLayout buttonLayout = new OfflineHorizontalLayout(); buttonLayout.setSpacing(true); layout.addComponent(buttonLayout); OfflineButton pingButton = new OfflineButton("Ping server"); pingButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Notification.show("Server says pong!"); } }); pingButton.setDescription("Button that will be automatically disabled on offline mode"); buttonLayout.addComponent(pingButton); OfflineButton writeButton = new OfflineButton("Store value (TODO)"); writeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Notification.show("No need to store, in online mode."); } }); buttonLayout.addComponent(writeButton); /* OfflineFormLayout formTest = new OfflineFormLayout(); OfflineCheckBox checkbox = new OfflineCheckBox("Flag me"); checkbox.setOfflineValueKey("flag"); formTest.addComponent(checkbox); layout.addComponent(formTest); */ Link link = new OfflineLink("Open project's GitHub page", new ExternalResource("https://github.com/alump/OfflineBuilder")); link.addStyleName("github-link"); layout.addComponent(link); }
From source file:uk.co.intec.keyDatesApp.components.HeaderComponent.java
License:Apache License
/** * Constructor, passing the Vaadin application page * * @param ui//w ww .java 2s. com * MainUI application page */ public HeaderComponent(MainUI ui) { setHeight("50px"); setStyleName("header"); final HorizontalLayout bannerArea = new HorizontalLayout(); bannerArea.setStyleName("menuArea"); bannerArea.setSizeFull(); final ThemeResource resource = new ThemeResource("img/intec-logo.gif.png"); final Image bannerImg = new Image(); bannerImg.setAlternateText("Intec"); bannerImg.setHeight("50px"); bannerImg.setDescription("Intec Logo"); bannerImg.setSource(resource); bannerImg.setWidth(null); bannerImg.setStyleName("bannerImg"); setMenubar(new MenuBar()); getMenubar().setStyleName(ValoTheme.MENU_SUBTITLE); getMenubar().addStyleName("valo-menu-subtitle-indent"); getMenubar().setWidth(100, Unit.PERCENTAGE); if (!"Anonymous".equals(getUserName())) { final MenuItem logout = menubar.addItem("Logout", null); logout.setStyleName("menuRight"); } final MenuItem userItem = menubar.addItem(getUserName(), null); userItem.setStyleName("menuRight"); bannerArea.addComponents(bannerImg, menubar); bannerArea.setExpandRatio(menubar, 1); addComponent(bannerArea); setExpandRatio(bannerArea, 1); setSizeFull(); }