diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java index 37913eb64f7d..188f67356f85 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.fileEditor; import com.intellij.openapi.vfs.VirtualFile; @@ -38,9 +24,16 @@ public interface FileEditorManagerListener extends EventListener{ Topic FILE_EDITOR_MANAGER = new Topic<>("file editor before events", Before.class, Topic.BroadcastDirection.TO_PARENT); - void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file); - void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file); + default void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { + } + default void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { + } + + /** + * @deprecated use {@link Before} directly + */ + @Deprecated class Adapter implements Before { @Override public void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java index f2acf87b0271..28d41126666f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java @@ -55,7 +55,7 @@ public final class EditorHistoryManager implements PersistentStateComponent trimToSize()); - connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() { + connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before() { @Override public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { updateHistoryEntry(file, false); diff --git a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt index 4a8c430dd47f..c1a3fbc36a26 100644 --- a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt +++ b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt @@ -80,7 +80,7 @@ class IdeaDecompiler : ClassFileDecompilers.Light() { private fun intercept() { val app = ApplicationManager.getApplication() val connection = app.messageBus.connect(app) - connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before.Adapter() { + connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before { override fun beforeFileOpened(source: FileEditorManager, file: VirtualFile) { if (!myLegalNoticeAccepted && file.fileType === StdFileTypes.CLASS && ClassFileDecompilers.find(file) === this@IdeaDecompiler) { myFutures[file] = app.executeOnPooledThread(Callable { decompile(file) }) @@ -96,10 +96,10 @@ class IdeaDecompiler : ClassFileDecompilers.Light() { PropertiesComponent.getInstance().setValue(LEGAL_NOTICE_KEY, true) myLegalNoticeAccepted = true - app.invokeLater({ + app.invokeLater { RefreshQueue.getInstance().processSingleEvent( - VFileContentChangeEvent(this@IdeaDecompiler, file, file.modificationStamp, -1, false)) - }) + VFileContentChangeEvent(this@IdeaDecompiler, file, file.modificationStamp, -1, false)) + } connection.disconnect() } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java index ca50b6921458..5c0d5051f4ca 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java @@ -1,3 +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. package org.jetbrains.plugins.ipnb.editor; import com.google.common.collect.Lists; @@ -59,7 +60,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor { public IpnbFileEditor(Project project, final VirtualFile vFile) { myDocument = FileDocumentManager.getInstance().getDocument(vFile); project.getMessageBus().connect(this) - .subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() { + .subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before() { @Override public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { if (!new File(file.getPath()).exists()) return;