コード例 #1
0
 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);
 }
コード例 #2
0
 @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;
 }
コード例 #3
0
 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);
   }
 }
コード例 #4
0
  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();
  }
コード例 #5
0
 public int getElementCount() {
   return myTableModel.getRowCount();
 }
コード例 #6
0
 public void addElement(T element, final boolean isMarked, ElementProperties elementProperties) {
   myTableModel.addElement(element, isMarked);
   myElementToPropertiesMap.put(element, elementProperties);
   selectRow(myTableModel.getRowCount() - 1);
   myTable.requestFocus();
 }