Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-05-06 08:18:17 -0400
committerMatthias Sohn2018-05-13 18:39:56 -0400
commit9d919ee23739a5f0159ec265ed1141a2adcf26af (patch)
treeaf3ff5c53aa6d2d60ed372ebdc58c7688d7f6573 /org.eclipse.egit.ui/src
parent477962a039498dc7dfa8b2919fe6fd6fb8a78d6c (diff)
downloadegit-9d919ee23739a5f0159ec265ed1141a2adcf26af.tar.gz
egit-9d919ee23739a5f0159ec265ed1141a2adcf26af.tar.xz
egit-9d919ee23739a5f0159ec265ed1141a2adcf26af.zip
Suggest complete repository path in NewRepositoryWizard
This simplifies the new repository wizard by suggesting "repository", "repository2", ... as the default name of the new repository. That way the wizard is even more simple to use for end users. This also simplifies validation, since with the old behavior this could easily trigger warnings of the directory not being empty (which is now guaranteed). Bug: 534404 Change-Id: I3175f8f0e791efa63ba458a250c5fa81c5164504 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src')
-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