List of usage examples for com.vaadin.ui Image Image
public Image(String caption, Resource source)
From source file:com.mycollab.module.project.ui.ProjectAssetsUtil.java
License:Open Source License
public static Component buildProjectLogo(String projectShortname, Integer projectId, String projectAvatarId, int size) { AbstractComponent wrapper;/*from w w w.j a va2s. co m*/ if (!StringUtils.isBlank(projectAvatarId)) { wrapper = new Image(null, new ExternalResource(StorageFactory.getResourcePath(String.format("%s/%s_%d.png", PathUtils.getProjectLogoPath(MyCollabUI.getAccountId(), projectId), projectAvatarId, size)))); } else { ELabel projectIcon = new ELabel(projectShortname).withStyleName(UIConstants.TEXT_ELLIPSIS, ValoTheme.LABEL_LARGE, "center"); wrapper = new VerticalLayout(); ((VerticalLayout) wrapper).addComponent(projectIcon); ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER); } wrapper.setWidth(size, Sizeable.Unit.PIXELS); wrapper.setHeight(size, Sizeable.Unit.PIXELS); wrapper.addStyleName(UIConstants.CIRCLE_BOX); wrapper.setDescription(UserUIContext.getMessage(ProjectI18nEnum.OPT_CHANGE_LOGO_HELP, UserUIContext.getMessage(ProjectI18nEnum.EDIT))); return wrapper; }
From source file:com.mycollab.module.project.ui.ProjectAssetsUtil.java
License:Open Source License
public static Component buildClientLogo(SimpleAccount account, int size) { AbstractComponent wrapper;// ww w . j ava 2 s .c o m if (!StringUtils.isBlank(account.getAvatarid())) { wrapper = new Image(null, new ExternalResource( StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), account.getAvatarid(), 100))); } else { String accountName = account.getAccountname(); accountName = (accountName.length() > 3) ? accountName.substring(0, 3) : accountName; ELabel projectIcon = new ELabel(accountName).withStyleName(UIConstants.TEXT_ELLIPSIS, "center"); wrapper = new VerticalLayout(); ((VerticalLayout) wrapper).addComponent(projectIcon); ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER); } wrapper.setWidth(size, Sizeable.Unit.PIXELS); wrapper.setHeight(size, Sizeable.Unit.PIXELS); wrapper.addStyleName(UIConstants.CIRCLE_BOX); wrapper.setDescription(UserUIContext.getMessage(ClientI18nEnum.OPT_CHANGE_LOGO_HELP, UserUIContext.getMessage(ClientI18nEnum.EDIT))); return wrapper; }
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 www . j ava2s . 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.ui.UserAvatarControlFactory.java
License:Open Source License
public static Image createUserAvatarEmbeddedComponent(String avatarId, int size) { return new Image(null, createAvatarResource(avatarId, size)); }
From source file:com.ocs.dynamo.ui.component.BaseBanner.java
License:Apache License
/** * Constructor/*from ww w . jav a 2 s .c o m*/ * * @param imagePath * the path to the image */ public BaseBanner(String imagePath) { super(true, false, false); this.imagePath = imagePath; setId("banner"); setSizeFull(); image = new Image(null, new ThemeResource(imagePath)); image.setWidth(null); addComponent(image); setComponentAlignment(image, Alignment.MIDDLE_LEFT); }
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 w w w . j a v a 2s.co 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:com.squadd.technical.ImageGetter.java
public Image get(Contact contact) { try {/* w w w. j a v a 2 s.com*/ String path = "src\\main\\webapp\\VAADIN\\themes\\mytheme\\" + "pictures/userPic" + contact.getId() + ".png"; File file = new File(path); if (file.exists()) { Resource res = new ThemeResource("pictures/userPic" + contact.getId() + ".png"); return new Image(null, res); } else { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } } catch (Exception e) { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } }
From source file:com.squadd.technical.ImageGetter.java
public Image get(UserInfoBean user) { DBManager db = new DBManager(); Contact contact = db.getContactByUserId(user); try {//w ww .j av a2 s . c o m String path = "src\\main\\webapp\\VAADIN\\themes\\mytheme\\" + "pictures/userPic" + contact.getId() + ".png"; File file = new File(path); if (file.exists()) { Resource res = new ThemeResource("pictures/userPic" + contact.getId() + ".png"); return new Image(null, res); } else { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } } catch (Exception e) { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } }
From source file:com.squadd.technical.ImageGetter.java
public Image get(Group group) { try {//from w w w. j a v a2 s . c om String path = new DBManager().getPathGroupImage(group); File file = new File(path); if (file.exists()) { String newPath = path.substring(path.indexOf("pictures"), path.length()); Resource res = new ThemeResource(newPath); return new Image(null, res); } else { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } } catch (Exception e) { Resource res = new ThemeResource("user_icon.png"); return new Image(null, res); } }
From source file:de.datenhahn.vaadin.componentrenderer.demo.StaticCustomerDetailsGenerator.java
License:Apache License
@Override public Component getDetails(Grid.RowReference rowReference) { rowReference.getGrid().scrollTo(rowReference.getItemId()); StaticCustomer customer = (StaticCustomer) rowReference.getItemId(); HorizontalLayout layout = new HorizontalLayout(); layout.setHeight(300, Sizeable.Unit.PIXELS); layout.setMargin(true);// ww w . jav a 2s. c om layout.setSpacing(true); Image image = new Image("", customer.getPhoto()); image.setHeight(200, Sizeable.Unit.PIXELS); image.setWidth(200, Sizeable.Unit.PIXELS); layout.addComponent(image); Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>", ContentMode.HTML); layout.addComponent(nameLabel); layout.setExpandRatio(nameLabel, 1.0f); return layout; }