diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java index f55218311220..ab5671a9cab9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.ui; import com.intellij.debugger.DebugEnvironment; @@ -32,7 +18,6 @@ import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.RunContentManager; import com.intellij.execution.ui.RunContentWithExecutorListener; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.xdebugger.XDebugProcess; @@ -42,11 +27,30 @@ import com.intellij.xdebugger.XDebuggerManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class DebuggerPanelsManager implements ProjectComponent { +public class DebuggerPanelsManager { private final Project myProject; public DebuggerPanelsManager(Project project) { myProject = project; + + project.getMessageBus().connect().subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() { + @Override + public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { + if (executor == DefaultDebugExecutor.getDebugExecutorInstance()) { + DebuggerSession session = descriptor == null ? null : getSession(project, descriptor); + if (session != null) { + getContextManager().setState(session.getContextManager().getContext(), session.getState(), DebuggerSession.Event.CONTEXT, null); + } + else { + getContextManager().setState(DebuggerContextImpl.EMPTY_CONTEXT, DebuggerSession.State.DISPOSED, DebuggerSession.Event.CONTEXT, null); + } + } + } + + @Override + public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { + } + }); } private DebuggerStateManager getContextManager() { @@ -80,35 +84,6 @@ public class DebuggerPanelsManager implements ProjectComponent { return debugSession.getRunContentDescriptor(); } - - @Override - public void projectOpened() { - myProject.getMessageBus().connect(myProject).subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() { - @Override - public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { - if (executor == DefaultDebugExecutor.getDebugExecutorInstance()) { - DebuggerSession session = descriptor == null ? null : getSession(myProject, descriptor); - if (session != null) { - getContextManager().setState(session.getContextManager().getContext(), session.getState(), DebuggerSession.Event.CONTEXT, null); - } - else { - getContextManager().setState(DebuggerContextImpl.EMPTY_CONTEXT, DebuggerSession.State.DISPOSED, DebuggerSession.Event.CONTEXT, null); - } - } - } - - @Override - public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { - } - }); - } - - @Override - @NotNull - public String getComponentName() { - return "DebuggerPanelsManager"; - } - public static DebuggerPanelsManager getInstance(Project project) { return project.getComponent(DebuggerPanelsManager.class); } diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java index da924f299f31..9006b2840b6f 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java @@ -1,7 +1,4 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl; import com.google.common.annotations.VisibleForTesting; @@ -11,7 +8,6 @@ import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.*; import com.intellij.openapi.application.impl.ApplicationInfoImpl; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.DocumentRunnable; @@ -49,7 +45,7 @@ import javax.swing.*; import java.util.*; import java.util.concurrent.ConcurrentMap; -public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements PrioritizedInternalDocumentListener, ProjectComponent { +public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements PrioritizedInternalDocumentListener, Disposable { static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiDocumentManagerImpl"); private static final Key HARD_REF_TO_DOCUMENT = Key.create("HARD_REFERENCE_TO_DOCUMENT"); private static final Key> ACTION_AFTER_COMMIT = Key.create("ACTION_AFTER_COMMIT"); @@ -77,15 +73,11 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen myDocumentCommitProcessor = documentCommitProcessor; mySynchronizer = new PsiToDocumentSynchronizer(this, bus); myPsiManager.addPsiTreeChangeListener(mySynchronizer); - bus.connect().subscribe(PsiDocumentTransactionListener.TOPIC, new PsiDocumentTransactionListener() { + bus.connect(this).subscribe(PsiDocumentTransactionListener.TOPIC, new PsiDocumentTransactionListener() { @Override public void transactionStarted(@NotNull Document document, @NotNull PsiFile file) { myUncommittedDocuments.remove(document); } - - @Override - public void transactionCompleted(@NotNull Document document, @NotNull PsiFile file) { - } }); } @@ -837,7 +829,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen handleCommitWithoutPsi(document); return; } - + boolean commitNecessary = files.stream().noneMatch(file -> PsiToDocumentSynchronizer.isInsideAtomicChange(file) || !(file instanceof PsiFileImpl)); boolean forceCommit = ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.class) && @@ -888,7 +880,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen if (!myProject.isInitialized() || myProject.isDisposed() || myProject.isDefault()) { return; } - + myUncommittedDocuments.remove(document); VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); @@ -1004,16 +996,10 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen } @Override - public void disposeComponent() { + public void dispose() { clearUncommittedDocuments(); } - @NotNull - @Override - public String getComponentName() { - return getClass().getSimpleName(); - } - @NotNull public PsiToDocumentSynchronizer getSynchronizer() { return mySynchronizer; @@ -1023,7 +1009,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen public void reparseFileFromText(@NotNull PsiFileImpl file) { ApplicationManager.getApplication().assertIsDispatchThread(); if (isCommitInProgress()) throw new IllegalStateException("Re-entrant commit is not allowed"); - + FileElement node = file.calcTreeElement(); CharSequence text = node.getChars(); ourIsFullReparseInProgress = true; diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentTransactionListener.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentTransactionListener.java index e38f034d5881..d7324bfdd4ef 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentTransactionListener.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentTransactionListener.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. /* * @author max @@ -29,5 +15,7 @@ public interface PsiDocumentTransactionListener { new Topic<>("psi.DocumentTransactionListener", PsiDocumentTransactionListener.class, Topic.BroadcastDirection.TO_PARENT); void transactionStarted(@NotNull Document document, @NotNull PsiFile file); - void transactionCompleted(@NotNull Document document, @NotNull PsiFile file); + + default void transactionCompleted(@NotNull Document document, @NotNull PsiFile file) { + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java index c64f0b38d0bf..29d6f4b8ec53 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java @@ -20,7 +20,6 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.util.EventDispatcher; import com.intellij.util.SmartList; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -68,13 +67,6 @@ public class EditorTracker implements ProjectComponent { Disposer.register(myProject, () -> myEditorFactoryListener.executeOnRelease(null)); } - @Override - @NonNls - @NotNull - public String getComponentName() { - return "EditorTracker"; - } - private void editorFocused(Editor editor) { ApplicationManager.getApplication().assertIsDispatchThread(); Window window = myEditorToWindowMap.get(editor); diff --git a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java index 5d6ef1d0d38e..0fd65a22dfda 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java @@ -3,9 +3,9 @@ package com.intellij.ide.impl.convert; import com.intellij.conversion.ConversionService; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; * @author nik */ @State(name = ProjectFileVersionImpl.COMPONENT_NAME) -public class ProjectFileVersionImpl extends ProjectFileVersion implements ProjectComponent, PersistentStateComponent { +public class ProjectFileVersionImpl extends ProjectFileVersion implements Disposable, PersistentStateComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.impl.convert.ProjectFileVersionImpl"); @NonNls public static final String COMPONENT_NAME = "ProjectFileVersion"; private final Project myProject; @@ -30,14 +30,7 @@ public class ProjectFileVersionImpl extends ProjectFileVersion implements Projec } @Override - @NonNls - @NotNull - public String getComponentName() { - return COMPONENT_NAME; - } - - @Override - public void disposeComponent() { + public void dispose() { if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) { return; } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java index 617b615aae9e..fc0b5f7f113e 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java @@ -6,7 +6,10 @@ import com.intellij.ide.gdpr.ConsentOptions; import com.intellij.internal.statistic.configurable.SendPeriod; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationManagerEx; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.RoamingType; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.util.text.StringUtil; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -17,8 +20,7 @@ import org.jetbrains.annotations.Nullable; name = "UsagesStatistic", storages = @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED) ) -public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersistenceComponent - implements NamedComponent, PersistentStateComponent { +public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersistenceComponent implements PersistentStateComponent { public static final String USAGE_STATISTICS_XML = "usage.statistics.xml"; @NonNls private boolean isShowNotification = true; @@ -118,11 +120,4 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste public boolean isShowNotification() { return isShowNotification; } - - @Override - @NonNls - @NotNull - public String getComponentName() { - return "SentUsagesPersistenceComponent"; - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java index a9f7a77fe92b..7ff22191f26b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java @@ -96,13 +96,6 @@ public class PersistentFSImpl extends PersistentFS implements BaseComponent, Dis } } - @Override - @NonNls - @NotNull - public String getComponentName() { - return "app.component.PersistentFS"; - } - @Override public boolean areChildrenLoaded(@NotNull final VirtualFile dir) { return areChildrenLoaded(getFileId(dir)); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index d539b0372c11..ba7ea8c2afec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -7,7 +7,10 @@ import com.intellij.ide.impl.DataManagerImpl; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.RoamingType; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; @@ -41,17 +44,13 @@ import java.awt.peer.ComponentPeer; import java.awt.peer.FramePeer; import java.util.*; -/** - * @author Anton Katilin - * @author Vladimir Kondratyev - */ @State( name = "WindowManager", defaultStateAsResource = true, storages = @Storage(value = "window.manager.xml", roamingType = RoamingType.DISABLED) ) -public final class WindowManagerImpl extends WindowManagerEx implements NamedComponent, PersistentStateComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.WindowManagerImpl"); +public final class WindowManagerImpl extends WindowManagerEx implements PersistentStateComponent { + private static final Logger LOG = Logger.getInstance(WindowManagerImpl.class); @NonNls public static final String FULL_SCREEN = "ide.frame.full.screen"; @@ -684,12 +683,6 @@ public final class WindowManagerImpl extends WindowManagerEx implements NamedCom myLayout.copyFrom(layout); } - @Override - @NotNull - public final String getComponentName() { - return "WindowManager"; - } - public WindowWatcher getWindowWatcher() { return myWindowWatcher; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java index 6f86135793d3..3f8aa3b47bf1 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes; import com.intellij.openapi.components.ProjectComponent; @@ -32,7 +18,6 @@ import com.intellij.util.ReflectionUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.vcsUtil.VcsUtil; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,7 +27,7 @@ import java.util.*; * @author max */ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements ProjectComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerImpl"); + private static final Logger LOG = Logger.getInstance(VcsDirtyScopeManagerImpl.class); private final Project myProject; private final ChangeListManager myChangeListManager; @@ -99,12 +84,6 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr myChangeListManager.scheduleUpdate(); } - @Override - @NotNull @NonNls - public String getComponentName() { - return "VcsDirtyScopeManager"; - } - @Override public void disposeComponent() { synchronized (LOCK) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java index 8ca532b06e75..aa9aabde82c6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java @@ -1,22 +1,7 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.committed; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -31,6 +16,7 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorNotificationPanel; import com.intellij.util.messages.MessageBus; +import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.text.DateFormatUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -42,8 +28,8 @@ import java.util.List; * @author yole * todo: use EditorNotifications */ -public class OutdatedVersionNotifier implements ProjectComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.committed.OutdatedVersionNotifier"); +public class OutdatedVersionNotifier { + private static final Logger LOG = Logger.getInstance(OutdatedVersionNotifier.class); private final FileEditorManager myFileEditorManager; private final CommittedChangesCache myCache; @@ -57,7 +43,8 @@ public class OutdatedVersionNotifier implements ProjectComponent { myFileEditorManager = fileEditorManager; myCache = cache; myProject = project; - messageBus.connect().subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() { + MessageBusConnection busConnection = messageBus.connect(); + busConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() { @Override public void incomingChangesUpdated(@Nullable final List receivedChanges) { if (myCache.getCachedIncomingChanges() == null) { @@ -73,6 +60,24 @@ public class OutdatedVersionNotifier implements ProjectComponent { updateAllEditorsLater(); } }); + + busConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { + @Override + public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { + if (myCache.getCachedIncomingChanges() == null) { + requestLoadIncomingChanges(); + } + else { + final Pair pair = myCache.getIncomingChangeList(file); + if (pair != null) { + final FileEditor[] fileEditors = source.getEditors(file); + for(FileEditor editor: fileEditors) { + initPanel(pair.first, pair.second, editor); + } + } + } + } + }); } private void requestLoadIncomingChanges() { @@ -90,19 +95,6 @@ public class OutdatedVersionNotifier implements ProjectComponent { LOG.debug(message); } - @Override - public void projectOpened() { - final FileEditorManagerListener myFileEditorManagerListener = new MyFileEditorManagerListener(); - myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener, myProject); - } - - @Override - @NonNls - @NotNull - public String getComponentName() { - return "OutdatedVersionNotifier"; - } - private void updateAllEditorsLater() { debug("Queueing update of editors"); ApplicationManager.getApplication().invokeLater(() -> updateAllEditors(), myProject.getDisposed()); @@ -145,24 +137,6 @@ public class OutdatedVersionNotifier implements ProjectComponent { myFileEditorManager.addTopComponent(editor, component); } - private class MyFileEditorManagerListener implements FileEditorManagerListener { - @Override - public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - if (myCache.getCachedIncomingChanges() == null) { - requestLoadIncomingChanges(); - } - else { - final Pair pair = myCache.getIncomingChangeList(file); - if (pair != null) { - final FileEditor[] fileEditors = source.getEditors(file); - for(FileEditor editor: fileEditors) { - initPanel(pair.first, pair.second, editor); - } - } - } - } - } - private static class OutdatedRevisionPanel extends EditorNotificationPanel { private CommittedChangeList myChangeList; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index a87540a5586e..726048aeed6c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.patch; import com.intellij.CommonBundle; @@ -36,7 +22,6 @@ import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager; import com.intellij.openapi.vcs.changes.ui.SessionDialog; import com.intellij.util.WaitForProgressToShow; import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,13 +77,6 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr myChangeListManager.registerCommitExecutor(this); } - @Override - @NonNls - @NotNull - public String getComponentName() { - return "CreatePatchCommitExecutor"; - } - private class CreatePatchCommitSession implements CommitSession, CommitSessionContextAware { private final CreatePatchConfigurationPanel myPanel = new CreatePatchConfigurationPanel(myProject); private CommitContext myCommitContext; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java index af7b218a2168..92d2ec16263b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java @@ -1,19 +1,4 @@ -/* - * 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. - */ - +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.shelf; import com.intellij.CommonBundle; @@ -29,9 +14,9 @@ import com.intellij.ide.actions.EditSourceAction; import com.intellij.ide.dnd.*; import com.intellij.ide.dnd.aware.DnDAwareTree; import com.intellij.ide.util.treeView.TreeState; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.impl.patch.FilePatch; import com.intellij.openapi.diff.impl.patch.PatchSyntaxException; @@ -87,8 +72,8 @@ import java.awt.*; import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; -import java.util.*; import java.util.List; +import java.util.*; import static com.intellij.icons.AllIcons.Vcs.Patch_applied; import static com.intellij.openapi.actionSystem.Anchor.AFTER; @@ -97,8 +82,7 @@ import static com.intellij.util.FontUtil.spaceAndThinSpace; import static com.intellij.util.ObjectUtils.assertNotNull; import static com.intellij.util.containers.ContainerUtil.notNullize; -public class ShelvedChangesViewManager implements ProjectComponent { - +public class ShelvedChangesViewManager implements Disposable { private static final Logger LOG = Logger.getInstance(ShelvedChangesViewManager.class); @NonNls static final String SHELF_CONTEXT_MENU = "Vcs.Shelf.ContextMenu"; private static final String SHELVE_PREVIEW_SPLITTER_PROPORTION = "ShelvedChangesViewManager.DETAILS_SPLITTER_PROPORTION"; @@ -126,7 +110,7 @@ public class ShelvedChangesViewManager implements ProjectComponent { } public ShelvedChangesViewManager(Project project, ChangesViewContentManager contentManager, ShelveChangesManager shelveChangesManager, - final MessageBus bus) { + final MessageBus bus, StartupManager startupManager) { myProject = project; myContentManager = contentManager; myShelveChangesManager = shelveChangesManager; @@ -210,11 +194,7 @@ public class ShelvedChangesViewManager implements ProjectComponent { mySplitterComponent.updatePreview(false); } }); - } - @Override - public void projectOpened() { - StartupManager startupManager = StartupManager.getInstance(myProject); if (startupManager == null) { LOG.error("Couldn't start loading shelved changes"); return; @@ -222,12 +202,6 @@ public class ShelvedChangesViewManager implements ProjectComponent { startupManager.registerPostStartupActivity((DumbAwareRunnable)() -> myUpdateQueue.queue(new MyContentUpdater())); } - @Override - @NonNls @NotNull - public String getComponentName() { - return "ShelvedChangesViewManager"; - } - @CalledInAwt private void updateChangesContent() { final List changeLists = new ArrayList<>(myShelveChangesManager.getShelvedChangeLists()); @@ -330,7 +304,7 @@ public class ShelvedChangesViewManager implements ProjectComponent { myTree.startEditingAtPath(myTree.getLeadSelectionPath()); }); } - + private static class ChangelistComparator implements Comparator { private final static ChangelistComparator ourInstance = new ChangelistComparator(); @@ -373,7 +347,7 @@ public class ShelvedChangesViewManager implements ProjectComponent { } @Override - public void disposeComponent() { + public void dispose() { myUpdateQueue.cancelAllUpdates(); }