mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reduce usage of ApplicationComponent.disposeComponent (to dispose in a correct order (as Disposer))
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,14 +18,13 @@ package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public abstract class ExecutorRegistry implements ApplicationComponent {
|
||||
public abstract class ExecutorRegistry {
|
||||
public static ExecutorRegistry getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(ExecutorRegistry.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -26,7 +26,9 @@ import com.intellij.execution.runners.ExecutionUtil;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.*;
|
||||
@@ -44,7 +46,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ExecutorRegistryImpl extends ExecutorRegistry {
|
||||
public class ExecutorRegistryImpl extends ExecutorRegistry implements Disposable, ApplicationComponentAdapter {
|
||||
private static final Logger LOG = Logger.getInstance(ExecutorRegistryImpl.class);
|
||||
|
||||
@NonNls public static final String RUNNERS_GROUP = "RunnerActions";
|
||||
@@ -124,13 +126,6 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
|
||||
return myId2Executor.get(executorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "ExecutorRegistyImpl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@@ -192,7 +187,7 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void disposeComponent() {
|
||||
public synchronized void dispose() {
|
||||
if (!myExecutors.isEmpty()) {
|
||||
for (Executor executor : new ArrayList<>(myExecutors)) {
|
||||
deinitExecutor(executor);
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityStateListener;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -56,7 +56,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EditorFactoryImpl extends EditorFactory implements ApplicationComponent {
|
||||
public class EditorFactoryImpl extends EditorFactory implements ApplicationComponentAdapter {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorFactoryImpl");
|
||||
private final EditorEventMulticasterImpl myEditorEventMulticaster = new EditorEventMulticasterImpl();
|
||||
private final EventDispatcher<EditorFactoryListener> myEditorFactoryEventDispatcher = EventDispatcher.create(EditorFactoryListener.class);
|
||||
@@ -89,12 +89,6 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
typedAction.setupRawHandler(new MyTypedHandler(originalHandler));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "EditorFactory";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
ModalityStateListener myModalityStateListener = entering -> {
|
||||
@@ -129,11 +123,6 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Document createDocument(@NotNull char[] text) {
|
||||
|
||||
+6
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,7 +18,7 @@ package com.intellij.openapi.editor.impl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.EditorLastActionTracker;
|
||||
@@ -27,12 +27,9 @@ import com.intellij.openapi.editor.event.EditorMouseEvent;
|
||||
import com.intellij.openapi.editor.event.EditorMouseListener;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EditorLastActionTrackerImpl extends EditorLastActionTracker implements ApplicationComponent,
|
||||
AnActionListener,
|
||||
EditorMouseListener {
|
||||
public class EditorLastActionTrackerImpl extends EditorLastActionTracker implements ApplicationComponentAdapter, AnActionListener, EditorMouseListener, Disposable {
|
||||
private static final Key<Boolean> DISPOSABLE_SET = Key.create("EditorLastActionTracker.dispose.handler.set");
|
||||
|
||||
private final ActionManager myActionManager;
|
||||
@@ -49,20 +46,12 @@ public class EditorLastActionTrackerImpl extends EditorLastActionTracker impleme
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
myActionManager.addAnActionListener(this);
|
||||
myEditorEventMulticaster.addEditorMouseListener(this);
|
||||
myActionManager.addAnActionListener(this, this);
|
||||
myEditorEventMulticaster.addEditorMouseListener(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
myEditorEventMulticaster.removeEditorMouseListener(this);
|
||||
myActionManager.removeAnActionListener(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "EditorLastActionTracker";
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user