From 46a27bfb5f15d4d6856cd1f11c0304243d14dc06 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 7 Aug 2019 18:13:26 +0200 Subject: [PATCH] deprecate NotificationsAdapter GitOrigin-RevId: a79ddbd44ed4232f2112134ac9691e406ddb089d --- .../intellij/notification/Notifications.java | 36 +++++++--------- .../notification/NotificationsAdapter.java | 42 +++---------------- .../NotificationsConfiguration.java | 18 +------- .../com/intellij/notification/EventLog.java | 6 +-- .../notification/impl/MacEventReader.java | 3 +- .../impl/NotificationsManagerImpl.java | 9 ++-- plugins/settings-repository/src/autoSync.kt | 3 +- .../com/intellij/tasks/TaskManagerTest.java | 3 +- 8 files changed, 30 insertions(+), 90 deletions(-) diff --git a/platform/platform-api/src/com/intellij/notification/Notifications.java b/platform/platform-api/src/com/intellij/notification/Notifications.java index 976c06260b93..ff3a4b3513e4 100644 --- a/platform/platform-api/src/com/intellij/notification/Notifications.java +++ b/platform/platform-api/src/com/intellij/notification/Notifications.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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.notification; import com.intellij.openapi.application.Application; @@ -25,19 +11,25 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -/** - * @author spleaner - */ public interface Notifications { Topic TOPIC = Topic.create("Notifications", Notifications.class, Topic.BroadcastDirection.NONE); String SYSTEM_MESSAGES_GROUP_ID = "System Messages"; - void notify(@NotNull Notification notification); + default void notify(@NotNull Notification notification) { + } - void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType); - void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType, boolean shouldLog); - void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType, boolean shouldLog, boolean shouldReadAloud); + default void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType) { + } + + default void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType, boolean shouldLog) { + } + + default void register(@NotNull String groupDisplayName, + @NotNull NotificationDisplayType defaultDisplayType, + boolean shouldLog, + boolean shouldReadAloud) { + } @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"}) class Bus { diff --git a/platform/platform-api/src/com/intellij/notification/NotificationsAdapter.java b/platform/platform-api/src/com/intellij/notification/NotificationsAdapter.java index 6474e16c167b..11cd5b2d75a0 100644 --- a/platform/platform-api/src/com/intellij/notification/NotificationsAdapter.java +++ b/platform/platform-api/src/com/intellij/notification/NotificationsAdapter.java @@ -1,41 +1,9 @@ -/* - * Copyright 2000-2013 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-2019 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.notification; -import org.jetbrains.annotations.NotNull; - +/** + * @deprecated Use {@link Notifications} directly + */ +@Deprecated public class NotificationsAdapter implements Notifications { - @Override - public void notify(@NotNull Notification notification) { - } - - @Override - public void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType) { - } - - @Override - public void register(@NotNull String groupDisplayName, - @NotNull NotificationDisplayType defaultDisplayType, - boolean shouldLog) { - } - - @Override - public void register(@NotNull String groupDisplayName, - @NotNull NotificationDisplayType defaultDisplayType, - boolean shouldLog, - boolean shouldReadAloud) { - } } diff --git a/platform/platform-api/src/com/intellij/notification/NotificationsConfiguration.java b/platform/platform-api/src/com/intellij/notification/NotificationsConfiguration.java index b68ba8ab4ee0..9ff75d74762a 100644 --- a/platform/platform-api/src/com/intellij/notification/NotificationsConfiguration.java +++ b/platform/platform-api/src/com/intellij/notification/NotificationsConfiguration.java @@ -1,23 +1,9 @@ -/* - * 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-2019 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.notification; import com.intellij.openapi.application.ApplicationManager; -public abstract class NotificationsConfiguration extends NotificationsAdapter { +public abstract class NotificationsConfiguration implements Notifications { /** * If notification group ID starts with this prefix it wouldn't be shown in Preferences */ diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 9d3ccc93cea1..5b45bf72527e 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -1,4 +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-2019 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.notification; @@ -63,7 +63,7 @@ public class EventLog { private final LogModel myModel = new LogModel(null, ApplicationManager.getApplication()); public EventLog() { - ApplicationManager.getApplication().getMessageBus().connect().subscribe(Notifications.TOPIC, new NotificationsAdapter() { + ApplicationManager.getApplication().getMessageBus().connect().subscribe(Notifications.TOPIC, new Notifications() { @Override public void notify(@NotNull Notification notification) { final Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); @@ -468,7 +468,7 @@ public class EventLog { printNotification(notification); } - project.getMessageBus().connect(project).subscribe(Notifications.TOPIC, new NotificationsAdapter() { + project.getMessageBus().connect(project).subscribe(Notifications.TOPIC, new Notifications() { @Override public void notify(@NotNull Notification notification) { printNotification(notification); diff --git a/platform/platform-impl/src/com/intellij/notification/impl/MacEventReader.java b/platform/platform-impl/src/com/intellij/notification/impl/MacEventReader.java index 02445b93f04d..0bdd5ba0babc 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/MacEventReader.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/MacEventReader.java @@ -3,7 +3,6 @@ package com.intellij.notification.impl; import com.intellij.notification.Notification; import com.intellij.notification.Notifications; -import com.intellij.notification.NotificationsAdapter; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -18,7 +17,7 @@ import java.util.concurrent.Executor; class MacEventReader { private static final int MAX_MESSAGE_LENGTH = 100; private static final Logger LOG = Logger.getInstance("#com.intellij.notification.impl.MacEventReader"); - private static final NotificationsAdapter ourNotificationAdapter = new NotificationsAdapter() { + private static final Notifications ourNotificationAdapter = new Notifications() { @Override public void notify(@NotNull Notification notification) { process(notification); diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index c20ef7a0423b..ef7626863d16 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java @@ -70,10 +70,7 @@ import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; -/** - * @author spleaner - */ -public class NotificationsManagerImpl extends NotificationsManager { +public final class NotificationsManagerImpl extends NotificationsManager { public static final Color DEFAULT_TEXT_COLOR = new JBColor(Gray._0, Gray._191); private static final Color TEXT_COLOR = JBColor.namedColor("Notification.foreground", DEFAULT_TEXT_COLOR); public static final Color FILL_COLOR = JBColor.namedColor("Notification.background", new JBColor(Gray._242, new Color(78, 80, 82))); @@ -1038,14 +1035,14 @@ public class NotificationsManagerImpl extends NotificationsManager { } } - private static void showPopup(@NotNull LinkLabel link, @NotNull DefaultActionGroup group) { + private static void showPopup(@NotNull LinkLabel link, @NotNull DefaultActionGroup group) { if (link.isShowing()) { ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); menu.getComponent().show(link, JBUIScale.scale(-10), link.getHeight() + JBUIScale.scale(2)); } } - private static class MyNotificationListener extends NotificationsAdapter { + private static class MyNotificationListener implements Notifications { private final Project myProject; private MyNotificationListener(@Nullable Project project) { diff --git a/plugins/settings-repository/src/autoSync.kt b/plugins/settings-repository/src/autoSync.kt index b49763d65947..1810fe3a1e5d 100644 --- a/plugins/settings-repository/src/autoSync.kt +++ b/plugins/settings-repository/src/autoSync.kt @@ -4,7 +4,6 @@ package org.jetbrains.settingsRepository import com.intellij.configurationStore.ComponentStoreImpl import com.intellij.notification.Notification import com.intellij.notification.Notifications -import com.intellij.notification.NotificationsAdapter import com.intellij.openapi.application.AppUIExecutor import com.intellij.openapi.application.Application import com.intellij.openapi.application.ApplicationManager @@ -48,7 +47,7 @@ internal class AutoSyncManager(private val icsManager: IcsManager) { } fun registerListeners(project: Project) { - project.messageBus.connect().subscribe(Notifications.TOPIC, object : NotificationsAdapter() { + project.messageBus.connect().subscribe(Notifications.TOPIC, object : Notifications { override fun notify(notification: Notification) { if (!icsManager.isActive) { return diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskManagerTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskManagerTest.java index 9c4dce88040a..0bf42c248c9f 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskManagerTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskManagerTest.java @@ -4,7 +4,6 @@ package com.intellij.tasks; import com.intellij.configurationStore.XmlSerializer; import com.intellij.notification.Notification; import com.intellij.notification.Notifications; -import com.intellij.notification.NotificationsAdapter; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.util.PasswordUtil; @@ -43,7 +42,7 @@ public class TaskManagerTest extends TaskManagerTestCase { public void testNotifications() { final Ref notificationRef = new Ref<>(); - getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(Notifications.TOPIC, new NotificationsAdapter() { + getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(Notifications.TOPIC, new Notifications() { @Override public void notify(@NotNull Notification notification) { notificationRef.set(notification);