List of usage examples for com.vaadin.ui Image setSource
public void setSource(Resource source)
From source file:com.esofthead.mycollab.vaadin.ui.AddViewLayout2.java
License:Open Source License
public AddViewLayout2(final String title, final Resource icon) { setStyleName("addview-layout"); this.viewIcon = icon; this.header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withWidth("100%") .withStyleName(UIConstants.HEADER_VIEW); this.header.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (!(icon instanceof FontAwesome)) { Image iconEmbed = new Image(); iconEmbed.setSource(icon); this.header.with(iconEmbed); }/*from ww w .j a v a2 s . co m*/ this.titleLbl = new Label("", ContentMode.HTML); this.titleLbl.setStyleName(UIConstants.HEADER_TEXT); this.header.with(this.titleLbl).expand(titleLbl); if (title == null) { if (icon != null) { this.setTitle("Undefined"); } } else { this.setTitle(title); } this.addComponent(header); body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body"); this.addComponent(body); }
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()); }//from ww w .ja va2s . c o 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.web.ui.AddViewLayout2.java
License:Open Source License
public AddViewLayout2(String title, Resource icon) { this.setMargin(new MarginInfo(false, false, true, false)); setStyleName("addview-layout"); this.viewIcon = icon; header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth(); header.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (!(icon instanceof FontAwesome)) { Image iconEmbed = new Image(); iconEmbed.setSource(icon); header.with(iconEmbed);//from w w w . j a v a2 s.co m } titleLbl = ELabel.h2(""); header.with(titleLbl).expand(titleLbl); if (title == null) { if (icon != null) { this.setTitle("Undefined"); } } else { this.setTitle(title); } this.addComponent(header); body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body"); this.addComponent(body); }
From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java
License:Apache License
public void displayPDFFile() { BlobResource blobResource = getBlobResource(); if (blobResource != null) { String fileName = blobResource.getFilename(); if (fileName != null) { String mimeType = blobResource.getMIMEType(); StreamSource streamSource = new StreamSource() { private DownloadStream downloadStream = getBlobResource() != null ? getBlobResource().getStream() : null;// w w w .j ava2s . co m @Override public InputStream getStream() { return downloadStream != null ? downloadStream.getStream() : null; } }; String viewButtonCaption = "View " + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) + " File"; Button viewDocButton = new Button(viewButtonCaption); viewDocButton.setStyleName(Reindeer.BUTTON_LINK); if (streamSource != null) { StreamResource streamResource = new StreamResource(streamSource, fileName); streamResource.setMIMEType(mimeType); BrowserWindowOpener opener = new BrowserWindowOpener(streamResource); opener.extend(viewDocButton); settingsLayout.addComponent(viewDocButton); Resource resource = FVIconFactory.getInstance().getFVIcon(FVIconFactory.ICON_NOTE); Image image = new Image(); image.setSource(resource); addComponent(image); } } } }
From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java
License:Apache License
private Image displayImage(BlobResource blobResource) { Image image = new Image(); image.setSource(blobResource); FVImageField imageField = new FVImageField(null, getAttributes()); image = imageField.resizeImage(image, MAX_WIDTH, MAX_HEIGHT); setWidth(image.getWidth() + "px"); setHeight(image.getHeight() + "px"); return image; }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * @param audioFile/* w ww. j a va 2 s .co m*/ * @param cover * @return */ private Component createPlayImage(final AudioFile audioFile, ExternalResource cover) { AbsoluteLayout absoluteLayout = new AbsoluteLayout(); absoluteLayout.setWidth("120px"); absoluteLayout.setHeight("120px"); absoluteLayout.addComponent(createImageCover(cover)); final Image play = createImageCover( new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png")); play.setWidth("50px"); play.setHeight("50px"); play.addClickListener(new ClickListener() { private static final long serialVersionUID = -5184601350921707969L; @Override public void click(ClickEvent event) { MusicPlayerPanel musicPanel = MusicPlayerPanel.getInstance(getPlayerLayout()); watched.addObserver(musicPanel); MusicPlayerPanel.setAudio(audioFile); MusicPlayerPanel.runDefaultSetup(); if (isPlay.equals(false)) { watched.setValue(isPlay = true); play.setSource(new ExternalResource( "http://icons.iconarchive.com/icons/icons-land/play-stop-pause/256/Pause-Disabled-icon.png")); } else { watched.setValue(isPlay = false); play.setSource( new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png")); } } }); absoluteLayout.addComponent(play, "top: 30px; left: 30px;"); return absoluteLayout; }
From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildShortcutIconPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true)); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(UserUIContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); final Image favIconRes = new Image("", new ExternalResource( StorageFactory.getFavIconPath(billingAccount.getId(), billingAccount.getFaviconpath()))); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); final UploadField favIconUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override//from w w w . ja v a 2s .c o m protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { try { AccountFavIconService favIconService = AppContextUtil .getSpringBean(AccountFavIconService.class); BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData)); String newFavIconPath = favIconService.upload(UserUIContext.getUsername(), image, MyCollabUI.getAccountId()); favIconRes.setSource(new ExternalResource( StorageFactory.getFavIconPath(billingAccount.getId(), newFavIconPath))); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException(e); } } else { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; favIconUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE)); favIconUploadField.addStyleName("upload-field"); favIconUploadField.setSizeUndefined(); favIconUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); favIconUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> { BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class); billingAccount.setFaviconpath(null); billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); }).withStyleName(WebThemes.BUTTON_OPTION); resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); buttonControls.with(resetButton, favIconUploadField); rightPanel.with(favIconRes, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Favicon", layout); this.with(formContainer); }
From source file:com.mycollab.vaadin.web.ui.AddViewLayout2.java
License:Open Source License
public AddViewLayout2(String title, Resource icon) { this.setMargin(new MarginInfo(false, false, true, false)); setStyleName("addview-layout"); this.viewIcon = icon; header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth(); header.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (!(icon instanceof FontAwesome)) { Image iconEmbed = new Image(); iconEmbed.setSource(icon); header.with(iconEmbed);//from www .j a v a2 s . c o m } titleLbl = ELabel.h2(""); header.with(titleLbl).expand(titleLbl); if (title == null) { if (icon != null) { this.setTitle(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)); } } else { this.setTitle(title); } this.addComponent(header); body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body"); this.addComponent(body); }
From source file:com.mycompany.exodious.login.java
public login() { this.setId("loginPanel"); this.setSpacing(true); Image logo = new Image(); logo.setId("logo"); logo.setSource(slikaLogo); logo.setHeight("18em"); logo.setWidth("30em"); Label welcome = new Label("Welcome, please login"); welcome.setId("welcome"); TextField username = new TextField("Your ID"); PasswordField password = new PasswordField("Password"); Button submit = new Button("Login"); submit.setIcon(FontAwesome.SIGN_IN); submit.addStyleName(ValoTheme.BUTTON_PRIMARY); submit.addClickListener(new Button.ClickListener() { @Override//ww w . j a va 2s .c o m public void buttonClick(Button.ClickEvent event) { } }); addComponents(logo, welcome, username, password, submit); setComponentAlignment(logo, Alignment.MIDDLE_CENTER); setComponentAlignment(welcome, Alignment.MIDDLE_CENTER); setComponentAlignment(username, Alignment.MIDDLE_CENTER); setComponentAlignment(password, Alignment.MIDDLE_CENTER); setComponentAlignment(submit, Alignment.MIDDLE_CENTER); }
From source file:com.uib.onlinepeptideshaker.presenter.view.SmallSideBtn.java
public SmallSideBtn(String iconUrl) { Image icon = new Image(); icon.setSource(new ThemeResource(iconUrl)); icon.setSizeFull();//from www . ja v a2 s. c o m SmallSideBtn.this.addComponent(icon); SmallSideBtn.this.setSizeFull(); SmallSideBtn.this.setStyleName("smallmenubtn"); }