use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class AutomaticRenamingDialog method createUIComponents.
private void createUIComponents() {
myTable = new JBTable();
myTable.setRowHeight(myTable.getFontMetrics(UIManager.getFont("Table.font").deriveFont(Font.BOLD)).getHeight() + 4);
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class PerFileConfigurableBase method createComponent.
@NotNull
@Override
public JComponent createComponent() {
//todo multi-editing, separate project/ide combos _if_ needed by specific configurable (SQL, no Web)
myPanel = new JPanel(new BorderLayout());
myTable = new JBTable(myModel = new MyModel<>(param(TARGET_TITLE), param(MAPPING_TITLE))) {
@Override
public String getToolTipText(@NotNull MouseEvent event) {
Point point = event.getPoint();
int row = rowAtPoint(point);
int col = columnAtPoint(point);
if (row != -1 && col == 1) {
return getToolTipFor((T) getValueAt(convertRowIndexToModel(row), col));
}
return super.getToolTipText(event);
}
};
setupPerFileTable();
JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).disableUpAction().disableDownAction().setAddAction(button -> doAddAction(button)).setRemoveAction(button -> doRemoveAction(button)).setEditAction(button -> doEditAction(button)).setEditActionUpdater(e -> myTable.getSelectedRows().length > 0).createPanel();
myTable.getEmptyText().setText(param(EMPTY_TEXT).replace("$addShortcut", KeymapUtil.getFirstKeyboardShortcutText(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD))));
JBLabel label = new JBLabel(param(DESCRIPTION));
label.setBorder(BorderFactory.createEmptyBorder(TITLED_BORDER_TOP_INSET, TITLED_BORDER_INDENT, TITLED_BORDER_BOTTOM_INSET, 0));
label.setComponentStyle(UIUtil.ComponentStyle.SMALL);
JComponent north = createDefaultMappingComponent();
if (north != null) {
myPanel.add(north, BorderLayout.NORTH);
}
myPanel.add(label, BorderLayout.SOUTH);
myPanel.add(tablePanel, BorderLayout.CENTER);
return myPanel;
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class JavaChangeSignatureDialog method createAdditionalPanels.
@NotNull
protected List<Pair<String, JPanel>> createAdditionalPanels() {
// this method is invoked before constructor body
myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList());
myExceptionsModel.setTypeInfos(myMethod.getMethod());
final JBTable table = new JBTable(myExceptionsModel);
table.setStriped(true);
table.setRowHeight(20);
table.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
final JavaCodeFragmentTableCellEditor cellEditor = new JavaCodeFragmentTableCellEditor(myProject);
cellEditor.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
final int row = table.getSelectedRow();
final int col = table.getSelectedColumn();
myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col);
updateSignature();
}
});
table.getColumnModel().getColumn(0).setCellEditor(cellEditor);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().setSelectionInterval(0, 0);
table.setSurrendersFocusOnKeystroke(true);
myPropExceptionsButton = new AnActionButton(RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, AllIcons.Hierarchy.Caller) {
@Override
public void actionPerformed(AnActionEvent e) {
final Ref<JavaCallerChooser> chooser = new Ref<>();
Consumer<Set<PsiMethod>> callback = psiMethods -> {
myMethodsToPropagateExceptions = psiMethods;
myExceptionPropagationTree = chooser.get().getTree();
};
chooser.set(new JavaCallerChooser(myMethod.getMethod(), myProject, RefactoringBundle.message("changeSignature.exception.caller.chooser"), myExceptionPropagationTree, callback));
chooser.get().show();
}
};
myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X"));
final JPanel panel = ToolbarDecorator.createDecorator(table).addExtraAction(myPropExceptionsButton).createPanel();
panel.setBorder(IdeBorderFactory.createEmptyBorder());
myExceptionsModel.addTableModelListener(mySignatureUpdater);
final ArrayList<Pair<String, JPanel>> result = new ArrayList<>();
final String message = RefactoringBundle.message("changeSignature.exceptions.panel.border.title");
result.add(Pair.create(message, panel));
return result;
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class EncapsulateFieldsDialog method createTable.
private JComponent createTable() {
myTableModel = new MyTableModel();
myTable = new JBTable(myTableModel);
myTable.setSurrendersFocusOnKeystroke(true);
MyTableRenderer renderer = new MyTableRenderer();
TableColumnModel columnModel = myTable.getColumnModel();
columnModel.getColumn(CHECKED_COLUMN).setCellRenderer(new BooleanTableCellRenderer());
columnModel.getColumn(FIELD_COLUMN).setCellRenderer(renderer);
columnModel.getColumn(GETTER_COLUMN).setCellRenderer(renderer);
columnModel.getColumn(SETTER_COLUMN).setCellRenderer(renderer);
TableUtil.setupCheckboxColumn(columnModel.getColumn(CHECKED_COLUMN));
myTable.setPreferredScrollableViewportSize(new Dimension(550, myTable.getRowHeight() * 12));
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
// JLabel label = new JLabel("Fields to Encapsulate");
// CompTitledBorder titledBorder = new CompTitledBorder(label);
JPanel panel = new JPanel(new BorderLayout());
Border border = IdeBorderFactory.createTitledBorder(RefactoringBundle.message("encapsulate.fields.fields.to.encapsulate.border.title"), false);
panel.setBorder(border);
panel.add(scrollPane);
// make ESC and ENTER work when focus is in the table
myTable.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TableCellEditor editor = myTable.getCellEditor();
if (editor != null) {
editor.cancelCellEditing();
} else {
doCancelAction();
}
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
// make SPACE check/uncheck selected rows
@NonNls InputMap inputMap = myTable.getInputMap();
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
@NonNls ActionMap actionMap = myTable.getActionMap();
actionMap.put("enable_disable", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (myTable.isEditing())
return;
int[] rows = myTable.getSelectedRows();
if (rows.length > 0) {
boolean valueToBeSet = false;
for (int row : rows) {
if (!myCheckedMarks[row]) {
valueToBeSet = true;
break;
}
}
for (int row : rows) {
myCheckedMarks[row] = valueToBeSet;
}
myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]);
TableUtil.selectRows(myTable, rows);
}
}
});
// make ENTER work when the table has focus
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl");
actionMap.put("invokeImpl", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
TableCellEditor editor = myTable.getCellEditor();
if (editor != null) {
editor.stopCellEditing();
} else {
clickDefaultButton();
}
}
});
return panel;
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class ChangeClassSignatureDialog method createCenterPanel.
protected JComponent createCenterPanel() {
myTable = new JBTable(myTableModel);
myTable.setStriped(true);
TableColumn nameColumn = myTable.getColumnModel().getColumn(NAME_COLUMN);
TableColumn boundColumn = myTable.getColumnModel().getColumn(BOUND_VALUE_COLUMN);
TableColumn valueColumn = myTable.getColumnModel().getColumn(DEFAULT_VALUE_COLUMN);
Project project = myClass.getProject();
nameColumn.setCellRenderer(new MyCellRenderer());
nameColumn.setCellEditor(new StringTableCellEditor(project));
boundColumn.setCellRenderer(new MyCodeFragmentTableCellRenderer());
boundColumn.setCellEditor(new JavaCodeFragmentTableCellEditor(project));
valueColumn.setCellRenderer(new MyCodeFragmentTableCellRenderer());
valueColumn.setCellEditor(new JavaCodeFragmentTableCellEditor(project));
myTable.setPreferredScrollableViewportSize(new Dimension(210, myTable.getRowHeight() * 4));
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.getSelectionModel().setSelectionInterval(0, 0);
myTable.setSurrendersFocusOnKeystroke(true);
myTable.setCellSelectionEnabled(true);
myTable.setFocusCycleRoot(true);
if (myHideDefaultValueColumn) {
final TableColumn defaultValue = myTable.getColumnModel().getColumn(DEFAULT_VALUE_COLUMN);
myTable.removeColumn(defaultValue);
myTable.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.INSERT) {
myTable.getModel().removeTableModelListener(this);
final TableColumnAnimator animator = new TableColumnAnimator(myTable);
animator.setStep(20);
animator.addColumn(defaultValue, myTable.getWidth() / 2);
animator.startAndDoWhenDone(() -> myTable.editCellAt(myTable.getRowCount() - 1, 0));
animator.start();
}
}
});
}
final JPanel panel = new JPanel(new BorderLayout());
panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title"), myTable), BorderLayout.NORTH);
panel.add(ToolbarDecorator.createDecorator(myTable).createPanel(), BorderLayout.CENTER);
return panel;
}
Aggregations