bug 366790: Allow to specify values from BundleImporterDelegate
declaratively, in plugin.xml
diff --git a/bundles/org.eclipse.team.core/schema/bundleImporters.exsd b/bundles/org.eclipse.team.core/schema/bundleImporters.exsd
index 747a545..35e80a2 100644
--- a/bundles/org.eclipse.team.core/schema/bundleImporters.exsd
+++ b/bundles/org.eclipse.team.core/schema/bundleImporters.exsd
@@ -52,16 +52,9 @@
<element name="importer">
<complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Fully qualified name of a Java class providing an implementation of <code>org.eclipse.team.core.importing.provisional.IBundleImporterDelegate</code> for this handler.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.team.core.importing.provisional.IBundleImporterDelegate"/>
- </appInfo>
- </annotation>
- </attribute>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="supports"/>
+ </sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
@@ -82,13 +75,35 @@
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
- The name of this bundle importer, suitable for display to an end user.
+ The name of this bundle importer, suitable for display to the end user.
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
+ <attribute name="repository" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of org.eclipse.team.core.repository extension that is associated with this importer.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.team.core.repository/repository/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="supports">
+ <complexType>
+ <attribute name="prefix" type="string" use="required">
+ <annotation>
+ <documentation>
+ The SCM URL prefix being supported by this importer.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -113,7 +128,10 @@
<extension point="org.eclipse.team.core.bundleImporters">
<importer
id="com.example.ExampleIdentifier"
- class="com.example.ExampleBundleImporter">
+ name="Example Importer"
+ repository="com.example.ExampleNature">
+ <supports prefix="scm:example:">
+ </supports>
</importer>
</extension>
</pre>
@@ -121,14 +139,6 @@
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- Value of a importer's <b>class</b> attribute must be a fully qualified name of a Java class that implements the interface <b>org.eclipse.team.core.importing.provisional.IBundleImporterDelegate</b>.
- </documentation>
- </annotation>
<annotation>
<appInfo>
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
index eb27bb5..f0201a9 100644
--- 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
@@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.team.internal.core.importing;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.RepositoryProviderType;
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.core.importing.provisional.*;
import org.eclipse.team.internal.core.TeamPlugin;
/**
@@ -58,7 +58,25 @@
*/
private synchronized IBundleImporterDelegate getDelegate() throws CoreException {
if (delegate == null) {
- delegate = (IBundleImporterDelegate) element.createExecutableExtension("class"); //$NON-NLS-1$
+ delegate = new BundleImporterDelegate() {
+ private Set supportedValues;
+ private RepositoryProviderType providerType;
+ protected Set getSupportedValues() {
+ if (supportedValues == null) {
+ IConfigurationElement[] supported = element.getChildren("supported"); //$NON-NLS-1$
+ supportedValues = new HashSet(supported.length);
+ for (int i = 0; i < supported.length; i++) {
+ supportedValues.add(supported[i].getAttribute("value")); //$NON-NLS-1$
+ }
+ }
+ return supportedValues;
+ }
+ protected RepositoryProviderType getProviderType() {
+ if (providerType == null)
+ providerType = RepositoryProviderType.getProviderType(element.getAttribute("repository")); //$NON-NLS-1$
+ return providerType;
+ }
+ };
}
return delegate;
}
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
index d26489f..f5228db 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.core/plugin.xml
@@ -253,9 +253,15 @@
<extension
point="org.eclipse.team.core.bundleImporters">
<importer
- class="org.eclipse.team.internal.ccvs.core.CvsBundleImporterDelegate"
+ id="org.eclipse.team.core.cvs.importer"
name="%cvsBundleImporter"
- id="org.eclipse.team.core.cvs.importer">
+ repository="org.eclipse.team.cvs.core.cvsnature">
+ <supports
+ prefix="scm:cvs:">
+ </supports>
+ <supports
+ prefix="scm:cvs|">
+ </supports>
</importer>
</extension>
</plugin>
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CvsBundleImporterDelegate.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CvsBundleImporterDelegate.java
deleted file mode 100644
index e4301a8..0000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CvsBundleImporterDelegate.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * 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.ccvs.core;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.team.core.RepositoryProviderType;
-import org.eclipse.team.core.importing.provisional.BundleImporterDelegate;
-
-/**
- * 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<delimiter><method><delimiter>path_to_repository<delimiter>module_name[;tag=version][;project=name]
- * scm:psf<delimiter><method><delimiter>path_to_repository<delimiter>module_name[;tag=version][;project=name]
- * </pre>
- */
-public class CvsBundleImporterDelegate extends BundleImporterDelegate {
-
- 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 RepositoryProviderType providerType;
-
- 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);
- }
-
- protected Set getSupportedValues() {
- return SUPPORTED_VALUES;
- }
-
- protected RepositoryProviderType getProviderType() {
- if (providerType == null)
- providerType = RepositoryProviderType.getProviderType(CVSProviderPlugin.getTypeId());
- return providerType;
- }
-
-}
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 76e88a8..3cc731c 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
@@ -38,10 +38,10 @@
import org.eclipse.team.core.ScmUrlImportDescription;
import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.importing.provisional.BundleImporterDelegate;
import org.eclipse.team.core.importing.provisional.IBundleImporter;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CvsBundleImporterDelegate;
import org.eclipse.team.internal.ccvs.ui.wizards.CVSScmUrlImportWizardPage;
import org.eclipse.team.internal.ui.ProjectSetImporter;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
@@ -294,7 +294,7 @@
Map[] manifests = new Map[1];
Map map = new HashMap();
- map.put(CvsBundleImporterDelegate.ECLIPSE_SOURCE_REFERENCES, s);
+ map.put(BundleImporterDelegate.ECLIPSE_SOURCE_REFERENCES, s);
manifests[0] = map;
ScmUrlImportDescription[] descriptions = cvsBundleImporter.validateImport(manifests);