cleanup to avoid unnecessary Disposable inner classes

This commit is contained in:
Dmitry Jemerov
2011-08-26 18:56:18 +02:00
parent a0c1e02daa
commit 17ca8fe80f
4 changed files with 9 additions and 49 deletions
@@ -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 {
@@ -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};
}
@@ -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;
}
@@ -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);