use of com.intellij.util.ui.ItemRemovable in project intellij-community by JetBrains.
the class TableUtil method removeSelectedItems.
@NotNull
public static List<Object[]> removeSelectedItems(@NotNull JTable table, @Nullable ItemChecker applyable) {
final TableModel model = table.getModel();
if (!(model instanceof ItemRemovable)) {
throw new RuntimeException("model must be instance of ItemRemovable");
}
if (table.getSelectionModel().isSelectionEmpty()) {
return new ArrayList<Object[]>(0);
}
final List<Object[]> removedItems = new SmartList<Object[]>();
final ItemRemovable itemRemovable = (ItemRemovable) model;
final int columnCount = model.getColumnCount();
doRemoveSelectedItems(table, new ItemRemovable() {
@Override
public void removeRow(int index) {
Object[] row = new Object[columnCount];
for (int column = 0; column < columnCount; column++) {
row[column] = model.getValueAt(index, column);
}
removedItems.add(row);
itemRemovable.removeRow(index);
}
}, applyable);
return ContainerUtil.reverse(removedItems);
}
Aggregations