List of usage examples for com.vaadin.ui Panel Panel
public Panel()
From source file:nz.co.senanque.vaadinsupport.viewmanager.LoginLayout.java
License:Apache License
public void afterPropertiesSet() throws Exception { setSizeFull();// ww w.j av a 2s . c o m Panel loginPanel = new Panel(); AbstractLayout panelLayout = (AbstractLayout) loginPanel.getContent(); panelLayout.setMargin(false); loginPanel.setWidth("460px"); final MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); final LoginForm loginForm = new LoginFormI18n(messageSourceAccessor.getMessage("username"), messageSourceAccessor.getMessage("password"), messageSourceAccessor.getMessage("login.button"), messageSourceAccessor.getMessage("welcome")); loginForm.setHeight("300px"); loginForm.addListener(new LoginListener() { private static final long serialVersionUID = 5201900702970450254L; public void onLogin(LoginEvent event) { if (getLoginListener() != null) { try { getLoginListener().onLogin(event); } catch (Exception e) { Throwable cause = e.getCause(); if (cause == null || !(cause instanceof LoginException)) { logger.error(e.getMessage(), e); } String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login"); getViewManager().getMainWindow().showNotification(message, Notification.TYPE_ERROR_MESSAGE); return; } } getViewManager().loadApplication(); } }); loginPanel.addComponent(loginForm); addComponent(loginPanel); setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
From source file:org.abstractform.vaadin.VaadinFormToolkit.java
License:Apache License
private AbstractComponentContainer buildSection(Section part, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { Panel panel = new Panel(); panel.setCaption(part.getName());/*from w w w . j ava 2 s. c o m*/ for (Component component : part.getChildList()) { ComponentContainer container = buildComponent(component, mapComponents, fieldIdList, extraObjects); panel.addComponent(container); } return panel; }
From source file:org.activiti.editor.ui.EditorProcessDefinitionInfoComponent.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); StreamSource streamSource = null; final byte[] editorSourceExtra = repositoryService.getModelEditorSourceExtra(modelData.getId()); if (editorSourceExtra != null) { streamSource = new StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { InputStream inStream = null; try { inStream = new ByteArrayInputStream(editorSourceExtra); } catch (Exception e) { LOGGER.warn("Error reading PNG in StreamSource", e); }// w w w .jav a2 s .c o m return inStream; } }; } if (streamSource != null) { Embedded embedded = new Embedded(null, new ImageStreamSource(streamSource, ExplorerApp.get())); 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(700, UNITS_PIXELS); HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeUndefined(); imagePanel.setContent(panelLayout); imagePanel.addComponent(embedded); processImageContainer.addComponent(imagePanel); } else { Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM)); processImageContainer.addComponent(noImageAvailable); } addComponent(processImageContainer); }
From source file:org.activiti.explorer.ui.content.email.EmailDetailPanel.java
License:Apache License
protected void addHtmlContent(String html) { Panel panel = new Panel(); panel.setWidth(800, UNITS_PIXELS);//from w ww. j a v a 2 s .c o m panel.setHeight(300, UNITS_PIXELS); content = new Label(html, Label.CONTENT_XHTML); content.setHeight(100, UNITS_PERCENTAGE); panel.addComponent(content); addComponent(panel); }
From source file:org.activiti.explorer.ui.custom.DetailPanel.java
License:Apache License
public DetailPanel() { setSizeFull();/* ww w . j av a2s .c o m*/ addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL); setMargin(true); CssLayout cssLayout = new CssLayout(); // Needed for rounded corners cssLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL); cssLayout.setSizeFull(); super.addComponent(cssLayout); mainPanel = new Panel(); mainPanel.addStyleName(Reindeer.PANEL_LIGHT); mainPanel.setSizeFull(); cssLayout.addComponent(mainPanel); // Use default layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth(100, UNITS_PERCENTAGE); verticalLayout.setMargin(true); mainPanel.setContent(verticalLayout); }
From source file:org.activiti.explorer.ui.custom.UploadComponent.java
License:Apache License
protected void addDropPanel() { Panel dropPanel = new Panel(); DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(dropPanel); dragAndDropWrapper.setDropHandler(this); dragAndDropWrapper.setWidth("80%"); addComponent(dragAndDropWrapper);// ww w . j a va 2 s. c om setComponentAlignment(dragAndDropWrapper, Alignment.MIDDLE_CENTER); Label dropLabel = new Label(i18nManager.getMessage(Messages.UPLOAD_DROP)); dropLabel.setSizeUndefined(); dropPanel.addComponent(dropLabel); ((VerticalLayout) dropPanel.getContent()).setComponentAlignment(dropLabel, Alignment.MIDDLE_CENTER); }
From source file:org.activiti.explorer.ui.management.job.JobDetailPanel.java
License:Apache License
protected void addJobState() { Label processDefinitionHeader = new Label(i18nManager.getMessage(Messages.JOB_HEADER_EXECUTION)); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_H3); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); processDefinitionHeader.setWidth(100, UNITS_PERCENTAGE); addComponent(processDefinitionHeader); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);//from ww w .j a v a 2 s .com layout.setSizeFull(); layout.setMargin(true, false, true, false); addDetailComponent(layout); setDetailExpandRatio(layout, 1.0f); // Exceptions if (job.getExceptionMessage() != null) { // Number of retries Label retrieslabel = new Label(getRetriesLabel(job)); layout.addComponent(retrieslabel); // Exception Label exceptionMessageLabel = new Label( i18nManager.getMessage(Messages.JOB_ERROR) + ": " + job.getExceptionMessage()); exceptionMessageLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_MESSAGE); layout.addComponent(exceptionMessageLabel); // Add Exception stacktrace String stack = managementService.getJobExceptionStacktrace(job.getId()); Label stackTraceLabel = new Label(stack); stackTraceLabel.setContentMode(Label.CONTENT_PREFORMATTED); stackTraceLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_TRACE); stackTraceLabel.setSizeFull(); Panel stackPanel = new Panel(); stackPanel.setWidth(100, UNITS_PERCENTAGE); stackPanel.setSizeFull(); stackPanel.setScrollable(true); stackPanel.addComponent(stackTraceLabel); layout.addComponent(stackPanel); layout.setExpandRatio(stackPanel, 1.0f); } else { if (job.getProcessDefinitionId() != null) { // This is a hack .. need to cleanify this in the engine JobEntity jobEntity = (JobEntity) job; if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) { addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_SUSPEND_PROCESSDEFINITION), false); } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) { addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_ACTIVATE_PROCESSDEFINITION), true); } else { addNotYetExecutedLabel(layout); } } else { addNotYetExecutedLabel(layout); } } }
From source file:org.activiti.explorer.ui.management.process.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 && processDefinitionEntity.isGraphicalNotationDefined()) { StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder() .buildStreamResource(processInstance, repositoryService, runtimeService); 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(400, UNITS_PIXELS); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(embedded); panelLayout.addComponent(imagePanel); }/*from w ww. j av a2 s .c om*/ } }
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; }/* www. j a v a2 s.c om*/ 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 {// ww w. ja v a 2 s .c o m 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); }