From a8fdca890bcd6bae57110af87264242b32eec79e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 30 Aug 2013 15:38:52 +0200 Subject: [PATCH] =?UTF-8?q?XInspectDialog=20=E2=80=94=20use=20XValueHintTr?= =?UTF-8?q?eeComponent,=20now=20UI=20of=20this=20component=20closer=20to?= =?UTF-8?q?=20inspect=20functionality=20from=20the=20editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evaluate/XDebuggerEvaluationDialog.java | 12 +++++++++-- .../quick/XValueHintTreeComponent.java | 21 ++++++++++++------- .../AbstractValueHintTreeComponent.java | 9 +++++--- .../xdebugger/impl/ui/tree/XDebuggerTree.java | 15 ++++++------- .../impl/ui/tree/XDebuggerTreePanel.java | 6 ++++++ .../impl/ui/tree/XInspectDialog.java | 11 +++++----- .../impl/ui/tree/actions/XInspectAction.java | 12 +++++------ 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java index bfbbf7430a7f..61c22c23ad94 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java @@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; import java.awt.event.KeyEvent; /** @@ -93,15 +94,17 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { mySwitchModeAction = new SwitchModeAction(); new AnAction(){ + @Override public void actionPerformed(AnActionEvent e) { doOKAction(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK)), getRootPane(), myDisposable); + }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)), getRootPane(), myDisposable); new AnAction() { + @Override public void actionPerformed(AnActionEvent e) { IdeFocusManager.getInstance(mySession.getProject()).requestFocus(myTreePanel.getTree(), true); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_DOWN_MASK)), getRootPane(), myDisposable); + }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK)), getRootPane(), myDisposable); EvaluationMode mode = EvaluationMode.EXPRESSION; if (text.indexOf('\n') != -1) { @@ -122,6 +125,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { super.dispose(); } + @Override protected void doOKAction() { evaluate(); } @@ -192,10 +196,12 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { myInputComponent.getInputEditor().selectAll(); } + @Override protected String getDimensionServiceKey() { return "#xdebugger.evaluate"; } + @Override protected JComponent createCenterPanel() { return myMainPanel; } @@ -207,11 +213,13 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { myEvaluator.evaluate(expression, evaluationCallback, null, inputEditor.getMode()); } + @Override public JComponent getPreferredFocusedComponent() { return myInputComponent.getInputEditor().getPreferredFocusedComponent(); } private class SwitchModeAction extends AbstractAction { + @Override public void actionPerformed(ActionEvent e) { String text = myInputComponent.getInputEditor().getText(); if (myMode == EvaluationMode.EXPRESSION) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHintTreeComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHintTreeComponent.java index b1cbb974f267..d0142a7eeac1 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHintTreeComponent.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/XValueHintTreeComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,16 @@ import com.intellij.xdebugger.frame.XValue; import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHintTreeComponent; import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree; import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -/** - * @author nik - */ public class XValueHintTreeComponent extends AbstractValueHintTreeComponent> { private final XValueHint myValueHint; private final XDebuggerTree myTree; - public XValueHintTreeComponent(final XValueHint valueHint, final XDebuggerTree tree, final Pair initialItem) { + public XValueHintTreeComponent(@Nullable XValueHint valueHint, @NotNull XDebuggerTree tree, @NotNull Pair initialItem) { super(valueHint, tree, initialItem); + myValueHint = valueHint; myTree = tree; updateTree(initialItem); @@ -38,14 +38,19 @@ public class XValueHintTreeComponent extends AbstractValueHintTreeComponent selectedItem) { myTree.setRoot(new XValueNodeImpl(myTree, null, selectedItem.getSecond(), selectedItem.getFirst()), true); - myValueHint.showTreePopup(this, myTree, selectedItem.getSecond()); + if (myValueHint != null) { + myValueHint.showTreePopup(this, myTree, selectedItem.getSecond()); + } } @Override protected void setNodeAsRoot(final Object node) { if (node instanceof XValueNodeImpl) { - final XValueNodeImpl valueNode = (XValueNodeImpl)node; - myValueHint.shiftLocation(); + if (myValueHint != null) { + myValueHint.shiftLocation(); + } + + XValueNodeImpl valueNode = (XValueNodeImpl)node; Pair item = Pair.create(valueNode.getValueContainer(), valueNode.getName()); addToHistory(item); updateTree(item); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHintTreeComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHintTreeComponent.java index e42cda7352c8..c7c6c1fd2cd1 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHintTreeComponent.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHintTreeComponent.java @@ -21,6 +21,8 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.treeStructure.Tree; import com.intellij.xdebugger.XDebuggerBundle; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.TreePath; @@ -40,7 +42,7 @@ public abstract class AbstractValueHintTreeComponent { private final Tree myTree; private JPanel myMainPanel; - protected AbstractValueHintTreeComponent(final AbstractValueHint valueHint, final Tree tree, final H initialItem) { + protected AbstractValueHintTreeComponent(@Nullable AbstractValueHint valueHint, @NotNull Tree tree, @NotNull H initialItem) { myValueHint = valueHint; myTree = tree; myHistory.add(initialItem); @@ -65,7 +67,6 @@ public abstract class AbstractValueHintTreeComponent { } } - @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(myHistory.size() > 1 && myCurrentIndex < myHistory.size() - 1); @@ -74,7 +75,9 @@ public abstract class AbstractValueHintTreeComponent { } private void updateHint() { - myValueHint.shiftLocation(); + if (myValueHint != null) { + myValueHint.shiftLocation(); + } updateTree(myHistory.get(myCurrentIndex)); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java index 1da81c865991..58c6ce407174 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java @@ -55,6 +55,7 @@ import java.util.List; public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposable { private static final DataKey XDEBUGGER_TREE_KEY = DataKey.create("xdebugger.tree"); private static final Convertor SPEED_SEARCH_CONVERTER = new Convertor() { + @Override public String convert(TreePath o) { String text = null; if (o != null) { @@ -75,7 +76,6 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa private XSourcePosition mySourcePosition; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private final XDebugSession mySession; - private final PopupHandler myPopupHandler; public XDebuggerTree(final @NotNull XDebugSession session, final @NotNull XDebuggerEditorsProvider editorsProvider, @@ -119,14 +119,13 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa new TreeSpeedSearch(this, SPEED_SEARCH_CONVERTER); final ActionManager actionManager = ActionManager.getInstance(); - myPopupHandler = new PopupHandler() { + addMouseListener(new PopupHandler() { + @Override public void invokePopup(final Component comp, final int x, final int y) { - final ActionGroup group = (ActionGroup)actionManager.getAction(popupActionGroupId); - ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, group); - popupMenu.getComponent().show(comp, x, y); + ActionGroup group = (ActionGroup)actionManager.getAction(popupActionGroupId); + actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent().show(comp, x, y); } - }; - addMouseListener(myPopupHandler); + }); registerShortcuts(); } @@ -188,6 +187,7 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa return myTreeModel; } + @Override @Nullable public Object getData(@NonNls final String dataId) { if (XDEBUGGER_TREE_KEY.is(dataId)) { @@ -226,6 +226,7 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa } } + @Override public void dispose() { ActionManager actionManager = ActionManager.getInstance(); actionManager.getAction(XDebuggerActions.SET_VALUE).unregisterCustomShortcutSet(this); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreePanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreePanel.java index 6e2dcbd50fd1..a90dc06f7ff2 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreePanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreePanel.java @@ -60,22 +60,26 @@ public class XDebuggerTreePanel implements DnDSource { return myMainPanel; } + @Override public boolean canStartDragging(final DnDAction action, final Point dragOrigin) { return getNodesToDrag().length > 0; } private XValueNodeImpl[] getNodesToDrag() { return myTree.getSelectedNodes(XValueNodeImpl.class, new Tree.NodeFilter() { + @Override public boolean accept(final XValueNodeImpl node) { return node.getValueContainer().getEvaluationExpression() != null; } }); } + @Override public DnDDragStartBean startDragging(final DnDAction action, final Point dragOrigin) { return new DnDDragStartBean(getNodesToDrag()); } + @Override public Pair createDraggedImage(final DnDAction action, final Point dragOrigin) { XValueNodeImpl[] nodes = getNodesToDrag(); if (nodes.length == 1) { @@ -84,9 +88,11 @@ public class XDebuggerTreePanel implements DnDSource { return DnDAwareTree.getDragImage(myTree, XDebuggerBundle.message("xdebugger.drag.text.0.elements", nodes.length), dragOrigin); } + @Override public void dragDropEnd() { } + @Override public void dropActionChanged(final int gestureModifiers) { } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XInspectDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XInspectDialog.java index 4b1714d726a4..29e3e5eba6ed 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XInspectDialog.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XInspectDialog.java @@ -16,13 +16,14 @@ package com.intellij.xdebugger.impl.ui.tree; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.util.Pair; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.frame.XValue; import com.intellij.xdebugger.impl.actions.XDebuggerActions; -import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; +import com.intellij.xdebugger.impl.evaluate.quick.XValueHintTreeComponent; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,16 +34,16 @@ import javax.swing.*; * @author nik */ public class XInspectDialog extends DialogWrapper { - private final XDebuggerTreePanel myTreePanel; + private final XValueHintTreeComponent myTreePanel; public XInspectDialog(XDebugSession session, XDebuggerEditorsProvider editorsProvider, XSourcePosition sourcePosition, @NotNull String name, @NotNull XValue value) { super(session.getProject(), false); setTitle(XDebuggerBundle.message("inspect.value.dialog.title", name)); setModal(false); - myTreePanel = new XDebuggerTreePanel(session, editorsProvider, myDisposable, sourcePosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP); - XDebuggerTree tree = myTreePanel.getTree(); - tree.setRoot(new XValueNodeImpl(tree, null, name, value), true); + + XDebuggerTree tree = new XDebuggerTree(session, editorsProvider, sourcePosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP); + myTreePanel = new XValueHintTreeComponent(null, tree, Pair.create(value, name)); init(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XInspectAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XInspectAction.java index cf3df1108e15..fc6062e5dbc5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XInspectAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XInspectAction.java @@ -15,19 +15,19 @@ */ package com.intellij.xdebugger.impl.ui.tree.actions; -import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; -import com.intellij.xdebugger.impl.ui.tree.XInspectDialog; -import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree; -import com.intellij.xdebugger.frame.XValue; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.xdebugger.frame.XValue; +import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree; +import com.intellij.xdebugger.impl.ui.tree.XInspectDialog; +import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; import org.jetbrains.annotations.NotNull; /** * @author nik */ public class XInspectAction extends XDebuggerTreeActionBase { - - protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) { + @Override + protected void perform(XValueNodeImpl node, @NotNull final String nodeName, AnActionEvent e) { XDebuggerTree tree = node.getTree(); XValue value = node.getValueContainer(); XInspectDialog dialog = new XInspectDialog(tree.getSession(), tree.getEditorsProvider(), tree.getSourcePosition(), nodeName, value);