Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateRepositoryPage.java26
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties1
3 files changed, 28 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index ac06e4009..02710c876 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -2684,6 +2684,9 @@ public class UIText extends NLS {
public static String CreateRepositoryPage_BrowseButton;
/** */
+ public static String CreateRepositoryPage_DefaultRepositoryName;
+
+ /** */
public static String CreateRepositoryPage_DirectoryLabel;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateRepositoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateRepositoryPage.java
index dacf4f684..31379b03a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateRepositoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateRepositoryPage.java
@@ -11,6 +11,7 @@
package org.eclipse.egit.ui.internal.repository;
import java.io.File;
+import java.nio.file.Paths;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -65,7 +66,21 @@ public class CreateRepositoryPage extends WizardPage {
Label directoryLabel = new Label(main, SWT.NONE);
directoryLabel.setText(UIText.CreateRepositoryPage_DirectoryLabel);
directoryText = new Text(main, SWT.BORDER);
- directoryText.setText(RepositoryUtil.getDefaultRepositoryDir());
+ String initialDirectory = RepositoryUtil.getDefaultRepositoryDir();
+ int cursorPosition = initialDirectory.length();
+ if (!initialDirectory.isEmpty()) {
+ initialDirectory = RepositoryUtil.getDefaultRepositoryDir()
+ + File.separatorChar
+ + UIText.CreateRepositoryPage_DefaultRepositoryName;
+ int repoCounter = 2;
+ while (Paths.get(initialDirectory).toFile().exists()) {
+ initialDirectory = RepositoryUtil.getDefaultRepositoryDir()
+ + File.separatorChar
+ + UIText.CreateRepositoryPage_DefaultRepositoryName + repoCounter++;
+ }
+ cursorPosition++;
+ }
+ directoryText.setText(initialDirectory);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.grab(true, false).applyTo(directoryText);
Button browseButton = new Button(main, SWT.PUSH);
@@ -113,7 +128,14 @@ public class CreateRepositoryPage extends WizardPage {
setControl(main);
directoryText.setFocus();
- directoryText.setSelection(directoryText.getText().length());
+ directoryText.setSelection(cursorPosition,
+ directoryText.getText().length());
+ if (!directoryText.getText().isEmpty()) {
+ // enforce validation if a default repository directory is set.
+ // Otherwise the wizards initial validation state would be different
+ // than when entering the same directory text manually
+ checkPage();
+ }
}
/**
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index ad27d62f8..aadd11170 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -901,6 +901,7 @@ CreateBranchWizard_NewBranchTitle=Create Branch
CreateRepositoryCommand_CreateButtonLabel=&Create
CreateRepositoryPage_BareCheckbox=&Create as bare repository
CreateRepositoryPage_BrowseButton=&Browse...
+CreateRepositoryPage_DefaultRepositoryName=repository
CreateRepositoryPage_DirectoryLabel=Repository &directory:
CreateRepositoryPage_NotEmptyMessage=Directory {0} is not empty
CreateRepositoryPage_PageMessage=Determine the directory for the new repository

Back to the top