Exemplo 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;
  }
Exemplo n.º 2
0
  /**
   * Refresh current selection.
   *
   * <p>This method ensures listeners are invoked just once.
   *
   * @param <Q> the type of the rows.
   * @param table the table.
   * @see #changeSelection(JTable, List, Boolean)
   */
  public static <Q> void refreshSelection(final JTable table) {

    Assert.notNull(table, "table");

    final List<Integer> selectedViewIndexes = TableUtils.getSelectedViewIndexes(table);

    // (JAF), 20110116, clear selection before turning on valueIsAdjusting, otherwise listeners may
    // not be notified
    table.clearSelection();

    TableUtils.changeSelection(table, selectedViewIndexes, Boolean.TRUE);
  }