mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
XInspectDialog — use XValueHintTreeComponent, now UI of this component closer to inspect functionality from the editor
This commit is contained in:
+10
-2
@@ -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) {
|
||||
|
||||
+13
-8
@@ -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<Pair<XValue, String>> {
|
||||
private final XValueHint myValueHint;
|
||||
private final XDebuggerTree myTree;
|
||||
|
||||
public XValueHintTreeComponent(final XValueHint valueHint, final XDebuggerTree tree, final Pair<XValue, String> initialItem) {
|
||||
public XValueHintTreeComponent(@Nullable XValueHint valueHint, @NotNull XDebuggerTree tree, @NotNull Pair<XValue, String> initialItem) {
|
||||
super(valueHint, tree, initialItem);
|
||||
|
||||
myValueHint = valueHint;
|
||||
myTree = tree;
|
||||
updateTree(initialItem);
|
||||
@@ -38,14 +38,19 @@ public class XValueHintTreeComponent extends AbstractValueHintTreeComponent<Pair
|
||||
@Override
|
||||
protected void updateTree(final Pair<XValue, String> 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<XValue, String> item = Pair.create(valueNode.getValueContainer(), valueNode.getName());
|
||||
addToHistory(item);
|
||||
updateTree(item);
|
||||
|
||||
+6
-3
@@ -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<H> {
|
||||
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<H> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(myHistory.size() > 1 && myCurrentIndex < myHistory.size() - 1);
|
||||
@@ -74,7 +75,9 @@ public abstract class AbstractValueHintTreeComponent<H> {
|
||||
}
|
||||
|
||||
private void updateHint() {
|
||||
myValueHint.shiftLocation();
|
||||
if (myValueHint != null) {
|
||||
myValueHint.shiftLocation();
|
||||
}
|
||||
updateTree(myHistory.get(myCurrentIndex));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.util.List;
|
||||
public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposable {
|
||||
private static final DataKey<XDebuggerTree> XDEBUGGER_TREE_KEY = DataKey.create("xdebugger.tree");
|
||||
private static final Convertor<TreePath, String> SPEED_SEARCH_CONVERTER = new Convertor<TreePath, String>() {
|
||||
@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<XDebuggerTreeListener> 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);
|
||||
|
||||
+6
@@ -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<XValueNodeImpl>() {
|
||||
@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<Image, Point> 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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user