Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Lay2012-01-30 10:51:16 +0000
committerMatthias Sohn2012-01-30 15:57:21 +0000
commitf743c8121dc5fae73fb57e0e4c5b912a31d7e63f (patch)
tree549df4564751edee972ed8af69e0cfd3df105d6f /org.eclipse.egit.ui/src/org/eclipse
parentafa51e7b33fefe961ffffee44e34a0cb91480a83 (diff)
downloadegit-f743c8121dc5fae73fb57e0e4c5b912a31d7e63f.tar.gz
egit-f743c8121dc5fae73fb57e0e4c5b912a31d7e63f.tar.xz
egit-f743c8121dc5fae73fb57e0e4c5b912a31d7e63f.zip
Redesign GitImportWizard to include contributed clone sources
The GitImportWizard now includes the extensions of the org.eclipse.egit.ui.cloneSourceProvider. The flow of pages is the same as described in the Mock-Up which is attached to Bug 361251. Bug: 361251 Change-Id: I957ee48121b24fd78a91fe5e2855130c4614649f Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java26
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportWizard.java143
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationContentProvider.java104
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationLabelProvider.java32
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationPage.java152
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties3
10 files changed, 450 insertions, 64 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 0d8a0361ec..b5315f1025 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
@@ -979,6 +979,12 @@ public class UIText extends NLS {
public static String RepositoryCommit_UserAndDate;
/** */
+ public static String RepositoryLocationPage_info;
+
+ /** */
+ public static String RepositoryLocationPage_title;
+
+ /** */
public static String RepositorySearchDialog_browse;
/** */
@@ -3031,6 +3037,9 @@ public class UIText extends NLS {
public static String GitImportWithDirectoriesPage_SelectFolderMessage;
/** */
+ public static String GitImportWizard_errorParsingURI;
+
+ /** */
public static String GitImportWizard_WizardTitle;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
index 6e55cc1789..5149cb5752 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/CloneDestinationPage.java
@@ -79,6 +79,12 @@ class CloneDestinationPage extends WizardPage {
private String helpContext = null;
+ private File clonedDestination;
+
+ private Ref clonedInitialBranch;
+
+ private String clonedRemote;
+
CloneDestinationPage() {
super(CloneDestinationPage.class.getName());
setTitle(UIText.CloneDestinationPage_title);
@@ -324,6 +330,11 @@ class CloneDestinationPage extends WizardPage {
* Check internal state for page completion status.
*/
private void checkPage() {
+ if (!cloneSettingsChanged()) {
+ setErrorMessage(null);
+ setPageComplete(true);
+ return;
+ }
final String dstpath = directoryText.getText();
if (dstpath.length() == 0) {
setErrorMessage(UIText.CloneDestinationPage_errorDirectoryRequired);
@@ -361,6 +372,21 @@ class CloneDestinationPage extends WizardPage {
setPageComplete(true);
}
+ void saveSettingsForClonedRepo() {
+ clonedDestination = getDestinationFile();
+ clonedInitialBranch = getInitialBranch();
+ clonedRemote = getRemote();
+ }
+
+ boolean cloneSettingsChanged() {
+ boolean cloneSettingsChanged = false;
+ if (clonedDestination == null || !clonedDestination.equals(getDestinationFile()) ||
+ clonedInitialBranch == null || !clonedInitialBranch.equals(getInitialBranch()) ||
+ clonedRemote == null || !clonedRemote.equals(getRemote()))
+ cloneSettingsChanged = true;
+ return cloneSettingsChanged;
+ }
+
private static boolean isEmptyDir(final File dir) {
if (!dir.exists())
return true;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
index df4bda8a46..86598cac2b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
@@ -53,10 +53,10 @@ public class GitCloneWizard extends AbstractGitCloneWizard {
setWindowTitle(UIText.GitCloneWizard_title);
setDefaultPageImageDescriptor(UIIcons.WIZBAN_IMPORT_REPO);
setNeedsProgressMonitor(true);
- cloneSource = new RepositorySelectionPage(true, presetURI);
- cloneSource.setHelpContext(HELP_CONTEXT);
validSource.setHelpContext(HELP_CONTEXT);
cloneDestination.setHelpContext(HELP_CONTEXT);
+ cloneSource = new RepositorySelectionPage(true, presetURI);
+ cloneSource.setHelpContext(HELP_CONTEXT);
gerritConfiguration = new GerritConfigurationPage() {
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportWizard.java
index b2bde77104..1a7d91f867 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010-2012 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,11 +7,14 @@
*
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
+ * Stefan Lay (SAP AG) - improvements
*******************************************************************************/
package org.eclipse.egit.ui.internal.clone;
import java.io.File;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -28,15 +31,19 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.core.securestorage.UserPasswordCredentials;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.internal.ConfigurationChecker;
+import org.eclipse.egit.ui.internal.clone.GitCloneSourceProviderExtension.CloneSourceProvider;
+import org.eclipse.egit.ui.internal.components.RepositorySelection;
+import org.eclipse.egit.ui.internal.provisional.wizards.IRepositorySearchResult;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.URIish;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
@@ -44,66 +51,96 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.NewProjectAction;
/**
- * The import wizard including options to clone/add repositories
+ * A wizard which allows to optionally clone a repository and to import projects from a repository.
*/
-public class GitImportWizard extends Wizard implements IImportWizard {
+public class GitImportWizard extends AbstractGitCloneWizard implements IImportWizard {
+
+ private List<CloneSourceProvider> repositoryImports;
+
private GitSelectRepositoryPage selectRepoPage = new GitSelectRepositoryPage();
- private GitSelectWizardPage importWithDirectoriesPage = new GitSelectWizardPage();
+ private GitSelectWizardPage importWithDirectoriesPage = new GitSelectWizardPage(){
+ public void setVisible(boolean visible) {
+ if (visible && (cloneDestination.cloneSettingsChanged())) {
+ setCallerRunsCloneOperation(true);
+ try {
+ performClone(new URIish(currentSearchResult.getGitRepositoryInfo().getCloneUri()), getCredentials());
+ importWithDirectoriesPage.getControl().getDisplay().asyncExec(new Runnable() {
- private GitProjectsImportPage projectsImportPage = new GitProjectsImportPage();
+ public void run() {
+ runCloneOperation(getContainer());
+ cloneDestination.saveSettingsForClonedRepo();
+ }});
+ } catch (URISyntaxException e) {
+ Activator.error(UIText.GitImportWizard_errorParsingURI, e);
+ }
+ }
+ super.setVisible(visible);
+ }
+ };
+
+ private GitProjectsImportPage projectsImportPage = new GitProjectsImportPage() ;
private GitCreateGeneralProjectPage createGeneralProjectPage = new GitCreateGeneralProjectPage();
+ private IRepositorySearchResult currentSearchResult;
+
/**
- * Default constructor
+ * The default constructor
*/
public GitImportWizard() {
setWindowTitle(UIText.GitImportWizard_WizardTitle);
setDefaultPageImageDescriptor(UIIcons.WIZBAN_IMPORT_REPO);
- selectRepoPage.setWizard(this);
- setNeedsProgressMonitor(true);
- ConfigurationChecker.checkConfiguration();
}
+
@Override
- public void addPages() {
+ protected void addPreClonePages() {
+ repositoryImports = GitCloneSourceProviderExtension.getCloneSourceProvider();
+ addPage(new RepositoryLocationPage(repositoryImports));
addPage(selectRepoPage);
+ }
+
+ @Override
+ protected void addPostClonePages() {
addPage(importWithDirectoriesPage);
addPage(projectsImportPage);
addPage(createGeneralProjectPage);
}
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // nothing to do
+ }
+
@Override
- public boolean performFinish() {
+ protected RepositorySelection getRepositorySelection() {
try {
- getContainer().run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- importProjects(monitor);
- }
- });
- } catch (InvocationTargetException e) {
- Activator
- .handleError(e.getCause().getMessage(), e.getCause(), true);
- return false;
- } catch (InterruptedException e) {
- Activator.handleError(
- UIText.GitCreateProjectViaWizardWizard_AbortedMessage, e,
- true);
- return false;
+ return (new RepositorySelection(new URIish(currentSearchResult.getGitRepositoryInfo().getCloneUri()), null));
+ } catch (URISyntaxException e) {
+ Activator.error(UIText.GitImportWizard_errorParsingURI, e);
+ return null;
}
- return true;
+ }
+
+ @Override
+ protected UserPasswordCredentials getCredentials() {
+ return currentSearchResult.getGitRepositoryInfo().getCredentials();
}
@Override
public IWizardPage getNextPage(IWizardPage page) {
- if (page == selectRepoPage) {
+ if (page == selectRepoPage ) {
importWithDirectoriesPage.setRepository(selectRepoPage
.getRepository());
return importWithDirectoriesPage;
+ }
+ else if (page instanceof IRepositorySearchResult) {
+ currentSearchResult = (IRepositorySearchResult)page;
+ return validSource;
+ } else if (page == cloneDestination) {
+ importWithDirectoriesPage.setRepository(getClonedRepository());
+ return importWithDirectoriesPage;
} else if (page == importWithDirectoriesPage) {
-
switch (importWithDirectoriesPage.getWizardSelection()) {
case GitSelectWizardPage.EXISTING_PROJECTS_WIZARD:
projectsImportPage.setProjectsList(importWithDirectoriesPage
@@ -117,7 +154,6 @@ public class GitImportWizard extends Wizard implements IImportWizard {
return createGeneralProjectPage;
}
-
} else if (page == createGeneralProjectPage
|| page == projectsImportPage) {
return null;
@@ -125,6 +161,39 @@ public class GitImportWizard extends Wizard implements IImportWizard {
return super.getNextPage(page);
}
+ private Repository getClonedRepository() {
+ try {
+ return org.eclipse.egit.core.Activator
+ .getDefault().getRepositoryCache().lookupRepository(new File(cloneDestination.getDestinationFile(), Constants.DOT_GIT));
+ } catch (IOException e) {
+ Activator.error("Error looking up repository at " + cloneDestination.getDestinationFile(), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+
+ @Override
+ public boolean performFinish() {
+ try {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ importProjects(monitor);
+ }
+ });
+ } catch (InvocationTargetException e) {
+ Activator
+ .handleError(e.getCause().getMessage(), e.getCause(), true);
+ return false;
+ } catch (InterruptedException e) {
+ Activator.handleError(
+ UIText.GitCreateProjectViaWizardWizard_AbortedMessage, e,
+ true);
+ return false;
+ }
+ return true;
+ }
+
@Override
public boolean canFinish() {
switch (importWithDirectoriesPage.getWizardSelection()) {
@@ -154,7 +223,7 @@ public class GitImportWizard extends Wizard implements IImportWizard {
IWorkingSet[] workingSetArray = projectsImportPage
.getSelectedWorkingSets();
workingSets.addAll(Arrays.asList(workingSetArray));
- repository[0] = selectRepoPage.getRepository();
+ repository[0] = getClonedRepository();
}
});
ProjectUtils.createProjects(projectsToCreate, repository[0],
@@ -166,7 +235,7 @@ public class GitImportWizard extends Wizard implements IImportWizard {
final File[] repoDir = new File[1];
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
- repoDir[0] = selectRepoPage.getRepository().getDirectory();
+ repoDir[0] = getClonedRepository().getDirectory();
}
});
final List<IProject> previousProjects = Arrays
@@ -211,7 +280,7 @@ public class GitImportWizard extends Wizard implements IImportWizard {
defaultLocation[0] = createGeneralProjectPage
.isDefaultLocation();
path[0] = importWithDirectoriesPage.getPath();
- repoDir[0] = selectRepoPage.getRepository().getDirectory();
+ repoDir[0] = getClonedRepository().getDirectory();
}
});
try {
@@ -244,7 +313,5 @@ public class GitImportWizard extends Wizard implements IImportWizard {
}
}
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // nothing to do
- }
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
index 4aa786e9a6..f3298dcd89 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
@@ -63,8 +63,6 @@ public class GitSelectRepositoryPage extends WizardPage {
private Button addRepo;
- private Button cloneRepo;
-
private IPreferenceChangeListener configChangeListener;
/**
@@ -120,27 +118,6 @@ public class GitSelectRepositoryPage extends WizardPage {
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tb);
GridDataFactory.fillDefaults().grab(false, true).applyTo(tb);
- cloneRepo = new Button(tb, SWT.PUSH);
- cloneRepo.setText(UIText.GitSelectRepositoryPage_CloneButton);
- cloneRepo.setToolTipText(UIText.GitSelectRepositoryPage_CloneTooltip);
-
- GridDataFactory.fillDefaults().grab(false, false).align(SWT.FILL,
- SWT.BEGINNING).applyTo(cloneRepo);
-
- cloneRepo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- GitCloneWizard cloneWizard = new GitCloneWizard();
- cloneWizard.setCallerRunsCloneOperation(true);
- WizardDialog dlg = new WizardDialog(getShell(), cloneWizard);
- dlg.setHelpAvailable(true);
- if (dlg.open() == Window.OK)
- cloneWizard.runCloneOperation(getContainer());
- checkPage();
- }
-
- });
-
addRepo = new Button(tb, SWT.PUSH);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL,
SWT.BEGINNING).applyTo(addRepo);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationContentProvider.java
new file mode 100644
index 0000000000..f9cf697d2f
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationContentProvider.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Lay (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.clone;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.clone.GitCloneSourceProviderExtension.CloneSourceProvider;
+import org.eclipse.egit.ui.internal.provisional.wizards.IRepositoryServerProvider;
+import org.eclipse.egit.ui.internal.provisional.wizards.RepositoryServerInfo;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+class RepositoryLocationContentProvider implements ITreeContentProvider {
+
+ private Map<RepositoryServerInfo, CloneSourceProvider> parents = new HashMap<RepositoryServerInfo, CloneSourceProvider>();
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // nothing to do
+ }
+
+ public void dispose() {
+ // nothing to do
+ }
+
+ public boolean hasChildren(Object element) {
+ Object[] children = calculateChildren(element);
+ return children != null && children.length > 0;
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof RepositoryServerInfo)
+ return parents.get(element);
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] getElements(Object inputElement) {
+ List<CloneSourceProvider> repositoryImports = (List<CloneSourceProvider>) inputElement;
+ return repositoryImports.toArray(new CloneSourceProvider[repositoryImports
+ .size()]);
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return calculateChildren(parentElement);
+ }
+
+ private Object[] calculateChildren(Object parentElement) {
+ if (parentElement instanceof CloneSourceProvider) {
+ CloneSourceProvider repositoryImport = (CloneSourceProvider) parentElement;
+ if (repositoryImport.hasFixLocation())
+ return null;
+ Collection<RepositoryServerInfo> repositoryServerInfos = getRepositoryServerInfos(repositoryImport);
+ if (repositoryServerInfos == null)
+ return null;
+ cacheParents(repositoryImport, repositoryServerInfos);
+ return repositoryServerInfos
+ .toArray(new RepositoryServerInfo[repositoryServerInfos
+ .size()]);
+ }
+ return null;
+ }
+
+ private Collection<RepositoryServerInfo> getRepositoryServerInfos(
+ CloneSourceProvider repositoryImport) {
+ Collection<RepositoryServerInfo> repositoryServerInfos = null;
+ IRepositoryServerProvider repositoryServerProvider;
+ try {
+ repositoryServerProvider = repositoryImport
+ .getRepositoryServerProvider();
+ } catch (CoreException e) {
+ Activator.error(e.getLocalizedMessage(), e);
+ return null;
+ }
+ if (repositoryServerProvider == null)
+ return null;
+ try {
+ repositoryServerInfos = repositoryServerProvider
+ .getRepositoryServerInfos();
+ } catch (RuntimeException e) {
+ Activator.error("Error on providing repository server infos", e); //$NON-NLS-1$
+ }
+ return repositoryServerInfos;
+ }
+
+ private void cacheParents(CloneSourceProvider repositoryImport,
+ Collection<RepositoryServerInfo> repositoryServerInfos) {
+ for (RepositoryServerInfo info : repositoryServerInfos)
+ parents.put(info, repositoryImport);
+ }
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationLabelProvider.java
new file mode 100644
index 0000000000..003367eb8b
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationLabelProvider.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Lay (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.clone;
+
+import org.eclipse.egit.ui.internal.clone.GitCloneSourceProviderExtension.CloneSourceProvider;
+import org.eclipse.egit.ui.internal.provisional.wizards.RepositoryServerInfo;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+class RepositoryLocationLabelProvider extends LabelProvider {
+ @Override
+ public String getText(Object element) {
+ if (element instanceof CloneSourceProvider)
+ return ((CloneSourceProvider) element).getLabel();
+ else if (element instanceof RepositoryServerInfo)
+ return ((RepositoryServerInfo) element).getLabel();
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return super.getImage(element);
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationPage.java
new file mode 100644
index 0000000000..976cd3795d
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/RepositoryLocationPage.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Lay (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.clone;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.clone.GitCloneSourceProviderExtension.CloneSourceProvider;
+import org.eclipse.egit.ui.internal.provisional.wizards.RepositoryServerInfo;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+/**
+ * Displays the possible locations of git repositories
+ */
+public class RepositoryLocationPage extends WizardPage {
+
+ private final List<CloneSourceProvider> repositoryImports;
+
+ // local cache for contributed WizardPages
+ private Map<CloneSourceProvider, WizardPage> resolvedWizardPages;
+
+ private TreeViewer tv;
+
+ /**
+ * @param cloneSourceProvider all contributed CloneSourceProviders
+ */
+ public RepositoryLocationPage(List<CloneSourceProvider> cloneSourceProvider) {
+ super(RepositoryLocationPage.class.getName());
+ cloneSourceProvider.add(0, CloneSourceProvider.LOCAL);
+ this.repositoryImports = cloneSourceProvider;
+ resolvedWizardPages = new HashMap<CloneSourceProvider, WizardPage>();
+ setTitle(UIText.RepositoryLocationPage_title);
+ setMessage(UIText.RepositoryLocationPage_info);
+ }
+
+ public void createControl(Composite parent) {
+ Composite main = new Composite(parent, SWT.NONE);
+
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0)
+ .applyTo(main);
+
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
+ // use a filtered tree
+ FilteredTree tree = new FilteredTree(main, SWT.SINGLE | SWT.BORDER
+ | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter(), true);
+
+ tv = tree.getViewer();
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(tree);
+ tv.setContentProvider(new RepositoryLocationContentProvider());
+
+ tv.setLabelProvider(new RepositoryLocationLabelProvider());
+
+ tv.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ checkPage();
+ }
+ });
+
+ tv.setInput(repositoryImports);
+ setControl(main);
+ }
+
+ private void checkPage() {
+ setErrorMessage(null);
+ boolean complete = false;
+ IStructuredSelection selection = (IStructuredSelection) tv
+ .getSelection();
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof CloneSourceProvider) {
+ CloneSourceProvider repositoryImport = (CloneSourceProvider) element;
+ if (repositoryImport.equals(CloneSourceProvider.LOCAL)
+ || repositoryImport.hasFixLocation())
+ complete = true;
+ } else if (element instanceof RepositoryServerInfo) {
+ complete = true;
+ }
+ }
+
+ setPageComplete(complete);
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ IStructuredSelection selection = (IStructuredSelection) tv
+ .getSelection();
+
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof CloneSourceProvider) {
+ return getNextPage((CloneSourceProvider) element);
+ } else if (element instanceof RepositoryServerInfo) {
+ Object parent = ((ITreeContentProvider) tv.getContentProvider())
+ .getParent(element);
+ if (parent instanceof CloneSourceProvider)
+ return getNextPage((CloneSourceProvider) parent);
+ }
+ }
+
+ return null;
+
+ }
+
+ private IWizardPage getNextPage(CloneSourceProvider repositoryImport) {
+ if (repositoryImport.equals(CloneSourceProvider.LOCAL))
+ return getWizard().getNextPage(this);
+ else
+ return getWizardPage(repositoryImport);
+ }
+
+ private WizardPage getWizardPage(CloneSourceProvider repositoryImport) {
+ WizardPage nextPage;
+ nextPage = resolvedWizardPages.get(repositoryImport);
+ if (nextPage == null) {
+ try {
+ nextPage = repositoryImport.getRepositorySearchPage();
+ } catch (CoreException e) {
+ Activator.error(e.getLocalizedMessage(), e);
+ }
+ if (nextPage != null) {
+ nextPage.setWizard(getWizard());
+ resolvedWizardPages.put(repositoryImport, nextPage);
+ }
+ }
+ return nextPage;
+ }
+}
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 75a7b06cf8..a424c8b69e 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
@@ -26,6 +26,8 @@ import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.UIUtils.IPreviousValueProposalHandler;
+import org.eclipse.egit.ui.internal.provisional.wizards.GitRepositoryInfo;
+import org.eclipse.egit.ui.internal.provisional.wizards.IRepositorySearchResult;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -64,7 +66,7 @@ import org.eclipse.ui.PlatformUI;
* Wizard page that allows the user entering the location of a remote repository
* by specifying URL manually or selecting a preconfigured remote repository.
*/
-public class RepositorySelectionPage extends WizardPage {
+public class RepositorySelectionPage extends WizardPage implements IRepositorySearchResult {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -377,6 +379,14 @@ public class RepositorySelectionPage extends WizardPage {
}
/**
+ * No args constructor; needed because the page is provided by the extension
+ * point {@code org.eclipse.egit.ui.cloneSourceProvider}
+ */
+ public RepositorySelectionPage() {
+ this(true, null);
+ }
+
+ /**
* @return repository selection representing current page state.
*/
public RepositorySelection getSelection() {
@@ -1001,4 +1011,10 @@ public class RepositorySelectionPage extends WizardPage {
return Activator.getDefault().getPreferenceStore();
}
+ public GitRepositoryInfo getGitRepositoryInfo() {
+ GitRepositoryInfo info = new GitRepositoryInfo(uri.toString());
+ info.setCredentials(user, password);
+ return info;
+ }
+
}
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 b50a590923..86a1f7eab7 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
@@ -306,6 +306,8 @@ RepositoryAction_errorFindingRepoTitle=Cannot Find Repository
RepositoryAction_multiRepoSelection=Cannot perform reset on multiple repositories simultaneously.\n\nPlease select items from only one repository.
RepositoryAction_multiRepoSelectionTitle=Multiple Repositories Selection
RepositoryCommit_UserAndDate=\ ({0} on {1})
+RepositoryLocationPage_info=Select a location of Git Repositories
+RepositoryLocationPage_title=Select Repository Source
RepositoryPropertySource_EditConfigurationTitle=Git Configuration Editor
RepositoryPropertySource_EffectiveConfigurationAction=Effective Configuration
@@ -1044,6 +1046,7 @@ GitCreateProjectViaWizardWizard_WizardTitle=Import Projects from Git Repository
GitImportWithDirectoriesPage_PageMessage=Depending on the wizard, you may select a directory to determine the wizard's scope
GitImportWithDirectoriesPage_PageTitle=Select a wizard to use for importing projects
GitImportWithDirectoriesPage_SelectFolderMessage=Please select a folder
+GitImportWizard_errorParsingURI=The URI of the repository to be cloned can't be parsed
GitImportWizard_WizardTitle=Import Projects from Git
GitScopeOperation_couldNotDetermineState=Could not determine state of changed files
GitScopeOperation_GitScopeManager=Git Scope Manager

Back to the top