use of com.intellij.debugger.engine.evaluation.TextWithImports 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();
}
use of com.intellij.debugger.engine.evaluation.TextWithImports in project intellij-community by JetBrains.
the class CompoundRendererConfigurable method reset.
public void reset() {
final TextWithImports emptyExpressionFragment = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
((CardLayout) getLayout()).show(this, myRenderer == null ? EMPTY_PANEL_ID : DATA_PANEL_ID);
if (myRenderer == null) {
return;
}
final String className = myRenderer.getClassName();
myClassNameField.setText(className);
updateContext(className);
final ValueLabelRenderer labelRenderer = myRenderer.getLabelRenderer();
final ChildrenRenderer childrenRenderer = myRenderer.getChildrenRenderer();
myShowTypeCheckBox.setSelected(myRenderer.isShowType());
if (myRenderer.isBaseRenderer(labelRenderer)) {
myLabelEditor.setExpression(TextWithImportsImpl.toXExpression(emptyExpressionFragment));
myRbDefaultLabel.setSelected(true);
} else {
myRbExpressionLabel.setSelected(true);
myLabelEditor.setExpression(TextWithImportsImpl.toXExpression(((LabelRenderer) labelRenderer).getLabelExpression()));
}
getTableModel().clear();
myAppendDefaultChildren.setSelected(false);
if (myRenderer.isBaseRenderer(childrenRenderer)) {
myRbDefaultChildrenRenderer.setSelected(true);
myChildrenEditor.setExpression(TextWithImportsImpl.toXExpression(emptyExpressionFragment));
myChildrenExpandedEditor.setExpression(TextWithImportsImpl.toXExpression(emptyExpressionFragment));
} else if (childrenRenderer instanceof ExpressionChildrenRenderer) {
myRbExpressionChildrenRenderer.setSelected(true);
final ExpressionChildrenRenderer exprRenderer = (ExpressionChildrenRenderer) childrenRenderer;
myChildrenEditor.setExpression(TextWithImportsImpl.toXExpression(exprRenderer.getChildrenExpression()));
myChildrenExpandedEditor.setExpression(TextWithImportsImpl.toXExpression(exprRenderer.getChildrenExpandable()));
} else {
myRbListChildrenRenderer.setSelected(true);
myChildrenEditor.setExpression(TextWithImportsImpl.toXExpression(emptyExpressionFragment));
myChildrenExpandedEditor.setExpression(TextWithImportsImpl.toXExpression(emptyExpressionFragment));
if (childrenRenderer instanceof EnumerationChildrenRenderer) {
EnumerationChildrenRenderer enumerationRenderer = (EnumerationChildrenRenderer) childrenRenderer;
getTableModel().init(enumerationRenderer.getChildren());
myAppendDefaultChildren.setSelected(enumerationRenderer.isAppendDefaultChildren());
}
}
updateEnabledState();
}
use of com.intellij.debugger.engine.evaluation.TextWithImports in project intellij-community by JetBrains.
the class DebuggerTreeCreatorImpl method createDescriptorByNode.
@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
if (node instanceof DebuggerTreeNodeImpl) {
final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {
@Override
public void threadAction() {
try {
final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
} catch (EvaluateException e) {
resultConsumer.onFailure(e);
}
}
});
}
}
use of com.intellij.debugger.engine.evaluation.TextWithImports in project intellij-community by JetBrains.
the class DebuggerTreeNodeExpression method createEvaluationText.
public static TextWithImports createEvaluationText(final DebuggerTreeNodeImpl node, final DebuggerContextImpl context) throws EvaluateException {
final EvaluateException[] ex = new EvaluateException[] { null };
final TextWithImports textWithImports = PsiDocumentManager.getInstance(context.getProject()).commitAndRunReadAction((Computable<TextWithImports>) () -> {
try {
final PsiExpression expressionText = getEvaluationExpression(node, context);
if (expressionText != null) {
return new TextWithImportsImpl(expressionText);
}
} catch (EvaluateException e) {
ex[0] = e;
}
return null;
});
if (ex[0] != null) {
throw ex[0];
}
return textWithImports;
}
use of com.intellij.debugger.engine.evaluation.TextWithImports in project intellij-community by JetBrains.
the class CustomFieldInplaceEditor method doOKAction.
@Override
public void doOKAction() {
List<Pair<String, TextWithImports>> children = getRendererChildren();
TextWithImports newText = TextWithImportsImpl.fromXExpression(myExpressionEditor.getExpression());
if (myDescriptor == null) {
children.add(0, Pair.create("", newText));
} else {
int index = myDescriptor.getEnumerationIndex();
children.set(index, Pair.create(children.get(index).first, newText));
}
myTree.putClientProperty(XDebuggerTreeRestorer.SELECTION_PATH_PROPERTY, createDummySelectionTreePath(newText.getText(), (XDebuggerTreeNode) myNode.getParent()));
XDebuggerUtilImpl.rebuildTreeAndViews(myTree);
super.doOKAction();
}
Aggregations