private Component createChameleonTab() {
   Embedded embedded = new Embedded();
   embedded.setSource(new ExternalResource("/splitbutton/chameleon?restartApplication"));
   embedded.setType(Embedded.TYPE_BROWSER);
   embedded.setSizeFull();
   return embedded;
 }
 private void displayPreviewImage() {
   if (scaleImageData != null && scaleImageData.length > 0) {
     ByteArrayImageResource previewResource =
         new ByteArrayImageResource(scaleImageData, "image/png");
     previewImage.setSource(previewResource);
   }
 }
Exemplo n.º 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;
  }
  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);
  }
Exemplo n.º 5
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);
        });
  }
Exemplo n.º 6
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);
    }
  }