This commit is contained in:
Vladimir Krivosheev
2013-08-30 14:39:56 +02:00
parent ca42bab1fc
commit c7c8f30d76
4 changed files with 28 additions and 17 deletions
@@ -17,7 +17,6 @@ package com.intellij.xdebugger.impl.actions;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.impl.XDebuggerSupport;
import com.intellij.xdebugger.impl.DebuggerSupport;
import org.jetbrains.annotations.NotNull;
@@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
* @author nik
*/
public abstract class XDebuggerActionBase extends AnAction implements AnAction.TransparentUpdate {
private boolean myHideDisabledInPopup;
private final boolean myHideDisabledInPopup;
protected XDebuggerActionBase() {
this(false);
@@ -35,6 +34,7 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
myHideDisabledInPopup = hideDisabledInPopup;
}
@Override
public void update(final AnActionEvent event) {
Presentation presentation = event.getPresentation();
boolean hidden = isHidden(event);
@@ -57,7 +57,7 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
protected boolean isEnabled(final AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
if (project != null) {
DebuggerSupport[] debuggerSupports = XDebuggerSupport.getDebuggerSupports();
DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
for (DebuggerSupport support : debuggerSupports) {
if (isEnabled(project, e, support)) {
return true;
@@ -74,6 +74,7 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
return getHandler(support).isEnabled(project, event);
}
@Override
public void actionPerformed(final AnActionEvent e) {
performWithHandler(e);
}
@@ -84,7 +85,7 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
return true;
}
DebuggerSupport[] debuggerSupports = XDebuggerSupport.getDebuggerSupports();
DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
for (DebuggerSupport support : debuggerSupports) {
if (isEnabled(project, e, support)) {
perform(project, e, support);
@@ -101,7 +102,7 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
protected boolean isHidden(AnActionEvent event) {
final Project project = event.getData(PlatformDataKeys.PROJECT);
if (project != null) {
for (DebuggerSupport support : XDebuggerSupport.getDebuggerSupports()) {
for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) {
if (!getHandler(support).isHidden(project, event)) {
return false;
}
@@ -31,7 +31,6 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import com.intellij.xdebugger.impl.ui.XDebugSessionData;
@@ -117,15 +116,12 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
}
public void addWatchExpression(@NotNull String expression, int index, final boolean navigateToWatchNode) {
XDebuggerEvaluator evaluator = null;
XStackFrame stackFrame = mySession.getCurrentStackFrame();
if (stackFrame != null) {
evaluator = stackFrame.getEvaluator();
}
myRootNode.addWatchExpression(evaluator, expression, index, navigateToWatchNode);
myRootNode.addWatchExpression(stackFrame == null ? null : stackFrame.getEvaluator(), expression, index, navigateToWatchNode);
updateSessionData();
}
@Override
protected void rebuildView(final SessionEvent event) {
XStackFrame stackFrame = mySession.getCurrentStackFrame();
XDebuggerTree tree = myTreePanel.getTree();
@@ -173,6 +169,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
List<XDebuggerTreeNode> toRemove = new ArrayList<XDebuggerTreeNode>();
if (children != null) {
for (XDebuggerTreeNode node : nodes) {
@SuppressWarnings("SuspiciousMethodCalls")
int index = children.indexOf(node);
if (index != -1) {
toRemove.add(node);
@@ -183,7 +180,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
myRootNode.removeChildren(toRemove);
List<? extends WatchNode> newChildren = myRootNode.getAllChildren();
if (newChildren != null && newChildren.size() > 0) {
if (newChildren != null && !newChildren.isEmpty()) {
WatchNode node = minIndex < newChildren.size() ? newChildren.get(minIndex) : newChildren.get(newChildren.size() - 1);
TreeUtil.selectNode(myTreePanel.getTree(), node);
}
@@ -206,6 +203,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
mySessionData.setWatchExpressions(ArrayUtil.toStringArray(watchExpressions));
}
@Override
public boolean update(final DnDEvent aEvent) {
Object object = aEvent.getAttachedObject();
boolean possible = false;
@@ -221,6 +219,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
return true;
}
@Override
public void drop(final DnDEvent aEvent) {
Object object = aEvent.getAttachedObject();
if (object instanceof XValueNodeImpl[]) {
@@ -240,9 +239,11 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
}
}
@Override
public void cleanUpOnLeave() {
}
@Override
public void updateDraggedImage(final Image image, final Point dropPoint, final Point imageOffset) {
}
}
@@ -15,21 +15,23 @@
*/
package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class XAddToWatchesAction extends XDebuggerTreeActionBase {
@Override
protected boolean isEnabled(final XValueNodeImpl node) {
return super.isEnabled(node) && node.getValueContainer().getEvaluationExpression() != null;
}
@Override
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
XDebugSession session = node.getTree().getSession();
XDebugSessionTab sessionTab = ((XDebugSessionImpl)session).getSessionTab();
@@ -38,4 +40,4 @@ public class XAddToWatchesAction extends XDebuggerTreeActionBase {
sessionTab.getWatchesView().addWatchExpression(expression, -1, true);
}
}
}
}
@@ -67,6 +67,7 @@ public class WatchesRootNode extends XDebuggerTreeNode {
fireNodeStructureChanged();
}
@Override
protected List<? extends TreeNode> getChildren() {
return myChildren;
}
@@ -76,6 +77,7 @@ public class WatchesRootNode extends XDebuggerTreeNode {
return myChildren;
}
@Override
public List<? extends XDebuggerTreeNode> getLoadedChildren() {
if (myLoadedChildren == null) {
myLoadedChildren = new ArrayList<XDebuggerTreeNode>();
@@ -135,6 +137,7 @@ public class WatchesRootNode extends XDebuggerTreeNode {
myTree.getTreeModel().nodesWereInserted(this, new int[]{index});
}
@SuppressWarnings("SuspiciousMethodCalls")
public int removeChildNode(XDebuggerTreeNode node) {
int index = myChildren.indexOf(node);
if (index != -1) {
@@ -185,16 +188,20 @@ public class WatchesRootNode extends XDebuggerTreeNode {
myResultPlace = resultPlace;
}
@Override
public void evaluated(@NotNull final XValue result) {
DebuggerUIUtil.invokeLater(new Runnable() {
@Override
public void run() {
replaceNode(myResultPlace, new WatchNodeImpl(myTree, WatchesRootNode.this, result, myResultPlace.getExpression()));
}
});
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
DebuggerUIUtil.invokeLater(new Runnable() {
@Override
public void run() {
replaceNode(myResultPlace, WatchMessageNode.createErrorNode(myTree, WatchesRootNode.this, myResultPlace.getExpression(), errorMessage));
}