use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.
the class ViewTextAction method createCollector.
@NotNull
@Override
protected ValueCollector createCollector(@NotNull AnActionEvent e) {
XValueNodeImpl node = getStringNode(e);
return new ValueCollector(XDebuggerTree.getTree(e.getDataContext())) {
MyDialog dialog = null;
@Override
public void handleInCollector(Project project, String value, XDebuggerTree tree) {
String text = StringUtil.unquoteString(value);
if (dialog == null) {
dialog = new MyDialog(project, text, node);
dialog.setTitle(ActionsBundle.message(node != null ? "action.Debugger.ViewEditText.text" : "action.Debugger.ViewText.text"));
dialog.show();
}
dialog.setText(text);
}
};
}
use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.
the class XVariablesViewBase method buildTreeAndRestoreState.
protected void buildTreeAndRestoreState(@NotNull final XStackFrame stackFrame) {
XSourcePosition position = stackFrame.getSourcePosition();
XDebuggerTree tree = getTree();
tree.setSourcePosition(position);
createNewRootNode(stackFrame);
final Project project = tree.getProject();
project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
clearInlays(tree);
Object newEqualityObject = stackFrame.getEqualityObject();
if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
disposeTreeRestorer();
myTreeRestorer = myTreeState.restoreState(tree);
}
if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
registerInlineEvaluator(stackFrame, position, project);
}
}
use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.
the class XWatchesViewImpl method update.
@Override
public boolean update(final DnDEvent aEvent) {
Object object = aEvent.getAttachedObject();
boolean possible = false;
if (object instanceof XValueNodeImpl[]) {
possible = true;
// do not add new watch if node is dragged to itself
if (((XValueNodeImpl[]) object).length == 1) {
Point point = aEvent.getPoint();
XDebuggerTree tree = getTree();
TreePath path = tree.getClosestPathForLocation(point.x, point.y);
if (path != null && path.getLastPathComponent() == ((XValueNodeImpl[]) object)[0]) {
// the same item is under pointer, filter out place below the tree
Rectangle pathBounds = tree.getPathBounds(path);
possible = pathBounds != null && pathBounds.y + pathBounds.height < point.y;
}
}
} else if (object instanceof EventInfo) {
possible = ((EventInfo) object).getTextForFlavor(DataFlavor.stringFlavor) != null;
}
aEvent.setDropPossible(possible, XDebuggerBundle.message("xdebugger.drop.text.add.to.watches"));
return true;
}
use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.
the class XDebuggerEvaluationDialog method evaluate.
private void evaluate() {
final XDebuggerEditorBase inputEditor = getInputEditor();
int offset = -1;
//try to save caret position
Editor editor = inputEditor.getEditor();
if (editor != null) {
offset = editor.getCaretModel().getOffset();
}
final XDebuggerTree tree = myTreePanel.getTree();
tree.markNodesObsolete();
tree.setRoot(new EvaluatingExpressionRootNode(this, tree), false);
myResultPanel.invalidate();
//editor is already changed
editor = inputEditor.getEditor();
//selectAll puts focus back
inputEditor.selectAll();
//try to restore caret position and clear selection
if (offset >= 0 && editor != null) {
offset = Math.min(editor.getDocument().getTextLength(), offset);
editor.getCaretModel().moveToOffset(offset);
editor.getSelectionModel().setSelection(offset, offset);
}
}
use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.
the class XWatchesViewImpl method installEditListeners.
private void installEditListeners() {
final XDebuggerTree watchTree = getTree();
final Alarm quitePeriod = new Alarm();
final Alarm editAlarm = new Alarm();
final ClickListener mouseListener = new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
if (!SwingUtilities.isLeftMouseButton(event) || ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.ALT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK)) != 0)) {
return false;
}
boolean sameRow = isAboveSelectedItem(event, watchTree, false);
if (!sameRow || clickCount > 1) {
editAlarm.cancelAllRequests();
return false;
}
final AnAction editWatchAction = ActionManager.getInstance().getAction(XDebuggerActions.XEDIT_WATCH);
Presentation presentation = editWatchAction.getTemplatePresentation().clone();
DataContext context = DataManager.getInstance().getDataContext(watchTree);
final AnActionEvent actionEvent = new AnActionEvent(null, context, "WATCH_TREE", presentation, ActionManager.getInstance(), 0);
Runnable runnable = () -> editWatchAction.actionPerformed(actionEvent);
if (editAlarm.isEmpty() && quitePeriod.isEmpty()) {
editAlarm.addRequest(runnable, UIUtil.getMultiClickInterval());
} else {
editAlarm.cancelAllRequests();
}
return false;
}
};
final ClickListener mouseEmptySpaceListener = new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent event) {
if (!isAboveSelectedItem(event, watchTree, true)) {
myRootNode.addNewWatch();
return true;
}
return false;
}
};
ListenerUtil.addClickListener(watchTree, mouseListener);
ListenerUtil.addClickListener(watchTree, mouseEmptySpaceListener);
final FocusListener focusListener = new FocusListener() {
@Override
public void focusGained(@NotNull FocusEvent e) {
quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
}
@Override
public void focusLost(@NotNull FocusEvent e) {
editAlarm.cancelAllRequests();
}
};
ListenerUtil.addFocusListener(watchTree, focusListener);
final TreeSelectionListener selectionListener = new TreeSelectionListener() {
@Override
public void valueChanged(@NotNull TreeSelectionEvent e) {
quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
}
};
watchTree.addTreeSelectionListener(selectionListener);
myDisposables.add(new Disposable() {
@Override
public void dispose() {
ListenerUtil.removeClickListener(watchTree, mouseListener);
ListenerUtil.removeClickListener(watchTree, mouseEmptySpaceListener);
ListenerUtil.removeFocusListener(watchTree, focusListener);
watchTree.removeTreeSelectionListener(selectionListener);
}
});
}
Aggregations