Ejemplo n.º 1
0
  public Widget draw() {

    this.titleWidget.setText(
        Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "ext sources");

    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));

    // get VO resources
    final GetGroupExtSources extSources = new GetGroupExtSources(groupId);

    // refresh table event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);

    // create ext source button
    CustomButton addButton =
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            true,
            ButtonTranslation.INSTANCE.addExtSource(),
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                session
                    .getTabManager()
                    .addTabToCurrentTab(new AddGroupExtSourceTabItem(groupId), true);
              }
            });
    if (session.isVoAdmin(voId)) {
      menu.addWidget(addButton);
    }

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(
            ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
    removeButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
            String text =
                "Following external sources will be removed from Group. You won't be able to import members from them anymore.";
            UiElements.showDeleteConfirm(
                extSourcesToRemove,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < extSourcesToRemove.size(); i++) {
                      RemoveExtSource request;
                      if (i == extSourcesToRemove.size() - 1) {
                        request =
                            new RemoveExtSource(
                                JsonCallbackEvents.disableButtonEvents(removeButton, events));
                      } else {
                        request =
                            new RemoveExtSource(
                                JsonCallbackEvents.disableButtonEvents(removeButton));
                      }
                      request.removeGroupExtSource(groupId, extSourcesToRemove.get(i).getId());
                    }
                  }
                });
          }
        });
    if (session.isVoAdmin(voId)) {
      menu.addWidget(removeButton);
    }

    // authorization - enable buttons for vo admin only.
    if (!session.isVoAdmin(voId)) {
      addButton.setEnabled(false);
      removeButton.setEnabled(false);
      extSources.setCheckable(false);
    }

    menu.addFilterWidget(
        new ExtendedSuggestBox(extSources.getOracle()),
        new PerunSearchEvent() {
          @Override
          public void searchFor(String text) {
            extSources.filterTable(text);
          }
        },
        "Filter external sources by name or type");

    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    CellTable<ExtSource> table = extSources.getTable();

    if (session.isVoAdmin(voId)) {
      removeButton.setEnabled(false);
      JsonUtils.addTableManagedButton(extSources, table, removeButton);
    }

    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");

    vp.add(sp);

    session.getUiElements().resizePerunTable(sp, 350, this);

    this.contentWidget.setWidget(vp);

    return getWidget();
  }
Ejemplo n.º 2
0
  public Widget draw() {

    this.titleWidget.setText(
        Utils.getStrippedStringWithEllipsis(service.getName()) + ": exec services");

    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    final ListExecServices callback = new ListExecServices(serviceId);
    CellTable<ExecService> table =
        callback.getTable(
            new FieldUpdater<ExecService, String>() {
              public void update(int index, ExecService object, String value) {
                // manage details of exec services (dependency, status, update values?)
                session.getTabManager().addTab(new ViewExecServiceTabItem(object));
              }
            });

    // refresh event after deletion
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);

    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CREATE,
            ButtonTranslation.INSTANCE.createExecService(),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().addTabToCurrentTab(new AddExecServiceTabItem(service));
              }
            }));

    final CustomButton deleteButton =
        TabMenu.getPredefinedButton(
            ButtonType.REMOVE, ButtonTranslation.INSTANCE.deleteSelectedExecServices());
    menu.addWidget(deleteButton);
    deleteButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<ExecService> execToRemove = callback.getTableSelectedList();
            UiElements.showDeleteConfirm(
                execToRemove,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < execToRemove.size(); i++) {
                      if (i == execToRemove.size() - 1) {
                        DeleteExecService request =
                            new DeleteExecService(
                                JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                        request.deleteExecService(execToRemove.get(i).getId());
                      } else {
                        DeleteExecService request =
                            new DeleteExecService(
                                JsonCallbackEvents.disableButtonEvents(deleteButton));
                        request.deleteExecService(execToRemove.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

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

    session.getUiElements().resizePerunTable(sp, 350, this);

    final CustomButton enable =
        TabMenu.getPredefinedButton(ButtonType.ENABLE, "Enable selected exec service(s)");
    final CustomButton disable =
        TabMenu.getPredefinedButton(ButtonType.DISABLE, "Disable selected exec service(s)");

    menu.addWidget(enable);
    menu.addWidget(disable);

    enable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            ArrayList<ExecService> list = callback.getTableSelectedList();
            for (int i = 0; i < list.size(); i++) {

              ExecService e = list.get(i);
              if (i < list.size() - 1) {
                // any call
                if (!e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable));
                  e.setEnabled(true);
                  request.updateExecService(e);
                }
              } else {
                // last call
                if (!e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable, events));
                  e.setEnabled(true);
                  request.updateExecService(e);
                }
              }
            }
          }
        });

    disable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            ArrayList<ExecService> list = callback.getTableSelectedList();
            for (int i = 0; i < list.size(); i++) {

              ExecService e = list.get(i);
              if (i < list.size() - 1) {
                // any call
                if (e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(disable));
                  e.setEnabled(false);
                  request.updateExecService(e);
                }
              } else {
                // last call
                if (e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(
                          JsonCallbackEvents.disableButtonEvents(disable, events));
                  e.setEnabled(false);
                  request.updateExecService(e);
                }
              }
            }
          }
        });

    deleteButton.setEnabled(false);
    enable.setEnabled(false);
    disable.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, deleteButton);
    JsonUtils.addTableManagedButton(callback, table, enable);
    JsonUtils.addTableManagedButton(callback, table, disable);

    vp.add(sp);
    vp.setCellHeight(sp, "100%");

    // add tabs to the main panel
    this.contentWidget.setWidget(vp);

    return getWidget();
  }
Ejemplo n.º 3
0
  public Widget draw() {

    titleWidget.setText("Add manager");

    final CustomButton searchButton =
        new CustomButton(
            "Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());

    this.users =
        new FindCompleteRichUsers(
            "",
            null,
            JsonCallbackEvents.disableButtonEvents(
                searchButton,
                new JsonCallbackEvents() {
                  @Override
                  public void onFinished(JavaScriptObject jso) {
                    // if found 1 item, select
                    ArrayList<User> list = JsonUtils.jsoAsList(jso);
                    if (list != null && list.size() == 1) {
                      users.getSelectionModel().setSelected(list.get(0), true);
                    }
                  }
                }));

    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");

    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();

    // get the table
    final CellTable<User> table;
    if (session.isPerunAdmin()) {
      table =
          users.getTable(
              new FieldUpdater<User, String>() {
                public void update(int i, User user, String s) {
                  session.getTabManager().addTab(new UserDetailTabItem(user));
                }
              });
    } else {
      table = users.getTable();
    }

    rebuildAlreadyAddedWidget();

    final CustomButton addButton =
        TabMenu.getPredefinedButton(
            ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToVo());
    final TabItem tab = this;

    // search textbox
    final ExtendedTextBox searchBox =
        tabMenu.addSearchWidget(
            new PerunSearchEvent() {
              @Override
              public void searchFor(String text) {
                startSearching(text);
                searchString = text;
              }
            },
            searchButton);

    tabMenu.addWidget(addButton);

    tabMenu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CLOSE,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
              }
            }));

    addButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
              for (int i = 0; i < list.size(); i++) {
                // FIXME - Should have only one callback to core
                final int n = i;
                AddAdmin request =
                    new AddAdmin(
                        JsonCallbackEvents.disableButtonEvents(
                            addButton,
                            new JsonCallbackEvents() {
                              @Override
                              public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                alreadyAddedList.add(list.get(n));
                                rebuildAlreadyAddedWidget();
                                // unselect added person
                                users.getSelectionModel().setSelected(list.get(n), false);
                                // clear search
                                searchBox.getTextBox().setText("");
                              }
                            }));
                request.addVoAdmin(vo, list.get(i));
              }
            }
          }
        });

    // if some text has been searched before
    if (!searchString.equals("")) {
      searchBox.getTextBox().setText(searchString);
      startSearching(searchString);
    }

    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, table, addButton);

    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");

    // add menu and the table to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(alreadyAdded);
    firstTabPanel.add(sp);

    session.getUiElements().resizePerunTable(sp, 350, this);

    this.contentWidget.setWidget(firstTabPanel);

    return getWidget();
  }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
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;
  }
Ejemplo n.º 6
0
  public Widget draw() {

    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    final FindAllCategories callback = new FindAllCategories();

    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);

    TabMenu menu = new TabMenu();
    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "Add new category",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CreateCategoryTabItem());
              }
            }));

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(ButtonType.DELETE, "Delete selected categories");
    removeButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<Category> delete = callback.getTableSelectedList();
            String text = "Following categories will be deleted";
            UiElements.showDeleteConfirm(
                delete,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < delete.size(); i++) {
                      if (i == delete.size() - 1) {
                        DeleteCategory request =
                            new DeleteCategory(
                                JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        request.deleteCategory(delete.get(i).getId());
                      } else {
                        DeleteCategory request =
                            new DeleteCategory(
                                JsonCallbackEvents.disableButtonEvents(removeButton));
                        request.deleteCategory(delete.get(i).getId());
                      }
                    }
                  }
                });
          }
        });
    menu.addWidget(removeButton);

    final CustomButton saveButton =
        TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in category ranks");
    saveButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final ArrayList<Category> list = callback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
              // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
              for (int i = 0; i < list.size(); i++) {
                if (i == list.size() - 1) {
                  UpdateCategory request =
                      new UpdateCategory(
                          JsonCallbackEvents.disableButtonEvents(saveButton, events));
                  request.updateCategory(list.get(i));
                } else {
                  UpdateCategory request =
                      new UpdateCategory(JsonCallbackEvents.disableButtonEvents(saveButton));
                  request.updateCategory(list.get(i));
                }
              }
            }
          }
        });
    menu.addWidget(saveButton);

    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    CellTable<Category> table = callback.getTable();

    removeButton.setEnabled(false);
    saveButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, removeButton);
    JsonUtils.addTableManagedButton(callback, table, saveButton);

    table.addStyleName("perun-table");

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

    vp.add(sp);

    // resize perun table to correct size on screen
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);

    this.contentWidget.setWidget(vp);

    return getWidget();
  }