ability to set predefined text in choose by name popup
authorRoman Chernyatchik <roman.chernyatchik@jetbrains.com>
Tue, 9 Feb 2010 12:34:27 +0000 (9 15:34 +0300)
committerRoman Chernyatchik <roman.chernyatchik@jetbrains.com>
Fri, 12 Feb 2010 14:04:16 +0000 (12 17:04 +0300)
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java

index 02dd80e..6f19f34 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.statistics.StatisticsInfo;
 import com.intellij.psi.statistics.StatisticsManager;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
@@ -35,8 +36,10 @@ import java.util.regex.Pattern;
 public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNamePopupComponent{
   private static final Key<ChooseByNamePopup> CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY = new Key<ChooseByNamePopup>("ChooseByNamePopup");
   private Component myOldFocusOwner = null;
-  private ChooseByNamePopup(final Project project, final ChooseByNameModel model, final ChooseByNamePopup oldPopup, final PsiElement context) {
-    super(project, model, oldPopup != null ? oldPopup.myTextField.getText() : null, context);
+
+  private ChooseByNamePopup(final Project project, final ChooseByNameModel model, final ChooseByNamePopup oldPopup,
+                            final PsiElement context, @Nullable final String predefinedText) {
+    super(project, model, oldPopup != null ? oldPopup.myTextField.getText() : predefinedText, context);
     if (oldPopup != null) { //inherit old focus owner
       myOldFocusOwner = oldPopup.myPreviouslyFocusedComponent;
     }
@@ -196,11 +199,15 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
   }
 
   public static ChooseByNamePopup createPopup(final Project project, final ChooseByNameModel model, final PsiElement context) {
+    return createPopup(project, model, context, null);
+  }
+  public static ChooseByNamePopup createPopup(final Project project, final ChooseByNameModel model, final PsiElement context,
+                                              @Nullable final String predefinedText) {
     final ChooseByNamePopup oldPopup = project.getUserData(CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
     if (oldPopup != null) {
       oldPopup.close(false);
     }
-    ChooseByNamePopup newPopup = new ChooseByNamePopup(project, model, oldPopup, context);
+    ChooseByNamePopup newPopup = new ChooseByNamePopup(project, model, oldPopup, context, predefinedText);
 
     project.putUserData(CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, newPopup);
     return newPopup;