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);
 }
 public List<Pair<Module, String>> getAllModules() {
   final int count = myTableModel.getRowCount();
   List<Pair<Module, String>> elements = new ArrayList<Pair<Module, String>>();
   for (int idx = 0; idx < count; idx++) {
     final Module module = myTableModel.getModuleAt(idx);
     elements.add(Pair.create(module, myTableModel.getGenDirName(module)));
   }
   return elements;
 }
 @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);
   }
 }
Ejemplo n.º 5
0
 public void actionPerformed(ActionEvent e) {
   VirtualFile[] files = getFiles();
   final MyTableModel tableModel = (MyTableModel) myTable.getModel();
   boolean changes = false;
   for (final VirtualFile file : files) {
     if (file != null) {
       tableModel.addTableItem(new TableItem(file));
       changes = true;
     }
   }
   if (changes) {
     saveData();
     TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
   }
 }
  public void removeModule(Module element) {
    final int elementRow = myTableModel.getElementRow(element);
    if (elementRow < 0) {
      return; // no such element
    }
    final boolean wasSelected = myTable.getSelectionModel().isSelectedIndex(elementRow);

    myTableModel.removeElement(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 addModule(Module element, String dirName) {
   myTableModel.addElement(element, dirName);
   selectRow(myTableModel.getRowCount() - 1);
   myTable.requestFocus();
 }
 public void addElement(T element, final boolean isMarked, ElementProperties elementProperties) {
   myTableModel.addElement(element, isMarked);
   myElementToPropertiesMap.put(element, elementProperties);
   selectRow(myTableModel.getRowCount() - 1);
   myTable.requestFocus();
 }