public FileExample() { setCaption("Interactive SVG"); addComponent(new MLabel( "A simple example from an svg file using Embedded component. Unlike with Image component, the SVGs JS etc are active. The example also demonstrates how to provide a trivial server side integration API for the SVG.")); Embedded svg = new Embedded(); svg.setWidth("400px"); svg.setHeight("400px"); svg.setSource(new ClassResource("/pull.svg")); // Expose a JS hook that pull.svg file calls when clicked JavaScript.getCurrent().addFunction("callMyVaadinFunction", (JsonArray arguments) -> { Notification.show("Message from SVG:" + arguments.getString(0)); }); addComponent(svg); }
public AccountSelectionPopup(String title) { super(title); // builds up UI setWidth(600, UNITS_PIXELS); setHeight(400, UNITS_PIXELS); this.i18nManager = ExplorerApp.get().getI18nManager(); // TODO: components are eager loaded. For performance they should be lazy loaded (eg through factory) // Imap initImapComponent(); String imap = i18nManager.getMessage(Messages.PROFILE_ACCOUNT_IMAP); addSelectionItem(new Embedded(null, Images.IMAP), imap, imapForm, imapClickListener); // Alfresco initAlfrescoComponent(); addSelectionItem(new Embedded(null, Images.ALFRESCO), i18nManager.getMessage(Messages.PROFILE_ACCOUNT_ALFRESCO), alfrescoForm, alfrescoClickListener); selectionTable.select(imap); }
protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) { if(renderPicture) { Picture picture = identityService.getUserPicture(userName); if(picture != null) { Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()), userName + picture.getMimeType(), ExplorerApp.get()); Embedded image = new Embedded(null, imageResource); image.addStyleName(ExplorerLayout.STYLE_CLICKABLE); image.setType(Embedded.TYPE_IMAGE); image.setHeight(30, Embedded.UNITS_PIXELS); image.setWidth(30, Embedded.UNITS_PIXELS); image.addListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7341560240277898495L; public void click(com.vaadin.event.MouseEvents.ClickEvent event) { viewManager.showProfilePopup(userName); } }); addComponent(image); setComponentAlignment(image, Alignment.MIDDLE_LEFT); } else { // TODO: what when no image is available? } } }
public Component getDetailComponent(Attachment attachment) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.addComponent(new Label(attachment.getDescription())); HorizontalLayout linkLayout = new HorizontalLayout(); linkLayout.setSpacing(true); verticalLayout.addComponent(linkLayout); // Icon linkLayout.addComponent(new Embedded(null, Images.RELATED_CONTENT_URL)); // Link Link link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl())); link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK); linkLayout.addComponent(link); return verticalLayout; }
protected void addProcessImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) { Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_NO_LINE); panelLayout.addComponent(header); StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder() .buildStreamResource(processInstance, repositoryService, runtimeService); Embedded embedded = new Embedded(null, diagram); embedded.setType(Embedded.TYPE_IMAGE); panelLayout.addComponent(embedded); } }
@Override protected Table createList() { final Table tableList = new Table(); // Listener to change right panel when clicked on a task tableList.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 8811553575319455854L; public void valueChange(ValueChangeEvent event) { // The itemId of the table list is the tableName String tableName = (String) event.getProperty().getValue(); setDetailComponent(new DatabaseDetailPanel(tableName)); // Update URL ExplorerApp.get().setCurrentUriFragment( new UriFragment(DatabaseNavigator.TABLE_URI_PART, tableName)); } }); // Create column headers tableList.addContainerProperty("icon", Embedded.class, null); tableList.setColumnWidth("icon", 22); tableList.addContainerProperty("tableName", String.class, null); tableList.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); return tableList; }
protected void addTableName() { HorizontalLayout header = new HorizontalLayout(); header.setWidth(100, UNITS_PERCENTAGE); header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); header.setSpacing(true); // TODO: use right image Embedded image = new Embedded(null, Images.DATABASE_50); header.addComponent(image); header.setComponentAlignment(image, Alignment.MIDDLE_LEFT); header.setMargin(false, false, true, false); Label name = new Label(tableName); name.addStyleName(Reindeer.LABEL_H2); header.addComponent(name); header.setExpandRatio(name, 1.0f); header.setComponentAlignment(name, Alignment.MIDDLE_LEFT); addDetailComponent(header); Label spacer = new Label(); spacer.setWidth(100, UNITS_PERCENTAGE); spacer.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addDetailComponent(spacer); }
public GroupItem(final Group group) { Button idButton = new Button(group.getId()); idButton.addStyleName(Reindeer.BUTTON_LINK); idButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showGroupPage(group.getId()); } }); addItemProperty("id", new ObjectProperty<Button>(idButton, Button.class)); if (group.getName() != null) { addItemProperty("name", new ObjectProperty<String>(group.getName(), String.class)); } if (group.getType() != null) { addItemProperty("type", new ObjectProperty<String>(group.getType(), String.class)); } Embedded deleteIcon = new Embedded(null, Images.DELETE); deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE); deleteIcon.addListener(new DeleteMembershipListener(identityService, userId, group.getId(), userDetailPanel)); addItemProperty("actions", new ObjectProperty<Embedded>(deleteIcon, Embedded.class)); }
protected void initPageTitle() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, UNITS_PERCENTAGE); layout.setSpacing(true); layout.setMargin(false, false, true, false); layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); addDetailComponent(layout); Embedded userImage = new Embedded(null, Images.USER_50); layout.addComponent(userImage); Label userName = new Label(user.getFirstName() + " " + user.getLastName()); userName.setSizeUndefined(); userName.addStyleName(Reindeer.LABEL_H2); layout.addComponent(userName); layout.setComponentAlignment(userName, Alignment.MIDDLE_LEFT); layout.setExpandRatio(userName, 1.0f); }
protected void initPageTitle() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, UNITS_PERCENTAGE); layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); layout.setSpacing(true); layout.setMargin(false, false, true, false); addDetailComponent(layout); Embedded groupImage = new Embedded(null, Images.GROUP_50); layout.addComponent(groupImage); Label groupName = new Label(getGroupName(group)); groupName.setSizeUndefined(); groupName.addStyleName(Reindeer.LABEL_H2); layout.addComponent(groupName); layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT); layout.setExpandRatio(groupName, 1.0f); }
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) { for (final HistoricTaskInstance subTask : subTasks) { // icon Embedded icon = new Embedded(null, Images.TASK_22); icon.setWidth(22, UNITS_PIXELS); icon.setWidth(22, UNITS_PIXELS); subTaskGrid.addComponent(icon); // Link to subtask Button subTaskLink = new Button(subTask.getName()); subTaskLink.addStyleName(Reindeer.BUTTON_LINK); subTaskLink.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showTaskPage(subTask.getId()); } }); subTaskGrid.addComponent(subTaskLink); subTaskGrid.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT); } }
protected Table initRelatedContentTable() { Table table = new Table(); table.setWidth(100, UNITS_PERCENTAGE); table.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_LIST); // Invisible by default, only shown when attachments are present table.setVisible(false); table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); table.addContainerProperty("type", Embedded.class, null); table.setColumnWidth("type", 16); table.addContainerProperty("name", Component.class, null); relatedContentLayout.addComponent(table); return table; }
protected void addAttachmentsToTable(List<Attachment> attachments) { for (Attachment attachment : attachments) { AttachmentRenderer renderer = attachmentRendererManager.getRenderer(attachment); Item attachmentItem = table.addItem(attachment.getId()); attachmentItem.getItemProperty("name").setValue(renderer.getOverviewComponent(attachment, this)); attachmentItem.getItemProperty("type").setValue(new Embedded(null, renderer.getImage(attachment))); Embedded deleteButton = new Embedded(null, Images.DELETE); deleteButton.addStyleName(ExplorerLayout.STYLE_CLICKABLE); deleteButton.addListener((ClickListener) new DeleteClickedListener(attachment)); attachmentItem.getItemProperty("delete").setValue(deleteButton); } if(table.getItemIds().size() > 0) { table.setVisible(true); } table.setPageLength(table.size()); }
public LebAnzeigen(FossaApplication app, SchuelerLaso schueler, KlasseLaso klasse) throws DocumentException, IOException { super(app); setCaption(" - Lernentwicklungsbericht anzeigen - "); VerticalLayout layout = new VerticalLayout(); setWidth("800px"); setContent(layout); layout.setSpacing(true); Embedded embeddedPdf = new Embedded(); embeddedPdf.setType(Embedded.TYPE_BROWSER); DateFormat dateFormat = new SimpleDateFormat("ddMMyy-HHmmss"); String dateiname = "Klasse" + klasse.getKlassenname() + "_" + schueler.getVorname() + "_" + schueler.getName() + "_" + dateFormat.format(new Date()) + ".pdf"; embeddedPdf.setSource(new LebCreator(app, schueler, klasse, dateiname).getLebResource()); embeddedPdf.setWidth(100, Sizeable.UNITS_PERCENTAGE); embeddedPdf.setHeight("580px"); windowCloseButton.setWidth(100, Sizeable.UNITS_PERCENTAGE); layout.addComponent(embeddedPdf); layout.addComponent(windowCloseButton); }
@Override public void buildMainLayout() { Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH)); logo.setType(Embedded.TYPE_IMAGE); logo.setWidth("100px"); logo.setHeight("96px"); headlineApp.addComponent(logo,"logo"); headlineApp.addComponent(authorizerLayout,"authorizerLayout"); headlineApp.addStyleName("headlineApp"); layout.addComponent(headlineApp,"headlineApp"); getMainWindow().setContent(layout); getMainWindow().addComponent(getAnimator()); if(getLoginLehrer().getIsAdmin()){ layout.addComponent(getAdminDashboard(), "admin"); } else { layout.addComponent(main, "main"); buildAppLayout(); } }
public static Component getLoginButton(final String openIdIdentifier, String icon, final String returnViewName) { //final Button googleOpenIdButton = new Button(""); final Site site = ((AbstractSiteUI) UI.getCurrent()).getSite(); //googleOpenIdButton.setIcon(site.getIcon(icon)); //googleOpenIdButton.setWidth(16, Sizeable.Unit.PIXELS); final Embedded embedded = new Embedded(null, site.getIcon(icon)); embedded.setStyleName("image-button"); embedded.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { try { final Company company = site.getSiteContext().getObject(Company.class); final String authenticationUrl = OpenIdUtil.prepareAuthenticationUrl(openIdIdentifier, company.getUrl(), returnViewName); UI.getCurrent().getPage().setLocation(authenticationUrl); } catch (final Exception e) { LOGGER.error("Error in open ID discovery.", e); Notification.show("Error in open ID discovery.", Notification.Type.ERROR_MESSAGE); } } }); return embedded; }
@Override public void attach() { super.attach(); int width = (int)getApplication().getMainWindow().getWidth(); int height = (int)getApplication().getMainWindow().getHeight(); /*Sets the browser and window sizes based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth("" + windowWidth + "px"); setHeight("" + windowHeight + "px"); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Changes the size of the browsers to fit within the sub-window*/ alarmsBrowser.setType(Embedded.TYPE_BROWSER); alarmsBrowser.setWidth("" + browserWidth + "px"); alarmsBrowser.setHeight("" + browserHeight + "px"); eventsBrowser.setType(Embedded.TYPE_BROWSER); eventsBrowser.setWidth("" + browserWidth + "px"); eventsBrowser.setHeight("" + browserHeight + "px"); }
/** * The NodeInfoWindow method constructs a sub-window instance which can be added to a main window. * The sub-window contains an embedded browser which displays the Node Info page of the currently selected * node. * @param node Selected node * @param width Width of the main window * @param height Height of the main window * @throws MalformedURLException */ public NodeInfoWindow(final Node node, final URL nodeURL) throws MalformedURLException{ nodeInfoBrowser = new Embedded("", new ExternalResource(nodeURL)); String label = node == null? "" : node.getLabel(); /*Sets up window settings*/ if (label == null || label.equals("") || label.equalsIgnoreCase(noLabel)) { label = ""; } else label = " - " + label; setCaption("Node Info" + label); setImmediate(true); setResizable(false); /*Adds the browser to the main layout*/ VerticalLayout layout = new VerticalLayout(); layout.addComponent(nodeInfoBrowser); addComponent(layout); }
@Override public void attach() { super.attach(); int width = (int)getApplication().getMainWindow().getWidth(); int height = (int)getApplication().getMainWindow().getHeight(); /*Sets the browser and window sizes based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth("" + windowWidth + "px"); setHeight("" + windowHeight + "px"); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Sets the size of the browser to fit within the sub-window*/ nodeInfoBrowser.setType(Embedded.TYPE_BROWSER); nodeInfoBrowser.setWidth("" + browserWidth + "px"); nodeInfoBrowser.setHeight("" + browserHeight + "px"); }
/** * The ResourceGraphsWindow method constructs a sub-window instance which can be added to a * main window. The sub-window contains an embedded browser which displays the Resource Graphs * page of the currently selected node * @param node Selected node * @param width Width of the main window * @param height Height of the main window * @throws MalformedURLException */ public ResourceGraphsWindow(final Node node, final URL nodeURL) throws MalformedURLException{ rgBrowser = new Embedded("", new ExternalResource(nodeURL)); String label = node == null? "" : node.getLabel(); /*Sets up window settings*/ if (label == null || label.equals("") || label.equalsIgnoreCase(noLabel)) { label = ""; } else { label = " - " + label; } setCaption("Resource Graphs" + label); setImmediate(true); setResizable(false); /*Adds the browser component to the main layout*/ VerticalLayout layout = new VerticalLayout(); layout.addComponent(rgBrowser); addComponent(layout); }
@Override public void attach() { super.attach(); int width = (int)getApplication().getMainWindow().getWidth(); int height = (int)getApplication().getMainWindow().getHeight(); /*Sets the browser and window size based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth("" + windowWidth + "px"); setHeight("" + windowHeight + "px"); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Changes the size of the browser to fit within the sub-window*/ rgBrowser.setType(Embedded.TYPE_BROWSER); rgBrowser.setWidth("" + browserWidth + "px"); rgBrowser.setHeight("" + browserHeight + "px"); }
private void buildMainLayout() { // common part: create layout pnYoutube = new Panel(); pnYoutube.setWidth("100%"); pnYoutube.setHeight("100%"); thkYoutube = new Embedded(null, new ExternalResource("http://www.youtube.com/watch?v=mkKsWguqJRU")); thkYoutube.setAlternateText("Thingtrack Quickstart video"); thkYoutube.setMimeType("application/x-shockwave-flash"); thkYoutube.setParameter("allowFullScreen", "true"); thkYoutube.setSizeFull(); //thkYoutube.setWidth("320px"); //thkYoutube.setHeight("265px"); pnYoutube.addComponent(thkYoutube); // top-level component properties addComponent(pnYoutube); }
@Override public void attach() { super.attach(); if(rootCategory.getIcon() != null) { StreamResource streamResource = new StreamResource(new StreamResource.StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { return new ByteArrayInputStream(rootCategory.getIcon()); } }, rootCategory.getName() + ".png", getApplication()); iconLayout.addComponent(new Embedded(null, streamResource)); } else { iconLayout.addComponent(new Embedded("", new ThemeResource("category.png"))); } }
public void checkIFSomeoneIsDeploying(VerticalLayout resultLayout, QRCode qrCode, Embedded loadingImg) { resultLayout.removeAllComponents(); buttonLinkToApp.setVisible(false); linkToApp.setVisible(false); qrCode.setVisible(false); if(deployingProjectsInUris.get(getApiLocation()).get(appName) != null) { deployButton.setEnabled(false); loadingImg.setVisible(true); loadingImg.setCaption(deployingProjectsInUris.get(getApiLocation()).get(appName).getName() + " is deploying"); } else { deployButton.setEnabled(true); loadingImg.setVisible(false); } }
private void addSliderWithIcons(ComponentContainer optionLayout) { final Component emb = new Embedded(null, getNextIcon()); emb.setWidth("32px"); final Embedded emb2 = new Embedded(null, getNextIcon()); emb2.setWidth("32px"); final Slider slider = new Slider(0, 100); slider.setWidth(100, UNITS_PERCENTAGE); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(emb); hl.addComponent(slider); hl.addComponent(emb2); hl.setWidth(100, UNITS_PERCENTAGE); hl.setExpandRatio(slider, 1); hl.setComponentAlignment(slider, Alignment.MIDDLE_CENTER); optionLayout.addComponent(hl); }
public AnimationExample() { setCaption("Animation"); addComponent(new MLabel( "A simple example from an svg file. Also demonstrates SVG animations.").withFullWidth()); Embedded svg = new Embedded(); svg.setWidth("800px"); svg.setHeight("400px"); svg.setSource(new ClassResource("/svg2009.svg")); addComponent(svg); }
/** * Konstruktor für einen Button mit einzeiligem Label * * @author Tobias Lindner * * @param iconPfad * String: Pfad zum Icon Image * @param text * String: Text für den Button * @param lcl * LayoutClickListener: Listener, der Aktionen bei Klick auf den ButtonMiddle ausführt. */ public ButtonMiddle (String iconPfad, String text, LayoutClickListener lcl) { this.lcl = lcl; setHeight(95, UNITS_PIXELS); setWidth(100, UNITS_PERCENTAGE); setStyleName("buttonMiddle"); gap1 = new Label (); gap1.setWidth(15, UNITS_PIXELS); icon = new Embedded(null, new ThemeResource(iconPfad)); icon.setWidth(40, UNITS_PIXELS); icon.setStyleName("buttonIconMiddle"); gap2 = new Label(); gap2.setWidth(10, UNITS_PIXELS); label = new Label (text); label.setStyleName("buttonLabelMiddle"); label.setWidth(Sizeable.SIZE_UNDEFINED, 0); label.setHeight(Sizeable.SIZE_UNDEFINED, 0); vl = new VerticalLayout(); vl.addComponent(label); vl.setSizeUndefined(); gap3 = new Label(); gap3.setSizeFull(); addComponent(gap1); addComponent(icon); addComponent(gap2); addComponent(vl); addComponent(gap3); setExpandRatio(gap3, 1.0f); setComponentAlignment(icon, Alignment.MIDDLE_CENTER); setComponentAlignment(vl, Alignment.MIDDLE_CENTER); addListener(lcl); }
/** * @param icon The 16x16 icon that will be displayed on the left in the selection table. * @param name The name that will be shown in the selection table * @param component The component that is selected when the item in the selection table is clicked. * @param clickListener The listener that will be attached to the OK button displayed beneath * the component. */ public void addSelectionItem(Embedded icon, String name, Component component, ClickListener clickListener) { Item item = selectionTable.addItem(name); item.getItemProperty("type").setValue(icon); item.getItemProperty("name").setValue(name); components.put(name, component); listeners.put(name, clickListener); }
protected void addDeploymentName() { GridLayout taskDetails = new GridLayout(3, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true); taskDetails.setMargin(false, false, true, false); // Add image Embedded image = new Embedded(null, Images.DEPLOYMENT_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add deployment name Label nameLabel = new Label(); if(deployment.getName() != null) { nameLabel.setValue(deployment.getName()); } else { nameLabel.setValue(i18nManager.getMessage(Messages.DEPLOYMENT_NO_NAME)); } nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 2, 0); // Add deploy time PrettyTimeLabel deployTimeLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.DEPLOYMENT_DEPLOY_TIME), deployment.getDeploymentTime(), null, true); deployTimeLabel.addStyleName(ExplorerLayout.STYLE_DEPLOYMENT_HEADER_DEPLOY_TIME); taskDetails.addComponent(deployTimeLabel, 1, 1); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); addDetailComponent(taskDetails); }