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
  public void onSuccessfulLogin2() {

    this.context = (WebApplicationContext) getContext();
    context
        .getHttpSession()
        .setAttribute("session", HibernateUtil.getSessionFactory().openSession());
    context.getHttpSession().setAttribute("userName", userCurrent.getName());
    controlUserPermissions = new ControlUserPermissions(userCurrent, context);

    String propName = this.getProperty("pathEntityOrder");
    String propPath =
        this.getContext().getBaseDirectory().getAbsolutePath() + File.separator + propName;
    HibernateUtil.getEntityOrder(propPath);

    /**
     * ******************************************** Cabecera
     * ******************************************************
     */
    HorizontalLayout headHorizontalLayout = new HorizontalLayout();
    headHorizontalLayout.setWidth("100%");
    headHorizontalLayout.setHeight("80");
    logoPNG = new Embedded(null, new ThemeResource("images/logo.png"));
    logoPNG.setWidth("140");
    logoPNG.setHeight("60");
    headHorizontalLayout.addComponent(logoPNG);
    headHorizontalLayout.setComponentAlignment(logoPNG, Alignment.MIDDLE_LEFT);
    headHorizontalLayout.setExpandRatio(logoPNG, 3);
    UserTab userTab = new UserTab(this);
    headHorizontalLayout.addComponent(userTab);
    headHorizontalLayout.setComponentAlignment(userTab, Alignment.MIDDLE_RIGHT);
    headHorizontalLayout.setExpandRatio(userTab, 1);
    /**
     * *********************************************************************
     * ***************************************
     */
    /**
     * ******************************************** Barra Menú
     * ****************************************************
     */
    toolbar = new YacareToolbar(this);
    /**
     * *********************************************************************
     * ***************************************
     */
    /**
     * ******************************************** Cuerpo de página
     * **********************************************
     */
    bodyPageVerticalLayout = new VerticalLayout();
    bodyPageVerticalLayout.addComponent(headHorizontalLayout);
    bodyPageVerticalLayout.addComponent(toolbar);
    YacareFooter footer = new YacareFooter();
    bodyPageVerticalLayout.addComponent(footer);
    bodyPageVerticalLayout.setComponentAlignment(footer, Alignment.BOTTOM_CENTER);
    /**
     * *********************************************************************
     * ***************************************
     */
    getMainWindow().setContent(bodyPageVerticalLayout);
  }
  public Component generateCell(Table source, Object itemId, Object columnId) {
    Embedded embedded = new Embedded(null, image);

    if (clickListener != null) {
      embedded.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
      embedded.setData(itemId);
      embedded.addListener(clickListener);
    }

    return embedded;
  }
예제 #5
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;
  }
 private void displayPreviewImage() {
   if (scaleImageData != null && scaleImageData.length > 0) {
     ByteArrayImageResource previewResource =
         new ByteArrayImageResource(scaleImageData, "image/png");
     previewImage.setSource(previewResource);
   }
 }
  public FileSearchResultComponent() {
    this.resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName(UIConstants.THEME_COMP_HEADER);

    final HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setWidth("100%");
    headerLayout.setSpacing(true);

    headerWrapper.addComponent(headerLayout);
    this.addComponent(headerWrapper);

    final Embedded headerIcon = new Embedded();
    headerIcon.setSource(MyCollabResource.newResource("icons/16/search.png"));
    headerLayout.addComponent(headerIcon);
    headerLayout.setComponentAlignment(headerIcon, Alignment.MIDDLE_LEFT);

    this.searchHeader = new Label();
    headerLayout.addComponent(this.searchHeader);
    headerLayout.setComponentAlignment(this.searchHeader, Alignment.MIDDLE_LEFT);
    headerLayout.setExpandRatio(this.searchHeader, 1.0f);

    final Button backButton =
        new Button(
            "Back to dashboard",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                backView();
              }
            });
    backButton.addStyleName(UIConstants.THEME_BLUE_LINK);
    headerLayout.addComponent(backButton);

    this.resourceTable = new ResourceTableDisplay();
    this.resourceTable.setWidth("100%");

    this.bodyLayout = new VerticalLayout();
    this.bodyLayout.addComponent(this.resourceTable);
    this.addComponent(this.bodyLayout);
    this.setMargin(true);
  }
  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);
  }
예제 #9
0
  @Override
  protected void init(VaadinRequest request) {
    setContent(main);
    Embedded appResourceTest =
        new Embedded("Test of ApplicationResources with full path", new FlagSeResource());
    main.addComponent(appResourceTest);
    Embedded specialNameResourceTest =
        new Embedded("Test ApplicationResources with special names", new SpecialNameResource());
    specialNameResourceTest.addStyleName("hugeBorder");
    main.addComponent(specialNameResourceTest);

    userInfo.setCaption("User info");
    userInfo.setContentMode(ContentMode.PREFORMATTED);
    main.addComponent(userInfo);

    tf.setEnabled(false);
    tf.setImmediate(true);
    main.addComponent(tf);

    portletEdit.setEnabled(false);
    main.addComponent(portletEdit);
    portletMax.setEnabled(false);
    main.addComponent(portletMax);

    Upload upload =
        new Upload(
            "Upload a file",
            new Receiver() {

              @Override
              public OutputStream receiveUpload(String filename, String mimeType) {
                return new ByteArrayOutputStream();
              }
            });
    main.addComponent(upload);

    possiblyChangedModeOrState();
    getSession().addPortletListener(new DemoPortletListener());
  }
  private VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader addFormSection(
      PhysicalAttributeConfirmActualsFieldSetComponent fieldSet) {
    GridLayout gridLayout = new GridLayout(3, 1);
    gridLayout.setWidth("70%");
    gridLayout.setSpacing(true);
    gridLayout.setStyleName("conx-entity-editor-form");
    gridLayout.setMargin(true, true, false, true);

    Embedded placeholder = new Embedded();
    placeholder.setHeight("22px");
    placeholder.setWidth("1px");

    GridLayout captionLayout = new GridLayout(1, 1);
    captionLayout.setWidth("100%");
    captionLayout.setSpacing(true);
    captionLayout.addComponent(placeholder, 0, 0, 0, 0);
    GridLayout expectedLayout = new GridLayout(2, 1);
    expectedLayout.setWidth("100%");
    expectedLayout.setSpacing(true);
    expectedLayout.addComponent(new VaadinConfirmActualsFormSectionHeader("Expected"), 0, 0, 1, 0);
    GridLayout actualLayout = new GridLayout(2, 1);
    actualLayout.setWidth("100%");
    actualLayout.setSpacing(true);
    actualLayout.addComponent(new VaadinConfirmActualsFormSectionHeader("Actual"), 0, 0, 1, 0);

    gridLayout.addComponent(captionLayout, 0, 0, 0, 0);
    gridLayout.addComponent(expectedLayout, 1, 0, 1, 0);
    gridLayout.addComponent(actualLayout, 2, 0, 2, 0);
    gridLayout.setColumnExpandRatio(0, 0.166f);
    gridLayout.setColumnExpandRatio(1, 0.417f);
    gridLayout.setColumnExpandRatio(2, 0.417f);

    VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader header =
        new VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader(fieldSet, gridLayout);
    innerLayout.addComponent(header);
    innerLayout.addComponent(header.getLayout());
    headers.put(fieldSet, header);
    return header;
  }
  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);
        }
      }
    }
  }
  private Component addFileUploadComponent(final int index) {
    HorizontalLayout outer = new HorizontalLayout();
    outer.setWidth("400px");
    outer.setHeight("165px");
    outer.addStyleName("v-upload");
    outer.setSpacing(true);

    VerticalLayout inner = new VerticalLayout();
    inner.setSpacing(true);
    inner.setWidth("200px");
    inner.addStyleName("v-preview-anon");

    final Embedded embedded = new Embedded();
    embedded.addStyleName("v-preview-anon");
    embedded.addStyleName("v-showhand");

    final TextField urlPaste = new TextField("Select Remote File");
    urlPaste.setWidth("100%");
    urlPaste.setInputPrompt("Paste URL here...");
    final UploadReceiver receiver = new UploadReceiver();
    final Upload uploadInstance = new Upload("Select Local File", receiver);
    uploadInstance.addStyleName("v-override");
    final Button uploadBtn = new Button("Upload");
    uploadInstance.setButtonCaption("Browse...");
    uploadInstance.addListener(
        new Upload.StartedListener() {
          @Override
          public void uploadStarted(Upload.StartedEvent event) {
            if (uploadInstance.getUploadSize() > MAX_FILE_SIZE) {
              uploadInstance.interruptUpload();
              DifferApplication.getCurrentApplication()
                  .getMainWindow()
                  .showNotification(
                      "File failed to upload",
                      "<br/>" + "File must not exceed 5MB for anonymous users",
                      Window.Notification.TYPE_WARNING_MESSAGE);
            }
            urlPaste.setEnabled(false);
            uploadBtn.setEnabled(false);
          }
        });
    uploadInstance.addListener(
        new Upload.FailedListener() {
          @Override
          public void uploadFailed(Upload.FailedEvent event) {
            urlPaste.setEnabled(true);
            uploadBtn.setEnabled(true);
          }
        });
    uploadInstance.addListener(
        new Upload.SucceededListener() {
          @Override
          public void uploadSucceeded(Upload.SucceededEvent event) {
            UploadFile ufile =
                new UploadFile(
                    UploadFile.TYPE.LOCAL_FILESYSTEM, receiver.getFile().getAbsolutePath());
            if (ufile.isValid()) {
              embedded.setVisible(true);
              try {
                embedded.setSource(
                    DifferApplication.getImageThumbnailProvider().getThumbnail(receiver.getFile()));
                DifferApplication.getTemporaryFilesCleaner().addFile(receiver.getFile());
              } catch (ImageDifferException ide) {
                DifferApplication.getCurrentApplication()
                    .getMainWindow()
                    .showNotification(
                        "Thumbnail can not be generated.",
                        "<br/>",
                        Window.Notification.TYPE_WARNING_MESSAGE);
              }
              compareButton.setEnabled(true);
              if (index == 0) {
                uploadA = receiver.getFile();
              } else {
                uploadB = receiver.getFile();
              }
              if (uploadA == null || uploadB == null) {
                compareButton.setCaption(BTN_TXT_PROCEED);
              } else {
                compareButton.setCaption(BTN_TXT_COMPARE);
              }
            } else {
              DifferApplication.getCurrentApplication()
                  .getMainWindow()
                  .showNotification(
                      "File failed to upload",
                      "<br/>" + ufile.getErrorMessage(),
                      Window.Notification.TYPE_WARNING_MESSAGE);
              urlPaste.setEnabled(true);
              uploadBtn.setEnabled(true);
            }
          }
        });
    uploadInstance.setImmediate(true);
    inner.addComponent(uploadInstance);

    final Label lbl = new Label("OR");
    lbl.addStyleName("v-labelspacer");
    inner.addComponent(lbl);

    urlPaste.addListener(
        new FieldEvents.TextChangeListener() {
          @Override
          public void textChange(FieldEvents.TextChangeEvent event) {
            if (event.getText().length() > 0) {
              uploadInstance.setEnabled(false);
            } else {
              uploadInstance.setEnabled(true);
            }
          }
        });
    urlPaste.setImmediate(true);
    urlPaste.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);

    inner.addComponent(urlPaste);

    uploadBtn.addListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent event) {
            UploadFile ufile =
                new UploadFile(UploadFile.TYPE.REMOTE_URL, (String) (urlPaste.getValue()));
            if (ufile.isValid()) {
              final File file = ufile.getFile();
              DifferApplication.getTemporaryFilesCleaner().addFile(file);
              embedded.setVisible(true);
              embedded.setSource(new FileResource(file, DifferApplication.getCurrentApplication()));
              embedded.addListener(
                  new MouseEvents.ClickListener() {
                    @Override
                    public void click(MouseEvents.ClickEvent event) {
                      Embedded fullview = new Embedded();
                      fullview.setSource(
                          new FileResource(file, DifferApplication.getCurrentApplication()));
                      DifferApplication.getMainApplicationWindow()
                          .addWindow(new FullSizeImageWindow(fullview));
                    }
                  });
              compareButton.setEnabled(true);
              if (index == 0) {
                uploadA = file;
              } else {
                uploadB = file;
              }
              if (uploadA == null || uploadB == null) {
                compareButton.setCaption(BTN_TXT_PROCEED);
              } else {
                compareButton.setCaption(BTN_TXT_COMPARE);
              }
            } else {
              DifferApplication.getCurrentApplication()
                  .getMainWindow()
                  .showNotification(
                      "File failed to upload",
                      "<br/>" + ufile.getErrorMessage(),
                      Window.Notification.TYPE_WARNING_MESSAGE);
              urlPaste.setValue("");
              uploadInstance.setEnabled(true);
            }
          }
        });
    inner.addComponent(uploadBtn);

    outer.addComponent(inner);
    outer.addComponent(embedded);

    return outer;
  }
예제 #13
0
  public void onSuccessfulLogin() {

    userCurrent = ((User) getUser());

    this.context = (WebApplicationContext) getContext();
    context
        .getHttpSession()
        .setAttribute("session", HibernateUtil.getSessionFactory().openSession());
    context.getHttpSession().setAttribute("userName", userCurrent.getName());
    context.getHttpSession().setAttribute("user", userCurrent);

    controlUserPermissions = new ControlUserPermissions(userCurrent, context);

    String propName = this.getProperty("pathEntityOrder");
    String propPath =
        this.getContext().getBaseDirectory().getAbsolutePath() + File.separator + propName;
    HibernateUtil.getEntityOrder(propPath);

    // cargar foto
    PhysicalPerson physicalPerson = userCurrent.getPhysicalPerson();
    String fileName = "";

    Embedded embedded = null;
    if (physicalPerson != null
        && physicalPerson.getDocumentObject() != null
        && physicalPerson.getDocumentObject().getName() != null) {
      fileName = physicalPerson.getDocumentObject().getName();

      if (checkFile(
          fileName,
          FactoryI18nManager.getI18nManager().getPathMessages("url.path.upload.photos")
              + File.separatorChar)) {
        FileResource resource =
            new FileResource(
                new File(
                    (FactoryI18nManager.getI18nManager().getPathMessages("url.path.upload.photos")
                        + File.separatorChar
                        + fileName)),
                this);
        embedded = new Embedded(null, resource);
      } else {
        embedded = new Embedded(null, new ThemeResource("images/apps/persona.gif"));
      }
    } else {
      embedded = new Embedded(null, new ThemeResource("images/apps/persona.gif"));
    }

    embedded.setWidth("63");
    embedded.setHeight("100%");

    logoHeaderPNG = new Embedded(null, new ThemeResource("images/apps/yacare.png"));
    logoHeaderPNG.setWidth("70");
    logoHeaderPNG.setHeight("50");

    descriptionPNG = new Embedded(null, new ThemeResource("images/apps/yacareDescription.png"));
    descriptionPNG.setWidth("420");
    descriptionPNG.setHeight("20");

    HorizontalLayout logosLayout = new HorizontalLayout();
    // logosLayout.setSpacing(true);
    logosLayout.addComponent(logoHeaderPNG);
    logosLayout.setComponentAlignment(logoHeaderPNG, Alignment.MIDDLE_CENTER);
    logosLayout.addComponent(descriptionPNG);
    logosLayout.setComponentAlignment(descriptionPNG, Alignment.MIDDLE_CENTER);
    logosLayout.setMargin(false, false, false, false);

    UserTabHeader userTab =
        new UserTabHeader(
            userCurrent.getPhysicalPerson().getLastName()
                + ", "
                + userCurrent.getPhysicalPerson().getName(),
            userCurrent.getName(),
            embedded,
            getURL().getPath());

    /**
     * ******************************************** Cabecera
     * ******************************************************
     */
    HorizontalLayout headHorizontalLayout = new HorizontalLayout();
    headHorizontalLayout.setWidth("100%");
    headHorizontalLayout.setHeight("50");
    headHorizontalLayout.addComponent(logosLayout);
    headHorizontalLayout.setComponentAlignment(logosLayout, Alignment.MIDDLE_LEFT);
    headHorizontalLayout.setExpandRatio(logosLayout, 3);
    headHorizontalLayout.addComponent(userTab);
    headHorizontalLayout.setComponentAlignment(userTab, Alignment.MIDDLE_RIGHT);
    headHorizontalLayout.setExpandRatio(userTab, 1);
    /**
     * ************************************************************************************************************
     */
    /**
     * ******************************************** Barra Menú
     * ****************************************************
     */
    toolbar = new YacareToolbar(this);
    /**
     * ************************************************************************************************************
     */
    /**
     * ******************************************** Footer
     * ****************************************************
     */
    YacareFooter footer = new YacareFooter();
    /**
     * ********************************************
     * ****************************************************
     */
    VerticalLayout vl = new VerticalLayout();
    vl.setWidth("100%");
    vl.setSpacing(false);
    vl.setMargin(false);
    vl.addComponent(headHorizontalLayout);
    vl.addComponent(toolbar);
    /**
     * ******************************************** Cuerpo de página
     * **********************************************
     */
    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(false);
    verticalLayout.setMargin(false);
    verticalLayout.setSizeFull();
    verticalLayout.addComponent(vl);
    verticalLayout.setComponentAlignment(vl, Alignment.TOP_CENTER);
    verticalLayout.addComponent(footer);
    verticalLayout.setComponentAlignment(footer, Alignment.BOTTOM_CENTER);
    /**
     * ************************************************************************************************************
     */
    getMainWindow().setContent(verticalLayout);
  }
예제 #14
0
  /** Updates the layout. */
  public void update() {
    removeAllComponents();
    if (current == null) return;
    DBManager.getCommunicator().refresh(current);
    List<Squad> squads = current.getSquads();
    List<Vehicle> vehicles = current.getVehicles();
    Application app = getApplication();

    for (final Squad squad : squads) {
      Panel panel = new Panel();
      addComponent(panel);
      HorizontalLayout horContent = new HorizontalLayout();
      horContent.setMargin(true);
      horContent.setSpacing(true);
      horContent.setWidth("100%");
      panel.setContent(horContent);

      Embedded emb = new Embedded();
      emb.setSource(new ClassResource("res/tac/trupp.png", app));
      emb.setWidth("50px");
      emb.setHeight("30px");
      horContent.addComponent(emb);

      VerticalLayout verContent = new VerticalLayout();
      verContent.setSpacing(true);
      horContent.addComponent(verContent);
      horContent.setExpandRatio(verContent, 1f);

      Label lblName = new Label(squad.getName());
      lblName.setStyleName(Reindeer.LABEL_H2);
      verContent.addComponent(lblName);
      verContent.addComponent(new Label(squad.getType().getName()));

      List<Helper> helpers = squad.getHelpers();
      for (Helper helper : helpers) {
        verContent.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
        verContent.addComponent(new Label(helper.getFirstName() + " " + helper.getLastName()));
        Label lblTel = new Label(helper.getTelNumber());
        lblTel.setStyleName(Reindeer.LABEL_SMALL);
        verContent.addComponent(lblTel);
        String quals = "";
        List<Qualification> qs = helper.getQualifications();
        for (int i = 1; i < qs.size(); i++) quals += qs.get(i - 1) + ", ";
        Label lblQuals = new Label(quals + qs.get(qs.size() - 1));
        lblQuals.setStyleName(Reindeer.LABEL_SMALL);
        verContent.addComponent(lblQuals);
      }

      Slider slider = new Slider(0, 9);
      slider.setOrientation(Slider.ORIENTATION_VERTICAL);
      slider.setImmediate(true);
      slider.addListener(
          new ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
              int state = ((Double) event.getProperty().getValue()).intValue();
              squad.setState(state);
              Long id = squad.getId();
              works.getItem(id).getItemProperty("state").setValue(state);
              boolean visible = units.areUnavailableVisible();
              units.setUnavailableVisible(true);
              units.getItem(id).getItemProperty("state").setValue(state);
              units.setUnavailableVisible(visible);
            }
          });
      try {
        slider.setValue(squad.getState());
      } catch (Exception e) {
      }
      horContent.addComponent(slider);
    }

    for (final Vehicle vehicle : vehicles) {
      Panel panel = new Panel();
      addComponent(panel);
      HorizontalLayout horContent = new HorizontalLayout();
      horContent.setMargin(true);
      horContent.setSpacing(true);
      horContent.setWidth("100%");
      panel.setContent(horContent);

      Embedded emb = new Embedded();
      File img = vehicle.getImage();
      if (img == null) {
        emb.setSource(new ClassResource("res/tac/fahrzeug.png", app));
      } else {
        emb.setSource(new FileResource(img, app));
      }
      emb.setWidth("50px");
      horContent.addComponent(emb);

      VerticalLayout verContent = new VerticalLayout();
      verContent.setSpacing(true);
      horContent.addComponent(verContent);
      horContent.setExpandRatio(verContent, 1f);

      Label lblName = new Label(vehicle.getName());
      lblName.setStyleName(Reindeer.LABEL_H2);
      verContent.addComponent(lblName);
      verContent.addComponent(new Label(vehicle.getType().getName()));

      List<Helper> helpers = vehicle.getHelpers();
      for (Helper helper : helpers) {
        verContent.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
        verContent.addComponent(new Label(helper.getFirstName() + " " + helper.getLastName()));
        Label lblTel = new Label(helper.getTelNumber());
        lblTel.setStyleName(Reindeer.LABEL_SMALL);
        verContent.addComponent(lblTel);
        String quals = "";
        List<Qualification> qs = helper.getQualifications();
        for (int i = 1; i < qs.size(); i++) quals += qs.get(i - 1) + ", ";
        Label lblQuals = new Label(quals + qs.get(qs.size() - 1));
        lblQuals.setStyleName(Reindeer.LABEL_SMALL);
        verContent.addComponent(lblQuals);
      }

      Slider slider = new Slider(0, 9);
      slider.setOrientation(Slider.ORIENTATION_VERTICAL);
      slider.setImmediate(true);
      slider.addListener(
          new ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
              int state = ((Double) event.getProperty().getValue()).intValue();
              vehicle.setState(state);
              Long id = vehicle.getId();
              works.getItem(id).getItemProperty("state").setValue(state);
              boolean visible = units.areUnavailableVisible();
              units.setUnavailableVisible(true);
              units.getItem(id).getItemProperty("state").setValue(state);
              units.setUnavailableVisible(visible);
            }
          });
      try {
        slider.setValue(vehicle.getState());
      } catch (Exception e) {
      }
      horContent.addComponent(slider);
    }
  }
예제 #15
0
  @SuppressWarnings("serial")
  @Override
  public void editPhoto(final byte[] imageData) {
    this.removeAllComponents();
    LOG.debug("Receive avatar upload with size: " + imageData.length);
    try {
      originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
      throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox =
        new MHorizontalLayout()
            .withSpacing(true)
            .withMargin(new MarginInfo(false, true, true, false))
            .withWidth("100%");

    Resource defaultPhoto =
        UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.with(previewImage).withAlign(previewImage, Alignment.TOP_LEFT);

    VerticalLayout previewBoxRight = new VerticalLayout();
    previewBoxRight.setMargin(new MarginInfo(false, true, false, true));
    Label lbPreview =
        new Label(
            "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p>"
                + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
                + "When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxRight.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null));
              }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    Button acceptBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                if (scaleImageData != null && scaleImageData.length > 0) {
                  try {
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                    UserAvatarService userAvatarService =
                        ApplicationContextUtil.getSpringBean(UserAvatarService.class);
                    userAvatarService.uploadAvatar(
                        image, AppContext.getUsername(), AppContext.getUserAvatarId());
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                  } catch (IOException e) {
                    throw new MyCollabException("Error when saving user avatar", e);
                  }
                }
              }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    previewBoxRight.addComponent(controlBtns);
    previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);

    previewBox.addComponent(previewBoxRight);
    previewBox.setExpandRatio(previewBoxRight, 1.0f);

    this.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.addStyleName(UIConstants.PHOTO_CROPBOX);
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource =
        new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(
        new Property.ValueChangeListener() {

          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.getProperty().getValue();
            int x1 = newSelection.getXTopLeft();
            int y1 = newSelection.getYTopLeft();
            int x2 = newSelection.getXBottomRight();
            int y2 = newSelection.getYBottomRight();
            if (x2 > x1 && y2 > y1) {
              BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
              ByteArrayOutputStream outStream = new ByteArrayOutputStream();
              try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
              } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
              }
            }
          }
        });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");

    currentPhotoBox.addComponent(cropField);

    cropBox.addComponent(currentPhotoBox);

    this.addComponent(previewBox);
    this.addComponent(cropBox);
    this.setExpandRatio(cropBox, 1.0f);
  }
예제 #16
0
  /** @param el */
  public BookImage(Books el, String user) {
    super();
    this.Book = el;

    this.setStyleName("cells");
    this.setHeight("250px");
    this.setWidth("200px");

    rating.setAnimated(true);
    rating.setCaption(null);
    rating.setMaxValue(5);
    rating.setStyleName("rating");
    rating.setReadOnly(true);

    rating_my.setAnimated(true);
    rating_my.setCaption(null);
    rating_my.setMaxValue(5);
    rating_my.setStyleName("rating_my");

    IRaitingService iRaitingService = new IRaitingService();
    try {
      double rate = iRaitingService.getRaiting(el.getId());
      rating.setReadOnly(false);
      rating.setValue(rate);
      rating.setReadOnly(true);
      double myrate = iRaitingService.getRaiting(user, el.getId());
      rating_my.setValue(myrate);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    rating_my.addValueChangeListener(
        e -> {
          try {
            Rating rat =
                iRaitingService.getUser(
                    getUI().getSession().getAttribute("user").toString(), el.getId());

            rat.setRaiting(rating_my.getValue());

            iRaitingService.update(rat);

            double rate = iRaitingService.getRaiting(el.getId());
            rating.setReadOnly(false);
            rating.setValue(rate);
            rating.setReadOnly(true);

            new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION)
                .show(Page.getCurrent());
          } catch (SQLException e1) {
            e1.printStackTrace();
          }
        });

    rating_layout.addComponent(rating);
    rating_layout.addComponent(rating_my);
    rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT);
    rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT);
    rating_layout.setStyleName("ratinglayout");

    imageEmbedded.setSource(new FileResource(new File(Book.getImage())));

    title.setValue(Book.getTitle());
    author.setValue(Book.getAuthor());

    if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false);

    buttonDownload.setWidth("80%");
    imageEmbedded.setWidth("100%");
    imageEmbedded.setHeight("100%");

    title.setWidth(null);
    author.setWidth(null);

    VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded);

    bodyLayout.setExpandRatio(title, 12);
    bodyLayout.setExpandRatio(author, 8);
    bodyLayout.setExpandRatio(imageEmbedded, 80);
    bodyLayout.setSizeFull();
    bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
    bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER);
    bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER);

    buttonDownload.setStyleName("super-button");
    title.setStyleName("name-label");
    author.setStyleName("author-label");

    this.addComponent(rating_layout);
    this.addComponent(bodyLayout);
    this.addComponent(buttonDownload);

    this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER);
    this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER);
    this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER);
    this.setExpandRatio(rating_layout, 5);
    this.setExpandRatio(bodyLayout, 85);
    this.setExpandRatio(buttonDownload, 10);

    StreamResource sr = getStream();
    FileDownloader fileDownloader = new FileDownloader(sr);
    fileDownloader.extend(buttonDownload);

    bodyLayout.addLayoutClickListener(
        e -> {
          BookWin win = new BookWin(this.Book);
          UI.getCurrent().addWindow(win);
        });
  }
예제 #17
0
 private void setTooltip(String tt) {
   setDescription(tt); // abslay
   if (titleImage != null) titleImage.setDescription(tt);
   if (title != null) title.setDescription(tt);
   content.setDescription(tt);
 }