Esempio n. 1
0
  /**
   * Returns thanks management widget for publication
   *
   * @return widget
   */
  private Widget loadThanksSubTab() {

    DisclosurePanel dp = new DisclosurePanel();
    dp.setWidth("100%");
    dp.setOpen(true);
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    dp.setContent(vp);

    FlexTable header = new FlexTable();
    header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.smallBusinessIcon()));
    header.setHTML(0, 1, "<h3>Acknowledgement</h3>");
    dp.setHeader(header);

    // menu
    TabMenu menu = new TabMenu();

    // callback
    final FindThanksByPublicationId thanksCall = new FindThanksByPublicationId(publicationId);
    thanksCall.setCheckable(false);

    if (!publication.getLocked()) {
      // editable if not locked
      vp.add(menu);
      vp.setCellHeight(menu, "30px");
      thanksCall.setCheckable(true);
    }

    CellTable<Thanks> table = thanksCall.getTable();

    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "Add acknowledgement to publication",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                session
                    .getTabManager()
                    .addTabToCurrentTab(
                        new CreateThanksTabItem(
                            publication, JsonCallbackEvents.refreshTableEvents(thanksCall)),
                        true);
              }
            }));

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove acknowledgement from publication");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(thanksCall, table, removeButton);
    menu.addWidget(removeButton);

    removeButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final ArrayList<Thanks> list = thanksCall.getTableSelectedList();
            String text = "Following acknowledgements will be removed from publication.";
            UiElements.showDeleteConfirm(
                list,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < list.size(); i++) {
                      // calls the request
                      if (i == list.size() - 1) {
                        DeleteThanks request =
                            new DeleteThanks(
                                JsonCallbackEvents.disableButtonEvents(
                                    removeButton,
                                    JsonCallbackEvents.refreshTableEvents(thanksCall)));
                        request.deleteThanks(list.get(i).getId());
                      } else {
                        DeleteThanks request =
                            new DeleteThanks(JsonCallbackEvents.disableButtonEvents(removeButton));
                        request.deleteThanks(list.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");

    vp.add(sp);

    return dp;
  }
Esempio n. 2
0
  /**
   * Returns widget with authors management for publication
   *
   * @return widget
   */
  private Widget loadAuthorsSubTab() {

    DisclosurePanel dp = new DisclosurePanel();
    dp.setWidth("100%");
    dp.setOpen(true);
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    dp.setContent(vp);

    FlexTable header = new FlexTable();
    header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.userGreenIcon()));
    header.setHTML(0, 1, "<h3>Authors / Reported by</h3>");
    dp.setHeader(header);

    // menu
    TabMenu menu = new TabMenu();

    // callback
    final FindAuthorsByPublicationId call = new FindAuthorsByPublicationId(publication.getId());
    call.setCheckable(false);

    if (!publication.getLocked()) {
      // editable if not locked
      vp.add(menu);
      vp.setCellHeight(menu, "30px");
      call.setCheckable(true);
    }

    final CustomButton addButton =
        new CustomButton(
            "Add myself", "Add you as author of publication", SmallIcons.INSTANCE.addIcon());
    addButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(call);
            CreateAuthorship request =
                new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, events));
            request.createAuthorship(publicationId, session.getActiveUser().getId());
          }
        });
    menu.addWidget(addButton);

    CustomButton addOthersButton =
        new CustomButton("Add others", "Add more authors", SmallIcons.INSTANCE.addIcon());
    addOthersButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            session
                .getTabManager()
                .addTabToCurrentTab(
                    new AddAuthorTabItem(publication, JsonCallbackEvents.refreshTableEvents(call)),
                    true);
          }
        });
    menu.addWidget(addOthersButton);

    // fill table
    CellTable<Author> table = call.getEmptyTable();
    call.retrieveData();

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove select author(s) from publication");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(call, table, removeButton);
    menu.addWidget(removeButton);

    removeButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final ArrayList<Author> list = call.getTableSelectedList();
            String text =
                "Following users will be removed from publication's authors. They will lose any benefit granted by publication's rank.";
            UiElements.showDeleteConfirm(
                list,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < list.size(); i++) {
                      // calls the request
                      if (i == list.size() - 1) {
                        DeleteAuthorship request =
                            new DeleteAuthorship(
                                JsonCallbackEvents.disableButtonEvents(
                                    removeButton, JsonCallbackEvents.refreshTableEvents(call)));
                        request.deleteAuthorship(publicationId, list.get(i).getId());
                      } else {
                        DeleteAuthorship request = new DeleteAuthorship();
                        request.deleteAuthorship(publicationId, list.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    table.addStyleName("perun-table");
    sp.addStyleName("perun-tableScrollPanel");

    vp.add(sp);

    return dp;
  }