/*
 * 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.
 */
package com.intellij.diff.tools.util;

import com.intellij.diff.comparison.DiffTooBigException;
import com.intellij.diff.util.TextDiffType;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.ui.EditorNotificationPanel;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;

public class DiffNotifications {
  @Deprecated @NotNull public static final JPanel INSERTED_CONTENT = createInsertedContent();
  @Deprecated @NotNull public static final JPanel REMOVED_CONTENT = createRemovedContent();
  @Deprecated @NotNull public static final JPanel EQUAL_CONTENTS = createEqualContents();
  @Deprecated @NotNull public static final JPanel ERROR = createError();
  @Deprecated @NotNull public static final JPanel OPERATION_CANCELED = createOperationCanceled();
  @Deprecated @NotNull public static final JPanel DIFF_TOO_BIG = createDiffTooBig();

  @NotNull
  public static JPanel createInsertedContent() {
    return createNotification("Content added", TextDiffType.INSERTED.getColor(null));
  }

  @NotNull
  public static JPanel createRemovedContent() {
    return createNotification("Content removed", TextDiffType.DELETED.getColor(null));
  }

  @NotNull
  public static JPanel createEqualContents() {
    return createNotification(DiffBundle.message("diff.contents.are.identical.message.text"));
  }

  @NotNull
  public static JPanel createError() {
    return createNotification("Can not calculate diff");
  }

  @NotNull
  public static JPanel createOperationCanceled() {
    return createNotification("Can not calculate diff. Operation canceled.");
  }

  @NotNull
  public static JPanel createDiffTooBig() {
    return createNotification("Can not calculate diff. " + DiffTooBigException.MESSAGE);
  }

  //
  // Impl
  //

  @NotNull
  public static JPanel createNotification(@NotNull String text) {
    return new EditorNotificationPanel().text(text);
  }

  @NotNull
  public static JPanel createNotification(@NotNull String text, @NotNull final Color background) {
    return new EditorNotificationPanel() {
      @Override
      public Color getBackground() {
        return background;
      }
    }.text(text);
  }
}

@@ -868,16 +868,59 @@
 NotNull;
+%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0Aimport
@@ -2500,47 +2500,208 @@
 urn 
-new EditorNotificationPanel().text(text
+createNotification(text, null);%0A  %7D%0A%0A  @NotNull%0A  public static JPanel createNotification(@NotNull String text, @Nullable final Color background) %7B%0A    return createNotification(text, background, true
 );%0A 
@@ -2781,22 +2781,23 @@
 text, @N
-otN
 ull
+able
  final C
@@ -2815,57 +2815,632 @@
 ound
-) %7B%0A    return new EditorNotificationPanel() %7B%0A  
+, boolean showHideAction) %7B%0A    final MyEditorNotificationPanel panel = new MyEditorNotificationPanel();%0A    panel.text(text);%0A    panel.setBackgroundColor(background);%0A    if (showHideAction) %7B%0A      panel.createActionLabel(%22Hide%22, new Runnable() %7B%0A        public void run() %7B%0A          panel.setVisible(false);%0A        %7D%0A      %7D).setToolTipText(%22Hide this notification%22);%0A    %7D%0A    return panel;%0A  %7D%0A%0A  private static class MyEditorNotificationPanel extends EditorNotificationPanel %7B%0A    @Nullable private Color myBackground;%0A%0A    public void setBackgroundColor(@Nullable Color value) %7B%0A      myBackground = value;%0A    %7D%0A%0A
     
@@ -3451,16 +3451,28 @@
 rride%0A  
+  @Nullable%0A
     publ
@@ -3508,18 +3508,18 @@
     
-  
 return 
-b
+myB
 ackg
@@ -3527,35 +3527,62 @@
 ound
-;%0A      %7D%0A    %7D.text(text);
+ != null ? myBackground : super.getBackground();%0A    %7D
 %0A  %7D

allow to hide notifications