From 151fbba79074f5303507a6cc853bd33cbe68245c Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 2 May 2017 19:43:47 +0300 Subject: [PATCH] IDEA-172133 "Add to Watches" action does not "follow" editor selection --- .../src/messages/ActionsBundle.properties | 1 - .../src/idea/LangActions.xml | 3 +-- .../impl/actions/AddToWatchesAction.java | 27 ++++++++++++++++++- .../EvaluateInConsoleFromTreeAction.java | 4 +-- ...tion.java => XAddToWatchesTreeAction.java} | 2 +- python/src/META-INF/python-core-common.xml | 2 +- 6 files changed, 31 insertions(+), 8 deletions(-) rename platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/{XAddToWatchesAction.java => XAddToWatchesTreeAction.java} (97%) diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 191e3078db48..b9cb15beae96 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1031,7 +1031,6 @@ action.XDebugger.JumpToTypeSource.text=Jump To Type Source action.XDebugger.JumpToTypeSource.description=Open source of the selected value's type action.XDebugger.Inspect.text=Inspect... -action.Debugger.Tree.AddToWatches.text=Add to Watches action.Debugger.Tree.EvaluateInConsole.text=Evaluate In Console action.XDebugger.RemoveWatch.text=Remove Watch diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index c1be52c025db..c972f20583d2 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -730,7 +730,6 @@ - @@ -796,7 +795,7 @@ - + diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java index c93496be2699..012e03a5d143 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -15,10 +15,15 @@ */ package com.intellij.xdebugger.impl.actions; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.xdebugger.impl.DebuggerSupport; +import com.intellij.xdebugger.impl.ui.tree.actions.XAddToWatchesTreeAction; +import com.intellij.xdebugger.impl.ui.tree.actions.XDebuggerTreeActionBase; import org.jetbrains.annotations.NotNull; final class AddToWatchesAction extends XDebuggerActionBase { + private static final XAddToWatchesTreeAction TREE_ACTION = new XAddToWatchesTreeAction(); + public AddToWatchesAction() { super(true); } @@ -28,4 +33,24 @@ final class AddToWatchesAction extends XDebuggerActionBase { protected DebuggerActionHandler getHandler(@NotNull DebuggerSupport debuggerSupport) { return debuggerSupport.getAddToWatchesActionHandler(); } + + @Override + public void update(AnActionEvent event) { + if (XDebuggerTreeActionBase.getSelectedNode(event.getDataContext()) != null) { + TREE_ACTION.update(event); + } + else { + super.update(event); + } + } + + @Override + public void actionPerformed(AnActionEvent event) { + if (XDebuggerTreeActionBase.getSelectedNode(event.getDataContext()) != null) { + TREE_ACTION.actionPerformed(event); + } + else { + super.actionPerformed(event); + } + } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/EvaluateInConsoleFromTreeAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/EvaluateInConsoleFromTreeAction.java index 26394069c590..405c5a2d654d 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/EvaluateInConsoleFromTreeAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/EvaluateInConsoleFromTreeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -23,7 +23,7 @@ import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -class EvaluateInConsoleFromTreeAction extends XAddToWatchesAction { +class EvaluateInConsoleFromTreeAction extends XAddToWatchesTreeAction { @Override protected boolean isEnabled(@NotNull XValueNodeImpl node, @NotNull AnActionEvent e) { return super.isEnabled(node, e) && getConsoleExecuteAction(e) != null; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesTreeAction.java similarity index 97% rename from platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java rename to platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesTreeAction.java index 5d83f172f3b6..d0998b353573 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesTreeAction.java @@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull; * This action works only in the variables view * @see com.intellij.xdebugger.impl.actions.AddToWatchesAction */ -class XAddToWatchesAction extends XDebuggerTreeActionBase { +public class XAddToWatchesTreeAction extends XDebuggerTreeActionBase { @Override protected boolean isEnabled(@NotNull final XValueNodeImpl node, @NotNull AnActionEvent e) { return super.isEnabled(node, e) && DebuggerUIUtil.hasEvaluationExpression(node.getValueContainer()) && getWatchesView(e) != null; diff --git a/python/src/META-INF/python-core-common.xml b/python/src/META-INF/python-core-common.xml index 88d22d7bba35..e532cce0b628 100644 --- a/python/src/META-INF/python-core-common.xml +++ b/python/src/META-INF/python-core-common.xml @@ -835,7 +835,7 @@ - +