From a90f2d283cbc2db0bd8948fd81c0464bbb31faf6 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 18 Apr 2012 21:54:27 +0400 Subject: [PATCH] 1. Re-run shorctcut blocks other actions even if disabled. 2. Hierarchy view refresh only works once if shorcut is used. --- .../execution/runners/FakeRerunAction.java | 4 +++ .../ide/hierarchy/HierarchyBrowserBaseEx.java | 27 ++++++++++--------- .../intellij/ide/actions/RefreshAction.java | 5 ++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java b/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java index b677da0c94cf..75899dec4809 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java @@ -25,6 +25,10 @@ import com.intellij.openapi.project.DumbAware; */ public class FakeRerunAction extends AnAction implements DumbAware{ public void actionPerformed(AnActionEvent e) { + } + + @Override + public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); presentation.setVisible(false); diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java index 4c8034227079..f2e93238790f 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java @@ -80,7 +80,6 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem private boolean myCachedIsValidBase = false; - private final List myRunOnDisposeList = new ArrayList(); private final HashMap myOccurrenceNavigators = new HashMap(); private static final OccurenceNavigator EMPTY_NAVIGATOR = new OccurenceNavigator() { @@ -205,7 +204,14 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem protected final JTree createTree(boolean dndAware) { final Tree tree; if (dndAware) { - tree = new DnDAwareTree(new DefaultTreeModel(new DefaultMutableTreeNode(""))); + tree = new DnDAwareTree(new DefaultTreeModel(new DefaultMutableTreeNode(""))) { + @Override + public void removeNotify() { + super.removeNotify(); + myRefreshAction.unregisterCustomShortcutSet(this); + } + }; + if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { DnDManager.getInstance().registerSource(new DnDSource() { public boolean canStartDragging(final DnDAction action, final Point dragOrigin) { @@ -242,16 +248,17 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem } } else { - tree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode(""))); + tree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode(""))) { + @Override + public void removeNotify() { + super.removeNotify(); + myRefreshAction.unregisterCustomShortcutSet(this); + } + }; } configureTree(tree); EditSourceOnDoubleClickHandler.install(tree); myRefreshAction.registerShortcutOn(tree); - myRunOnDisposeList.add(new Runnable() { - public void run() { - myRefreshAction.unregisterCustomShortcutSet(tree); - } - }); return tree; } @@ -423,10 +430,6 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem for (final HierarchyTreeBuilder builder : builders) { Disposer.dispose(builder); } - for (final Runnable aRunOnDisposeList : myRunOnDisposeList) { - aRunOnDisposeList.run(); - } - myRunOnDisposeList.clear(); myBuilders.clear(); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RefreshAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RefreshAction.java index 15987fa7b15b..d66dea5d64cf 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RefreshAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RefreshAction.java @@ -41,6 +41,11 @@ public class RefreshAction extends AnAction implements DumbAware { // empty } + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabled(false); + } + public void registerShortcutOn(JComponent component) { final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet(); registerCustomShortcutSet(shortcutSet, component);