Exemplo 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();
 }
Exemplo 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()));
  }
 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();
 }
Exemplo n.º 4
0
 @Override
 public void actionPerformed(AnActionEvent e) {
   final DataContext dataContext = e.getDataContext();
   final Project project = DataKeys.PROJECT.getData(dataContext);
   if (project == null) {
     return;
   }
   final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
   final TreeClassChooser classChooser =
       chooserFactory.createWithInnerClassesScopeChooser(
           chooserTitle, GlobalSearchScope.allScope(project), myFilter, null);
   classChooser.showDialog();
   final PsiClass selectedClass = classChooser.getSelected();
   if (selectedClass == null) {
     return;
   }
   final String qualifiedName = selectedClass.getQualifiedName();
   final ListWrappingTableModel tableModel = table.getModel();
   final int index = tableModel.indexOf(qualifiedName, 0);
   final int rowIndex;
   if (index < 0) {
     tableModel.addRow(qualifiedName);
     rowIndex = tableModel.getRowCount() - 1;
   } else {
     rowIndex = index;
   }
   final ListSelectionModel selectionModel = table.getSelectionModel();
   selectionModel.setSelectionInterval(rowIndex, rowIndex);
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           final Rectangle rectangle = table.getCellRect(rowIndex, 0, true);
           table.scrollRectToVisible(rectangle);
         }
       });
 }