Merge branch 'refactor-package-manager'
[idea/community.git] / python / ide / src / com / jetbrains / python / newProject / actions / AbstractProjectSettingsStep.java
index 9e214aeb8be3f09cba62dcd24320285a85c263f0..6514741fda4528f840a65ff9034c465aa002b683 100644 (file)
@@ -37,6 +37,7 @@ import com.jetbrains.python.packaging.PyPackageManager;
 import com.jetbrains.python.sdk.PySdkUtil;
 import com.jetbrains.python.sdk.PythonSdkType;
 import icons.PythonIcons;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
@@ -74,22 +75,6 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
     myCallback = callback;
     myIsWelcomeScreen = isWelcomeScreen;
     myProjectDirectory = FileUtil.findSequentNonexistentFile(new File(ProjectUtil.getBaseDir()), "untitled", "");
-    if (myProjectGenerator instanceof WebProjectTemplate) {
-      ((WebProjectTemplate)myProjectGenerator).getPeer().addSettingsStateListener(new WebProjectGenerator.SettingsStateListener() {
-        @Override
-        public void stateChanged(boolean validSettings) {
-          checkValid();
-        }
-      });
-    }
-    else if (myProjectGenerator instanceof PythonProjectGenerator) {
-      ((PythonProjectGenerator)myProjectGenerator).addSettingsStateListener(new PythonProjectGenerator.SettingsListener() {
-        @Override
-        public void stateChanged() {
-          checkValid();
-        }
-      });
-    }
 
     myCreateAction = new AnAction("Create", "Create Project", getIcon()) {
       @Override
@@ -107,6 +92,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
 
   @Override
   public JPanel createPanel() {
+    initGeneratorListeners();
     final JPanel basePanel = createBasePanel();
     final JPanel mainPanel = new JPanel(new BorderLayout());
 
@@ -137,6 +123,25 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
     return mainPanel;
   }
 
+  private void initGeneratorListeners() {
+    if (myProjectGenerator instanceof WebProjectTemplate) {
+      ((WebProjectTemplate)myProjectGenerator).getPeer().addSettingsStateListener(new WebProjectGenerator.SettingsStateListener() {
+        @Override
+        public void stateChanged(boolean validSettings) {
+          checkValid();
+        }
+      });
+    }
+    else if (myProjectGenerator instanceof PythonProjectGenerator) {
+      ((PythonProjectGenerator)myProjectGenerator).addSettingsStateListener(new PythonProjectGenerator.SettingsListener() {
+        @Override
+        public void stateChanged() {
+          checkValid();
+        }
+      });
+    }
+  }
+
   protected Icon getIcon() {
     return myProjectGenerator.getLogo();
   }
@@ -433,6 +438,10 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
     return myLocationField.getText();
   }
 
+  public void setLocation(@NotNull final String location) {
+    myLocationField.setText(location);
+  }
+
   public boolean installFramework() {
     return myInstallFramework;
   }