Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.core')
-rw-r--r--bundles/org.eclipse.team.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.team.core/build.properties3
-rw-r--r--bundles/org.eclipse.team.core/plugin.properties4
-rw-r--r--bundles/org.eclipse.team.core/plugin.xml11
-rw-r--r--bundles/org.eclipse.team.core/schema/bundleImporters.exsd156
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java35
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java22
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporter.java48
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporterDelegate.java67
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/package.html23
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java3
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java94
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/CvsBundleImporterDelegate.java123
13 files changed, 583 insertions, 8 deletions
diff --git a/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
index 97cf318db..a5bb7b70e 100644
--- a/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Export-Package: org.eclipse.team.core,
org.eclipse.team.core.diff.provider,
org.eclipse.team.core.history,
org.eclipse.team.core.history.provider,
+ org.eclipse.team.core.importing.provisional;x-friends:="org.eclipse.pde.core",
org.eclipse.team.core.mapping,
org.eclipse.team.core.mapping.provider,
org.eclipse.team.core.subscribers,
@@ -18,6 +19,7 @@ Export-Package: org.eclipse.team.core,
org.eclipse.team.core.variants,
org.eclipse.team.internal.core;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui",
org.eclipse.team.internal.core.history;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui",
+ org.eclipse.team.internal.core.importing;x-friends:="org.eclipse.pde.core",
org.eclipse.team.internal.core.mapping;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui",
org.eclipse.team.internal.core.streams;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui",
org.eclipse.team.internal.core.subscribers;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui"
diff --git a/bundles/org.eclipse.team.core/build.properties b/bundles/org.eclipse.team.core/build.properties
index 59273f4b2..708a62030 100644
--- a/bundles/org.eclipse.team.core/build.properties
+++ b/bundles/org.eclipse.team.core/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 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
@@ -16,4 +16,5 @@ bin.includes = about.html,\
.options,\
META-INF/
source..=src/
+output.. = bin/
src.includes=about.html,schema/
diff --git a/bundles/org.eclipse.team.core/plugin.properties b/bundles/org.eclipse.team.core/plugin.properties
index 3e550aafc..497dfea6b 100644
--- a/bundles/org.eclipse.team.core/plugin.properties
+++ b/bundles/org.eclipse.team.core/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 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
@@ -18,3 +18,5 @@ Repository=Repository Providers
DefaultValidator=Default File Modification Validator
StorageMergers = Storage Mergers
+expoint.bundleImporters.name = Bundle Importers
+bundleImporter.cvs = CVS Bundle Importer
diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml
index 19c19023e..1d58b6d45 100644
--- a/bundles/org.eclipse.team.core/plugin.xml
+++ b/bundles/org.eclipse.team.core/plugin.xml
@@ -8,7 +8,7 @@
<extension-point id="repository" name="%Repository" schema="schema/repository.exsd"/>
<extension-point id="defaultFileModificationValidator" name="%DefaultValidator" schema="schema/defaultFileModificationValidator.exsd"/>
<extension-point id="storageMergers" name="%StorageMergers" schema="schema/storageMergers.exsd"/>
-
+ <extension-point id="bundleImporters" name="%expoint.bundleImporters.name" schema="schema/bundleImporters.exsd"/>
<!-- Define common known file types -->
<extension
point="org.eclipse.team.core.fileTypes">
@@ -158,5 +158,12 @@
<adapter type="org.eclipse.core.resources.mapping.ResourceMapping"/>
</factory>
</extension>
-
+ <extension
+ point="org.eclipse.team.core.bundleImporters">
+ <importer
+ class="org.eclipse.team.internal.core.importing.CvsBundleImporterDelegate"
+ name="%bundleImporter.cvs"
+ id="org.eclipse.team.core.cvs.importer">
+ </importer>
+ </extension>
</plugin>
diff --git a/bundles/org.eclipse.team.core/schema/bundleImporters.exsd b/bundles/org.eclipse.team.core/schema/bundleImporters.exsd
new file mode 100644
index 000000000..8cfffbd4f
--- /dev/null
+++ b/bundles/org.eclipse.team.core/schema/bundleImporters.exsd
@@ -0,0 +1,156 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.team.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.team.core" id="bundleImporters" name="Bundle Importers"/>
+ </appInfo>
+ <documentation>
+ &lt;strong&gt;EXPERIMENTAL&lt;/strong&gt;. This extension point has been added as part of a work in progress. There is no guarantee that this API will work or that it will remain the same in future releases. Please do not use this API without consulting with the PDE team.
+&lt;p&gt;
+A bundle importer is capable of creating a project in the workspace based on a bundle manifest. For example, the CVS bundle importer leverages the &apos;Eclipse-SourceReferences&apos; header to import projects from CVS.
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element internal="true" />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="importer"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="importer">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Fully qualified name of a Java class providing an implementation of &lt;code&gt;org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate&lt;/code&gt; for this handler.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique identifier for this project factory extension.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+ A short description of this importer suitable for display to the end user.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name of this bundle importer, suitable for display to an end user.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.6
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of a bundle importer extension.
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.pde.core.bundleImporters&quot;&gt;
+ &lt;importer
+ id=&quot;com.example.ExampleIdentifier&quot;
+ class=&quot;com.example.ExampleBundleImporter&quot;&gt;
+ &lt;/importer&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ Value of a importer&apos;s &lt;b&gt;class&lt;/b&gt; attribute must be a fully qualified name of a Java class that implements the interface &lt;b&gt;org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate&lt;/b&gt;.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ PDE provides a bundle importer extension capable of importing projects from CVS referenced by &apos;Eclipse-SourceReferences&apos; headers.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2011 IBM Corporation and others.
+&lt;br&gt;
+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
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;.
+ </documentation>
+ </annotation>
+
+</schema>
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
index 1b8e797b2..e1ffd620f 100644
--- 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
@@ -11,6 +11,7 @@
package org.eclipse.team.core;
import java.net.URI;
+import java.util.HashMap;
/**
@@ -32,6 +33,7 @@ import java.net.URI;
public class ScmUrlImportDescription {
private String url;
private String project;
+ private HashMap properties;
public ScmUrlImportDescription(String url, String project) {
this.url = url;
@@ -62,9 +64,34 @@ public class ScmUrlImportDescription {
this.url = url;
}
- public Object getProperty(String plugin) {
- // TODO Auto-generated method stub
- // called by: org.eclipse.pde.internal.ui.wizards.imports.PluginImportWizardFirstPage.configureBundleImportPages(IPluginModelBase[])
- return null;
+ /**
+ * Sets or removes a client property.
+ *
+ * @param key property key
+ * @param value property value or <code>null</code> to remove the property
+ */
+ public synchronized void setProperty(String key, Object value) {
+ if (properties == null) {
+ properties = new HashMap();
+ }
+ if (value == null) {
+ properties.remove(key);
+ } else {
+ properties.put(key, value);
+ }
+
+ }
+
+ /**
+ * Returns the specified client property, or <code>null</code> if none.
+ *
+ * @param key property key
+ * @return property value or <code>null</code>
+ */
+ public synchronized Object getProperty(String key) {
+ if (properties == null) {
+ return null;
+ }
+ return properties.get(key);
}
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
index 1def5fd34..67c4275f6 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
@@ -18,8 +18,10 @@ import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.team.core.importing.provisional.IBundleImporter;
import org.eclipse.team.core.mapping.IStorageMerger;
import org.eclipse.team.internal.core.*;
+import org.eclipse.team.internal.core.importing.BundleImporterExtension;
/**
* The Team class provides a global point of reference for the global ignore set
@@ -63,6 +65,8 @@ public final class Team {
private final static FileContentManager fFileContentManager;
+ private static List fProjectFactories;
+
static {
fFileContentManager= new FileContentManager();
}
@@ -523,4 +527,22 @@ public final class Team {
public IStorageMerger createStorageMerger(String extension) {
return createMerger(extension);
}
+
+ /**
+ * @return IBundleImporter[] returns the available bundle importers
+ * @since 3.6
+ */
+ public synchronized static IBundleImporter[] getBundleImporters() {
+ if (fProjectFactories == null) {
+ fProjectFactories = new ArrayList();
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.EXTENSION_POINT_BUNDLE_IMPORTERS);
+ if (point != null) {
+ IConfigurationElement[] infos = point.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ fProjectFactories.add(new BundleImporterExtension(infos[i]));
+ }
+ }
+ }
+ return (IBundleImporter[]) fProjectFactories.toArray(new IBundleImporter[fProjectFactories.size()]);
+ }
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporter.java
new file mode 100644
index 000000000..c53a64ae0
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporter.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.importing.provisional;
+
+
+/**
+ * A bundle importer represents an instance of a bundle importer extension.
+ * Clients contributing a bundle importer extension contribute an implementation
+ * of {@link IBundleImporterDelegate} rather than this interface.
+ * <p>
+ * Clients contributing a bundle importer extension are intended to implement
+ * {@link IBundleImporterDelegate}.
+ * </p>
+ * @since 3.7
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IBundleImporter extends IBundleImporterDelegate {
+
+ /**
+ * Returns this impoter's unique identifier.
+ *
+ * @return identifier
+ */
+ public String getId();
+
+ /**
+ * Returns a short description of this importer, or <code>null</code> if unspecified.
+ *
+ * @return description or <code>null</code>
+ */
+ public String getDescription();
+
+ /**
+ * Returns a human readable name for this importer.
+ *
+ * @return name
+ */
+ public String getName();
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporterDelegate.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporterDelegate.java
new file mode 100644
index 000000000..b69e40e9b
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/IBundleImporterDelegate.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.importing.provisional;
+
+import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.ScmUrlImportDescription;
+
+/**
+ * A bundle importer delegate is contributed by a bundle importer extension and is capable
+ * of importing projects into the workspace from a repository based on bundle manifest entries.
+ * <p>
+ * Following is an example extension:
+ * <pre>
+ * &lt;extension point=&quot;org.eclipse.pde.core.bundleImporters&quot;&gt;
+ * &lt;importer
+ * id=&quot;com.example.ExampleIdentifier&quot;
+ * class=&quot;com.example.ExampleBundleImporterDelegate&quot;&gt;
+ * &lt;/importer&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ * </p>
+ * <p>
+ * Clients contributing bundle importer extensions are intended to implement this interface.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same. Please do not use this API without
+ * consulting with the PDE team.
+ * </p>
+ * @since 3.7
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IBundleImporterDelegate {
+
+ /**
+ * Returns an array of objects describing how each given bundle (manifest headers and values)
+ * can be imported into a workspace project. A <code>null</code> entry in the returned array
+ * indicates the corresponding bundle cannot be imported by this delegate.
+ *
+ * @param manifests array of maps containing manifest headers and values of the associated bundles
+ * @return array of bundle import descriptions that may contain <code>null</code> entries
+ */
+ public ScmUrlImportDescription[] validateImport(Map[] manifests);
+
+ /**
+ * Imports bundles into the workspace creating a project for each import description.
+ * Reports progress to the given monitor, if not <code>null</code>.
+ *
+ * @param descriptions description of bundles to import
+ * @param monitor progress monitor or <code>null</code>
+ * @return collection of projects created in the workspace or <code>null</code> if none
+ * @throws CoreException if unable to import projects
+ */
+ public IProject[] performImport(ScmUrlImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException;
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/package.html b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/package.html
new file mode 100644
index 000000000..7cecc1194
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/package.html
@@ -0,0 +1,23 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Application programming interfaces for importing projects into the workspace.
+<h2>
+Package Specification</h2>
+<p>
+Provides support for importing projects into the workspace from a repository.
+</p>
+<p>
+A bundle manifest may contain information identifying source code for the bundle
+or a project in a repository associated with the bundle. Clients may contribute
+implementations of <code>org.eclipse.tea,.core.importing.provisional.IBundleImporterDelegate</code>
+to the <code>org.eclipse.team.core.bundleImporters</code> extension point to participate
+in the import of bundles into workspace projects based on bundle manifests.
+</p>
+</body>
+</html>
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
index 4c729c20d..67910012a 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
@@ -56,6 +56,9 @@ final public class TeamPlugin extends Plugin {
public final static QualifiedName PROVIDER_PROP_KEY =
new QualifiedName("org.eclipse.team.core", "repository"); //$NON-NLS-1$ //$NON-NLS-2$
+ // The id for the Bundle Import extension point
+ public static final String EXTENSION_POINT_BUNDLE_IMPORTERS = ID + ".bundleImporters"; //$NON-NLS-1$
+
// The one and only plug-in instance
private static TeamPlugin plugin;
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java
new file mode 100644
index 000000000..2cdfd2850
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 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.internal.core.importing;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.ScmUrlImportDescription;
+import org.eclipse.team.core.importing.provisional.IBundleImporter;
+import org.eclipse.team.core.importing.provisional.IBundleImporterDelegate;
+import org.eclipse.team.internal.core.TeamPlugin;
+
+/**
+ * A bundle importer extension.
+ *
+ * @since 3.7
+ */
+public class BundleImporterExtension implements IBundleImporter {
+
+ private IBundleImporterDelegate delegate;
+ private IConfigurationElement element;
+
+ /**
+ * Constructs a bundle importer extension on the given element.
+ *
+ * @param element contribution
+ */
+ public BundleImporterExtension(IConfigurationElement element) {
+ this.element = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.project.IBundleImporterDelegate#validateImport(java.util.Map[])
+ */
+ public ScmUrlImportDescription[] validateImport(Map[] manifests) {
+ try {
+ return getDelegate().validateImport(manifests);
+ } catch (CoreException e) {
+ TeamPlugin.log(e);
+ return null;
+ }
+ }
+
+ /**
+ * Returns underlying delegate.
+ *
+ * @return delegate
+ * @exception CoreException if unable to instantiate delegate
+ */
+ private synchronized IBundleImporterDelegate getDelegate() throws CoreException {
+ if (delegate == null) {
+ delegate = (IBundleImporterDelegate) element.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ return delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.importing.IBundleImporterDelegate#performImport(org.eclipse.pde.core.importing.BundleImportDescription[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IProject[] performImport(ScmUrlImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException {
+ return getDelegate().performImport(descriptions, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.project.IBundleImporter#getId()
+ */
+ public String getId() {
+ return element.getAttribute("id"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.project.IBundleImporter#getDescription()
+ */
+ public String getDescription() {
+ return element.getAttribute("description"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.project.IBundleImporter#getName()
+ */
+ public String getName() {
+ return element.getAttribute("name"); //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/CvsBundleImporterDelegate.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/CvsBundleImporterDelegate.java
new file mode 100644
index 000000000..121e1d9a0
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/CvsBundleImporterDelegate.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.internal.core.importing;
+
+import java.util.*;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.*;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.team.core.*;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * Handles SCM CVS headers of the following form. Tag and project name can be specified
+ * as extra attributes. When a tag is unspecified, the HEAD tag is used. When a project
+ * name is unspecified, it is generated by the module name.
+ * <pre>
+ * scm:cvs&lt;delimiter&gt;&lt;method&gt;&lt;delimiter&gt;path_to_repository&lt;delimiter&gt;module_name[;tag=version][;project=name]
+ * scm:psf&lt;delimiter&gt;&lt;method&gt;&lt;delimiter&gt;path_to_repository&lt;delimiter&gt;module_name[;tag=version][;project=name]
+ * </pre>
+ * @since 3.7
+ */
+public class CvsBundleImporterDelegate implements org.eclipse.team.core.importing.provisional.IBundleImporterDelegate {
+
+ private static Set SUPPORTED_VALUES;
+
+ private static final String SCM = "scm:"; //$NON-NLS-1$
+ private static final String CVS = "cvs"; //$NON-NLS-1$
+// private static final String PSF = "psf"; //$NON-NLS-1$
+ private static final String COLON = ":"; //$NON-NLS-1$
+ private static final String PIPE = "|"; //$NON-NLS-1$
+
+ //private static final String ATTR_TAG = "tag"; //$NON-NLS-1$
+ private static final String ATTR_PROJECT = "project"; //$NON-NLS-1$
+
+ public static final String ECLIPSE_SOURCE_REFERENCES = "Eclipse-SourceReferences"; //$NON-NLS-1$
+
+ private static RepositoryProviderType CVS_PROVIDER_TYPE = RepositoryProviderType.getProviderType("org.eclipse.team.cvs.core.cvsnature"); //$NON-NLS-1$
+
+ static {
+ SUPPORTED_VALUES = new HashSet();
+ SUPPORTED_VALUES.add(SCM + CVS + COLON);
+ SUPPORTED_VALUES.add(SCM + CVS + PIPE);
+// SUPPORTED_VALUES.add(SCM + PSF + COLON);
+// SUPPORTED_VALUES.add(SCM + PSF + PIPE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.project.IBundleImporterDelegate#validateImport(java.util.Map[])
+ */
+ public ScmUrlImportDescription[] validateImport(Map[] manifests) {
+ // TODO: this is not CVS specific, the code is the same for all providers
+ ScmUrlImportDescription[] results = new ScmUrlImportDescription[manifests.length];
+ if (CVS_PROVIDER_TYPE != null) {
+ for (int i = 0; i < manifests.length; i++) {
+ Map manifest = manifests[i];
+ String value = (String) manifest.get(ECLIPSE_SOURCE_REFERENCES);
+ if (value != null && value.length() > 8) {
+ String prefix = value.substring(0, 8);
+ if (SUPPORTED_VALUES.contains(prefix)) {
+ try {
+ ManifestElement[] elements = ManifestElement.parseHeader(ECLIPSE_SOURCE_REFERENCES, value);
+ for (int j = 0; j < elements.length; j++) {
+ ManifestElement element = elements[j];
+ String url = element.getValue();
+ //String tag = element.getAttribute(ATTR_TAG);
+ String project = element.getAttribute(ATTR_PROJECT);
+ if (project == null) {
+ String bsn = (String) manifests[i].get(Constants.BUNDLE_SYMBOLICNAME);
+ if (bsn != null) {
+ ManifestElement[] bsnElement = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, bsn);
+ project = bsnElement[0].getValue();
+ }
+ }
+ results[i] = new ScmUrlImportDescription(url, project);
+ }
+ } catch (BundleException e) {
+ //TODO log exception
+ //PDECore.log(e);
+ }
+ }
+ }
+ }
+ }
+ return results;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.core.importing.IBundleImporterDelegate#performImport(org.eclipse.pde.core.importing.BundleImportDescription[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IProject[] performImport(ScmUrlImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException {
+ // TODO: import takes places when finishing contributed pages. this method can be removed
+ List references = new ArrayList();
+ ProjectSetCapability psfCapability = CVS_PROVIDER_TYPE.getProjectSetCapability();
+ // collect and validate all header values
+ for (int i = 0; i < descriptions.length; i++) {
+ ScmUrlImportDescription description = (ScmUrlImportDescription) descriptions[i];
+ references.add(psfCapability.asReference(description.getUri(), description.getProject()));
+ }
+ // create projects
+ if (!references.isEmpty()) {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, references.size());
+ if (psfCapability != null) {
+ // TODO: specify shell
+ psfCapability.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), subMonitor);
+ } else {
+ //TODO: error
+ }
+ subMonitor.done();
+ }
+ return null;
+ }
+
+}

Back to the top