diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 5e2b81d0eb84..cfa06e10ab70 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -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 diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 42edb905d965..32efe5e05383 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -666,6 +666,7 @@ + @@ -710,6 +711,7 @@ + diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesView.java index 9248410ccd36..c5a536566bd7 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesView.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesView.java @@ -154,6 +154,11 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget { updateSessionData(); } + public void removeAllWatches() { + myRootNode.removeAllChildren(); + updateSessionData(); + } + private void updateSessionData() { List watchExpressions = new ArrayList(); final List children = myRootNode.getAllChildren(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XEditWatchAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XEditWatchAction.java index b4afff520a7d..ee21e92c5126 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XEditWatchAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XEditWatchAction.java @@ -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 watchNodes = getSelectedNodes(tree, WatchNode.class); if (watchNodes.size() != 1) return; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XNewWatchAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XNewWatchAction.java index 34b01977497d..273ff6a1d5b3 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XNewWatchAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XNewWatchAction.java @@ -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; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveAllWatchesAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveAllWatchesAction.java new file mode 100644 index 000000000000..001f25f34448 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveAllWatchesAction.java @@ -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(); + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveWatchAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveWatchAction.java index 179f558cf5cb..5e725d7d8696 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveWatchAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XRemoveWatchAction.java @@ -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 nodes = getSelectedNodes(tree, XDebuggerTreeNode.class); XDebugSessionTab tab = ((XDebugSessionImpl)tree.getSession()).getSessionTab(); tab.getWatchesView().removeWatches(nodes); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XWatchesTreeActionBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XWatchesTreeActionBase.java index 0c1d4b6f39c8..cfe9e5231c63 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XWatchesTreeActionBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/actions/XWatchesTreeActionBase.java @@ -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; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java index b5065519c4e1..299ca0500d94 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java @@ -139,6 +139,12 @@ public class WatchesRootNode extends XDebuggerTreeNode { fireNodeChildrenChanged(); } + public void removeAllChildren() { + myChildren.clear(); + myLoadedChildren = null; + fireNodeChildrenChanged(); + } + public void addNewWatch() { editWatch(null); }