use of com.intellij.codeInspection.ui.ListWrappingTableModel in project intellij-community by JetBrains.
the class UiUtils method createAddRemovePanel.
public static JPanel createAddRemovePanel(final ListTable table) {
final JPanel panel = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final ListWrappingTableModel tableModel = table.getModel();
tableModel.addRow();
EventQueue.invokeLater(() -> {
final int lastRowIndex = tableModel.getRowCount() - 1;
editTableCell(table, lastRowIndex, 0);
});
}
}).setRemoveAction(button -> TableUtil.removeSelectedItems(table)).disableUpDownActions().createPanel();
panel.setPreferredSize(JBUI.size(150, 100));
return panel;
}
use of com.intellij.codeInspection.ui.ListWrappingTableModel in project intellij-community by JetBrains.
the class UiUtils method createAddRemoveTreeClassChooserPanel.
public static JPanel createAddRemoveTreeClassChooserPanel(final ListTable table, final String chooserTitle, @NonNls String... ancestorClasses) {
final ClassFilter filter;
if (ancestorClasses.length == 0) {
filter = ClassFilter.ALL;
} else {
filter = new SubclassFilter(ancestorClasses);
}
final JPanel panel = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final DataContext dataContext = DataManager.getInstance().getDataContext(table);
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final int rowIndex;
final ListWrappingTableModel tableModel = table.getModel();
if (project == null) {
tableModel.addRow();
rowIndex = tableModel.getRowCount() - 1;
} else {
final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
final TreeClassChooser classChooser = chooserFactory.createWithInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null);
classChooser.showDialog();
final PsiClass selectedClass = classChooser.getSelected();
if (selectedClass == null) {
return;
}
final String qualifiedName = selectedClass.getQualifiedName();
final int index = tableModel.indexOf(qualifiedName, 0);
if (index < 0) {
tableModel.addRow(qualifiedName);
rowIndex = tableModel.getRowCount() - 1;
} else {
rowIndex = index;
}
}
editTableCell(table, rowIndex, table.getColumnCount() > 1 && project != null ? 1 : 0);
}
}).setRemoveAction(button -> TableUtil.removeSelectedItems(table)).disableUpDownActions().createPanel();
panel.setPreferredSize(JBUI.size(150, 100));
return panel;
}
Aggregations