fix introduce variable dialog combobox collapsing on some laf's
authorAlexey Pegov <alexey.pegov@jetbrains.com>
Wed, 7 Apr 2010 13:30:32 +0000 (17:30 +0400)
committerAlexey Pegov <alexey.pegov@jetbrains.com>
Wed, 7 Apr 2010 13:30:32 +0000 (17:30 +0400)
platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java

index 4f3a1835d8adbbf3778a44c9668ad53999a8d089..3e2d33fb73098f5fbe25f35104c9076e7504506f 100644 (file)
@@ -36,8 +36,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import javax.swing.event.EventListenerList;
 import java.awt.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
+import java.awt.event.*;
 import java.util.ArrayList;
 import java.util.EventListener;
 import java.util.List;
@@ -50,6 +49,8 @@ public class NameSuggestionsField extends JPanel {
   private MyDocumentListener myDocumentListener;
   private MyComboBoxItemListener myComboBoxItemListener;
 
+  private boolean myNonHumanChange = false;
+
   public NameSuggestionsField(Project project) {
     super(new BorderLayout());
     myProject = project;
@@ -207,7 +208,13 @@ public class NameSuggestionsField extends JPanel {
   }
 
   private void setupComboBox(final ComboBox combobox, FileType fileType) {
-    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox);
+    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
+      @Override
+      public void setItem(Object anObject) {
+        myNonHumanChange = true;
+        super.setItem(anObject);
+      }
+    };
 
     combobox.setEditor(comboEditor);
     combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));
@@ -294,9 +301,10 @@ public class NameSuggestionsField extends JPanel {
     }
 
     public void documentChanged(DocumentEvent event) {
-      if (myComponent instanceof JComboBox) {
+      if (!myNonHumanChange && myComponent instanceof JComboBox && ((JComboBox)myComponent).isPopupVisible()) {
         ((JComboBox)myComponent).hidePopup();
       }
+      myNonHumanChange = false;
 
       fireDataChanged();
     }