'remove all watches' action (IDEA-62204)

This commit is contained in:
nik
2011-03-16 15:01:01 +03:00
parent e862e94861
commit be2d6b023d
9 changed files with 68 additions and 13 deletions
@@ -819,6 +819,7 @@ action.XDebugger.JumpToSource.description=Open for the selected item
action.XDebugger.Inspect.text=Inspect
action.XDebugger.AddToWatches.text=Add to Watches
action.XDebugger.RemoveWatch.text=Remove Watch
action.XDebugger.RemoveAllWatches.text=Remove All Watches
action.XDebugger.NewWatch.text=New Watch...
action.XDebugger.EditWatch.text=Edit...
action.XDebugger.AutoTooltip.text=Value Auto Tooltip
@@ -666,6 +666,7 @@
<action id="XDebugger.NewWatch" class="com.intellij.xdebugger.impl.frame.actions.XNewWatchAction" icon="/debugger/newWatch.png"/>
<action id="XDebugger.EditWatch" class="com.intellij.xdebugger.impl.frame.actions.XEditWatchAction"/>
<action id="XDebugger.RemoveWatch" class="com.intellij.xdebugger.impl.frame.actions.XRemoveWatchAction" icon="/actions/delete.png"/>
<action id="XDebugger.RemoveAllWatches" class="com.intellij.xdebugger.impl.frame.actions.XRemoveAllWatchesAction"/>
<action id="XDebugger.MuteBreakpoints" class="com.intellij.xdebugger.impl.actions.MuteBreakpointAction"
icon="/debugger/muteBreakpoints.png"/>
<action id="XDebugger.AutoTooltip" class="com.intellij.xdebugger.impl.actions.ValueTooltipAutoShowAction"/>
@@ -710,6 +711,7 @@
<group id="XDebugger.Watches.Tree.Popup">
<reference ref="XDebugger.NewWatch"/>
<reference ref="XDebugger.RemoveWatch"/>
<reference ref="XDebugger.RemoveAllWatches"/>
<reference ref="XDebugger.EditWatch"/>
<reference ref="XDebugger.Inspect"/>
<reference ref="XDebugger.SetValue"/>
@@ -154,6 +154,11 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
updateSessionData();
}
public void removeAllWatches() {
myRootNode.removeAllChildren();
updateSessionData();
}
private void updateSessionData() {
List<String> watchExpressions = new ArrayList<String>();
final List<? extends WatchNode> children = myRootNode.getAllChildren();
@@ -34,10 +34,8 @@ public class XEditWatchAction extends XWatchesTreeActionBase {
super.update(e);
}
public void actionPerformed(final AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
if (tree == null) return;
@Override
protected void perform(AnActionEvent e, XDebuggerTree tree) {
List<? extends WatchNode> watchNodes = getSelectedNodes(tree, WatchNode.class);
if (watchNodes.size() != 1) return;
@@ -24,10 +24,8 @@ import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
* @author nik
*/
public class XNewWatchAction extends XWatchesTreeActionBase {
public void actionPerformed(final AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
if (tree == null) return;
@Override
protected void perform(AnActionEvent e, XDebuggerTree tree) {
XDebuggerTreeNode root = tree.getRoot();
if (root instanceof WatchesRootNode) {
final WatchesRootNode watchesRoot = (WatchesRootNode)root;
@@ -0,0 +1,38 @@
/*
* Copyright 2000-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class XRemoveAllWatchesAction extends XWatchesTreeActionBase {
@Override
protected boolean isEnabled(AnActionEvent e, @NotNull XDebuggerTree tree) {
return tree.getRoot().getChildCount() > 0;
}
@Override
protected void perform(AnActionEvent e, XDebuggerTree tree) {
XDebugSessionTab tab = ((XDebugSessionImpl)tree.getSession()).getSessionTab();
tab.getWatchesView().removeAllWatches();
}
}
@@ -32,11 +32,8 @@ public class XRemoveWatchAction extends XWatchesTreeActionBase {
return !getSelectedNodes(tree, XDebuggerTreeNode.class).isEmpty();
}
public void actionPerformed(final AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
if (tree == null) return;
@Override
protected void perform(AnActionEvent e, XDebuggerTree tree) {
List<? extends XDebuggerTreeNode> nodes = getSelectedNodes(tree, XDebuggerTreeNode.class);
XDebugSessionTab tab = ((XDebugSessionImpl)tree.getSession()).getSessionTab();
tab.getWatchesView().removeWatches(nodes);
@@ -49,6 +49,16 @@ public abstract class XWatchesTreeActionBase extends AnAction {
e.getPresentation().setEnabled(enabled);
}
@Override
public void actionPerformed(AnActionEvent e) {
final XDebuggerTree tree = XDebuggerTree.getTree(e);
if (tree != null) {
perform(e, tree);
}
}
protected abstract void perform(AnActionEvent e, XDebuggerTree tree);
protected boolean isEnabled(AnActionEvent e, @NotNull XDebuggerTree tree) {
return true;
}
@@ -139,6 +139,12 @@ public class WatchesRootNode extends XDebuggerTreeNode {
fireNodeChildrenChanged();
}
public void removeAllChildren() {
myChildren.clear();
myLoadedChildren = null;
fireNodeChildrenChanged();
}
public void addNewWatch() {
editWatch(null);
}