IDEA-54920
authorAlexey Kudravtsev <cdr@intellij.com>
Fri, 14 May 2010 10:14:04 +0000 (14:14 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Fri, 14 May 2010 10:15:29 +0000 (14:15 +0400)
java/java-impl/src/com/intellij/application/options/editor/JavaAutoImportOptions.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java

index 01196d2fdea60e57562ee13bca71fdb6170693c6..adf09ac28080e6854ed61ee297ff59c36de2d912 100644 (file)
@@ -30,6 +30,8 @@ import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
 import com.intellij.openapi.ui.InputValidator;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.EmptyRunnable;
+import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.ui.ListScrollingUtil;
 import com.intellij.ui.ListUtil;
 import org.jetbrains.annotations.NonNls;
 
@@ -94,14 +96,14 @@ public class JavaAutoImportOptions implements AutoImportOptionsProvider {
   }
 
   public void addExcludePackage(String packageName) {
-    if (packageName != null) {
-      myExcludePackagesModel.add(myExcludePackagesModel.size(), packageName);
-      myExcludePackagesList.setSelectedValue(packageName, true);
+    if (packageName == null) {
+      return;
     }
-  }
-
-  public JList getExcludePackagesList() {
-    return myExcludePackagesList;
+    int index = myExcludePackagesModel.size();
+    myExcludePackagesModel.add(index, packageName);
+    myExcludePackagesList.setSelectedValue(packageName, true);
+    ListScrollingUtil.ensureIndexIsVisible(myExcludePackagesList, index, 0);
+    IdeFocusManager.getGlobalInstance().requestFocus(myExcludePackagesList, false);
   }
 
   public void reset() {
index 2bfc5e615541612adcabaa3dcb291a70aeb17411..afee224443e9d9871ce49295d391ee62b4b355f2 100644 (file)
@@ -162,7 +162,6 @@ public class AddImportAction implements QuestionAction {
           public void run() {                 
             final JavaAutoImportOptions options = ContainerUtil.findInstance(configurable.getConfigurables(), JavaAutoImportOptions.class);
             options.addExcludePackage(prefix);
-            IdeFocusManager.getInstance(project).requestFocus(options.getExcludePackagesList(), false);
           }
         });
       }