コード例 #1
0
ファイル: GetExtSources.java プロジェクト: papperwing/perun
  /**
   * Return table widget with external sources
   *
   * @return table widget containing ext sources
   */
  public CellTable<ExtSource> getTable() {

    // retrieve data
    retrieveData();

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

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

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

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

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

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No external sources found in Perun.");

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

    // ID column
    table.addIdColumn("Ext. source ID", null);

    // Name column
    table.addNameColumn(null);

    // Type column
    TextColumn<ExtSource> typeColumn =
        new TextColumn<ExtSource>() {
          @Override
          public String getValue(ExtSource extSource) {
            return String.valueOf(renameContent(extSource.getType()));
          }
        };
    table.addColumn(typeColumn, "Type");

    // return cellTable
    return table;
  }
コード例 #2
0
  /**
   * 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;
  }
コード例 #3
0
ファイル: GetAdminGroups.java プロジェクト: Holdo/perun
  /**
   * 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;
  }
コード例 #4
0
  /**
   * Returns empty table
   *
   * @return table widget
   */
  public CellTable<Destination> getEmptyTable() {

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

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

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

    if (showFac) {
      loaderImage.setEmptyResultMessage("Service has no destination.");
    } else {
      loaderImage.setEmptyResultMessage(
          "Facility has no services destinations. Service configuration can't be propagated.");
    }

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

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

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

    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    // add id column
    table.addIdColumn("Destination ID", null);

    // DESTINATION COLUMN
    TextColumn<Destination> destinationColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getDestination();
          }
        };

    // TYPE COLUMN
    TextColumn<Destination> typeColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getType().toUpperCase();
          }
        };

    // SERVICE COLUMN
    TextColumn<Destination> serviceColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getService().getName();
          }
        };

    // FACILITY COLUMN
    TextColumn<Destination> facilityColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getFacility().getName();
          }
        };

    destinationColumn.setSortable(true);
    columnSortHandler.setComparator(
        destinationColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getDestination().compareToIgnoreCase(o2.getDestination());
          }
        });

    typeColumn.setSortable(true);
    columnSortHandler.setComparator(
        typeColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getType().compareToIgnoreCase(o2.getType());
          }
        });

    serviceColumn.setSortable(true);
    columnSortHandler.setComparator(
        serviceColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getService().getName().compareToIgnoreCase(o2.getService().getName());
          }
        });

    facilityColumn.setSortable(true);
    columnSortHandler.setComparator(
        facilityColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getFacility().getName().compareToIgnoreCase(o2.getFacility().getName());
          }
        });

    // updates the columns size
    table.setColumnWidth(serviceColumn, 250.0, Unit.PX);
    table.setColumnWidth(facilityColumn, 250.0, Unit.PX);

    // Add the columns.

    if (showServ) {
      table.addColumn(serviceColumn, "Service");
    }
    if (showFac) {
      table.addColumn(facilityColumn, "Facility");
    }

    table.addColumn(destinationColumn, "Destination");
    table.addColumn(typeColumn, "Type");

    return table;
  }
コード例 #5
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;
  }
コード例 #6
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;
  }