Fixed one more case (WI-8555).
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 23 Nov 2011 12:19:43 +0000 (13:19 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 23 Nov 2011 12:19:43 +0000 (13:19 +0100)
platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.java

index 73d6e706674bc40f839b9cbfc7bae1a91eab22d6..d8e5c8a24f43cb7f662fcc11bbf58473d91a1e78 100644 (file)
@@ -54,6 +54,7 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
   private String myBaseDir;
   private boolean myModifyingLocation = false;
   private boolean myModifyingProjectName = false;
+  private boolean myExternalModify = false;
 
   private static final Object EMPTY_PROJECT_GENERATOR = new Object();
   private final String mySuggestedProjectName;
@@ -82,13 +83,15 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
                                                                            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
         protected void onFileChoosen(VirtualFile chosenFile) {
           myBaseDir = chosenFile.getPath();
-          if (myProjectNameWasChanged) {
+          if (myProjectNameWasChanged && !myProjectNameTextField.getText().equals(chosenFile.getName())) {
+            myExternalModify = true;
             myLocationField.setText(new File(chosenFile.getPath(), myProjectNameTextField.getText()).toString());
+            myExternalModify = false;
           } else {
-            myModifyingLocation = true;
+            myExternalModify = true;
             myLocationField.setText(chosenFile.getPath());
             myProjectNameTextField.setText(chosenFile.getName());
-            myModifyingLocation = false;
+            myExternalModify = false;
           }
         }
       };
@@ -96,6 +99,9 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
     myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
       @Override
       protected void textChanged(DocumentEvent e) {
+        if (myExternalModify) {
+          return;
+        }
         myModifyingLocation = true;
         String path = myLocationField.getText().trim();
         if (path.endsWith(File.separator)) {
@@ -119,7 +125,7 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
 
     myProjectNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
       protected void textChanged(final DocumentEvent e) {
-        if (!myModifyingLocation) {
+        if (!myModifyingLocation && !myExternalModify) {
           myProjectNameWasChanged = true;
           myModifyingProjectName = true;
           File f = new File(myBaseDir);