Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-05-21 14:16:26 -0400
committerMichael Valenta2004-05-21 14:16:26 -0400
commit1f14b3ecc416f69ab2b2f8cebb4fc479c8ca3b69 (patch)
treea089edfc97f92e00409dc1a2eab37ecde03199c0 /examples
parent2d5617e135261f0c0930e9a78708824005746b2d (diff)
downloadeclipse.platform.team-1f14b3ecc416f69ab2b2f8cebb4fc479c8ca3b69.tar.gz
eclipse.platform.team-1f14b3ecc416f69ab2b2f8cebb4fc479c8ca3b69.tar.xz
eclipse.platform.team-1f14b3ecc416f69ab2b2f8cebb4fc479c8ca3b69.zip
Testing project set serialization backwards compatibility
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/plugin.xml8
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java29
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java123
3 files changed, 159 insertions, 1 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.xml b/examples/org.eclipse.team.examples.filesystem/plugin.xml
index bda3da5f8..2195e4a7b 100644
--- a/examples/org.eclipse.team.examples.filesystem/plugin.xml
+++ b/examples/org.eclipse.team.examples.filesystem/plugin.xml
@@ -32,10 +32,16 @@
point="org.eclipse.team.core.repository">
<repository
class="org.eclipse.team.examples.filesystem.FileSystemProvider"
+ typeClass="org.eclipse.team.examples.filesystem.FileSystemProviderType"
id="org.eclipse.team.examples.filesystem.FileSystemProvider">
</repository>
</extension>
-
+
+<!-- ************** Project Sets **************** -->
+ <extension point="org.eclipse.team.core.projectSets">
+ <projectSet id="org.eclipse.team.examples.filesystem.FileSystemProvider" class="org.eclipse.team.examples.filesystem.ui.ProjectSetSerializer"/>
+ </extension>
+
<!-- *************** Deployment Provider **************** -->
<extension
point="org.eclipse.team.core.deployment">
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java
new file mode 100644
index 000000000..97a9aff37
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.examples.filesystem;
+
+import org.eclipse.team.core.ProjectSetCapability;
+import org.eclipse.team.core.RepositoryProviderType;
+
+/**
+ * The file system repository provider types
+ */
+public class FileSystemProviderType extends RepositoryProviderType {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()
+ */
+ public ProjectSetCapability getProjectSetCapability() {
+ // Create an empty project set capability to test backwards compatibility
+ return new ProjectSetCapability() {};
+ }
+
+}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
new file mode 100644
index 000000000..04935f9f5
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.examples.filesystem.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.IProjectSetSerializer;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.examples.filesystem.FileSystemPlugin;
+import org.eclipse.team.examples.filesystem.FileSystemProvider;
+import org.eclipse.team.examples.filesystem.Policy;
+import org.eclipse.team.internal.core.Assert;
+
+/**
+ * This is an old-style (pre-3.0) project set serializer used to test backwards compatibility
+ */
+public class ProjectSetSerializer implements IProjectSetSerializer {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.IProjectSetSerializer#asReference(org.eclipse.core.resources.IProject[], java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) throws TeamException {
+ Assert.isTrue(context instanceof Shell);
+ List refs = new ArrayList();
+ for (int i = 0; i < providerProjects.length; i++) {
+ IProject project = providerProjects[i];
+ FileSystemProvider provider = (FileSystemProvider)RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
+ if (provider != null) {
+ refs.add(asReference(provider));
+ }
+ }
+ return (String[]) refs.toArray(new String[refs.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.IProjectSetSerializer#addToWorkspace(java.lang.String[], java.lang.String, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) throws TeamException {
+ Assert.isTrue(context instanceof Shell);
+ List projects = new ArrayList();
+ for (int i = 0; i < referenceStrings.length; i++) {
+ String string = referenceStrings[i];
+ String projectName = getProjectName(string);
+ String path = getPath(string);
+ if (projectName != null && path != null) {
+ try {
+ IProject project = createProject(projectName, monitor);
+ RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID);
+ FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project);
+ provider.setTargetLocation(path);
+ projects.add(project);
+ } catch (CoreException e) {
+ ErrorDialog.openError(
+ (Shell)context,
+ Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$
+ Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$
+ e.getStatus());
+ }
+ }
+ }
+ return (IProject[]) projects.toArray(new IProject[projects.size()]);
+ }
+
+ /**
+ * @param provider
+ * @return
+ */
+ private String asReference(FileSystemProvider provider) {
+ return provider.getProject().getName() + "," + provider.getRoot().toString();
+ }
+
+ /**
+ * @param string
+ * @return
+ */
+ private String getProjectName(String string) {
+ int i = string.indexOf(',');
+ if (i == -1) return null;
+ return string.substring(0, i);
+ }
+
+ /**
+ * @param string
+ * @return
+ */
+ private String getPath(String string) {
+ int i = string.indexOf(',');
+ if (i == -1) return null;
+ return string.substring(i + 1);
+ }
+
+ /**
+ * @param projectName
+ * @return
+ * @throws CoreException
+ */
+ private IProject createProject(String projectName, IProgressMonitor monitor) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (!project.exists()) {
+ project.create(monitor);
+ }
+ if (!project.isOpen()) {
+ project.open(monitor);
+ }
+ return project;
+ }
+}

Back to the top