Esempio n. 1
0
  /**
   * Gets the selected rows model indexes.
   *
   * @param table the table.
   * @return the model indexes.
   */
  public static List<Integer> getSelectedModelIndexes(JTable table) {

    Assert.notNull(table, TableUtils.TABLE);

    final List<Integer> viewIndexes = TableUtils.getSelectedViewIndexes(table);
    final List<Integer> modelIndexes = TableUtils.getModelIndexes(table, viewIndexes);

    return modelIndexes;
  }
Esempio n. 2
0
  /**
   * Changes selection.
   *
   * <p>This method ensures listeners are invoked just once.
   *
   * @param <Q> the type of the rows.
   * @param table the table.
   * @param tableModel the table model.
   * @param newSelection the entities to be selected. If any entity does not belong to entities
   *     currently being shown then it is ignored.
   * @see #changeSelection(JTable, List)
   */
  public static <Q> void changeSelection(
      final JTable table, final GlazedTableModel tableModel, final List<Q> newSelection) {

    Assert.notNull(table, TableUtils.TABLE);
    Assert.notNull(tableModel, TableUtils.TABLE_MODEL);
    Assert.notNull(newSelection, "entities");

    // Calculate view indexes and call overloaded method
    final List<Integer> modelIndexes = TableUtils.getModelIndexes(tableModel, newSelection);
    final List<Integer> viewIndexes = TableUtils.getViewIndexes(table, modelIndexes);

    TableUtils.changeSelection(table, viewIndexes);
  }