diff options
| author | Mathias Kinzler | 2010-03-05 13:58:31 +0000 |
|---|---|---|
| committer | Mathias Kinzler | 2010-03-05 14:35:15 +0000 |
| commit | 4d88f03ad6b97e43712a856f08bc6b45f6ac868b (patch) | |
| tree | 179beeed5cd0e6111098c13c0be5c11aa0301288 | |
| parent | de2a3d222c1d2ac52f55995124cac6b0ab4f7c5b (diff) | |
| download | egit-4d88f03ad6b97e43712a856f08bc6b45f6ac868b.tar.gz egit-4d88f03ad6b97e43712a856f08bc6b45f6ac868b.tar.xz egit-4d88f03ad6b97e43712a856f08bc6b45f6ac868b.zip | |
"Local file..." button for Repository import
A button is added to the "Import Git Repository" wizard in order to allow the user
to select a directory in the local file system.
After a directory was selected, the URI-field of the wizard is filled with a file-URI.
Bug: 304478
Change-Id: I7599e2edc27e9b39a2b828f8768f535ad19b92de
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
3 files changed, 44 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index c1588a4da9..7f9c5a2ce2 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -144,6 +144,9 @@ public class UIText extends NLS { public static String GitProjectPropertyPage_ValueUnbornBranch; /** */ + public static String RepositorySelectionPage_BrowseLocalFile; + + /** */ public static String RepositorySelectionPage_sourceSelectionTitle; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java index 192a11fca4..0ef09825a9 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java @@ -12,6 +12,7 @@ package org.eclipse.egit.ui.internal.components; import java.io.File; +import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; import java.util.List; @@ -33,9 +34,11 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.URIish; @@ -266,6 +269,8 @@ public class RepositorySelectionPage extends BaseWizardPage { final Group g = createGroup(parent, UIText.RepositorySelectionPage_groupLocation); + g.setLayout(new GridLayout(3, false)); + newLabel(g, UIText.RepositorySelectionPage_promptURI + ":"); //$NON-NLS-1$ uriText = new Text(g, SWT.BORDER); uriText.setLayoutData(createFieldGridData()); @@ -319,9 +324,42 @@ public class RepositorySelectionPage extends BaseWizardPage { } }); + Button browseButton = new Button(g, SWT.NULL); + browseButton.setText(UIText.RepositorySelectionPage_BrowseLocalFile); + browseButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + DirectoryDialog dialog = new DirectoryDialog(getShell()); + // if a file-uri was selected before, let's try to open + // the directory dialog on the same directory + if (!uriText.getText().equals("")) { //$NON-NLS-1$ + try { + URI testUri = URI.create(uriText.getText().replace( + '\\', '/')); + if (testUri.getScheme().equals("file")) { //$NON-NLS-1$ + String path = testUri.getPath(); + if (path.length() > 1 && path.startsWith("/")) //$NON-NLS-1$ + path = path.substring(1); + + dialog.setFilterPath(path); + } + } catch (IllegalArgumentException e1) { + // ignore here, we just' don't set the directory in the + // browser + } + + } + String result = dialog.open(); + if (result != null) + uriText.setText("file:///" + result); //$NON-NLS-1$ + } + + }); + newLabel(g, UIText.RepositorySelectionPage_promptHost + ":"); //$NON-NLS-1$ hostText = new Text(g, SWT.BORDER); - hostText.setLayoutData(createFieldGridData()); + GridDataFactory.fillDefaults().span(2, 1).applyTo(hostText); hostText.addModifyListener(new ModifyListener() { public void modifyText(final ModifyEvent e) { setURI(uri.setHost(nullString(hostText.getText()))); @@ -330,7 +368,7 @@ public class RepositorySelectionPage extends BaseWizardPage { newLabel(g, UIText.RepositorySelectionPage_promptPath + ":"); //$NON-NLS-1$ pathText = new Text(g, SWT.BORDER); - pathText.setLayoutData(createFieldGridData()); + GridDataFactory.fillDefaults().span(2, 1).applyTo(pathText); pathText.addModifyListener(new ModifyListener() { public void modifyText(final ModifyEvent e) { setURI(uri.setPath(nullString(pathText.getText()))); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index 7c8b9a1cbb..5bdabee0af 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -54,6 +54,7 @@ GitProjectPropertyPage_LabelWorkdir=Working directory: GitProjectPropertyPage_ValueEmptyRepository=None (empty repository) GitProjectPropertyPage_ValueUnbornBranch=None (unborn branch) +RepositorySelectionPage_BrowseLocalFile=Local file... RepositorySelectionPage_sourceSelectionTitle=Source Git Repository RepositorySelectionPage_sourceSelectionDescription=Enter the location of the source repository. RepositorySelectionPage_destinationSelectionTitle=Destination Git Repository |
