예제 #1
0
 /** Called, when operation finishes successfully. */
 public void onFinished(JavaScriptObject jso) {
   setList(JsonUtils.<ExtSource>jsoAsList(jso));
   sortTable();
   session.getUiElements().setLogText("Loading external sources finished: " + list.size());
   events.onFinished(jso);
   loaderImage.loadingFinished();
 }
 /** Called, when operation finishes successfully. */
 public void onFinished(JavaScriptObject jso) {
   setList(JsonUtils.<Publication>jsoAsList(jso));
   sortTable();
   session.getUiElements().setLogText("Publications loaded: " + list.size());
   events.onFinished(jso);
   loaderImage.loadingFinished();
 }
예제 #3
0
  private FlexTable getFooter() {

    ft = new FlexTable();
    ft.addStyleName("perunFooter");

    FlexTable.FlexCellFormatter ftf = ft.getFlexCellFormatter();

    if (!voContact.getHTML().isEmpty()) {
      // show only if any contact is present
      voContact.setHTML(
          "<strong>"
              + ApplicationMessages.INSTANCE.supportContact()
              + "</strong> "
              + voContact.getHTML());
    }

    ft.setWidget(0, 0, voContact);
    ft.setWidget(
        0,
        1,
        new HTML(
            PerunWebConstants.INSTANCE.footerPerunCopyright() + " " + JsonUtils.getCurrentYear()));

    ftf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
    ftf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    ftf.getElement(0, 1).setAttribute("style", "text-wrap: avoid;");
    ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    ftf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);

    return ft;
  }
예제 #4
0
  /** Starts the search for users */
  protected void startSearching(String text) {

    users.clearTable();

    // IS searched string IDs?
    if (JsonUtils.isStringWithIds(text)) {

      FindUsersByIdsNotInRpc req =
          new FindUsersByIdsNotInRpc(
              new JsonCallbackEvents() {
                @Override
                public void onFinished(JavaScriptObject jso) {
                  ArrayList<User> usersList = JsonUtils.jsoAsList(jso);
                  for (User u : usersList) {
                    users.addToTable(u);
                  }
                }
              },
              text);

      req.retrieveData();
      return;
    }

    users.searchFor(text);
  }
예제 #5
0
 /**
  * Creates a new instance of callback
  *
  * @param entity entity
  * @param id entity ID
  * @param attributes list of attributes urns (null if default / empty if all / explicit for
  *     selection)
  */
 public GetRichAdminsWithAttributes(PerunEntity entity, int id, ArrayList<String> attributes) {
   this.entity = entity;
   this.entityId = id;
   // if null use default
   if (attributes == null) {
     this.attributes = JsonUtils.getAttributesListForUserTables();
   } else {
     this.attributes = attributes;
   }
 }
 /** Called, when operation finishes successfully. */
 public void onFinished(JavaScriptObject jso) {
   clearTable();
   for (Attribute a : JsonUtils.<Attribute>jsoAsList(jso)) {
     if (!a.getDefinition().equals("core")) {
       addToTable(a);
     }
   }
   sortTable();
   loaderImage.loadingFinished();
   session.getUiElements().setLogText("Resource required attributes loaded: " + list.size());
   events.onFinished(jso);
 }
예제 #7
0
  /** Called when loading successfully finishes. */
  public void onFinished(JavaScriptObject jso) {

    applFormItems.clear();
    applFormItems.addAll(JsonUtils.<ApplicationFormItem>jsoAsList(jso));
    applFormGenerators.clear();

    if (settings) {
      prepareSettings(applFormItems);
    } else {
      prepareApplicationForm(applFormItems);
    }

    session
        .getUiElements()
        .setLogText(
            "Loading application form items in selected VO finished:" + applFormItems.size());
    events.onFinished(jso);
    loaderImage.loadingFinished();
  }
  /**
   * Returns empty table widget with attributes
   *
   * @return table widget
   */
  public CellTable<Attribute> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);

    // Cell table
    table = new PerunTable<Attribute>(list);
    table.removeRowCountChangeHandler(); // remove row count change handler

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // because of tab index
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    // checkbox column
    if (checkable) {

      // checkbox column column
      Column<Attribute, Attribute> checkBoxColumn =
          new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {
            @Override
            public Attribute getValue(Attribute object) {
              // Get the value from the selection model.
              GeneralObject go = object.cast();
              go.setChecked(selectionModel.isSelected(object));
              return go.cast();
            }
          };

      // updates the columns size
      table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);

      // Add the columns

      // Checkbox column header
      CheckboxCell cb = new CheckboxCell();
      Header<Boolean> checkBoxHeader =
          new Header<Boolean>(cb) {
            public Boolean getValue() {
              return false; // return true to see a checked checkbox.
            }
          };
      checkBoxHeader.setUpdater(
          new ValueUpdater<Boolean>() {
            public void update(Boolean value) {
              // sets selected to all, if value = true, unselect otherwise
              for (Attribute obj : list) {
                if (obj.isWritable()) {
                  selectionModel.setSelected(obj, value);
                }
              }
            }
          });

      table.addColumn(checkBoxColumn, checkBoxHeader);
    }

    // Create ID column.
    table.addIdColumn("Attr ID", null, 90);

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
    valueColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Attribute>() {
          public void update(int index, Attribute object, Attribute value) {
            object = value;
            selectionModel.setSelected(object, object.isAttributeValid());
          }
        });

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);

    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");

    return this.table;
  }
 /**
  * Return selected items from list
  *
  * @return return list of checked items
  */
 public ArrayList<TaskResult> getTableSelectedList() {
   return JsonUtils.setToList(selectionModel.getSelectedSet());
 }
  public Widget draw() {

    // contentWidget.setSize("100%", "100%");

    DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
    contentWidget.setWidget(ft);

    final DataGrid gridTable = new DataGrid();
    gridTable.setSize("100%", "100%");

    final ArrayList<Attribute> vosList = new ArrayList<Attribute>();
    final GetAttributesV2 getVos =
        new GetAttributesV2(
            new JsonCallbackEvents() {
              public void onFinished(JavaScriptObject jso) {
                vosList.addAll(
                    new TableSorter<Attribute>()
                        .sortByAttrNameTranslation(JsonUtils.<Attribute>jsoAsList(jso)));
                gridTable.setRowData(vosList);
                gridTable.redraw();
              }
            });
    getVos.getUserAttributes(3411);
    getVos.retrieveData();

    gridTable.setSelectionModel(
        new MultiSelectionModel<Attribute>(new GeneralKeyProvider<Attribute>()));
    final SelectionModel<Attribute> selectionModel = gridTable.getSelectionModel();
    gridTable.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    Column<Attribute, Boolean> checkBoxColumn =
        new Column<Attribute, Boolean>(new CheckboxCell(true, true)) {
          @Override
          public Boolean getValue(Attribute object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    checkBoxColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Boolean>() {
          @Override
          public void update(int i, Attribute Attribute, Boolean aBoolean) {
            selectionModel.setSelected(Attribute, aBoolean);
          }
        });

    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader =
        new Header<Boolean>(cb) {
          public Boolean getValue() {
            return false; // return true to see a checked checkbox.
          }
        };
    checkBoxHeader.setUpdater(
        new ValueUpdater<Boolean>() {
          public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (Attribute obj : vosList) {
              selectionModel.setSelected(obj, value);
            }
          }
        });

    gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
    gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);

    TextColumn<Attribute> idColumn =
        new TextColumn<Attribute>() {
          @Override
          public String getValue(Attribute object) {
            return String.valueOf(object.getId());
          }
        };

    if (JsonUtils.isExtendedInfoVisible()) {
      gridTable.addColumn(idColumn, "Id", "Id");
      gridTable.setColumnWidth(idColumn, "90px");
    }

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Value column
    Column<Attribute, Attribute> valueColumn =
        JsonUtils.addColumn(
            new PerunAttributeValueCell(),
            new FieldUpdater<Attribute, Attribute>() {
              public void update(int index, Attribute object, Attribute value) {
                object = value;
                selectionModel.setSelected(object, object.isAttributeValid());
              }
            });

    ColumnSortEvent.ListHandler<Attribute> columnSortHandler =
        new ColumnSortEvent.ListHandler<Attribute>(vosList);
    gridTable.addColumnSortHandler(columnSortHandler);

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    gridTable.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    gridTable.setColumnWidth(nameColumn, 200.0, Style.Unit.PX);
    gridTable.setColumnWidth(valueColumn, 420.0, Style.Unit.PX);

    gridTable.addColumn(nameColumn, "Name");
    gridTable.addColumn(valueColumn, "Value");
    gridTable.addColumn(descriptionColumn, "Description");

    TabMenu tabMenu = new TabMenu();

    tabMenu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().addTabToCurrentTab(new TestDataGridTabItem(), true);
              }
            }));

    ft.addNorth(tabMenu, 50);
    ft.add(gridTable);

    return getWidget();
  }
예제 #11
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();
  }
예제 #12
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();
  }
예제 #13
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();
  }
예제 #14
0
  /**
   * Return table with tasks
   *
   * @return table widget
   */
  public CellTable<Task> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Task>(list);

    // Cell table
    table = new PerunTable<Task>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Task> columnSortHandler = new ListHandler<Task>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Task>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // checkbox column column
    table.addCheckBoxColumn();

    table.addIdColumn("Task Id", tableFieldUpdater);

    // Service column
    Column<Task, String> serviceColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getExecService().getService().getName());
              }
            },
            tableFieldUpdater);

    // Service Type column
    Column<Task, String> serviceTypeColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getExecService().getType());
              }
            },
            tableFieldUpdater);

    // status column
    Column<Task, String> statusColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getStatus());
              }
            },
            tableFieldUpdater);

    // start COLUMN
    TextColumn<Task> startTimeColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getStartTime();
          }
        };

    // end COLUMN
    TextColumn<Task> endTimeColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getEndTime();
          }
        };

    // schedule COLUMN
    TextColumn<Task> scheduleColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getSchedule();
          }
        };

    // Add the columns.
    table.addColumn(serviceColumn, "Service");
    table.addColumn(serviceTypeColumn, "Type");
    table.addColumn(statusColumn, "Status");
    table.addColumn(scheduleColumn, "Scheduled");
    table.addColumn(startTimeColumn, "Started");
    table.addColumn(endTimeColumn, "Ended");

    // set row styles based on task state
    table.setRowStyles(
        new RowStyles<Task>() {
          public String getStyleNames(Task row, int rowIndex) {

            if (row.getStatus().equalsIgnoreCase("NONE")) {
              return "rowdarkgreen";
            } else if (row.getStatus().equalsIgnoreCase("DONE")) {
              return "rowgreen";
            } else if (row.getStatus().equalsIgnoreCase("PROCESSING")) {
              return "rowyellow";
            } else if (row.getStatus().equalsIgnoreCase("ERROR")) {
              return "rowred";
            }
            return "";
          }
        });

    return table;
  }
예제 #15
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;
  }
예제 #16
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;
  }
 /**
  * Return selected items from list
  *
  * @return return list of checked items
  */
 public ArrayList<Publication> getTableSelectedList() {
   return JsonUtils.setToList(selectionModel.getSelectedSet());
 }
예제 #18
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();
  }
예제 #19
0
  public Widget draw() {

    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()));

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

    AbsolutePanel dp = new AbsolutePanel();
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);

    // Add facility information
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.databaseServerIcon()));
    Label facilityName = new Label();
    facilityName.setText(Utils.getStrippedStringWithEllipsis(facility.getName(), 40));
    facilityName.setStyleName("now-managing");
    facilityName.setTitle(facility.getName());
    menu.setWidget(0, 1, facilityName);

    menu.setHTML(0, 2, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");

    int column = 3;

    final JsonCallbackEvents events =
        new JsonCallbackEvents() {
          public void onFinished(JavaScriptObject jso) {
            new GetEntityById(
                    PerunEntity.FACILITY,
                    facilityId,
                    new JsonCallbackEvents() {
                      public void onFinished(JavaScriptObject jso) {
                        facility = jso.cast();
                        open();
                        draw();
                      }
                    })
                .retrieveData();
          }
        };

    CustomButton change =
        new CustomButton(
            "",
            ButtonTranslation.INSTANCE.editFacilityDetails(),
            SmallIcons.INSTANCE.applicationFormEditIcon());
    change.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // prepare confirm content
            session
                .getTabManager()
                .addTabToCurrentTab(new EditFacilityDetailsTabItem(facility, events));
          }
        });
    menu.setWidget(0, column, change);

    column++;

    menu.setHTML(0, column, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, column, "25px");
    column++;

    if (JsonUtils.isExtendedInfoVisible()) {
      menu.setHTML(
          0,
          column,
          "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">"
              + facility.getId()
              + "</span>");
      column++;
      menu.setHTML(0, column, "&nbsp;");
      menu.getFlexCellFormatter().setWidth(0, column, "25px");
      column++;
    }

    menu.setHTML(
        0,
        column,
        "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">"
            + facility.getDescription()
            + "&nbsp;</span>");

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

    // TAB PANEL

    tabPanel.clear();
    tabPanel.add(new FacilityResourcesTabItem(facility), "Resources");
    tabPanel.add(new FacilityAllowedGroupsTabItem(facility), "Allowed Groups");
    tabPanel.add(new FacilityStatusTabItem(facility), "Services status");
    tabPanel.add(new FacilitySettingsTabItem(facility), "Services settings");
    tabPanel.add(new FacilityDestinationsTabItem(facility), "Services destinations");
    tabPanel.add(new FacilityHostsTabItem(facility), "Hosts");
    tabPanel.add(new FacilityManagersTabItem(facility), "Managers");
    tabPanel.add(new FacilitySecurityTeamsTabItem(facility), "Security teams");
    tabPanel.add(new FacilityBlacklistTabItem(facility), "Blacklist");
    tabPanel.add(new FacilityOwnersTabItem(facility), "Owners");

    // Resize must be called after page fully displays
    Scheduler.get()
        .scheduleDeferred(
            new Command() {
              @Override
              public void execute() {
                tabPanel.finishAdding();
              }
            });

    vp.add(tabPanel);

    this.contentWidget.setWidget(vp);
    return getWidget();
  }
  /**
   * Returns table with publications
   *
   * @return table
   */
  public CellTable<Publication> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);

    // Cell table
    table = new PerunTable<Publication>(list);
    table.removeRowCountChangeHandler();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Publication> columnSortHandler =
        new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(
        loaderImage.prepareToSearch(
            "Please select external pub. system and year range to search for publications for import."));

    // show checkbox column
    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    /*
    // CATEGORY COLUMN
    ArrayList<String> categories = new ArrayList<String>();
    categories.add("Bodované v RIVu");
    categories.add("Nebodované v RIVu");
    categories.add("Příspěvek do ročenky");
    categories.add("Výjimečné výsledky");
    categories.add("Jiné");

    Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
    	@Override
    	public String getValue(Publication object) {
    		// category ID as string, 0 if not set
    		int id = object.getCategoryId();
    		if (id == 0) {
    			// set default == 21/Bodované v RIVu to object
    			object.setCategoryId(21);
    		}
    		if (id == 21) {
    			return "Bodované v RIVu";
    		} else if (id == 22) {
    			return "Nebodované v RIVu";
    		} else if (id == 23) {
    			return "Výjimečné výsledky";
    		} else if (id == 24) {
    			return "Příspěvek do ročenky";
    		} else if (id == 25) {
    			return "Jiné";
    		} else {
    			return String.valueOf(id); // return ID if no match
    		}
    	}
    };
    categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
    	public void update(int index, Publication object, String value) {

    		int id = 0;
    		if (value.equalsIgnoreCase("Bodované v RIVu")) {
    			id = 21;
    		} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
    			id = 22;
    		} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
    			id = 24;
    		} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
    			id = 23;
    		} else if (value.equalsIgnoreCase("Jiné")) {
    			id = 25;
    		}
    		object.setCategoryId(id);
    		selectionModel.setSelected(object, true);

    	}
    });
    table.addColumn(categoryColumn, "Category");

    // NOT USEFULL => DISABLED
    // EXTERNAL ID
    TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
    	public String getValue(Publication object) {
    		return String.valueOf(object.getExternalId());
    	};
    };
    externalIdColumn.setSortable(true);
    columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
    table.addColumn(externalIdColumn, "External Id");
     */

    // TITLE COLUMN
    TextColumn<Publication> titleColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getTitle();
          };
        };
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(
        titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");

    // AUTHORS COLUMN
    TextColumn<Publication> authorColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getAuthorsFormatted();
          };
        };
    authorColumn.setSortable(true);
    columnSortHandler.setComparator(
        authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
    table.addColumn(authorColumn, "Authors");

    // YEAR COLUMN
    TextColumn<Publication> yearColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return String.valueOf(object.getYear());
          };
        };
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(
        yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");

    // ISBN COLUMN
    TextColumn<Publication> isbnColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getIsbn();
          };
        };
    isbnColumn.setSortable(true);
    columnSortHandler.setComparator(
        isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
    table.addColumn(isbnColumn, "ISBN");

    // CITE COLUMN
    Column<Publication, String> citaceColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Publication, String>() {
              public String getValue(Publication object) {
                return "Cite";
              }
            },
            new FieldUpdater<Publication, String>() {
              public void update(int index, Publication object, String value) {
                SimplePanel sp = new SimplePanel();
                sp.add(new HTML(object.getMain()));
                Confirm cf = new Confirm("Cite publication", sp, true);
                cf.show();
              };
            });

    table.addColumn(citaceColumn, "Cite");

    return table;
  }
예제 #21
0
파일: Attribute.java 프로젝트: Holdo/perun
 public final Map<String, JSONValue> getValueAsMap() {
   return JsonUtils.parseJsonToMap(getValueAsJso());
 }
예제 #22
0
  /**
   * Returns the table with member-Groups
   *
   * @return CellTable widget
   */
  public CellTable<Group> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);

    // Cell table
    table = new PerunTable<Group>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage(
          "VO has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage(
          "Group has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no groups of managers (try to switch to 'Users' view).");
    }

    // Checkbox column column
    table.addCheckBoxColumn();

    // Create Group ID column.
    Column<Group, String> groupIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Group, String>() {
              public String getValue(Group object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    groupIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        groupIdColumn, new GeneralComparator<Group>(GeneralComparator.Column.ID));

    table.setColumnWidth(groupIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(groupIdColumn, "Group ID");
    }

    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);

    return table;
  }
예제 #23
0
  /**
   * Returns the table with member-users
   *
   * @return CellTable widget
   */
  public CellTable<User> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<User>(list);

    // Cell table
    table = new PerunTable<User>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage("VO has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage("Group has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.SECURITY_TEAM)) {
      loaderImage.setEmptyResultMessage(
          "SecurityTeam has no members (try to switch to 'Groups' view).");
    }

    // Sorting
    ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // Checkbox column column
    if (checkable) {
      table.addCheckBoxColumn();
    }

    // Create User ID column.
    Column<User, String> userIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        userIdColumn, new GeneralComparator<User>(GeneralComparator.Column.ID));

    table.setColumnWidth(userIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(userIdColumn, "User ID");
    }

    table.setHyperlinksAllowed(false);
    table.addNameColumn(tableFieldUpdater);

    // Create organization column.
    Column<User, String> organizationColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue();
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create e-mail column.
    Column<User, String> emailColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at =
                    object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue().replace(",", " ");
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create name column.
    Column<User, String> loginsColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return object.getLogins();
              }
            },
            this.tableFieldUpdater);

    organizationColumn.setSortable(true);
    columnSortHandler.setComparator(
        organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));

    emailColumn.setSortable(true);
    columnSortHandler.setComparator(
        emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));

    // Add the other columns.
    table.addColumn(organizationColumn, "Organization");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginsColumn, "Logins");

    return table;
  }