mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Notification actions: Close First, Close All
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -481,6 +481,11 @@
|
||||
<action id="AddNewTabToTheEndMode" class="com.intellij.ide.actions.TabsAddedToTheEndSwitcher"/>
|
||||
</group>
|
||||
|
||||
<group id="Notifications" popup="true">
|
||||
<action class="com.intellij.ui.CloseFirstNotificationAction" id="CloseFirstNotification"/>
|
||||
<action class="com.intellij.ui.CloseAllNotificationsAction" id="CloseAllNotifications"/>
|
||||
</group>
|
||||
|
||||
<group id="BackgroundTasks" popup="true">
|
||||
<action id="ShowProcessWindow" class="com.intellij.openapi.wm.impl.status.ShowProcessWindowAction"/>
|
||||
<action id="AutoShowProcessWindow" class="com.intellij.openapi.wm.impl.status.AutoShowProcessPopupAction"/>
|
||||
|
||||
Reference in New Issue
Block a user