private Component createChameleonTab() {
   Embedded embedded = new Embedded();
   embedded.setSource(new ExternalResource("/splitbutton/chameleon?restartApplication"));
   embedded.setType(Embedded.TYPE_BROWSER);
   embedded.setSizeFull();
   return embedded;
 }
  public void onViewDocument(FileEntry fileEntry) {
    this.fileEntry = fileEntry;
    try {
      String fileEntryId = Long.toString(DocViewerPresenter.this.fileEntry.getFileEntryId());
      String version = fileEntry.getVersion();

      MainMVPApplication mvpApp = (MainMVPApplication) super.getApplication();
      IRemoteDocumentRepository docLibRepository =
          mvpApp.getDaoProvider().provideByDAOClass(IRemoteDocumentRepository.class);

      String docUrl = docLibRepository.getFileAsURL(fileEntryId, version);
      ExternalResource eress = new ExternalResource(docUrl, fileEntry.getMimeType());

      Embedded pdf = new Embedded(null, eress);

      // pdf.setType(Embedded.TYPE_BROWSER);
      pdf.setType(Embedded.TYPE_BROWSER);
      String mt = fileEntry.getMimeType();
      pdf.setMimeType(mt);
      pdf.setSizeFull();
      pdf.setHeight("800px");
      getView().getMainLayout().addComponent(pdf);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {

    }
  }
Пример #3
0
  Layout getHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setMargin(false);
    header.setSpacing(true);

    ThemeResource themeResource = new ThemeResource("icons/processbase.png");
    Embedded logo = new Embedded();
    logo.setSource(themeResource);
    logo.setType(Embedded.TYPE_IMAGE);

    header.addComponent(logo);
    header.setExpandRatio(logo, 1.0f);
    Label helloUser;
    if (StringUtils.isEmpty(user.firstName) && StringUtils.isEmpty(user.lastName))
      helloUser = new Label(getPbMessages("welcome") + ", " + user.username);
    else
      helloUser = new Label(getPbMessages("welcome") + ", " + user.firstName + " " + user.lastName);
    //        helloUser.setStyleName(Runo.LABEL_H2);
    header.addComponent(helloUser);
    header.setComponentAlignment(helloUser, Alignment.MIDDLE_RIGHT);
    header.setExpandRatio(helloUser, 1.0f);

    if (!BPMModule.USER_GUEST.equals(user.username)) {
      Button profile =
          new Button(
              getPbMessages("btnProfile"),
              new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                  openProfileWindow();
                }
              });
      profile.setStyleName(Runo.BUTTON_LINK);
      header.addComponent(profile);
      header.setComponentAlignment(profile, Alignment.MIDDLE_RIGHT);
    }
    Button logout =
        new Button(
            getPbMessages("btnLogout"),
            new Button.ClickListener() {

              public void buttonClick(ClickEvent event) {
                openLogoutWindow();
              }
            });
    logout.setStyleName(Runo.BUTTON_LINK);
    header.addComponent(logout);
    header.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);

    return header;
  }
  protected void addDeleteWarning() {
    List<ProcessDefinition> processDefinitions =
        repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();

    int nrOfProcessInstances = 0;
    for (ProcessDefinition processDefinition : processDefinitions) {
      nrOfProcessInstances +=
          runtimeService
              .createProcessInstanceQuery()
              .processDefinitionId(processDefinition.getId())
              .count();
    }

    if (nrOfProcessInstances == 0) {
      Label noInstancesLabel = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_NO_INSTANCES));
      noInstancesLabel.addStyleName(Reindeer.LABEL_SMALL);
      addComponent(noInstancesLabel);
    } else {
      HorizontalLayout warningLayout = new HorizontalLayout();
      warningLayout.setSpacing(true);
      addComponent(warningLayout);

      Embedded warningIcon = new Embedded(null, Images.WARNING);
      warningIcon.setType(Embedded.TYPE_IMAGE);
      warningLayout.addComponent(warningIcon);

      Label warningLabel =
          new Label(
              i18nManager.getMessage(
                  Messages.DEPLOYMENT_DELETE_POPUP_WARNING, nrOfProcessInstances),
              Label.CONTENT_XHTML);
      warningLabel.setSizeUndefined();
      warningLabel.addStyleName(Reindeer.LABEL_SMALL);
      warningLayout.addComponent(warningLabel);
    }

    // Some empty space
    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    addComponent(emptySpace);
  }
  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 = XMLInputFactory.newInstance();
          XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
          BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

          if (bpmnModel.getFlowLocationMap().size() > 0) {

            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()
                        + "&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 == false && 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(100, UNITS_PERCENTAGE);

          HorizontalLayout panelLayoutT = new HorizontalLayout();
          panelLayoutT.setSizeUndefined();
          imagePanel.setContent(panelLayoutT);
          imagePanel.addComponent(embedded);

          panelLayout.addComponent(imagePanel);
        }
      }
    }
  }