/*
 * 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()
  }
}
/*
 * 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

abstract class CloseNotificationAction : 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 : CloseNotificationAction() {
  override fun actionPerformed(e: AnActionEvent) {
    getBalloonLayout(e)?.closeFirst()
  }
}

class CloseAllNotificationsAction : CloseNotificationAction() {
  override fun actionPerformed(e: AnActionEvent) {
    getBalloonLayout(e)?.closeAll()
  }
}
Rename one of NotificationAction classes to avoid confusion with another
Rename one of NotificationAction classes to avoid confusion with another

mglukhikh/intellij-community,xfournet/intellij-community,FHannes/intellij-community,xfournet/intellij-community,suncycheng/intellij-community,asedunov/intellij-community,ibinti/intellij-community,da1z/intellij-community,allotria/intellij-community,mglukhikh/intellij-community,ThiagoGarciaAlves/intellij-community,signed/intellij-community,ibinti/intellij-community,ibinti/intellij-community,apixandru/intellij-community,apixandru/intellij-community,semonte/intellij-community,ibinti/intellij-community,signed/intellij-community,ibinti/intellij-community,vvv1559/intellij-community,asedunov/intellij-community,apixandru/intellij-community,suncycheng/intellij-community,FHannes/intellij-community,signed/intellij-community,xfournet/intellij-community,allotria/intellij-community,apixandru/intellij-community,ibinti/intellij-community,vvv1559/intellij-community,mglukhikh/intellij-community,signed/intellij-community,mglukhikh/intellij-community,allotria/intellij-community,semonte/intellij-community,ibinti/intellij-community,apixandru/intellij-community,asedunov/intellij-community,ThiagoGarciaAlves/intellij-community,allotria/intellij-community,da1z/intellij-community,FHannes/intellij-community,da1z/intellij-community,vvv1559/intellij-community,da1z/intellij-community,xfournet/intellij-community,FHannes/intellij-community,vvv1559/intellij-community,asedunov/intellij-community,ThiagoGarciaAlves/intellij-community,suncycheng/intellij-community,signed/intellij-community,ThiagoGarciaAlves/intellij-community,da1z/intellij-community,suncycheng/intellij-community,asedunov/intellij-community,FHannes/intellij-community,ThiagoGarciaAlves/intellij-community,mglukhikh/intellij-community,da1z/intellij-community,signed/intellij-community,xfournet/intellij-community,FHannes/intellij-community,semonte/intellij-community,signed/intellij-community,suncycheng/intellij-community,mglukhikh/intellij-community,asedunov/intellij-community,signed/intellij-community,asedunov/intellij-community,semonte/intellij-community,ThiagoGarciaAlves/intellij-community,da1z/intellij-community,apixandru/intellij-community,mglukhikh/intellij-community,da1z/intellij-community,suncycheng/intellij-community,asedunov/intellij-community,xfournet/intellij-community,ibinti/intellij-community,mglukhikh/intellij-community,allotria/intellij-community,semonte/intellij-community,ibinti/intellij-community,apixandru/intellij-community,mglukhikh/intellij-community,xfournet/intellij-community,allotria/intellij-community,signed/intellij-community,FHannes/intellij-community,vvv1559/intellij-community,FHannes/intellij-community,ibinti/intellij-community,suncycheng/intellij-community,ThiagoGarciaAlves/intellij-community,apixandru/intellij-community,ibinti/intellij-community,FHannes/intellij-community,allotria/intellij-community,vvv1559/intellij-community,mglukhikh/intellij-community,signed/intellij-community,xfournet/intellij-community,da1z/intellij-community,vvv1559/intellij-community,apixandru/intellij-community,xfournet/intellij-community,allotria/intellij-community,vvv1559/intellij-community,suncycheng/intellij-community,vvv1559/intellij-community,semonte/intellij-community,semonte/intellij-community,suncycheng/intellij-community,ThiagoGarciaAlves/intellij-community,signed/intellij-community,suncycheng/intellij-community,FHannes/intellij-community,ibinti/intellij-community,allotria/intellij-community,allotria/intellij-community,FHannes/intellij-community,apixandru/intellij-community,apixandru/intellij-community,suncycheng/intellij-community,ThiagoGarciaAlves/intellij-community,allotria/intellij-community,apixandru/intellij-community,asedunov/intellij-community,signed/intellij-community,semonte/intellij-community,apixandru/intellij-community,semonte/intellij-community,suncycheng/intellij-community,mglukhikh/intellij-community,vvv1559/intellij-community,da1z/intellij-community,xfournet/intellij-community,semonte/intellij-community,xfournet/intellij-community,ThiagoGarciaAlves/intellij-community,ThiagoGarciaAlves/intellij-community,da1z/intellij-community,mglukhikh/intellij-community,allotria/intellij-community,xfournet/intellij-community,FHannes/intellij-community,xfournet/intellij-community,semonte/intellij-community,da1z/intellij-community,asedunov/intellij-community,signed/intellij-community,vvv1559/intellij-community,semonte/intellij-community,ThiagoGarciaAlves/intellij-community,apixandru/intellij-community,da1z/intellij-community,FHannes/intellij-community,vvv1559/intellij-community,asedunov/intellij-community,asedunov/intellij-community,mglukhikh/intellij-community,asedunov/intellij-community,allotria/intellij-community,vvv1559/intellij-community,ibinti/intellij-community,semonte/intellij-community