public void setAllElementsMarked(boolean marked) { final int[] rows = new int[myTableModel.getRowCount()]; for (int idx = 0; idx < rows.length; idx++) { rows[idx] = idx; } myTableModel.setMarked(rows, marked); }
@NotNull public List<T> getMarkedElements() { final int count = myTableModel.getRowCount(); List<T> elements = new ArrayList<T>(); for (int idx = 0; idx < count; idx++) { final T element = myTableModel.getElementAt(idx); if (myTableModel.isElementMarked(idx)) { elements.add(element); } } return elements; }
public void moveElement(T element, int newRow) { final int elementRow = myTableModel.getElementRow(element); if (elementRow < 0 || elementRow == newRow || newRow < 0 || newRow >= myTableModel.getRowCount()) { return; } final boolean wasSelected = myTable.getSelectionModel().isSelectedIndex(elementRow); myTableModel.changeElementRow(element, newRow); if (wasSelected) { selectRow(newRow); } }
public void removeElement(T element) { final int elementRow = myTableModel.getElementRow(element); if (elementRow < 0) { return; // no such element } final boolean wasSelected = myTable.getSelectionModel().isSelectedIndex(elementRow); myTableModel.removeElement(element); myElementToPropertiesMap.remove(element); if (wasSelected) { final int rowCount = myTableModel.getRowCount(); if (rowCount > 0) { selectRow(elementRow % rowCount); } else { myTable.getSelectionModel().clearSelection(); } } myTable.requestFocus(); }
public int getElementCount() { return myTableModel.getRowCount(); }
public void addElement(T element, final boolean isMarked, ElementProperties elementProperties) { myTableModel.addElement(element, isMarked); myElementToPropertiesMap.put(element, elementProperties); selectRow(myTableModel.getRowCount() - 1); myTable.requestFocus(); }