// 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.openapi.wm;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.Consumer;
import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.MouseEvent;

/**
 * @see StatusBarWidgetProvider
 */
public interface StatusBarWidget extends Disposable {
  /**
   * @deprecated do not use it
   */
  @ApiStatus.ScheduledForRemoval
  @Deprecated
  enum PlatformType {
    DEFAULT, MAC
  }

  @NotNull
  String ID();

  @Nullable
  default WidgetPresentation getPresentation() {
    return getPresentation(SystemInfo.isMac ? PlatformType.MAC : PlatformType.DEFAULT);
  }

  /**
   * @deprecated use this{@link #getPresentation()} instead
   */
  @ApiStatus.ScheduledForRemoval
  @Deprecated
  @Nullable
  default WidgetPresentation getPresentation(@NotNull PlatformType type) {
    return null;
  }

  void install(@NotNull StatusBar statusBar);

  interface Multiframe extends StatusBarWidget {
    StatusBarWidget copy();
  }

  interface WidgetPresentation {
    @Nullable
    String getTooltipText();

    @Nullable
    Consumer<MouseEvent> getClickConsumer();
  }

  interface IconPresentation extends WidgetPresentation {
    @Nullable
    Icon getIcon();
  }

  interface TextPresentation extends WidgetPresentation {
    @NotNull
    String getText();

    /**
     * @deprecated unused
     */
    @NotNull
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    default String getMaxPossibleText() { return ""; }

    float getAlignment();
  }

  interface MultipleTextValuesPresentation extends WidgetPresentation {
    @Nullable("null means the widget is unable to show the popup")
    ListPopup getPopupStep();

    @Nullable
    String getSelectedValue();

    /**
     * @deprecated unused
     */
    @NotNull
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    default String getMaxValue() { return ""; }

    @Nullable
    default Icon getIcon() {
      return null;
    }
  }

  abstract class WidgetBorder implements Border {
    public static final Border ICON = JBUI.Borders.empty(0, 4);
    public static final Border INSTANCE = JBUI.Borders.empty(0, 6);
    public static final Border WIDE = JBUI.Borders.empty(0, 6);
  }
}

@@ -752,33 +752,55 @@
 eduledForRemoval
+(inVersion = %222020.2%22)
 %0A
-
   @Deprecated%0A  
@@ -1126,16 +1126,38 @@
 rRemoval
+(inVersion = %222020.2%22)
 %0A  @Depr
@@ -1830,32 +1830,54 @@
 eduledForRemoval
+(inVersion = %222020.2%22)
 %0A    default Str
@@ -2227,32 +2227,32 @@
     @Deprecated%0A
-
     @ApiStatus.S
@@ -2269,16 +2269,38 @@
 rRemoval
+(inVersion = %222020.2%22)
 %0A    def

Add inVersion parameter