From 17ca8fe80f3c6d24c29cb0c1c9a31c8e90e4287a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 26 Aug 2011 18:40:11 +0200 Subject: [PATCH] cleanup to avoid unnecessary Disposable inner classes --- .../ImportUsageFilteringRuleProvider.java | 9 +----- .../impl/UsageFilteringRuleProviderImpl.java | 12 ++------ .../impl/UsageGroupingRuleProviderImpl.java | 30 ++++--------------- .../intellij/usages/impl/UsageViewImpl.java | 7 +---- 4 files changed, 9 insertions(+), 49 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java b/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java index fedb73315ddb..1a85c3e3b306 100644 --- a/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java +++ b/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java @@ -15,7 +15,6 @@ */ package com.intellij.usages.impl; -import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.extensions.Extensions; @@ -54,13 +53,7 @@ public class ImportUsageFilteringRuleProvider implements UsageFilteringRuleProvi if (view.getPresentation().isCodeUsages()) { final JComponent component = view.getComponent(); final ShowImportsAction showImportsAction = new ShowImportsAction(impl); - showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component); - - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - showImportsAction.unregisterCustomShortcutSet(component); - } - }); + showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view); return new AnAction[] { showImportsAction }; } else { diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java index 9e0e938558b0..69bdf15f3482 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.usages.impl; -import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; @@ -62,17 +61,10 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide final JComponent component = view.getComponent(); final ShowReadAccessUsagesAction read = new ShowReadAccessUsagesAction(); - read.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)), component); + read.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)), component, impl); final ShowWriteAccessUsagesAction write = new ShowWriteAccessUsagesAction(); - write.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)), component); - - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - read.unregisterCustomShortcutSet(component); - write.unregisterCustomShortcutSet(component); - } - }); + write.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)), component, impl); return new AnAction[] {read, write}; } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java index 33c61ad38de8..7f695b624f5e 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.usages.impl; -import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.extensions.Extensions; @@ -78,33 +77,18 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider final JComponent component = impl.getComponent(); final GroupByModuleTypeAction groupByModuleTypeAction = new GroupByModuleTypeAction(impl); - groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component); + groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl); final GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl); - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - groupByModuleTypeAction.unregisterCustomShortcutSet(component); - } - }); final GroupByScopeAction groupByScopeAction = new GroupByScopeAction(impl); final GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl); - groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component); - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - groupByPackageAction.unregisterCustomShortcutSet(component); - } - }); + groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl); if(view.getPresentation().isCodeUsages()) { final GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl); - groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component); - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - groupByUsageTypeAction.unregisterCustomShortcutSet(component); - } - }); + groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl); return new AnAction[] { groupByUsageTypeAction, groupByScopeAction, @@ -127,13 +111,9 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider final JComponent component = impl.getComponent(); final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl); groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M, - InputEvent.CTRL_DOWN_MASK)), component); + InputEvent.CTRL_DOWN_MASK)), component, + impl); - impl.scheduleDisposeOnClose(new Disposable() { - public void dispose() { - groupByFileStructureAction.unregisterCustomShortcutSet(component); - } - }); return groupByFileStructureAction; } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index 076b48df32ca..f83c37a9b663 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -391,12 +391,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra public void addFilteringActions(DefaultActionGroup group) { final JComponent component = getComponent(); final MergeDupLines mergeDupLines = new MergeDupLines(); - mergeDupLines.registerCustomShortcutSet(mergeDupLines.getShortcutSet(), component); - scheduleDisposeOnClose(new Disposable() { - public void dispose() { - mergeDupLines.unregisterCustomShortcutSet(component); - } - }); + mergeDupLines.registerCustomShortcutSet(mergeDupLines.getShortcutSet(), component, this); group.add(mergeDupLines); final UsageFilteringRuleProvider[] providers = Extensions.getExtensions(UsageFilteringRuleProvider.EP_NAME);