Пример #1
0
 /** Download actual file */
 public void download() {
   StreamResource resource = new StreamResource(source, fileName);
   resource
       .getStream()
       .setParameter("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
   resource.setMIMEType("application/octet-stream");
   resource.setCacheTime(0);
   FileDownloader downloader = new FileDownloader(resource);
   downloader.extend(ui);
 }
  protected Component buildExportSelection() {
    // TODO These links should become a drop down menu for multiple formats
    HorizontalLayout exportbar = new HorizontalLayout();
    exportbar.setSpacing(true);
    exportPDF = new Button("Export as PDF");
    exportPDF.setEnabled(false);
    FileDownloader downloader = new FileDownloader(createResourceForExport(Format.PDF));
    downloader.extend(exportPDF);
    exportbar.addComponent(exportPDF);

    // TODO Export in other formats
    return exportbar;
  }
Пример #3
0
  public SubsEditViewImpl() {
    ButtonRenderer deleteButton = createDeleteButton();
    Slider percentSlider = createPercentSlider();
    MultiFileUpload uploader = createUploader();

    // need to update the grid a first time for initialization.
    updateGrid(null);
    grid.getColumn("delete").setRenderer(deleteButton);
    fileDownloader = new FileDownloader(generateResource());
    fileDownloader.extend(downloadButton);

    // create the main layout
    VerticalLayout content = new VerticalLayout();

    // layout which contains the uploader and the percentage - in other words : all the
    // configuration information
    HorizontalLayout configHorizontalLayout = new HorizontalLayout();
    configHorizontalLayout.addComponent(uploader);

    // Configure the layout which contains the percentage slider
    AbsoluteLayout sliderLayout = new AbsoluteLayout();
    sliderLayout.setWidth("100px");
    sliderLayout.setHeight("35px");
    sliderLayout.addComponent(percentSlider);

    // Configure the layout which contains the percentage slider layout and the labels linked to the
    // percentage
    HorizontalLayout percentageLayout = new HorizontalLayout();
    percentageLayout.addComponent(percentSliderTitle);
    percentageLayout.addComponent(sliderLayout);
    percentageLayout.addComponent(percentLabel);
    percentageLayout.setComponentAlignment(percentSliderTitle, Alignment.MIDDLE_LEFT);
    percentageLayout.setComponentAlignment(percentLabel, Alignment.MIDDLE_LEFT);

    // add the percentage Layout to the layout which contains the uploader
    configHorizontalLayout.addComponent(percentageLayout);
    configHorizontalLayout.setComponentAlignment(percentageLayout, Alignment.BOTTOM_LEFT);

    // add every layouts to the principal one
    content.addComponent(configHorizontalLayout);
    content.addComponent(new Label(" ", Label.CONTENT_XHTML));
    content.addComponents(grid);
    content.addComponent(downloadButton);
    setCompositionRoot(content);
  }
Пример #4
0
  public void loadTable(InputStream in, String fileName, String mimeType) {
    //        String uploadDate = dateTimeFormatHelper.getDayMonthYear(new Date());
    String fileId = storageService.save(in, mimeType, fileName);
    Set<String> files = updateEmpDetails(fileId);

    for (String filesId : files) {

      Button download = new Button("Download");
      download.setStyleName(Reindeer.BUTTON_LINK);
      download.setData(filesId);

      PersonFilesgeUtil personFilesgeUtil = new PersonFilesgeUtil(fileId);
      StreamResource.StreamSource imageSource = personFilesgeUtil;
      StreamResource resource = new StreamResource(imageSource, personFilesgeUtil.getFileName());
      FileDownloader fileDownloader = new FileDownloader(resource);
      fileDownloader.extend(download);

      Button delete = new Button("Delete");
      delete.setStyleName(Reindeer.BUTTON_LINK);
      delete.setData(filesId);
      delete.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
              deleteFile((String) event.getButton().getData());
              removeItem((String) event.getButton().getData());
            }
          });

      addItem(
          new Object[] {
            storageService.getById(filesId).getFilename(), download, delete,
          },
          filesId);
    }
    // Allow selecting items from the table.
    setNullSelectionAllowed(false);
    setSelectable(true);
    // Send changes in selection immediately to server.
    setImmediate(true);
  }
Пример #5
0
  @Override
  protected ComponentContainer createButtonControls() {
    ProjectPreviewFormControlsGenerator<Page> pagesPreviewForm =
        new ProjectPreviewFormControlsGenerator<>(previewForm);
    HorizontalLayout topPanel =
        pagesPreviewForm.createButtonControls(
            ProjectPreviewFormControlsGenerator.ADD_BTN_PRESENTED
                | ProjectPreviewFormControlsGenerator.EDIT_BTN_PRESENTED
                | ProjectPreviewFormControlsGenerator.DELETE_BTN_PRESENTED,
            ProjectRolePermissionCollections.PAGES);

    Button exportPdfBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF), FontAwesome.EXTERNAL_LINK);
    exportPdfBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    FileDownloader fileDownloader = new FileDownloader(getPDFStream());
    fileDownloader.extend(exportPdfBtn);

    pagesPreviewForm.insertToControlBlock(exportPdfBtn);

    return topPanel;
  }
  public TaskDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    taskSearchPanel = new TaskSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    groupWrapLayout.addComponent(new Label("Filter:"));
    final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox();
    savedFilterComboBox.addQuerySelectListener(
        new SavedFilterComboBox.QuerySelectListener() {
          @Override
          public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) {
            List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos();
            TaskSearchCriteria criteria =
                SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos);
            criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
            EventBusFactory.getInstance()
                .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria));
          }
        });
    groupWrapLayout.addComponent(savedFilterComboBox);

    groupWrapLayout.addComponent(new Label("Sort:"));
    final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING);
    sortCombo.setWidth("100px");
    sortCombo.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            String sortValue = (String) sortCombo.getValue();
            if (ASCENDING.equals(sortValue)) {
              sortDirection = SearchCriteria.ASC;
            } else {
              sortDirection = SearchCriteria.DESC;
            }
            queryAndDisplayTasks();
          }
        });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new Label("Group by:"));
    final ComboBox groupCombo =
        new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST);
    groupCombo.setWidth("100px");
    groupCombo.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            groupByState = (String) groupCombo.getValue();
            queryAndDisplayTasks();
          }
        });
    groupByState = GROUP_DUE_DATE;
    groupWrapLayout.addComponent(groupCombo);

    taskSearchPanel.addHeaderRight(groupWrapLayout);

    Button exportBtn = new Button("Export");
    final SplitButton exportSplitBtn = new SplitButton(exportBtn);
    exportBtn.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            exportSplitBtn.setPopupVisible(true);
          }
        });
    exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    OptionPopupContent popupButtonsControl = new OptionPopupContent();

    Button exportPdfBtn = new Button("PDF");
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF));
    pdfFileDownloder.extend(exportPdfBtn);
    popupButtonsControl.addOption(exportPdfBtn);

    Button exportExcelBtn = new Button("Excel");
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    FileDownloader excelFileDownloader =
        new FileDownloader(buildStreamSource(ReportExportType.EXCEL));
    excelFileDownloader.extend(exportExcelBtn);
    popupButtonsControl.addOption(exportExcelBtn);

    exportSplitBtn.setContent(popupButtonsControl);
    groupWrapLayout.with(exportSplitBtn);

    Button newTaskBtn =
        new Button(
            AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                SimpleTask newTask = new SimpleTask();
                newTask.setProjectid(CurrentProjectVariables.getProjectId());
                UI.getCurrent().addWindow(new TaskAddWindow(newTask));
              }
            });
    newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    newTaskBtn.setIcon(FontAwesome.PLUS);
    newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP));
    newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    groupWrapLayout.addComponent(newTaskBtn);

    Button advanceDisplayBtn = new Button();
    advanceDisplayBtn.setWidth("50px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription(
        AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP));

    Button calendarBtn =
        new Button(
            null,
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent clickEvent) {
                EventBusFactory.getInstance()
                    .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this));
              }
            });
    calendarBtn.setWidth("50px");
    calendarBtn.setDescription("Calendar View");
    calendarBtn.setIcon(FontAwesome.CALENDAR);

    Button chartDisplayBtn =
        new Button(
            null,
            new Button.ClickListener() {
              private static final long serialVersionUID = -5707546605789537298L;

              @Override
              public void buttonClick(ClickEvent event) {
                displayGanttChartView();
              }
            });
    chartDisplayBtn.setWidth("50px");
    chartDisplayBtn.setDescription("Display Gantt chart");
    chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O);

    Button kanbanBtn =
        new Button(
            null,
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent clickEvent) {
                displayKanbanView();
              }
            });
    kanbanBtn.setWidth("50px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(FontAwesome.TH);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(calendarBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.addButton(chartDisplayBtn);
    viewButtons.setDefaultButton(advanceDisplayBtn);
    groupWrapLayout.addComponent(viewButtons);

    mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth();
    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false));
    rightColumn =
        new MVerticalLayout()
            .withWidth("350px")
            .withMargin(new MarginInfo(true, false, false, false));
    mainLayout.with(wrapBody, rightColumn).expand(wrapBody);
  }
Пример #7
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);
        });
  }
Пример #8
0
  @Override
  public void execute() {
    List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good);
    Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("650px");
    subWindow.setWidth("700px");
    subWindow.setClosable(true);
    view.getUi().addWindow(subWindow);

    final Button pdfButton = new Button(bundle.getString("pdf.export"));
    pdfButton.setIcon(new ThemeResource("img/pdf.png"));
    pdfButton.setWidth("150");
    StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good));
    pdfStream.setMIMEType("application/pdf");
    FileDownloader pdfDownloader = new FileDownloader(pdfStream);
    pdfDownloader.extend(pdfButton);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(pdfButton);

    for (ChangeRecord record : historyList) {
      for (ChangeRecord.PropertyChange p : record.getChangeList()) {
        p.setName(bundle.getString(p.getName()));
      }
      Panel panel = new Panel();
      BeanItemContainer<ChangeRecord.PropertyChange> container =
          new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList());
      Table table = new Table();
      table.setContainerDataSource(container);
      table.setVisibleColumns("name", "oldValue", "newValue");
      table.setColumnHeaders(
          bundle.getString("history.property"),
          bundle.getString("history.old"),
          bundle.getString("history.new"));
      table.setColumnExpandRatio("name", 0.33f);
      table.setColumnExpandRatio("oldValue", 0.33f);
      table.setColumnExpandRatio("newValue", 0.33f);
      table.setPageLength(0);
      table.setWidth("100%");

      VerticalLayout panelLayout = new VerticalLayout();
      panelLayout.addComponent(
          new Label(
              "<b>"
                  + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate())
                  + ": "
                  + record.getUser().getName()
                  + " "
                  + record.getUser().getSurname()
                  + "</b><br/>",
              ContentMode.HTML));
      panelLayout.addComponent(table);
      panel.setContent(panelLayout);
      layout.addComponent(panel);
    }

    subWindow.setContent(layout);
  }