use of com.intellij.xdebugger.impl.ui.XDebuggerExpressionEditor in project intellij-community by JetBrains.
the class CompoundRendererConfigurable method createChildrenListEditor.
private JComponent createChildrenListEditor(JavaDebuggerEditorsProvider editorsProvider) {
final MyTableModel tableModel = new MyTableModel();
myTable = new JBTable(tableModel);
myListChildrenEditor = new XDebuggerExpressionEditor(myProject, editorsProvider, "NamedChildrenConfigurable", null, XExpressionImpl.EMPTY_EXPRESSION, false, false, false);
JComponent editorComponent = myListChildrenEditor.getComponent();
AbstractTableCellEditor editor = new AbstractTableCellEditor() {
@Override
public Object getCellEditorValue() {
return TextWithImportsImpl.fromXExpression(myListChildrenEditor.getExpression());
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
myListChildrenEditor.setExpression(TextWithImportsImpl.toXExpression((TextWithImports) value));
return editorComponent;
}
};
editorComponent.registerKeyboardAction(e -> editor.stopCellEditing(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
editorComponent.registerKeyboardAction(e -> editor.cancelCellEditing(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
TableColumn exprColumn = myTable.getColumnModel().getColumn(EXPRESSION_TABLE_COLUMN);
exprColumn.setCellEditor(editor);
exprColumn.setCellRenderer(new DefaultTableCellRenderer() {
@NotNull
@Override
public Component getTableCellRendererComponent(@NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final TextWithImports textWithImports = (TextWithImports) value;
final String text = (textWithImports != null) ? textWithImports.getText() : "";
return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
}
});
return ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
tableModel.addRow("", DebuggerUtils.getInstance().createExpressionWithImports(""));
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int selectedRow = myTable.getSelectedRow();
if (selectedRow >= 0 && selectedRow < myTable.getRowCount()) {
getTableModel().removeRow(selectedRow);
}
}
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsUp(myTable);
}
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsDown(myTable);
}
}).createPanel();
}
Aggregations