diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonLayoutImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonLayoutImpl.java index d4668982fa0a..ebcf22f23f00 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonLayoutImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonLayoutImpl.java @@ -253,6 +253,20 @@ public class BalloonLayoutImpl implements BalloonLayout { } } + public void closeAll() { + myCloseAll.run(); + } + + public void closeFirst() { + if (!myBalloons.isEmpty()) { + remove(myBalloons.get(0), true); + } + } + + public int getBalloonCount() { + return myBalloons.size(); + } + private static int getVisibleCount() { return Registry.intValue("ide.notification.visible.count", 2); } diff --git a/platform/platform-impl/src/com/intellij/ui/NotificationActions.kt b/platform/platform-impl/src/com/intellij/ui/NotificationActions.kt new file mode 100644 index 000000000000..6078fc7fb085 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/NotificationActions.kt @@ -0,0 +1,45 @@ +/* + * 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. + */ +package com.intellij.ui + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.wm.IdeFrame + +/** + * @author Alexander Lobas + */ + +abstract class NotificationAction : AnAction() { + override fun update(e: AnActionEvent) { + val layout = getBalloonLayout(e) + e.presentation.isEnabled = layout != null && layout.balloonCount > 0 + } + + protected fun getBalloonLayout(e: AnActionEvent) = e.getData(IdeFrame.KEY)?.balloonLayout as BalloonLayoutImpl? +} + +class CloseFirstNotificationAction : NotificationAction() { + override fun actionPerformed(e: AnActionEvent) { + getBalloonLayout(e)?.closeFirst() + } +} + +class CloseAllNotificationsAction : NotificationAction() { + override fun actionPerformed(e: AnActionEvent) { + getBalloonLayout(e)?.closeAll() + } +} \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 94e69d8e377b..d9bdb53bbb53 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -942,6 +942,9 @@ action.CloseAllUnpinnedEditors.description=Close all editors which are not pinne action.CloseContent.text=_Close action.CloseContent.description=Close currently focused content group.EditorTabsGroup.text=Editor _Tabs +action.CloseFirstNotification.text=Close First +action.CloseAllNotifications.text=Close All +group.Notifications.text=Notifications action.SplitVertically.text=Split _Vertically action.SplitVertically.description=Split editor area into 2 tab groups and move the current tab to the right group action.SplitHorizontally.text=Split _Horizontally diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 95fdcbe2d8f0..ee6a165d818a 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -481,6 +481,11 @@ + + + + +