Ejemplo n.º 1
0
 private void moveSelectedRows(int increment) {
   if (increment == 0) {
     return;
   }
   if (myEntryTable.isEditing()) {
     myEntryTable.getCellEditor().stopCellEditing();
   }
   final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
   for (int row = increment < 0 ? 0 : myModel.getRowCount() - 1;
       increment < 0 ? row < myModel.getRowCount() : row >= 0;
       row += increment < 0 ? +1 : -1) {
     if (selectionModel.isSelectedIndex(row)) {
       final int newRow = moveRow(row, increment);
       selectionModel.removeSelectionInterval(row, row);
       selectionModel.addSelectionInterval(newRow, newRow);
     }
   }
   myModel.fireTableRowsUpdated(0, myModel.getRowCount() - 1);
   Rectangle cellRect = myEntryTable.getCellRect(selectionModel.getMinSelectionIndex(), 0, true);
   if (cellRect != null) {
     myEntryTable.scrollRectToVisible(cellRect);
   }
   myEntryTable.repaint();
   myListeners.getMulticaster().entryMoved();
 }
Ejemplo n.º 2
0
  @Override
  public void addItems(List<ClasspathTableItem<?>> toAdd) {
    for (ClasspathTableItem<?> item : toAdd) {
      myModel.addItem(item);
    }
    myModel.fireTableDataChanged();
    final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
    selectionModel.setSelectionInterval(
        myModel.getRowCount() - toAdd.size(), myModel.getRowCount() - 1);
    TableUtil.scrollSelectionToVisible(myEntryTable);

    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
  @Override
  public void addItems(List<ClasspathTableItem<?>> toAdd) {
    for (ClasspathTableItem<?> item : toAdd) {
      myModel.addRow(item);
    }
    TIntArrayList toSelect = new TIntArrayList();
    for (int i = myModel.getRowCount() - toAdd.size(); i < myModel.getRowCount(); i++) {
      toSelect.add(myEntryTable.convertRowIndexToView(i));
    }
    TableUtil.selectRows(myEntryTable, toSelect.toNativeArray());
    TableUtil.scrollSelectionToVisible(myEntryTable);

    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
 private void moveSelectedRows(int increment) {
   LOG.assertTrue(increment == -1 || increment == 1);
   if (myEntryTable.isEditing()) {
     myEntryTable.getCellEditor().stopCellEditing();
   }
   final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
   for (int row = increment < 0 ? 0 : myModel.getRowCount() - 1;
       increment < 0 ? row < myModel.getRowCount() : row >= 0;
       row += increment < 0 ? +1 : -1) {
     if (selectionModel.isSelectedIndex(row)) {
       final int newRow = moveRow(row, increment);
       selectionModel.removeSelectionInterval(row, row);
       selectionModel.addSelectionInterval(newRow, newRow);
     }
   }
   Rectangle cellRect = myEntryTable.getCellRect(selectionModel.getMinSelectionIndex(), 0, true);
   myEntryTable.scrollRectToVisible(cellRect);
   myEntryTable.repaint();
 }
 public void selectOrderEntry(@NotNull OrderEntry entry) {
   for (int row = 0; row < myModel.getRowCount(); row++) {
     final OrderEntry orderEntry = getItemAt(row).getEntry();
     if (orderEntry != null
         && entry.getPresentableName().equals(orderEntry.getPresentableName())) {
       myEntryTable.getSelectionModel().setSelectionInterval(row, row);
       TableUtil.scrollSelectionToVisible(myEntryTable);
     }
   }
   IdeFocusManager.getInstance(myState.getProject()).requestFocus(myEntryTable, true);
 }
Ejemplo n.º 6
0
 public List<OrderEntry> getEntries() {
   final int count = myModel.getRowCount();
   final List<OrderEntry> entries = new ArrayList<OrderEntry>(count);
   for (int row = 0; row < count; row++) {
     final OrderEntry entry = myModel.getItemAt(row).getEntry();
     if (entry != null) {
       entries.add(entry);
     }
   }
   return entries;
 }
 public void forceInitFromModel() {
   Set<ClasspathTableItem<?>> oldSelection = new HashSet<ClasspathTableItem<?>>();
   for (int i : myEntryTable.getSelectedRows()) {
     ContainerUtil.addIfNotNull(getItemAt(i), oldSelection);
   }
   myModel.clear();
   myModel.init();
   myModel.fireTableDataChanged();
   TIntArrayList newSelection = new TIntArrayList();
   for (int i = 0; i < myModel.getRowCount(); i++) {
     if (oldSelection.contains(getItemAt(i))) {
       newSelection.add(i);
     }
   }
   TableUtil.selectRows(myEntryTable, newSelection.toNativeArray());
 }
 private int moveRow(final int row, final int increment) {
   int newIndex = Math.abs(row + increment) % myModel.getRowCount();
   myModel.exchangeRows(row, newIndex);
   return newIndex;
 }
Ejemplo n.º 9
0
 private int moveRow(final int row, final int increment) {
   int newIndex = Math.abs(row + increment) % myModel.getRowCount();
   final ClasspathTableItem<?> item = myModel.removeDataRow(row);
   myModel.addItemAt(item, newIndex);
   return newIndex;
 }