Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Macguire2003-02-04 21:26:53 +0000
committerKevin Macguire2003-02-04 21:26:53 +0000
commit86c7cb5a034ae6758721a9b202a3e4455700326e (patch)
treee54a711211425bdbfcef8908babd5994a1b16d73
parenta8a7a855bba3482e1ae7149acc80fd87f04e3916 (diff)
downloadeclipse.platform.team-86c7cb5a034ae6758721a9b202a3e4455700326e.tar.gz
eclipse.platform.team-86c7cb5a034ae6758721a9b202a3e4455700326e.tar.xz
eclipse.platform.team-86c7cb5a034ae6758721a9b202a3e4455700326e.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java8
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java64
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java108
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.xml1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java52
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetExportWizard.java57
6 files changed, 270 insertions, 20 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java
new file mode 100644
index 000000000..62f7fb99d
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java
@@ -0,0 +1,8 @@
+package org.eclipse.team.core;
+
+/*
+ */
+public final class DefaultRepositoryProviderType extends RepositoryProviderType {
+
+
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java
new file mode 100644
index 000000000..80e401383
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java
@@ -0,0 +1,64 @@
+package org.eclipse.team.core;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Provisional
+ */
+
+public abstract class ProjectSetCapability {
+ /**
+ * Notify the provider that a project set has been created at path.
+ * Only providers identified as having projects in the project set will be
+ * notified. The project set may or may not be created in a workspace
+ * project (thus may not be a resource).
+ *
+ * @param File the project set file that was created
+ */
+ public void projectSetCreated(File file, Object context, IProgressMonitor monitor) {
+ //default is to do nothing
+ }
+
+ /**
+ * Returns true if when importing a project set the projects can be created
+ * at a specified file system location different than the default.
+ *
+ * NOTE: If this method is overriden to return true, then the provider
+ * <b>must</b> also override addToWorkspace(String[], String, IPath, Object,
+ * IProgressMonitor);
+ *
+ * @return boolean
+ */
+ public boolean supportsProjectSetImportRelocation() {
+ return false;
+ }
+
+ /**
+ * This method will only be called if
+ * RepositoryProviderType#supportsProjectSetImportRelocation returns true.
+ *
+ * For every String in referenceStrings,
+ * create in the workspace a corresponding IProject. Return an Array of the
+ * resulting IProjects. Result is unspecified in the case where an IProject
+ * of that name already exists. In the case of failure, a TeamException must
+ * be thrown. The opaque strings in referenceStrings are guaranteed to have
+ * been previously produced by IProjectSetSerializer.asReference().
+ * @see IProjectSetSerializer#asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor)
+ *
+ * @param referenceStrings an array of referene strings uniquely identifying the projects
+ * @param filename the name of the file that the references were read from. This is included
+ * in case the provider needs to deduce relative paths
+ * @param root the root file system path under which the projects should be
+ * created.
+ * @param context a UI context object. This object will either be a
+ * com.ibm.swt.widgets.Shell or it will be null.
+ * @param monitor a progress monitor
+ * @return IProject[] an array of projects that were created
+ * @throws TeamException
+ */
+ public abstract IProject[] addToWorkspace(String[] referenceStrings, String filename, IPath root, Object context, IProgressMonitor monitor) throws TeamException;
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java
new file mode 100644
index 000000000..048368a8e
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java
@@ -0,0 +1,108 @@
+package org.eclipse.team.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.internal.core.Policy;
+import org.eclipse.team.internal.core.TeamPlugin;
+
+/**
+ * Provisional.
+ *
+ * This class represents things you can ask/do with a type of provider. This
+ * is in the absence of a project, as opposed to RepositoryProvider which
+ * requires a concrete project in order to be instantiated.
+ */
+
+public abstract class RepositoryProviderType {
+ private static Map allProviderTypes = new HashMap();
+
+ private String id;
+
+ /**
+ * Constructor for RepositoryProviderType.
+ */
+ public RepositoryProviderType() {
+ }
+
+ public static RepositoryProviderType getProviderType(String id) {
+ RepositoryProviderType type = (RepositoryProviderType) allProviderTypes.get(id);
+
+ if(type != null)
+ return type;
+
+ //If there isn't one in the table, we'll try to create one from the extension point
+ //Its possible that newProviderType() will return null, but in that case it will have also logged the error so just return the result
+ return newProviderType(id);
+ }
+
+ private void setID(String id) {
+ this.id = id;
+ }
+
+ private static RepositoryProviderType newProviderType(String id) {
+ TeamPlugin plugin = TeamPlugin.getPlugin();
+ if (plugin != null) {
+ IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(TeamPlugin.REPOSITORY_EXTENSION);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$
+
+ if (extensionId != null && extensionId.equals(id)) {
+ try {
+ RepositoryProviderType providerType;
+ //Its ok not to have a typeClass extension. In this case, a default instance will be created.
+ if(configElements[j].getAttribute("typeClass") == null) {
+ providerType = new DefaultRepositoryProviderType();
+ } else {
+ providerType = (RepositoryProviderType) configElements[j].createExecutableExtension("typeClass"); //$NON-NLS-1$
+ }
+
+ providerType.setID(id);
+ allProviderTypes.put(id, providerType);
+ return providerType;
+ } catch (CoreException e) {
+ TeamPlugin.log(e.getStatus());
+ } catch (ClassCastException e) {
+ String className = configElements[j].getAttribute("typeClass"); //$NON-NLS-1$
+ TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoryProviderType.invalidClass", id, className), e); //$NON-NLS-1$
+ }
+ return null;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Answer the id of this provider instance. The id will be the repository
+ * provider type's id as defined in the provider plugin's plugin.xml.
+ *
+ * @return the nature id of this provider
+ */
+ public final String getID() {
+ return this.id;
+ }
+
+ /**
+ * Answers the ProjectSetCapability that implements methods to import and
+ * create project sets. If the provider doesn't wish to provide this
+ * feature, return null.
+ *
+ * @return ProjectSetCapability
+ */
+
+ public ProjectSetCapability getProjectSetCapability() {
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
index 6e467d853..4162d3939 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.core/plugin.xml
@@ -46,6 +46,7 @@
point="org.eclipse.team.core.repository">
<repository
class="org.eclipse.team.internal.ccvs.core.CVSTeamProvider"
+ typeClass="org.eclipse.team.internal.ccvs.core.CVSTeamProviderType"
id="org.eclipse.team.cvs.core.cvsnature">
</repository>
</extension>
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java
new file mode 100644
index 000000000..f27e1a00f
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java
@@ -0,0 +1,52 @@
+package org.eclipse.team.internal.ccvs.core;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.ProjectSetCapability;
+import org.eclipse.team.core.RepositoryProviderType;
+import org.eclipse.team.core.TeamException;
+
+
+/**
+ * This class represents the CVS Provider's capabilities in the absence of a
+ * particular project.
+ */
+
+public class CVSTeamProviderType extends RepositoryProviderType {
+
+ /**
+ * @see org.eclipse.team.core.RepositoryProviderType#supportsProjectSetImportRelocation()
+ */
+ public boolean supportsProjectSetImportRelocation() {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()
+ */
+ public ProjectSetCapability getProjectSetCapability() {
+ return new ProjectSetCapability() {
+ public IProject[] addToWorkspace(
+ String[] referenceStrings,
+ String filename,
+ IPath root,
+ Object context,
+ IProgressMonitor monitor)
+ throws TeamException {
+ return null;
+ }
+
+ public void projectSetCreated(
+ File file,
+ Object context,
+ IProgressMonitor monitor) {
+
+ int i = 0;
+ }
+ };
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetExportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetExportWizard.java
index 6cb15a50d..a24d180ec 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetExportWizard.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetExportWizard.java
@@ -33,7 +33,9 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.IProjectSetSerializer;
+import org.eclipse.team.core.ProjectSetCapability;
import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.ui.TeamImages;
@@ -89,6 +91,26 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard {
return;
}
}
+
+ // Hash the projects by provider
+ IProject[] projects = mainPage.getSelectedProjects();
+ Map map = new HashMap();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ RepositoryProvider provider = RepositoryProvider.getProvider(project);
+ if (provider != null) {
+ String id = provider.getID();
+ List list = (List)map.get(id);
+ if (list == null) {
+ list = new ArrayList();
+ map.put(id, list);
+ }
+ list.add(project);
+ }
+ }
+
+ Shell shell = getShell();
+
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); //$NON-NLS-1$
@@ -97,26 +119,8 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard {
writer.newLine();
writer.write("<psf version=\"2.0\">"); //$NON-NLS-1$
writer.newLine();
- IProject[] projects = mainPage.getSelectedProjects();
-
- // Hash the projects by provider
- Map map = new HashMap();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- RepositoryProvider provider = RepositoryProvider.getProvider(project);
- if (provider != null) {
- String id = provider.getID();
- List list = (List)map.get(id);
- if (list == null) {
- list = new ArrayList();
- map.put(id, list);
- }
- list.add(project);
- }
- }
// For each provider id, do the writing
- Shell shell = getShell();
Iterator it = map.keySet().iterator();
monitor.beginTask(null, 1000 * map.keySet().size());
while (it.hasNext()) {
@@ -129,7 +133,7 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard {
IProject[] projectArray = (IProject[])list.toArray(new IProject[list.size()]);
IProjectSetSerializer serializer = Team.getProjectSetSerializer(id);
if (serializer != null) {
- String[] references = serializer.asReference(projectArray, shell, new SubProgressMonitor(monitor, 1000));
+ String[] references = serializer.asReference(projectArray, shell, new SubProgressMonitor(monitor, 990));
for (int i = 0; i < references.length; i++) {
writer.write("\t\t<project reference=\""); //$NON-NLS-1$
writer.write(references[i]);
@@ -148,7 +152,6 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard {
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
- monitor.done();
if (writer != null) {
try {
writer.close();
@@ -157,6 +160,20 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard {
}
}
}
+
+ // notify provider types of the project set write
+ for (Iterator iter = map.keySet().iterator();iter.hasNext();) {
+ String id = (String) iter.next();
+ RepositoryProviderType type = RepositoryProviderType.getProviderType(id);
+ if (type != null) {
+ ProjectSetCapability capability = type.getProjectSetCapability();
+ if (capability != null) {
+ capability.projectSetCreated(file, shell, new SubProgressMonitor(monitor, 10));
+ }
+ }
+ }
+
+ monitor.done();
}
});
} catch (InterruptedException e) {

Back to the top