/*
 * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
 * Use is subject to license terms.
 */
package com.intellij.openapi.project;

import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.ui.popup.BalloonHandler;
import org.jetbrains.annotations.NotNull;

/**
 * @author peter
 */
public class DumbModeIndicator implements ProjectComponent {
  private final Project myProject;

  public DumbModeIndicator(Project project) {
    myProject = project;
  }

  public void projectOpened() {
    myProject.getMessageBus().connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
      BalloonHandler myHandler;

      public void beforeEnteringDumbMode() {
      }

      public void enteredDumbMode() {
        myHandler = DumbService.getInstance(myProject).showDumbModeNotification(
          "Index update is in progress...<br>" +
          "During this process some actions that require these indices won't be available.<br>" +
          "<a href=\'help\'>Click here for more info</a>");
      }

      public void exitDumbMode() {
        if (myHandler != null) myHandler.hide();
        myHandler = null;
      }
    });
  }

  public void projectClosed() {
  }

  @NotNull
  public String getComponentName() {
    return DumbModeIndicator.class.getSimpleName();
  }

  public void initComponent() {
  }

  public void disposeComponent() {
  }
}

@@ -253,16 +253,48 @@
 andler;%0A
+import com.intellij.util.Alarm;%0A
 import o
@@ -448,16 +448,47 @@
 Project;
+%0A  private final Alarm myAlarm;
 %0A%0A  publ
@@ -552,16 +552,50 @@
 roject;%0A
+    myAlarm = new Alarm(project);%0A
   %7D%0A%0A  p
@@ -850,32 +850,110 @@
 redDumbMode() %7B%0A
+        myAlarm.addRequest(new Runnable() %7B%0A          public void run() %7B%0A    
         myHandle
@@ -1027,16 +1027,20 @@
         
+ 
+   
 %22Index u
@@ -1062,32 +1062,36 @@
 gress...%3Cbr%3E%22 +%0A
+    
           %22Durin
@@ -1182,16 +1182,20 @@
         
+   
+ 
 %22%3Ca href
@@ -1236,16 +1236,46 @@
 %3C/a%3E%22);%0A
+          %7D%0A        %7D, 1000);%0A
       %7D%0A
@@ -1302,32 +1302,69 @@
 xitDumbMode() %7B%0A
+        myAlarm.cancelAllRequests();%0A
         if (myHa

add 1 second latency for dumb mode message