List of usage examples for com.vaadin.server ExternalResource ExternalResource
public ExternalResource(String sourceURL)
From source file:info.magnolia.ui.contentapp.browser.BrowserSubApp.java
License:Open Source License
/** * Add an additional menu item on the actionPopup. */// w w w. j ava 2s. c om private ContextMenu.ContextMenuItem addActionPopupItem(BrowserSubAppDescriptor subAppDescriptor, ActionPopup actionPopup, ActionbarItemDefinition itemDefinition) { String actionName = itemDefinition.getName(); ActionDefinition action = subAppDescriptor.getActions().get(actionName); String label = action.getLabel(); String iconFontCode = ActionPopup.ICON_FONT_CODE + action.getIcon(); ExternalResource iconFontResource = new ExternalResource(iconFontCode); ContextMenu.ContextMenuItem menuItem = actionPopup.addItem(label, iconFontResource); // Set data variable so that the event handler can determine which action to launch. menuItem.setData(actionName); return menuItem; }
From source file:info.magnolia.ui.form.field.component.AbstractBaseItemContentPreviewComponent.java
License:Open Source License
@Override public Component refreshContentPreview(Item item) { Image thumbnail = new Image(); String path = imageProvider.getPortraitPath(((JcrItemAdapter) item).getItemId()); if (StringUtils.isNotBlank(path)) { thumbnail = new Image("", new ExternalResource(path)); thumbnail.addStyleName("file-preview-area"); }//w w w . ja v a 2 s . c o m return thumbnail; }
From source file:info.magnolia.ui.form.field.ThumbnailField.java
License:Open Source License
/** * Set the Label And Image./*from w ww . ja va2 s.c o m*/ */ public void setLabelAndImage(String nodePath) { try { if (StringUtils.isEmpty(nodePath)) { return; } Node parentNode = MgnlContext.getJCRSession(workspace).getNode(nodePath); String uuid = parentNode.getIdentifier(); if (!currentIdentifier.equals(uuid)) { // Set Text info label.setValue(createFieldDetail(parentNode)); // Set Thumbnail String path = imageThumbnailProvider.getPortraitPath(new JcrNodeAdapter(parentNode)); if (layout.getComponentIndex(embedded) != -1) { layout.removeComponent(embedded); } embedded = path != null ? new Image("", new ExternalResource(path)) : new Image(null); layout.addComponent(embedded); } } catch (RepositoryException e) { log.warn("Not able to refresh the Thumbnail Field view for the following Node path: {}", nodePath, e); } }
From source file:info.magnolia.ui.framework.app.embedded.EmbeddedPageViewImpl.java
License:Open Source License
@Override public void setUrl(String url) { final BrowserFrame page = new BrowserFrame(null, new ExternalResource(url)); page.setSizeFull();/*from w w w. j a v a 2 s .co m*/ layout.removeAllComponents(); layout.addComponent(page); }
From source file:io.fns.calculator.Application.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { setContent(new CssLayout(new Label("Hello! I'm the root UI!"), new Link("Go to other UI", new ExternalResource("anotherUI")))); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * actualiza los settings (la parte que muestra la sesin del usuario) * * *///w w w . jav a2 s.com private void refreshSettings() { VaadinSession s = VaadinSession.getCurrent(); settings.removeItems(); if (s.getAttribute("usuario") == null) { System.out.println("***** NO AUTENTICADO."); if (getApp().isAuthenticationNeeded()) { MenuItem settingsItem = settings.addItem("Login", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { openLoginDialog(true); } }); } } else { System.out.println("***** AUTENTICADO. USUARIO=" + s.getAttribute("usuario")); MenuItem settingsItem = settings.addItem("", foto = (getApp().getUserData().getPhoto() != null) ? new ExternalResource(getApp().getUserData().getPhoto()) : sinfoto, null); settingsItem.addItem("Edit Profile", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { editProfile(); } }); settingsItem.addItem("Change password", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { changePassword(); } }); settingsItem.addItem("Change photo", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { uploadFoto(); } }); settingsItem.addSeparator(); settingsItem.addItem("Sign Out", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { VaadinSession.getCurrent().setAttribute("usuario", null); getApp().setUserData(null); getViewDisplay().removeAllComponents(); refreshSettings(); if (MateuUI.getApp().isFavouritesAvailable()) linkFavoritos.setVisible(false); if (MateuUI.getApp().isLastEditedAvailable()) linkUltimosRegistros.setVisible(false); if (MateuUI.getApp().isFavouritesAvailable()) linkNuevoFavorito.setVisible(false); refreshMenu(null, null); addView(MyUI.this, getApp().getPublicHome()); if (!"".equals(navigator.getState())) navigator.navigateTo(""); } }); } }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre el dilogo para cambiar la foto/*from w ww.jav a2 s . c o m*/ * * */ private void uploadFoto() { // Create a sub-window and set the content Window subWindow = new Window("My photo"); subWindow.setWidth("475px"); FormLayout f = new FormLayout(); f.setMargin(true); Label e = new Label(); Image image = new Image(); class MyUploader implements Upload.Receiver, Upload.SucceededListener { File file; public File getFile() { return file; } public OutputStream receiveUpload(String fileName, String mimeType) { // Create and return a file output stream System.out.println("receiveUpload(" + fileName + "," + mimeType + ")"); FileOutputStream os = null; if (fileName != null && !"".equals(fileName)) { long id = fileId++; String extension = ".tmp"; if (fileName == null || "".equals(fileName.trim())) fileName = "" + id + extension; if (fileName.lastIndexOf(".") < fileName.length() - 1) { extension = fileName.substring(fileName.lastIndexOf(".")); fileName = fileName.substring(0, fileName.lastIndexOf(".")); } File temp = null; try { temp = File.createTempFile(fileName, extension); os = new FileOutputStream(file = temp); } catch (IOException e) { e.printStackTrace(); } } return os; } public void uploadSucceeded(Upload.SucceededEvent event) { // Show the uploaded file in the image viewer image.setSource(new FileResource(file)); System.out.println("uploadSucceeded(" + file.getAbsolutePath() + ")"); } public FileLocator getFileLocator() throws IOException { String extension = ".tmp"; String fileName = file.getName(); if (file.getName() == null || "".equals(file.getName().trim())) fileName = "" + getId(); if (fileName.lastIndexOf(".") < fileName.length() - 1) { extension = fileName.substring(fileName.lastIndexOf(".")); fileName = fileName.substring(0, fileName.lastIndexOf(".")).replaceAll(" ", "_"); } java.io.File temp = (System.getProperty("tmpdir") == null) ? java.io.File.createTempFile(fileName, extension) : new java.io.File(new java.io.File(System.getProperty("tmpdir")), fileName + extension); System.out.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir")); System.out.println("Temp file : " + temp.getAbsolutePath()); if (System.getProperty("tmpdir") == null || !temp.exists()) { System.out.println("writing temp file to " + temp.getAbsolutePath()); Files.copy(file, temp); } else { System.out.println("temp file already exists"); } String baseUrl = System.getProperty("tmpurl"); URL url = null; try { if (baseUrl == null) { url = file.toURI().toURL(); } else url = new URL(baseUrl + "/" + file.getName()); } catch (MalformedURLException e) { e.printStackTrace(); } return new FileLocator(0, file.getName(), url.toString(), file.getAbsolutePath()); } } ; MyUploader receiver = new MyUploader(); Upload upload = new Upload(null, receiver); //upload.setImmediateMode(false); upload.addSucceededListener(receiver); f.addComponent(image); f.addComponent(upload); f.addComponent(e); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok = new Button("Change it!", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Changing photo..."); try { FileLocator loc = receiver.getFileLocator(); io.mateu.ui.core.client.app.MateuUI.getBaseService() .updateFoto(getApp().getUserData().getLogin(), loc, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("OK!"); getApp().getUserData().setPhoto(loc.getUrl()); foto = (getApp().getUserData().getPhoto() != null) ? new ExternalResource(getApp().getUserData().getPhoto()) : new ClassResource("profile-pic-300px.jpg"); subWindow.close(); refreshSettings(); } }); } catch (IOException e1) { e1.printStackTrace(); io.mateu.ui.core.client.app.MateuUI.alert("" + e1.getClass().getName() + ":" + e1.getMessage()); } } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); upload.focus(); }
From source file:management.limbr.ui.VaadinUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { final VerticalLayout root = new VerticalLayout(); root.setSizeFull();//from w w w .jav a 2 s .c o m root.setMargin(true); root.setSpacing(true); setContent(root); Image logo = new Image(null, new ExternalResource("images/logo1.png")); logo.setHeight(1.2f, Unit.EM); logo.setWidthUndefined(); CssLayout navBar = new CssLayout(); navBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); navBar.addComponent(logo); navBar.addComponent(createNavButton("Users", UsersViewImpl.VIEW_NAME)); root.addComponent(navBar); final Panel viewContainer = new Panel(); viewContainer.setSizeFull(); root.addComponent(viewContainer); root.setExpandRatio(viewContainer, 1.0f); Navigator navigator = new Navigator(this, viewContainer); navigator.addProvider(viewProvider); }
From source file:me.uni.emuseo.view.common.helpers.ImagePreviewWindow.java
License:Open Source License
public ImagePreviewWindow(String url) { setSizeUndefined();/* www . ja v a 2 s .c o m*/ setWidth(400, Unit.PIXELS); setHeight(360, Unit.PIXELS); windowLayout = new VerticalLayout(); if (url != null) { Image image = new Image(); image.setSource(new ExternalResource(url)); image.setSizeFull(); windowLayout.addComponent(image); } // buildButtons(); // windowLayout.addComponent(buttonLayout); setContent(windowLayout); setModal(true); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.about.AboutProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vl = new VerticalLayout(); vl.addComponent(new Image("", LOGO)); TextField version = new TextField(TRANSLATOR.translate("general.version")); version.setValue(((ValidationManagerUI) UI.getCurrent()).getVersion()); version.setReadOnly(true);/*from w ww. j a v a 2 s. c om*/ vl.addComponent(version); TextField build = new TextField(TRANSLATOR.translate("general.build")); build.setValue(((ValidationManagerUI) UI.getCurrent()).getBuild()); build.setReadOnly(true); vl.addComponent(build); TextArea desc = new TextArea(); desc.setValue("Validation Manager is a tool to handle all the " + "cumbersome paperwork of regulated environment validations. " + "Including Validation Plans, protocols, " + "executions and exceptions. Keeping everything in one " + "place and best of all paperless. "); desc.setReadOnly(true); desc.setWidth(100, Unit.PERCENTAGE); Link link = new Link("Get more information here", new ExternalResource("https://github.com/javydreamercsw/validation-manager")); vl.addComponent(desc); vl.addComponent(link); vl.setId(getComponentCaption()); return vl; }