/*
 * 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.find.editorHeaderActions;

import com.intellij.find.SearchSession;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.scale.JBUIScale;

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

public class StatusTextAction extends DumbAwareAction implements CustomComponentAction {
  @Override
  public void update(AnActionEvent e) {
    SearchSession search = e.getData(SearchSession.KEY);
    String statusText = search == null ? "" : search.getComponent().getStatusText();
    JLabel label = (JLabel)e.getPresentation().getClientProperty(COMPONENT_KEY);
    if (label != null) {
      label.setText(statusText);
      label.setVisible(StringUtil.isNotEmpty(statusText));
    }
  }

  @Override
  public void actionPerformed(AnActionEvent e) {
  }

  @Override
  public JComponent createCustomComponent(Presentation presentation, String place) {
    JLabel label = new JLabel();
    //noinspection HardCodedStringLiteral
    label.setText("9888 results");
    Dimension size = label.getPreferredSize();
    size.height = Math.max(size.height, JBUIScale.scale(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.getHeight()));
    label.setPreferredSize(size);
    label.setText(null);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
  }
}

@@ -1,13 +1,10 @@
 /
-*%0A *
+/
  Copyrig
@@ -18,9 +18,9 @@
 -201
-5
+8
  Jet
@@ -36,566 +36,109 @@
 r.o.
-%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */
+ Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 %0Apac
@@ -533,78 +533,144 @@
 lij.
-openapi.util.text.StringUtil;%0Aimport com.intellij.ui.scale.JBUIScale;%0A
+ui.scale.JBUIScale;%0Aimport com.intellij.util.ui.UIUtil;%0Aimport consulo.ui.annotation.RequiredUIAccess;%0A%0Aimport javax.annotation.Nonnull;
 %0Aimp
@@ -797,16 +797,36 @@
 ction %7B%0A
+  @RequiredUIAccess%0A
   @Overr
@@ -850,16 +850,25 @@
  update(
+@Nonnull 
 AnAction
@@ -939,93 +939,8 @@
 Y);%0A
-    String statusText = search == null ? %22%22 : search.getComponent().getStatusText();%0A
     
@@ -1034,17 +1034,17 @@
 bel 
-!
+=
 = null) 
 %7B%0A  
@@ -1043,16 +1043,20 @@
 ll) 
-%7B
+return;
 %0A    
-  
 labe
@@ -1066,16 +1066,63 @@
 etText(s
+earch == null ? %22%22 : search.getComponent().getS
 tatusTex
@@ -1122,21 +1122,21 @@
 atusText
+()
 );%0A
-  
     labe
@@ -1144,62 +1144,131 @@
 .set
-Visible(StringUtil.isNotEmpty(statusText));%0A    %7D%0A  %7D%0A
+Foreground(search == null ? UIUtil.getLabelForeground() : search.getComponent().getStatusColor());%0A  %7D%0A%0A  @RequiredUIAccess
 %0A  @
@@ -1306,16 +1306,25 @@
 rformed(
+@Nonnull 
 AnAction
@@ -1339,16 +1339,27 @@
  %7B%0A  %7D%0A%0A
+  @Nonnull%0A
   @Overr
@@ -1404,16 +1404,25 @@
 mponent(
+@Nonnull 
 Presenta
@@ -1439,16 +1439,25 @@
 ntation,
+ @Nonnull
  String 

if there no results - mark as red