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-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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.diagnostic;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
@@ -55,7 +56,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PerformanceWatcher implements ApplicationComponent {
|
||||
public class PerformanceWatcher extends ApplicationComponent.Adapter implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.diagnostic.PerformanceWatcher");
|
||||
private static final int TOLERABLE_LATENCY = 100;
|
||||
private final ScheduledFuture<?> myThread;
|
||||
@@ -84,12 +85,6 @@ public class PerformanceWatcher implements ApplicationComponent {
|
||||
return ApplicationManager.getApplication().getComponent(PerformanceWatcher.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "PerformanceWatcher";
|
||||
}
|
||||
|
||||
public PerformanceWatcher() {
|
||||
myCurHangLogDir = mySessionLogDir = new File(PathManager.getLogPath() + "/threadDumps-" + myDateFormat.format(new Date())
|
||||
+ "-" + ApplicationInfo.getInstance().getBuild().asString());
|
||||
@@ -181,7 +176,7 @@ public class PerformanceWatcher implements ApplicationComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
if (myThread != null) {
|
||||
myThread.cancel(true);
|
||||
}
|
||||
|
||||
+3
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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,28 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl.libraries;
|
||||
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class LibraryKindLoader implements ApplicationComponent {
|
||||
public class LibraryKindLoader implements ApplicationComponentAdapter {
|
||||
@Override
|
||||
public void initComponent() {
|
||||
//todo[nik] this is temporary workaround for IDEA-98118: we need to initialize all library types to ensure that their kinds are created and registered in LibraryKind.ourAllKinds
|
||||
//In order to properly fix the problem we should extract all UI-related methods from LibraryType to a separate class and move LibraryType to projectModel-impl module
|
||||
LibraryType.EP_NAME.getExtensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "LibraryKindLoader";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
package com.intellij.util.net;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
@@ -73,7 +74,7 @@ import static com.intellij.openapi.util.Pair.pair;
|
||||
@Storage(value = "other.xml", deprecated = true)
|
||||
}
|
||||
)
|
||||
public class HttpConfigurable implements PersistentStateComponent<HttpConfigurable>, ApplicationComponent {
|
||||
public class HttpConfigurable implements PersistentStateComponent<HttpConfigurable>, ApplicationComponentAdapter, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.net.HttpConfigurable");
|
||||
private static final File PROXY_CREDENTIALS_FILE = new File(PathManager.getOptionsPath(), "proxy.settings.pwd");
|
||||
public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("idea.connection.timeout", 10000);
|
||||
@@ -182,18 +183,12 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
final String name = getClass().getName();
|
||||
CommonProxy.getInstance().removeCustom(name);
|
||||
CommonProxy.getInstance().removeCustomAuth(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
private void correctPasswords(@NotNull HttpConfigurable to) {
|
||||
synchronized (myLock) {
|
||||
to.myGenericPasswords.retainEntries(new TObjectObjectProcedure<CommonProxy.HostInfo, ProxyInfo>() {
|
||||
|
||||
@@ -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.
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -57,7 +56,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class MacOSApplicationProvider implements ApplicationComponent {
|
||||
public class MacOSApplicationProvider {
|
||||
private static final Logger LOG = Logger.getInstance(MacOSApplicationProvider.class);
|
||||
private static final AtomicBoolean ENABLED = new AtomicBoolean(true);
|
||||
private static final Callback IMPL = new Callback() {
|
||||
@@ -105,18 +104,6 @@ public class MacOSApplicationProvider implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "MACOSApplicationProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() { }
|
||||
|
||||
@Override
|
||||
public void disposeComponent() { }
|
||||
|
||||
@Nullable
|
||||
public ColorSpace getGenericRgbColorSpace() {
|
||||
return genericRgbColorSpace;
|
||||
|
||||
+2
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -16,18 +16,16 @@
|
||||
package com.intellij.openapi.actionSystem.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MouseGestureManager implements ApplicationComponent {
|
||||
public class MouseGestureManager {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("MouseGestureManager");
|
||||
|
||||
@@ -83,22 +81,6 @@ public class MouseGestureManager implements ApplicationComponent {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "MouseGestureListener";
|
||||
}
|
||||
|
||||
public static MouseGestureManager getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(MouseGestureManager.class);
|
||||
}
|
||||
|
||||
+4
@@ -24,7 +24,11 @@ public interface ApplicationComponentAdapter extends ApplicationComponent {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link com.intellij.openapi.Disposable}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
default void disposeComponent() {
|
||||
}
|
||||
}
|
||||
|
||||
+2
-17
@@ -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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.lifecycle;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -24,7 +23,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PeriodicalTasksCloser implements ApplicationComponent {
|
||||
public class PeriodicalTasksCloser {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.lifecycle.PeriodicalTasksCloser");
|
||||
private final Object myLock = new Object();
|
||||
|
||||
@@ -32,20 +31,6 @@ public class PeriodicalTasksCloser implements ApplicationComponent {
|
||||
return ApplicationManager.getApplication().getComponent(PeriodicalTasksCloser.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return PeriodicalTasksCloser.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public <T> T safeGetComponent(@NotNull final Project project, final Class<T> componentClass) throws ProcessCanceledException {
|
||||
T component = null;
|
||||
try {
|
||||
|
||||
+17
-13
@@ -1,22 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.vcs.changes.actions.migrate;
|
||||
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ApplicationComponentAdapter;
|
||||
import com.intellij.openapi.diff.DiffManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MigrateDiffApplicationComponent implements ApplicationComponent {
|
||||
public class MigrateDiffApplicationComponent implements ApplicationComponentAdapter {
|
||||
@Override
|
||||
public void initComponent() {
|
||||
DiffManager.getInstance().registerDiffTool(MigrateDiffTool.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "MigrateDiffApplicationComponent";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user