List of usage examples for com.vaadin.ui Embedded setHeight
@Override public void setHeight(String height)
From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java
License:Open Source License
private void showHTML(final String htmlContent, final Application app) throws IllegalArgumentException, NullPointerException { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = -2307854110750435145L; {// ww w . j ava2 s . com center(); setWidth("75%"); setHeight("600px"); StreamResource.StreamSource source = new StreamResource.StreamSource() { private static final long serialVersionUID = -3745013501121916404L; public InputStream getStream() { return new ByteArrayInputStream(htmlContent.getBytes()); } }; StreamResource resource = new StreamResource(source, "TestReport.html", app); Embedded e = new Embedded(); e.setMimeType("text/html"); e.setType(Embedded.TYPE_BROWSER); e.setWidth("100%"); e.setHeight("590px"); e.setSource(resource); addComponent(e); } }); }
From source file:org.activiti.explorer.ui.management.processinstance.ProcessInstanceDetailPanel.java
License:Apache License
protected void addProcessImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null) { boolean didDrawImage = false; if (ExplorerApp.get().isUseJavascriptDiagram()) { try { final InputStream definitionStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition.getResourceName()); XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory(); XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (!bpmnModel.getFlowLocationMap().isEmpty()) { int maxX = 0; int maxY = 0; for (String key : bpmnModel.getLocationMap().keySet()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key); double elementX = graphicInfo.getX() + graphicInfo.getWidth(); if (maxX < elementX) { maxX = (int) elementX; }/*w ww . j a v a 2s .c o m*/ double elementY = graphicInfo.getY() + graphicInfo.getHeight(); if (maxY < elementY) { maxY = (int) elementY; } } Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); URL explorerURL = ExplorerApp.get().getURL(); URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId() + "&processInstanceId=" + processInstance.getId()); Embedded browserPanel = new Embedded("", new ExternalResource(url)); browserPanel.setType(Embedded.TYPE_BROWSER); browserPanel.setWidth(maxX + 350 + "px"); browserPanel.setHeight(maxY + 220 + "px"); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(browserPanel); panelLayout.addComponent(imagePanel); didDrawImage = true; } } catch (Exception e) { LOGGER.error("Error loading process diagram component", e); } } if (!didDrawImage && processDefinitionEntity.isGraphicalNotationDefined()) { ProcessEngineConfiguration processEngineConfiguration = ProcessEngines.getDefaultProcessEngine() .getProcessEngineConfiguration(); ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator(); StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource( processInstance, repositoryService, runtimeService, diagramGenerator, processEngineConfiguration); if (diagram != null) { 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); Embedded embedded = new Embedded(null, diagram); embedded.setType(Embedded.TYPE_IMAGE); embedded.setSizeUndefined(); Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.setScrollable(true); imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(embedded); panelLayout.addComponent(imagePanel); } } } }
From source file:org.activiti.explorer.ui.process.ProcessDefinitionInfoComponent.java
License:Apache License
protected void initImage() { processImageContainer = new VerticalLayout(); Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM)); processTitle.addStyleName(ExplorerLayout.STYLE_H3); processImageContainer.addComponent(processTitle); boolean didDrawImage = false; if (ExplorerApp.get().isUseJavascriptDiagram()) { try {/*from w w w. j a v a 2 s . c om*/ final InputStream definitionStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition.getResourceName()); XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory(); XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (!bpmnModel.getFlowLocationMap().isEmpty()) { int maxX = 0; int maxY = 0; for (String key : bpmnModel.getLocationMap().keySet()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key); double elementX = graphicInfo.getX() + graphicInfo.getWidth(); if (maxX < elementX) { maxX = (int) elementX; } double elementY = graphicInfo.getY() + graphicInfo.getHeight(); if (maxY < elementY) { maxY = (int) elementY; } } Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); URL explorerURL = ExplorerApp.get().getURL(); URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId()); Embedded browserPanel = new Embedded("", new ExternalResource(url)); browserPanel.setType(Embedded.TYPE_BROWSER); browserPanel.setWidth(maxX + 350 + "px"); browserPanel.setHeight(maxY + 220 + "px"); HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeUndefined(); imagePanel.setContent(panelLayout); imagePanel.addComponent(browserPanel); processImageContainer.addComponent(imagePanel); didDrawImage = true; } } catch (Exception e) { LOGGER.error("Error loading process diagram component", e); } } if (didDrawImage == false) { StreamResource diagram = null; // Try generating process-image stream if (processDefinition.getDiagramResourceName() != null) { diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processDefinition, repositoryService); } if (diagram != null) { Embedded embedded = new Embedded(null, diagram); embedded.setType(Embedded.TYPE_IMAGE); embedded.setSizeUndefined(); Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeUndefined(); imagePanel.setContent(panelLayout); imagePanel.addComponent(embedded); processImageContainer.addComponent(imagePanel); didDrawImage = true; } } if (didDrawImage == false) { Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM)); processImageContainer.addComponent(noImageAvailable); } addComponent(processImageContainer); }
From source file:org.activiti.explorer.ui.task.TaskEventsPanel.java
License:Apache License
protected void addTaskEventPicture(final org.activiti.engine.task.Event taskEvent, GridLayout eventGrid) { final Picture userPicture = identityService.getUserPicture(taskEvent.getUserId()); Embedded authorPicture = null; if (userPicture != null) { StreamResource imageresource = new StreamResource(new StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { return userPicture.getInputStream(); }/*from w w w. j a v a 2 s .c om*/ }, "event_" + taskEvent.getUserId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get()); authorPicture = new Embedded(null, imageresource); } else { authorPicture = new Embedded(null, Images.USER_50); } authorPicture.setType(Embedded.TYPE_IMAGE); authorPicture.setHeight("48px"); authorPicture.setWidth("48px"); authorPicture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); eventGrid.addComponent(authorPicture); }
From source file:org.activiti.explorer.ui.task.UserDetailsComponent.java
License:Apache License
protected void addUserPicture() { Resource pictureResource = Images.USER_32; // default icon if (user != null) { final Picture userPicture = identityService.getUserPicture(user.getId()); if (userPicture != null) { pictureResource = new StreamResource(new StreamSource() { public InputStream getStream() { return userPicture.getInputStream(); }/* w ww. j av a 2s. co m*/ }, user.getId(), ExplorerApp.get()); } } Embedded picture = new Embedded(null, pictureResource); picture.setType(Embedded.TYPE_IMAGE); picture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); if (user != null) { // Only set fixed height and width when user has image, otherwise icon's dimensions will be used picture.setHeight("32px"); picture.setWidth("32px"); } addComponent(picture); // Add profile popup listener if (user != null) { picture.addStyleName(ExplorerLayout.STYLE_CLICKABLE); picture.addListener(new com.vaadin.event.MouseEvents.ClickListener() { public void click(ClickEvent event) { viewManager.showProfilePopup(user.getId()); } }); } }
From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
/** * Factory method to create an embeddable icon. * //from ww w . j av a 2 s . com * @param name * the name of the icon to use (is also used as tooltip text); * @param res * the resource denoting the actual icon. * @return an embeddable icon, never <code>null</code>. */ protected Embedded createIcon(String name, Resource res) { Embedded embedded = new Embedded(name, res); embedded.setType(Embedded.TYPE_IMAGE); embedded.setDescription(name); embedded.setHeight(ICON_HEIGHT + "px"); embedded.setWidth(ICON_WIDTH + "px"); return embedded; }
From source file:org.diretto.web.richwebclient.view.sections.UploadSection.java
/** * Uploads the currently processed file. * //from w w w. ja v a 2 s . co m * @param uploadSettings The {@code UploadSettings} of the file * @param filesWithSameSettings A {@code List} with the names of the files * which should get the given {@code UploadSettings} as presetting */ public void upload(final UploadSettings uploadSettings, List<String> filesWithSameSettings) { final FileInfo fileInfo = currentFile; settings.put(fileInfo.getName(), uploadSettings); for (String fileName : filesWithSameSettings) { preSettings.put(fileName, uploadSettings); } new Thread(new Runnable() { @Override public void run() { ProgressIndicator progressIndicator = multipleUpload.upload(fileInfo); synchronized (application) { VerticalLayout uploadBoxLayout = new VerticalLayout(); mainLayout.addComponent(uploadBoxLayout); HorizontalLayout fileInfoLayout = new HorizontalLayout(); uploadBoxLayout.addComponent(fileInfoLayout); Label nameLabel = StyleUtils.getLabelBold(fileInfo.getName()); fileInfoLayout.addComponent(nameLabel); fileInfoLayout.addComponent(StyleUtils.getLabelSmallHTML(" ")); fileInfoLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); BigDecimal fileSize = new BigDecimal((((double) fileInfo.getSize()) / 1000000.0d)); fileSize = fileSize.setScale(2, BigDecimal.ROUND_HALF_UP); Label typeSizeLabel = StyleUtils.getLabelSmallHTML( fileInfo.getType() + " -- " + fileSize.toPlainString() + " MB"); fileInfoLayout.addComponent(typeSizeLabel); fileInfoLayout.setComponentAlignment(typeSizeLabel, Alignment.MIDDLE_LEFT); uploadBoxLayout.addComponent(StyleUtils.getVerticalSpace("100%", "8px")); uploadBoxLayout.addComponent(progressIndicator); uploadBoxLayout.addComponent(StyleUtils.getVerticalSpace("100%", "8px")); HorizontalLayout resultLayout = new HorizontalLayout(); uploadBoxLayout.addComponent(resultLayout); Label uploadedLabel = StyleUtils.getLabelSmallHTML("Uploaded: "); resultLayout.addComponent(uploadedLabel); resultLayout.setComponentAlignment(uploadedLabel, Alignment.MIDDLE_LEFT); Embedded uploadedEmbedded = new Embedded(null, ResourceUtils.RUNO_ICON_32_GLOBE_RESOURCE); uploadedEmbedded.addStyleName("image-opacity-65"); uploadedEmbedded.setType(Embedded.TYPE_IMAGE); uploadedEmbedded.setImmediate(true); uploadedEmbedded.setWidth("22px"); uploadedEmbedded.setHeight("22px"); resultLayout.addComponent(uploadedEmbedded); uploadedEmbeddeds.put(fileInfo, uploadedEmbedded); resultLayout.addComponent(StyleUtils.getLabelSmallHTML(" ")); Label publishedLabel = StyleUtils.getLabelSmallHTML("Published: "); resultLayout.addComponent(publishedLabel); resultLayout.setComponentAlignment(publishedLabel, Alignment.MIDDLE_LEFT); Embedded publishedEmbedded = new Embedded(null, ResourceUtils.RUNO_ICON_32_GLOBE_RESOURCE); publishedEmbedded.addStyleName("image-opacity-65"); publishedEmbedded.setType(Embedded.TYPE_IMAGE); publishedEmbedded.setImmediate(true); publishedEmbedded.setWidth("22px"); publishedEmbedded.setHeight("22px"); resultLayout.addComponent(publishedEmbedded); publishedEmbeddeds.put(fileInfo, publishedEmbedded); mainLayout.addComponent(StyleUtils.getVerticalSpace("100%", "5px")); requestRepaint(); } } }).start(); handleNextFile(); }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
private void paintReviewGrid() { if (reviewGrid == null) { reviewGrid = new GridLayout(2, currentPageLength); reviewGrid.setSizeFull();// w w w .j a v a2 s . c o m reviewGrid.setSpacing(true); layout.addComponent(reviewGrid); } else { reviewGrid.removeAllComponents(); } int rows = reviewGrid.getRows(); if (rows != currentPageLength) { reviewGrid.setRows(Math.min(size, currentPageLength)); } int row = 0; List<ReviewEntry> latestReviews = getLatestReviews(currentPage, currentPageLength); for (ReviewEntry review : latestReviews) { ProjectRating rating = review.getRating(); Embedded e = new Embedded(null, getIcon(rating)); e.setDescription(getDescription(rating)); e.setWidth("22px"); //$NON-NLS-1$ e.setHeight("22px"); //$NON-NLS-1$ reviewGrid.addComponent(e, 0, row); StringBuilder sb = new StringBuilder(); sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$ sb.append(HtmlUtils.clean(review.getComment())); sb.append("<br>"); //$NON-NLS-1$ sb.append("<span style=\"font-size:x-small\">").append(" posted by "); //$NON-NLS-1$ sb.append(StringEscapeUtils.escapeHtml(review.getVoter())); sb.append(" "); //$NON-NLS-1$ long deltaMillis = System.currentTimeMillis() - review.getTimestamp(); long deltaDays = deltaMillis / MILLIS_PER_DAY; if (deltaDays > 0) { sb.append(deltaDays); sb.append(" days ago"); } else { long deltaHours = deltaMillis / MILLIS_PER_HOUR; if (deltaHours > 0) { sb.append(deltaHours).append(" hours ago"); } else { long deltaMinutes = deltaMillis / MILLIS_PER_MINUTE; if (deltaMinutes > 0) { sb.append(deltaMinutes).append(" minutes ago"); } else { sb.append(" just now"); } } sb.append("</span></span>"); //$NON-NLS-1$ } CssLayout css = new CssLayout(); css.setSizeFull(); Label comment = new Label(sb.toString(), Label.CONTENT_XHTML); comment.setSizeUndefined(); css.addComponent(comment); reviewGrid.addComponent(css, 1, row); reviewGrid.setColumnExpandRatio(1, 1.0f); ++row; } }
From source file:org.escidoc.browser.ui.mainpage.HeaderContainer.java
License:Open Source License
private void addNormalLayout() { headerContainer = new HorizontalLayout(); headerContainer.setStyleName(Reindeer.LAYOUT_WHITE); headerContainer.setWidth("100%"); headerContainer.setHeight("55px"); headerContainer.addStyleName("header"); HorizontalLayout hlLogo = new HorizontalLayout(); Resource res = new ThemeResource("images/escidoc-logo-klein.jpg"); Embedded e = new Embedded(null, res); e.setHeight(50 + "px"); hlLogo.addComponent(e);/*www. ja v a2s . c om*/ headerContainer.addComponent(hlLogo); headerContainer.setExpandRatio(hlLogo, 0.2f); hl = new HorizontalLayout(); headerContainer.addComponent(hl); headerContainer.setExpandRatio(hl, 0.8f); this.addComponent(headerContainer); headerContainer.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT); }
From source file:org.fossa.rolp.demo.DemoWelcomeScreen.java
License:Open Source License
public DemoWelcomeScreen(RolpApplication app, FossaAuthorizer authorizer) { super(app);/*w ww . j a v a2 s .c o m*/ this.app = app; setStyleName("demo"); setWidth("900px"); center(); this.authorizer = authorizer; CustomLayout layout = new CustomLayout("./demo/welcomeScreen"); CustomLayout layoutTop = new CustomLayout("./demo/welcomeScreenTop"); CustomLayout layoutMiddle = new CustomLayout("./demo/welcomeScreenMiddle"); CustomLayout layoutBottom = new CustomLayout("./demo/welcomeScreenBottom"); Embedded logoRolp = new Embedded(null, new ThemeResource(DEMO_LOGO_ROLP_PATH)); logoRolp.setType(Embedded.TYPE_IMAGE); logoRolp.setWidth("100px"); logoRolp.setHeight("96px"); Label rolpDemoText = new Label( "<h2>Wilkommen</h2>Dies ist eine Demoversion der Software ROLP. Whlen Sie eine Rolle aus, um in das entsprechende Szenario zu gelangen. Der Schulleiter hat eine eigene Verwaltungsoberflche, wo er die Lehrer und Klassen berblicken und zuweisen kann. Als Klassenlehrer und Fachlehrer gelangt man auf den Startbildschirm. Von da aus gelangt man zum Klassenlehrer-Dashboard und dem Fachlehrer-Dashboard. Der Klassenlehrer hat Zugang zu beiden Dashboards, da er im Normalfall auch Fcher unterrichtet.", Label.CONTENT_XHTML); Label githubLinkDummy = new Label( "ROLP auf <a href=\"https://github.com/fossaag/rolp\" target=\"_blank\">GitHub.com</a>", Label.CONTENT_XHTML); Embedded logoFossa = new Embedded(null, new ThemeResource(DEMO_LOGO_FOSSA_PATH)); logoFossa.setType(Embedded.TYPE_IMAGE); logoFossa.setWidth("150px"); Label roleSelectCaption = new Label("Bitte whlen Sie eine Rolle aus:", Label.CONTENT_XHTML); BeanItemContainer<String> roles = new BeanItemContainer<String>(String.class); roles.addBean("Fachlehrer"); roles.addBean("Klassenlehrer"); roles.addBean("Schulleiter"); roleSelect.setContainerDataSource(roles); roleSelect.setWidth("200px"); layoutTop.addComponent(logoRolp, "logoRolp"); layoutTop.addComponent(rolpDemoText, "rolpDemoText"); layoutTop.addComponent(logoFossa, "logoFossa"); layout.addComponent(layoutTop, "layoutTop"); layoutMiddle.addComponent(roleSelectCaption, "roleSelectCaption"); layoutMiddle.addComponent(roleSelect, "roleSelect"); layoutMiddle.addComponent(okButton, "okButton"); layout.addComponent(layoutMiddle, "layoutMiddle"); layoutBottom.addComponent(githubLinkDummy, "githubLinkDummy"); layout.addComponent(layoutBottom, "layoutBottom"); setContent(layout); }