Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java49
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java82
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IScmUrlImportWizardPage.java15
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java45
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java100
7 files changed, 247 insertions, 58 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java
new file mode 100644
index 000000000..bfe889171
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.core;
+
+import java.net.URI;
+
+
+/**
+ * @since 3.6
+ */
+public class ScmUrlImportDescription {
+ private String url;
+ private String project;
+
+ public ScmUrlImportDescription(String url, String project) {
+ this.url = url;
+ this.project = project;
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public URI getUri() {
+ return URI.create(url);
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Object getProperty(String plugin) {
+ // TODO Auto-generated method stub
+ // called here: org.eclipse.pde.internal.ui.wizards.imports.PluginImportWizardFirstPage.configureBundleImportPages(IPluginModelBase[])
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java
index 7f92030d6..1d9b36df2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@@ -175,9 +175,9 @@ public class CVSURI {
private static String getProjectName(URI uri) {
String f = uri.getFragment();
if (f != null) {
- int i = f.lastIndexOf(',');
+ int i = f.indexOf(',');
if (i != -1) {
- String s = f.substring(i + 1);
+ String s = f.substring(0, i);
if (!s.equals("")) //$NON-NLS-1$
return s;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 29647fa1e..e9c7cd0e4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2010 IBM Corporation and others.
+# Copyright (c) 2000, 2011 IBM Corporation and others.
# 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
@@ -1215,3 +1215,9 @@ CVSScmUrlImportWizardPage_1=Import CVS projects corresponding to plug-ins and fr
CVSScmUrlImportWizardPage_2=Import from &HEAD
CVSScmUrlImportWizardPage_3=Import specific &version(s) shown below
CVSScmUrlImportWizardPage_4=Total: {0}
+
+CVSScmUrlImportWizardPage_0=Import Projects from CVS
+CVSScmUrlImportWizardPage_1=Import CVS projects corresponding to plug-ins and fragments in the file system.
+CVSScmUrlImportWizardPage_2=Import from &HEAD
+CVSScmUrlImportWizardPage_3=Import specific &version(s) shown below
+CVSScmUrlImportWizardPage_4=Total: {0}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java
index 24cacd067..7bb2c24f8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2011 IBM Corporation and others.
* 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
@@ -11,6 +11,8 @@
package org.eclipse.team.internal.ccvs.ui.wizards;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.*;
@@ -21,6 +23,7 @@ import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
+import org.eclipse.team.core.*;
import org.eclipse.team.internal.ccvs.core.filesystem.CVSURI;
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
@@ -31,14 +34,15 @@ import org.eclipse.ui.ide.IDE;
public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImportWizardPage {
- private URI[] scmUris;
+ private RepositoryProviderType provider;
+ private ScmUrlImportDescription[] descriptions;
private Button useHead;
private TableViewer bundlesViewer;
private Label counterLabel;
private static final String CVS_PAGE_USE_HEAD = "org.eclipse.team.cvs.ui.import.page.head"; //$NON-NLS-1$
- class CvsLabelProvider extends StyledCellLabelProvider implements ILabelProvider {
+ class CVSLabelProvider extends StyledCellLabelProvider implements ILabelProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
@@ -67,9 +71,10 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
private StyledString getStyledText(Object element) {
StyledString styledString = new StyledString();
- if (element instanceof URI) {
- URI scmUrl = (URI) element;
- String project = getProject(scmUrl);
+ if (element instanceof ScmUrlImportDescription) {
+ ScmUrlImportDescription description = (ScmUrlImportDescription) element;
+ String project = description.getProject();
+ URI scmUrl = description.getUri();
String version = getTag(scmUrl);
String host = getServer(scmUrl);
styledString.append(project);
@@ -120,7 +125,7 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
table.setLayoutData(gd);
bundlesViewer = new TableViewer(table);
- bundlesViewer.setLabelProvider(new CvsLabelProvider());
+ bundlesViewer.setLabelProvider(new CVSLabelProvider());
bundlesViewer.setContentProvider(new ArrayContentProvider());
bundlesViewer.setComparator(new ViewerComparator());
counterLabel = new Label(comp, SWT.NONE);
@@ -141,8 +146,8 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
}
if (!found) {
- for (int i = 0; i < scmUris.length; i++) {
- URI scmUrl = scmUris[i];
+ for (int i = 0; i < descriptions.length; i++) {
+ URI scmUrl = descriptions[i].getUri();
if (getTag(scmUrl) != null) {
head = false;
break;
@@ -152,8 +157,8 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
useHead.setSelection(head);
versions.setSelection(!head);
- if (scmUris != null) {
- bundlesViewer.setInput(scmUris);
+ if (descriptions != null) {
+ bundlesViewer.setInput(descriptions);
updateCount();
}
@@ -183,29 +188,44 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
if (head) {
// modify tags on bundle import descriptions
- for (int i = 0; i < scmUris.length; i++) {
- URI scmUri = scmUris[i];
- scmUris[i] = removeTag(scmUri);
+ for (int i = 0; i < descriptions.length; i++) {
+ URI scmUri = descriptions[i].getUri();
+ descriptions[i].setUrl(removeTag(scmUri));
}
}
+
+ // TODO: same actions for all providers, this is not specific to CVS, pull up
+
+ ProjectSetCapability c = getProvider().getProjectSetCapability();
+ List references = new ArrayList();
+ for (int i = 0; i < descriptions.length; i++) {
+ references.add(c.asReference(descriptions[i].getUri(), descriptions[i].getProject()));
+ }
+ try {
+ c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null);
+ } catch (TeamException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
return true;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.IScmUrlImportWizardPage#getSelection()
*/
- public URI[] getSelection() {
- return scmUris;
+ public ScmUrlImportDescription[] getSelection() {
+ return descriptions;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.IScmUrlImportWizardPage#getSelection()
*/
- public void setSelection(URI[] scmUris) {
- this.scmUris = scmUris;
+ public void setSelection(ScmUrlImportDescription[] descriptions) {
+ this.descriptions = descriptions;
// fill viewer
if (bundlesViewer != null) {
- bundlesViewer.setInput(scmUris);
+ bundlesViewer.setInput(descriptions);
updateCount();
}
}
@@ -214,24 +234,16 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
* Updates the count of bundles that will be imported
*/
private void updateCount() {
- counterLabel.setText(NLS.bind(CVSUIMessages.CVSScmUrlImportWizardPage_4, new Integer(scmUris.length)));
+ counterLabel.setText(NLS.bind(CVSUIMessages.CVSScmUrlImportWizardPage_4, new Integer(descriptions.length)));
counterLabel.getParent().layout();
}
- private static String getProject(URI scmUri) {
- // TODO: remove once bug 332732 is fixed
- CVSURI cvsUri = CVSURI.fromUri(scmUri);
- if (cvsUri.getProjectName() == null)
- return cvsUri.getPath().lastSegment();
- return cvsUri.getProjectName();
- }
-
private static String getTag(URI scmUri) {
return CVSURI.fromUri(scmUri).getTag().getName();
}
- private static URI removeTag(URI scmUri) {
- // TODO: move to CVSURI
+ // TODO: move to CVSURI
+ private static String removeTag(URI scmUri) {
StringBuffer sb = new StringBuffer();
sb.append(scmUri.getScheme()).append(':');
String ssp = scmUri.getSchemeSpecificPart();
@@ -252,11 +264,19 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo
} else {
sb.append(ssp);
}
- return URI.create(sb.toString());
+ return sb.toString();
}
private static String getServer(URI scmUri) {
return CVSURI.fromUri(scmUri).getRepository().getHost();
}
+
+ public void setProvider(RepositoryProviderType provider) {
+ this.provider = provider;
+ }
+
+ public RepositoryProviderType getProvider() {
+ return provider;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IScmUrlImportWizardPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IScmUrlImportWizardPage.java
index 82b3cf390..8bf70174e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IScmUrlImportWizardPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IScmUrlImportWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2011 IBM Corporation and others.
* 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
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.team.ui;
-import java.net.URI;
-
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.team.core.RepositoryProviderType;
+import org.eclipse.team.core.ScmUrlImportDescription;
/**
* TODO: <strong>EXPERIMENTAL</strong>
@@ -23,6 +23,7 @@ public interface IScmUrlImportWizardPage extends IWizardPage {
public static final String ATT_EXTENSION = "scmUrlImportPages"; //$NON-NLS-1$
public static final String ATT_PAGE = "page"; //$NON-NLS-1$
+ public static final String ATT_REPOSITORY = "repository"; //$NON-NLS-1$
/**
* TODO:
@@ -37,7 +38,7 @@ public interface IScmUrlImportWizardPage extends IWizardPage {
*
* @return the SCM URLs edited or created on the page.
*/
- public URI[] getSelection();
+ public ScmUrlImportDescription[] getSelection();
/**
* TODO:
@@ -45,6 +46,10 @@ public interface IScmUrlImportWizardPage extends IWizardPage {
* @param scmUrls
* the SCM URLs edited on the page.
*/
- public void setSelection(URI[] scmUrls);
+ public void setSelection(ScmUrlImportDescription[] scmUrls);
+
+ public void setProvider(RepositoryProviderType provider);
+
+ public RepositoryProviderType getProvider();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
index 4f7b1dd08..f56b7bd03 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@@ -11,13 +11,11 @@
package org.eclipse.team.ui;
import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.team.core.ProjectSetCapability;
-import org.eclipse.team.core.RepositoryProviderType;
+import org.eclipse.team.core.*;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.history.GenericHistoryView;
import org.eclipse.team.internal.ui.registry.TeamContentProviderManager;
@@ -147,25 +145,27 @@ public class TeamUI {
/**
* TODO:
* <strong>EXPERIMENTAL</strong>
+ * @param descriptions
* @throws CoreException
* @since 3.6
*/
- public static IScmUrlImportWizardPage[] getPages(URI[] scmUris) throws CoreException {
+ public static IScmUrlImportWizardPage[] getPages(ScmUrlImportDescription[] descriptions) throws CoreException {
// TODO: check scmUrls
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(TeamUIPlugin.PLUGIN_ID, IScmUrlImportWizardPage.ATT_EXTENSION);
if (elements.length > 0) {
- Set/*<IConfigurationElement>*/ pages = new HashSet();
+ Set/*<IScmUrlImportWizardPage>*/ pages = new HashSet();
for (int i = 0; i < elements.length; i++) {
- String repository = elements[i].getAttribute("repository"); //$NON-NLS-1$
+ String repository = elements[i].getAttribute(IScmUrlImportWizardPage.ATT_REPOSITORY);
RepositoryProviderType providerType = RepositoryProviderType.getProviderType(repository);
- String scheme = providerType.getFileSystemScheme();
- Set schemeUris = new HashSet();
- for (int j = 0; j < scmUris.length; j++) {
- URI scmUrl = scmUris[j];
- if (scmUrl != null) {
- if (ProjectSetCapability.SCHEME_SCM.equals(scmUrl.getScheme())) {
- if (scmUrl.getSchemeSpecificPart().startsWith(scheme)) {
- schemeUris.add(scmUrl);
+ String extensionScheme = providerType.getFileSystemScheme();
+ Set/*<URI>*/ schemeUris = new HashSet();
+ // group descriptions by scheme/provider
+ for (int j = 0; j < descriptions.length; j++) {
+ URI scmUri = descriptions[j].getUri();
+ if (scmUri != null) {
+ if (ProjectSetCapability.SCHEME_SCM.equals(scmUri.getScheme())) {
+ if (scmUri.getSchemeSpecificPart().startsWith(extensionScheme)) {
+ schemeUris.add(scmUri);
}
}
}
@@ -174,7 +174,18 @@ public class TeamUI {
Object ext = TeamUIPlugin.createExtension(elements[i], IScmUrlImportWizardPage.ATT_PAGE);
if (ext instanceof IScmUrlImportWizardPage) {
IScmUrlImportWizardPage page = (IScmUrlImportWizardPage) ext;
- page.setSelection((URI[]) schemeUris.toArray(new URI[0]));
+ page.setProvider(providerType);
+
+ Set/*<ScmUrlImportDescription>*/ d = new HashSet();
+ for (Iterator iterator = schemeUris.iterator(); iterator.hasNext();) {
+ URI uri = (URI) iterator.next();
+ for (int j = 0; j < descriptions.length; j++) {
+ if (descriptions[j].getUri().equals(uri)) {
+ d.add(descriptions[j]);
+ }
+ }
+ }
+ page.setSelection((ScmUrlImportDescription[]) d.toArray(new ScmUrlImportDescription[0]));
pages.add(page);
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java
index 76e7a8436..8b1dcac6d 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* 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
@@ -23,16 +23,26 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.ProjectSetCapability;
import org.eclipse.team.core.ProjectSetSerializationContext;
import org.eclipse.team.core.RepositoryProviderType;
+import org.eclipse.team.core.ScmUrlImportDescription;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.ui.wizards.CVSScmUrlImportWizardPage;
import org.eclipse.team.internal.ui.ProjectSetImporter;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
+import org.eclipse.team.ui.IScmUrlImportWizardPage;
+import org.eclipse.team.ui.TeamUI;
public class ProjectSetImporterTests extends EclipseTest {
@@ -217,4 +227,92 @@ public class ProjectSetImporterTests extends EclipseTest {
new ProjectSetSerializationContext(), null);
// If we got here and no NPE was thrown, we're good.
}
+
+ public void testScmUrlImport() throws TeamException, CoreException {
+ IProject project = createProject("ProjectSetImporterTests-testScmUrlImport", new String[0]);
+ project.delete(true, true, null);
+ ensureDoesNotExistInWorkspace(project);
+
+ String s = ProjectSetCapability.SCHEME_SCM + ":cvs:" + CVSTestSetup.REPOSITORY_LOCATION + ":" + project.getName();
+ ScmUrlImportDescription d = new ScmUrlImportDescription(s, project.getName());
+ IScmUrlImportWizardPage[] pages = TeamUI.getPages(new ScmUrlImportDescription[] {d});
+ assertEquals(1, pages.length);
+ // the URIs haven't been changed in the UI so it's basically the same collection as the one passed to TeamUI.getPages(...)
+ ScmUrlImportDescription[] selection = pages[0].getSelection();
+ ProjectSetCapability c = pages[0].getProvider().getProjectSetCapability();
+
+ // this is what every bundle importer should do, should this be in PDE?
+ List references = new ArrayList();
+ for (int i = 0; i < selection.length; i++) {
+ references.add(c.asReference(selection[i].getUri(), selection[i].getProject()));
+ }
+ c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null);
+ assertExistsInWorkspace(project);
+ }
+
+ public void testScmUrlImportWithName() throws TeamException, CoreException {
+ IProject project = createProject("ProjectSetImporterTests-testScmUrlImportWithName", new String[0]);
+ project.delete(true, true, null);
+ ensureDoesNotExistInWorkspace(project);
+
+ String s = ProjectSetCapability.SCHEME_SCM + ":cvs:" + CVSTestSetup.REPOSITORY_LOCATION + ":" + project.getName() + ";project=project1";
+ ScmUrlImportDescription d = new ScmUrlImportDescription(s, project.getName());
+ IScmUrlImportWizardPage[] pages = TeamUI.getPages(new ScmUrlImportDescription[] {d});
+ assertEquals(1, pages.length);
+ // the URIs haven't been changed in the UI so it's basically the same collection as the one passed to TeamUI.getPages(...)
+ ScmUrlImportDescription[] selection = pages[0].getSelection();
+ ProjectSetCapability c = pages[0].getProvider().getProjectSetCapability();
+
+ // this is what every bundle importer should do, should this be in PDE?
+ List references = new ArrayList();
+ for (int i = 0; i < selection.length; i++) {
+ references.add(c.asReference(selection[i].getUri(), selection[i].getProject()));
+ }
+ c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null);
+ IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject("project1");
+ assertExistsInWorkspace(project1);
+ }
+
+ public void testScmUrlImportWithTag() throws TeamException, CoreException, IOException {
+ IProject project = createProject("ProjectSetImporterTests-testScmUrlImportWithTag", new String[0]);
+ tagProject(project, new CVSTag("tag", CVSTag.VERSION), false);
+ project.delete(true, true, null);
+ ensureDoesNotExistInWorkspace(project);
+
+ String s = ProjectSetCapability.SCHEME_SCM + ":cvs:" + CVSTestSetup.REPOSITORY_LOCATION + ":" + project.getName()+";tag=tag";
+ ScmUrlImportDescription d = new ScmUrlImportDescription(s, project.getName());
+ final IScmUrlImportWizardPage[] pages = TeamUI.getPages(new ScmUrlImportDescription[] {d});
+ assertEquals(1, pages.length);
+
+ // simulate clicking "Import from HEAD" on the CVS import page
+ assertTrue(pages[0] instanceof CVSScmUrlImportWizardPage);
+ Wizard wizard = new Wizard() {
+ public boolean performFinish() {
+ pages[0].finish();
+ return true;
+ }
+ };
+ wizard.addPage(pages[0]);
+ WizardDialog wizardDialog = new WizardDialog(new Shell(Display.getCurrent()), wizard);
+ wizardDialog.setBlockOnOpen(false);
+ wizardDialog.open();
+ Button useHead = (Button) ReflectionUtils.getField(pages[0], "useHead");
+ useHead.setSelection(true);
+ wizard.performFinish();
+ wizardDialog.close();
+ // altered selection, check out from HEAD
+ ScmUrlImportDescription[] selection = pages[0].getSelection();
+ ProjectSetCapability c = pages[0].getProvider().getProjectSetCapability();
+
+ // this is what every bundle importer should do, should this be in PDE?
+ List references = new ArrayList();
+ for (int i = 0; i < selection.length; i++) {
+ references.add(c.asReference(selection[i].getUri(), selection[i].getProject()));
+ }
+ c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null);
+ assertExistsInWorkspace(project);
+ IProject copy = checkoutCopy(project, CVSTag.DEFAULT);
+ // expecting the project to be checked out from HEAD
+ assertEquals(project, copy, false, false);
+ }
}

Back to the top