Пример #1
0
  public DashboardView() {
    addStyleName(ValoTheme.PANEL_BORDERLESS);
    setSizeFull();
    DashboardEventBus.register(this);

    root = new VerticalLayout();
    root.setSizeFull();
    root.setSpacing(false);
    root.addStyleName("dashboard-view");
    setContent(root);
    Responsive.makeResponsive(root);

    root.addComponent(buildHeader());

    root.addComponent(buildSparklines());

    Component content = buildContent();
    root.addComponent(content);
    root.setExpandRatio(content, 1);

    // All the open sub-windows should be closed whenever the root layout
    // gets clicked.
    root.addLayoutClickListener(
        new LayoutClickListener() {
          @Override
          public void layoutClick(final LayoutClickEvent event) {
            DashboardEventBus.post(new CloseOpenWindowsEvent());
          }
        });
  }
Пример #2
0
  public Depot(
      final Label titleLbl,
      final ComponentContainer headerElement,
      final ComponentContainer component,
      final String headerWidth,
      final String headerLeftWidth) {
    this.setStyleName("depotComp");
    this.setMargin(new MarginInfo(true, false, false, false));
    this.header = new HorizontalLayout();
    this.header.setStyleName("depotHeader");
    this.header.setWidth(headerWidth);
    this.bodyContent = component;
    if (headerElement != null) {
      this.headerContent = headerElement;
    } else {
      this.headerContent = new HorizontalLayout();
      ((HorizontalLayout) this.headerContent).setSpacing(true);
      ((HorizontalLayout) this.headerContent).setMargin(true);
      ((HorizontalLayout) this.headerContent).setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
      this.headerContent.setVisible(false);
    }

    this.headerContent.setStyleName("header-elements");
    this.headerContent.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS);
    // this.headerContent.setHeight("100%");
    this.headerContent.setSizeUndefined();

    this.addComponent(this.header);

    final VerticalLayout headerLeft = new VerticalLayout();
    this.headerLbl = titleLbl;
    this.headerLbl.setStyleName("h2");
    this.headerLbl.setWidth("100%");
    headerLeft.addComponent(this.headerLbl);
    headerLeft.setStyleName("depot-title");
    headerLeft.addLayoutClickListener(
        new LayoutClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void layoutClick(final LayoutClickEvent event) {
            Depot.this.isOpenned = !Depot.this.isOpenned;
            if (Depot.this.isOpenned) {
              Depot.this.bodyContent.setVisible(true);
              Depot.this.removeStyleName("collapsed");
            } else {
              Depot.this.bodyContent.setVisible(false);
              Depot.this.addStyleName("collapsed");
            }
          }
        });
    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerLeft);
    headerWrapper.setStyleName("header-wrapper");
    headerWrapper.setWidth(headerLeftWidth);
    this.header.addComponent(headerWrapper);
    this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT);
    this.header.addComponent(this.headerContent);
    this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT);
    this.header.setExpandRatio(headerWrapper, 1.0f);

    final CustomComponent customComp = new CustomComponent(this.bodyContent);
    customComp.setWidth("100%");
    this.bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
  }
Пример #3
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);
        });
  }