View | Details | Raw Unified | Return to bug 195729 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+2 lines)
Lines 9-14 Link Here
9
Export-Package: 
9
Export-Package: 
10
 org.eclipse.pde.core,
10
 org.eclipse.pde.core,
11
 org.eclipse.pde.core.build,
11
 org.eclipse.pde.core.build,
12
 org.eclipse.pde.core.importing,
12
 org.eclipse.pde.core.plugin,
13
 org.eclipse.pde.core.plugin,
13
 org.eclipse.pde.core.project,
14
 org.eclipse.pde.core.project,
14
 org.eclipse.pde.internal.core;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.runtime,org.eclipse.pde.launching",
15
 org.eclipse.pde.internal.core;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.runtime,org.eclipse.pde.launching",
Lines 21-26 Link Here
21
 org.eclipse.pde.internal.core.feature;x-friends:="org.eclipse.pde.ui",
22
 org.eclipse.pde.internal.core.feature;x-friends:="org.eclipse.pde.ui",
22
 org.eclipse.pde.internal.core.ibundle;x-friends:="org.eclipse.pde.ui",
23
 org.eclipse.pde.internal.core.ibundle;x-friends:="org.eclipse.pde.ui",
23
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui",
24
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui",
25
 org.eclipse.pde.internal.core.importing;x-friends:="org.eclipse.pde.ui",
24
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
26
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
25
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
27
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
26
 org.eclipse.pde.internal.core.isite;x-friends:="org.eclipse.pde.ui",
28
 org.eclipse.pde.internal.core.isite;x-friends:="org.eclipse.pde.ui",
(-)plugin.properties (+3 lines)
Lines 18-23 Link Here
18
expoint.source.name = Code Source Locations
18
expoint.source.name = Code Source Locations
19
expoint.javadoc.name = Javadoc Locations
19
expoint.javadoc.name = Javadoc Locations
20
expoint.target.name = Target Profiles
20
expoint.target.name = Target Profiles
21
expoint.bundleImporters.name = Bundle Importers
22
23
bundleImporter.cvs = CVS Bundle Importer
21
24
22
target.name.0 = Base RCP (with Source)
25
target.name.0 = Base RCP (with Source)
23
target.name.1 = Base RCP (Binary Only)
26
target.name.1 = Base RCP (Binary Only)
(-)plugin.xml (+9 lines)
Lines 15-20 Link Here
15
     <extension-point id="source" name="%expoint.source.name" schema="schema/source.exsd"/>
15
     <extension-point id="source" name="%expoint.source.name" schema="schema/source.exsd"/>
16
     <extension-point id="javadoc" name="%expoint.javadoc.name" schema="schema/javadoc.exsd"/>
16
     <extension-point id="javadoc" name="%expoint.javadoc.name" schema="schema/javadoc.exsd"/>
17
     <extension-point id="targets" name="%expoint.target.name" schema="schema/targets.exsd"/>
17
     <extension-point id="targets" name="%expoint.target.name" schema="schema/targets.exsd"/>
18
     <extension-point id="bundleImporters" name="%expoint.bundleImporters.name" schema="schema/bundleImporters.exsd"/>
18
19
19
   <extension
20
   <extension
20
         point="org.eclipse.jdt.core.classpathVariableInitializer">
21
         point="org.eclipse.jdt.core.classpathVariableInitializer">
Lines 334-338 Link Here
334
         </describer>
335
         </describer>
335
      </content-type>
336
      </content-type>
336
    </extension>
337
    </extension>
338
   <extension
339
         point="org.eclipse.pde.core.bundleImporters">
340
      <importer
341
            class="org.eclipse.pde.internal.core.importing.CvsBundleImporterDelegate"
342
            name="%bundleImporter.cvs"
343
            id="org.eclipse.pde.core.cvs.importer">
344
      </importer>
345
   </extension>
337
   
346
   
338
</plugin>
347
</plugin>
(-)schema/bundleImporters.exsd (+153 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.core" id="bundleImporters" name="Bundle Importers"/>
7
      </appInfo>
8
      <documentation>
9
         A bundle importer is capable of creating a project in the workspace based on specific entries contained in a bundle manifest. An importer can register for one or more bundle headers, identified by name. By default, a bundle importer is registered for the &apos;Eclipse-SourceReferences&apos; header.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence minOccurs="1" maxOccurs="unbounded">
21
            <element ref="importer"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="importer">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  Fully qualified name of a Java class providing an implementation of &lt;code&gt;org.eclipse.pde.core.importing.IBundleImporterDelegate&lt;/code&gt; for this handler.
56
               </documentation>
57
               <appInfo>
58
                  <meta.attribute kind="java" basedOn=":org.eclipse.pde.core.importing.IBundleImporterDelegate"/>
59
               </appInfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="id" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  Unique identifier for this project factory extension.
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="description" type="string">
70
            <annotation>
71
               <documentation>
72
                  A short description of this importer suitable for display to the end user.
73
               </documentation>
74
               <appInfo>
75
                  <meta.attribute translatable="true"/>
76
               </appInfo>
77
            </annotation>
78
         </attribute>
79
         <attribute name="name" type="string" use="required">
80
            <annotation>
81
               <documentation>
82
                  The name of this bundle importer, suitable for display to an end user.
83
               </documentation>
84
               <appInfo>
85
                  <meta.attribute translatable="true"/>
86
               </appInfo>
87
            </annotation>
88
         </attribute>
89
      </complexType>
90
   </element>
91
92
   <annotation>
93
      <appInfo>
94
         <meta.section type="since"/>
95
      </appInfo>
96
      <documentation>
97
         3.6
98
      </documentation>
99
   </annotation>
100
101
   <annotation>
102
      <appInfo>
103
         <meta.section type="examples"/>
104
      </appInfo>
105
      <documentation>
106
         The following is an example of a bundle importer extension.
107
108
&lt;p&gt;
109
&lt;pre&gt;
110
 &lt;extension point=&quot;org.eclipse.pde.core.bundleImporters&quot;&gt;
111
  &lt;importer
112
   id=&quot;com.example.ExampleIdentifier&quot;
113
   class=&quot;com.example.ExampleBundleImporter&quot;&gt;
114
  &lt;/importer&gt;
115
 &lt;/extension&gt;
116
&lt;/pre&gt;
117
&lt;/p&gt;
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="apiinfo"/>
124
      </appInfo>
125
      <documentation>
126
         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.core.importing.IBundleImporterDelegate&lt;/b&gt;.
127
      </documentation>
128
   </annotation>
129
130
   <annotation>
131
      <appInfo>
132
         <meta.section type="implementation"/>
133
      </appInfo>
134
      <documentation>
135
         PDE provides a bundle importer extension capable of importing projects from CVS referenced by &apos;Eclipse-SourceReferences&apos; headers.
136
      </documentation>
137
   </annotation>
138
139
   <annotation>
140
      <appInfo>
141
         <meta.section type="copyright"/>
142
      </appInfo>
143
      <documentation>
144
         Copyright (c) 2010 IBM Corporation and others.
145
&lt;br&gt;
146
All rights reserved. This program and the accompanying materials are made 
147
available under the terms of the Eclipse Public License v1.0 which 
148
accompanies this distribution, and is available at 
149
&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;.
150
      </documentation>
151
   </annotation>
152
153
</schema>
(-)src/org/eclipse/pde/core/importing/BundleImportDescription.java (+107 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.core.importing;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
/**
17
 * Describes how a bundle import will be executed. A bundle importer delegate
18
 * creates bundle import descriptions when it validates bundle manifests for
19
 * importing. When asked to import bundles, it is passed back the instances
20
 * of bundle import descriptions is created. However, the target project
21
 * may have been modified and properties may have been modified.
22
 * <p>
23
 * Clients may instantiate this class. Clients may subclass this class to
24
 * implement model specific behavior and include model specific data in import
25
 * descriptions.
26
 * </p> 
27
 * @since 3.6
28
 */
29
public class BundleImportDescription {
30
31
	private String project;
32
	private Map manifest;
33
	private Map properties;
34
35
	/**
36
	 * Constructs a bundle import description with given project and manifest.
37
	 * 
38
	 * @param project the project the bundle should be imported into which may
39
	 *  or may not exist
40
	 * @param manifest bundle manifest headers and values
41
	 */
42
	public BundleImportDescription(String project, Map manifest) {
43
		this.project = project;
44
		this.manifest = manifest;
45
	}
46
47
	/**
48
	 * Sets or removes a client property.
49
	 * 
50
	 * @param key property key
51
	 * @param value property value or <code>null</code> to remove the property
52
	 */
53
	public synchronized void setProperty(String key, Object value) {
54
		if (properties == null) {
55
			properties = new HashMap();
56
		}
57
		if (value == null) {
58
			properties.remove(key);
59
		} else {
60
			properties.put(key, value);
61
		}
62
63
	}
64
65
	/**
66
	 * Returns the specified client property, or <code>null</code> if none.
67
	 * 
68
	 * @param key property key
69
	 * @return property value or <code>null</code>
70
	 */
71
	public synchronized Object getProperty(String key) {
72
		if (properties == null) {
73
			return null;
74
		}
75
		return properties.get(key);
76
	}
77
78
	/**
79
	 * Returns the project name the bundle will be imported into. The project
80
	 * may or may not exist before the import. However, when the import operation
81
	 * beings, the project will not exist.
82
	 * 
83
	 * @return target project
84
	 */
85
	public synchronized String getProject() {
86
		return project;
87
	}
88
89
	/**
90
	 * Returns the manifest of the bundle to be imported.
91
	 * 
92
	 * @return bundle manifest keys and values
93
	 */
94
	public Map getManifest() {
95
		return manifest;
96
	}
97
98
	/**
99
	 * Sets the project name that is the target of the import operation.
100
	 * 
101
	 * @param project target project
102
	 */
103
	public synchronized void setProject(String project) {
104
		this.project = project;
105
	}
106
107
}
(-)src/org/eclipse/pde/core/importing/IBundleImporter.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.core.importing;
12
13
/**
14
 * A bundle importer represents an instance of a bundle importer extension.
15
 * Clients contributing a bundle importer extension contribute an implementation
16
 * of {@link IBundleImporterDelegate} rather than this interface.
17
 * <p>
18
 * Clients contributing a bundle importer extension are intended to implement
19
 * {@link IBundleImporterDelegate}.
20
 * </p>
21
 * @since 3.6
22
 * @noextend This interface is not intended to be extended by clients.
23
 * @noimplement This interface is not intended to be implemented by clients.
24
 */
25
public interface IBundleImporter extends IBundleImporterDelegate {
26
27
	/**
28
	 * Returns this impoter's unique identifier.
29
	 * 
30
	 * @return identifier
31
	 */
32
	public String getId();
33
34
	/**
35
	 * Returns a short description of this importer, or <code>null</code> if unspecified.
36
	 * 
37
	 * @return description or <code>null</code>
38
	 */
39
	public String getDescription();
40
41
	/**
42
	 * Returns a human readable name for this importer.
43
	 * 
44
	 * @return name
45
	 */
46
	public String getName();
47
}
(-)src/org/eclipse/pde/core/importing/IBundleImporterDelegate.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.core.importing;
12
13
import java.util.Map;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
18
/**
19
 * A bundle importer delegate is contributed by a bundle importer extension and is capable
20
 * of importing projects into the workspace from a repository based on bundle manifest entries.
21
 * <p>
22
 * Following is an example extension:
23
 * <pre>
24
 * &lt;extension point=&quot;org.eclipse.pde.core.bundleImporters&quot;&gt;
25
 *  &lt;importer
26
 *   id=&quot;com.example.ExampleIdentifier&quot;
27
 *   class=&quot;com.example.ExampleBundleImporterDelegate&quot;&gt;
28
 *  &lt;/importer&gt;
29
 * &lt;/extension&gt;
30
 * </pre>
31
 * </p>
32
 * <p>
33
 * Clients contributing bundle importer extensions are intended to implement this interface.
34
 * </p>
35
 * @since 3.6
36
 * @noextend This interface is not intended to be extended by clients.
37
 */
38
public interface IBundleImporterDelegate {
39
40
	/**
41
	 * Returns an array of objects describing how each given bundle (manifest headers and values)
42
	 * can be imported into a workspace project. A <code>null</code> entry in the returned array
43
	 * indicates the corresponding bundle cannot be imported by this delegate.
44
	 * 
45
	 * @param manifest manifest headers and values of the associated bundle
46
	 * @return array of bundle import descriptions that may contain <code>null</code> entries
47
	 */
48
	public BundleImportDescription[] validateImport(Map[] manifests);
49
50
	/**
51
	 * Imports bundles into the workspace creating a project for each import description.
52
	 * Reports progress to the given monitor, if not <code>null</code>.
53
	 * 
54
	 * @param descriptions description of bundles to import
55
	 * @param options bundle import options to consider or <code>null</code> if none
56
	 * @param monitor progress monitor or <code>null</code>
57
	 * @return collection of projects created in the workspace or <code>null</code> if none
58
	 * @throws CoreException if unable to import projects
59
	 */
60
	public IProject[] performImport(BundleImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException;
61
}
(-)src/org/eclipse/pde/internal/core/ICoreConstants.java (+2 lines)
Lines 152-157 Link Here
152
	public static final String ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle"; //$NON-NLS-1$
152
	public static final String ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle"; //$NON-NLS-1$
153
	public static final String ECLIPSE_SYSTEM_BUNDLE = "Eclipse-SystemBundle"; //$NON-NLS-1$
153
	public static final String ECLIPSE_SYSTEM_BUNDLE = "Eclipse-SystemBundle"; //$NON-NLS-1$
154
	public static final String ECLIPSE_BUNDLE_SHAPE = "Eclipse-BundleShape"; //$NON-NLS-1$
154
	public static final String ECLIPSE_BUNDLE_SHAPE = "Eclipse-BundleShape"; //$NON-NLS-1$
155
	public static final String ECLIPSE_SOURCE_REFERENCES = "Eclipse-SourceReferences"; //$NON-NLS-1$
155
	public static final String SERVICE_COMPONENT = "Service-Component"; //$NON-NLS-1$
156
	public static final String SERVICE_COMPONENT = "Service-Component"; //$NON-NLS-1$
156
157
157
	// Equinox-specific system properties
158
	// Equinox-specific system properties
Lines 192-197 Link Here
192
193
193
	// Extension point identifiers
194
	// Extension point identifiers
194
	public static final String EXTENSION_POINT_SOURCE = PDECore.PLUGIN_ID + ".source"; //$NON-NLS-1$
195
	public static final String EXTENSION_POINT_SOURCE = PDECore.PLUGIN_ID + ".source"; //$NON-NLS-1$
196
	public static final String EXTENSION_POINT_BUNDLE_IMPORTERS = PDECore.PLUGIN_ID + ".bundleImporters"; //$NON-NLS-1$
195
197
196
	// file extensions
198
	// file extensions
197
199
(-)src/org/eclipse/pde/internal/core/importing/BundleImporterExtension.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.importing;
12
13
import java.util.Map;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.pde.core.importing.*;
17
import org.eclipse.pde.internal.core.PDECore;
18
19
/**
20
 * A bundle importer extension.
21
 * 
22
 * @since 3.6
23
 */
24
public class BundleImporterExtension implements IBundleImporter {
25
26
	private IBundleImporterDelegate delegate;
27
	private IConfigurationElement element;
28
29
	/**
30
	 * Constructs a bundle importer extension on the given element.
31
	 * 
32
	 * @param element contribution
33
	 */
34
	public BundleImporterExtension(IConfigurationElement element) {
35
		this.element = element;
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.pde.core.project.IBundleImporterDelegate#validateImport(java.util.Map[])
40
	 */
41
	public BundleImportDescription[] validateImport(Map[] manifests) {
42
		try {
43
			return getDelegate().validateImport(manifests);
44
		} catch (CoreException e) {
45
			PDECore.log(e);
46
			return null;
47
		}
48
	}
49
50
	/**
51
	 * Returns underlying delegate.
52
	 * 
53
	 * @return delegate
54
	 * @exception CoreException if unable to instantiate delegate
55
	 */
56
	private synchronized IBundleImporterDelegate getDelegate() throws CoreException {
57
		if (delegate == null) {
58
			delegate = (IBundleImporterDelegate) element.createExecutableExtension("class"); //$NON-NLS-1$
59
		}
60
		return delegate;
61
	}
62
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.pde.core.importing.IBundleImporterDelegate#performImport(org.eclipse.pde.core.importing.BundleImportDescription[], org.eclipse.core.runtime.IProgressMonitor)
65
	 */
66
	public IProject[] performImport(BundleImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException {
67
		return getDelegate().performImport(descriptions, monitor);
68
	}
69
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.pde.core.project.IBundleImporter#getId()
72
	 */
73
	public String getId() {
74
		return element.getAttribute("id"); //$NON-NLS-1$
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.pde.core.project.IBundleImporter#getDescription()
79
	 */
80
	public String getDescription() {
81
		return element.getAttribute("description"); //$NON-NLS-1$
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.pde.core.project.IBundleImporter#getName()
86
	 */
87
	public String getName() {
88
		return element.getAttribute("name"); //$NON-NLS-1$
89
	}
90
91
}
(-)src/org/eclipse/pde/internal/core/importing/CvsBundleImportDescription.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.importing;
12
13
import java.util.Map;
14
import org.eclipse.pde.core.importing.BundleImportDescription;
15
16
/**
17
 * Describes a bundle to be imported by CVS.
18
 * @since 3.6
19
 */
20
public class CvsBundleImportDescription extends BundleImportDescription {
21
22
	String tag;
23
	String server;
24
	String path;
25
	String module;
26
	String protocol;
27
28
	/**
29
	 * @param project
30
	 * @param manifest
31
	 */
32
	public CvsBundleImportDescription(String project, Map manifest, String protocol, String server, String path, String module, String tag) {
33
		super(project, manifest);
34
		this.protocol = protocol;
35
		this.server = server;
36
		this.path = path;
37
		this.module = module;
38
		this.tag = tag;
39
	}
40
41
	public void setTag(String tag) {
42
		this.tag = tag;
43
	}
44
45
	public String getTag() {
46
		return tag;
47
	}
48
49
	public String getServer() {
50
		return server;
51
	}
52
53
	public String getPath() {
54
		return path;
55
	}
56
57
	public String getModule() {
58
		return module;
59
	}
60
61
	public String getProtocol() {
62
		return protocol;
63
	}
64
65
}
(-)src/org/eclipse/pde/internal/core/importing/CvsBundleImporterDelegate.java (+199 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.importing;
12
13
import java.util.*;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.osgi.util.ManifestElement;
17
import org.eclipse.pde.core.importing.BundleImportDescription;
18
import org.eclipse.pde.core.importing.IBundleImporterDelegate;
19
import org.eclipse.pde.internal.core.ICoreConstants;
20
import org.eclipse.pde.internal.core.PDECore;
21
import org.eclipse.team.core.*;
22
import org.osgi.framework.BundleException;
23
import org.osgi.framework.Constants;
24
25
/**
26
 * Handles SCM CVS headers of the following form. Tag and project name can be specified
27
 * as extra attributes. When a tag is unspecified, the HEAD tag is used. When a project
28
 * name is unspecified, it is generated by the module name.
29
 * <pre>
30
 * scm:cvs&lt;delimiter&gt;&lt;method&gt;&lt;delimiter&gt;path_to_repository&lt;delimiter&gt;module_name[;tag=version][;project=name]
31
 * scm:psf&lt;delimiter&gt;&lt;method&gt;&lt;delimiter&gt;path_to_repository&lt;delimiter&gt;module_name[;tag=version][;project=name]
32
 * </pre>
33
 * @since 3.6
34
 */
35
/**
36
 *
37
 */
38
public class CvsBundleImporterDelegate implements IBundleImporterDelegate {
39
40
	private static Set SUPPORTED_VALUES;
41
42
	private static final String SCM = "scm:"; //$NON-NLS-1$
43
	private static final String CVS = "cvs"; //$NON-NLS-1$
44
//	private static final String PSF = "psf"; //$NON-NLS-1$
45
	private static final String COLON = ":"; //$NON-NLS-1$
46
	private static final String PIPE = "|"; //$NON-NLS-1$
47
48
	private static final String ATTR_TAG = "tag"; //$NON-NLS-1$
49
	private static final String ATTR_PROJECT = "project"; //$NON-NLS-1$
50
51
	private static RepositoryProviderType CVS_PROVIDER_TYPE = RepositoryProviderType.getProviderType("org.eclipse.team.cvs.core.cvsnature"); //$NON-NLS-1$
52
53
	static {
54
		SUPPORTED_VALUES = new HashSet();
55
		SUPPORTED_VALUES.add(SCM + CVS + COLON);
56
		SUPPORTED_VALUES.add(SCM + CVS + PIPE);
57
//		SUPPORTED_VALUES.add(SCM + PSF + COLON);
58
//		SUPPORTED_VALUES.add(SCM + PSF + PIPE);
59
	}
60
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.pde.core.project.IBundleImporterDelegate#validateImport(java.util.Map[])
63
	 */
64
	public BundleImportDescription[] validateImport(Map[] manifests) {
65
		BundleImportDescription[] results = new BundleImportDescription[manifests.length];
66
		if (CVS_PROVIDER_TYPE != null) {
67
			for (int i = 0; i < manifests.length; i++) {
68
				Map manifest = manifests[i];
69
				String value = (String) manifest.get(ICoreConstants.ECLIPSE_SOURCE_REFERENCES);
70
				if (value != null && value.length() > 8) {
71
					String prefix = value.substring(0, 8);
72
					if (SUPPORTED_VALUES.contains(prefix)) {
73
						try {
74
							ManifestElement[] elements = ManifestElement.parseHeader(ICoreConstants.ECLIPSE_SOURCE_REFERENCES, value);
75
							for (int j = 0; j < elements.length; j++) {
76
								ManifestElement element = elements[j];
77
								String url = element.getValue();
78
								String tag = element.getAttribute(ATTR_TAG);
79
								String project = element.getAttribute(ATTR_PROJECT);
80
								if (project == null) {
81
									String bsn = (String) manifests[i].get(Constants.BUNDLE_SYMBOLICNAME);
82
									if (bsn != null) {
83
										ManifestElement[] bsnElement = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, bsn);
84
										project = bsnElement[0].getValue();
85
									}
86
								}
87
								results[i] = createImportDescription(url, manifest, tag, project);
88
							}
89
						} catch (BundleException e) {
90
							PDECore.log(e);
91
						}
92
					}
93
				}
94
			}
95
		}
96
		return results;
97
	}
98
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.pde.core.importing.IBundleImporterDelegate#performImport(org.eclipse.pde.core.importing.BundleImportDescription[], org.eclipse.core.runtime.IProgressMonitor)
101
	 */
102
	public IProject[] performImport(BundleImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException {
103
		List references = new ArrayList();
104
		// collect and validate all header values
105
		for (int i = 0; i < descriptions.length; i++) {
106
			references.add(createPSF((CvsBundleImportDescription) descriptions[i]));
107
		}
108
		// create projects
109
		if (!references.isEmpty()) {
110
			SubMonitor subMonitor = SubMonitor.convert(monitor, references.size());
111
			ProjectSetCapability psfCapability = CVS_PROVIDER_TYPE.getProjectSetCapability();
112
			if (psfCapability != null) {
113
				// TODO: specify shell
114
				psfCapability.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), subMonitor);
115
			} else {
116
				//TODO: error
117
			}
118
			subMonitor.done();
119
		}
120
		return null;
121
	}
122
123
	/**
124
	 * Constructs a CVS project set import description from an SCMURL.
125
	 * 
126
	 * @param url
127
	 * @param manifest bundle manifest
128
	 * @param tag attribute value or <code>null</code>
129
	 * @param project suggested project name or <code>null</code>
130
	 * @return corresponding CVS project set reference
131
	 */
132
	private BundleImportDescription createImportDescription(String url, Map manifest, String tag, String project) {
133
		// format is 1.0,protocol:host:cvs folder,project name [, tag]
134
		String suffix = url.substring(8);
135
		String sep = url.substring(7, 8);
136
		String[] pieces = suffix.split(sep);
137
		String protocol = pieces[0];
138
		// the last piece is the module name
139
		String module = pieces[pieces.length - 1];
140
		// path is the second last piece
141
		String path = pieces[pieces.length - 2];
142
		// there might be a user:password:server:port
143
		int index = pieces.length - 3; // start looking at the third last piece and work backwards
144
		// if it's a port number, keep moving back
145
		String server = null;
146
		try {
147
			Integer.parseInt(pieces[index]);
148
			index--;
149
			server = pieces[index];
150
		} catch (NumberFormatException e) {
151
			server = pieces[index];
152
		}
153
		// trim any user/password
154
		index = server.indexOf('@');
155
		if (index >= 0) {
156
			server = server.substring(index + 1);
157
		}
158
		if (project == null) {
159
			// use module name as default
160
			int slash = pieces[3].lastIndexOf('/');
161
			if (slash >= 0) {
162
				project = pieces[3].substring(slash + 1);
163
			} else {
164
				project = pieces[3];
165
			}
166
		}
167
		return new CvsBundleImportDescription(project, manifest, protocol, server, path, module, tag);
168
	}
169
170
	/**
171
	 * Constructs a CVS project set import description from an SCMURL.
172
	 * 
173
	 * @param url
174
	 * @param tag attribute value or <code>null</code>
175
	 * @param project suggested project name or <code>null</code>
176
	 * @return corresponding CVS project set reference
177
	 */
178
	private String createPSF(CvsBundleImportDescription description) {
179
		// format is 1.0,protocol:host:cvs folder,project name [, tag]
180
		StringBuffer buffer = new StringBuffer();
181
		buffer.append("1.0,:"); //$NON-NLS-1$
182
		buffer.append(description.protocol); // protocol
183
		buffer.append(COLON);
184
		buffer.append(description.server);
185
		buffer.append(COLON);
186
		buffer.append(description.path);
187
		buffer.append(',');
188
		buffer.append(description.module);
189
		buffer.append(',');
190
		buffer.append(description.getProject());
191
		String tag = description.tag;
192
		if (tag != null) {
193
			buffer.append(',');
194
			buffer.append(tag);
195
		}
196
		return buffer.toString();
197
	}
198
199
}
(-)src/org/eclipse/pde/internal/core/project/BundleProjectService.java (-2 / +160 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.project;
11
package org.eclipse.pde.internal.core.project;
12
12
13
import org.eclipse.pde.internal.core.importing.BundleImporterExtension;
14
15
import org.eclipse.pde.core.importing.BundleImportDescription;
16
import org.eclipse.pde.core.importing.IBundleImporter;
17
18
import java.io.*;
19
import java.util.*;
20
import java.util.jar.JarFile;
21
import java.util.zip.ZipEntry;
22
import java.util.zip.ZipFile;
13
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.osgi.service.resolver.VersionRange;
25
import org.eclipse.osgi.service.resolver.VersionRange;
26
import org.eclipse.osgi.util.ManifestElement;
27
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.pde.core.plugin.IPluginModelBase;
17
import org.eclipse.pde.core.project.*;
29
import org.eclipse.pde.core.project.*;
30
import org.eclipse.pde.internal.core.ICoreConstants;
31
import org.eclipse.pde.internal.core.PDECore;
32
import org.eclipse.pde.internal.core.target.Messages;
33
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
34
import org.osgi.framework.BundleException;
18
import org.osgi.framework.Version;
35
import org.osgi.framework.Version;
19
36
20
/**
37
/**
Lines 25-32 Link Here
25
 */
42
 */
26
public final class BundleProjectService implements IBundleProjectService {
43
public final class BundleProjectService implements IBundleProjectService {
27
44
45
	/**
46
	 * Property key used in {@link BundleImportDescription}s.
47
	 */
48
	public static final String BUNDLE_IMPORTER = "BUNDLE_IMPORTER"; //$NON-NLS-1$
49
50
	/**
51
	 * Property key used in {@link BundleImportDescription}s.
52
	 */
53
	public static final String PLUGIN = "PLUGIN"; //$NON-NLS-1$
54
28
	private static IBundleProjectService fgDefault;
55
	private static IBundleProjectService fgDefault;
29
56
57
	private List fProjectFactories;
58
30
	/**
59
	/**
31
	 * Returns the bundle project service.
60
	 * Returns the bundle project service.
32
	 * 
61
	 * 
Lines 146-149 Link Here
146
	public void setBundleRoot(IProject project, IPath bundleRoot) throws CoreException {
175
	public void setBundleRoot(IProject project, IPath bundleRoot) throws CoreException {
147
		PDEProject.setBundleRoot(project, project.getFolder(bundleRoot));
176
		PDEProject.setBundleRoot(project, project.getFolder(bundleRoot));
148
	}
177
	}
178
179
	/* (non-Javadoc)
180
	 * @see org.eclipse.pde.core.project.IBundleProjectService#getSourceReferenceHandler(java.lang.String)
181
	 */
182
	public IBundleImporter getSourceReferenceHandler(String id) {
183
184
		return null;
185
	}
186
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.pde.core.project.IBundleProjectService#getBundleImporters()
189
	 */
190
	public synchronized IBundleImporter[] getBundleImporters() {
191
		if (fProjectFactories == null) {
192
			fProjectFactories = new ArrayList();
193
			IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(ICoreConstants.EXTENSION_POINT_BUNDLE_IMPORTERS);
194
			if (point != null) {
195
				IConfigurationElement[] infos = point.getConfigurationElements();
196
				for (int i = 0; i < infos.length; i++) {
197
					fProjectFactories.add(new BundleImporterExtension(infos[i]));
198
				}
199
			}
200
		}
201
		return (IBundleImporter[]) fProjectFactories.toArray(new IBundleImporter[fProjectFactories.size()]);
202
	}
203
204
	/**
205
	 * Creates and returns a map of bundle import descriptions for the given bundles.
206
	 * The map is of {@link IBundleImporter} -> arrays of {@link BundleImportDescription}.
207
	 * Adds 'BUNDLE_IMPORTER' property to each description that maps to the importer that
208
	 * created each description.
209
	 * Adds 'PLUGIN' property that maps to the original plug-in model.
210
	 * 
211
	 * @param models plug-in models
212
	 * @return import instructions
213
	 * @exception CoreException if unable to read manifest
214
	 */
215
	public Map getImportDescriptions(IPluginModelBase[] models) throws CoreException {
216
		// build manifests
217
		List manifests = new ArrayList();
218
		List plugins = new ArrayList();
219
		for (int i = 0; i < models.length; i++) {
220
			String location = models[i].getInstallLocation();
221
			if (location != null) {
222
				Map manifest = loadManifest(new File(location));
223
				if (manifest != null) {
224
					manifests.add(manifest);
225
					plugins.add(models[i]);
226
				}
227
			}
228
		}
229
		if (!manifests.isEmpty()) {
230
			Map[] marray = (Map[]) manifests.toArray(new Map[manifests.size()]);
231
			Map result = new HashMap();
232
			IBundleImporter[] importers = getBundleImporters();
233
			for (int i = 0; i < importers.length; i++) {
234
				IBundleImporter importer = importers[i];
235
				BundleImportDescription[] descriptions = importer.validateImport(marray);
236
				List valid = new ArrayList();
237
				for (int j = 0; j < descriptions.length; j++) {
238
					BundleImportDescription description = descriptions[j];
239
					if (description != null) {
240
						valid.add(description);
241
						description.setProperty(BUNDLE_IMPORTER, importer);
242
						description.setProperty(PLUGIN, plugins.get(j));
243
					}
244
				}
245
				result.put(importer, valid.toArray(new BundleImportDescription[valid.size()]));
246
			}
247
			return result;
248
		}
249
		return null;
250
	}
251
252
	/**
253
	 * Parses a bunlde's manifest into a dictionary and returns the map
254
	 * or <code>null</code> if none. The bundle may be in a jar
255
	 * or in a directory at the specified location.
256
	 * 
257
	 * @param bundleLocation root location of the bundle
258
	 * @return bundle manifest dictionary or <code>null</code>
259
	 * @throws CoreException if manifest has invalid syntax or is missing
260
	 */
261
	private Map loadManifest(File bundleLocation) throws CoreException {
262
		ZipFile jarFile = null;
263
		InputStream manifestStream = null;
264
		String extension = new Path(bundleLocation.getName()).getFileExtension();
265
		try {
266
			if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
267
				jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
268
				ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
269
				if (manifestEntry != null) {
270
					manifestStream = jarFile.getInputStream(manifestEntry);
271
				}
272
			} else {
273
				File file = new File(bundleLocation, JarFile.MANIFEST_NAME);
274
				if (file.exists()) {
275
					manifestStream = new FileInputStream(file);
276
				}
277
			}
278
			if (manifestStream == null) {
279
				return null;
280
			}
281
			return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
282
		} catch (BundleException e) {
283
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundleLocation.getAbsolutePath()), e));
284
		} catch (IOException e) {
285
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundleLocation.getAbsolutePath()), e));
286
		} finally {
287
			closeZipFileAndStream(manifestStream, jarFile);
288
		}
289
	}
290
291
	private void closeZipFileAndStream(InputStream stream, ZipFile jarFile) {
292
		try {
293
			if (stream != null) {
294
				stream.close();
295
			}
296
		} catch (IOException e) {
297
			PDECore.log(e);
298
		}
299
		try {
300
			if (jarFile != null) {
301
				jarFile.close();
302
			}
303
		} catch (IOException e) {
304
			PDECore.log(e);
305
		}
306
	}
149
}
307
}
(-).settings/org.eclipse.jdt.ui.prefs (-2 / +2 lines)
Lines 1-11 Link Here
1
#Sun Dec 23 21:49:35 CST 2007
1
#Sun Feb 28 21:27:07 CST 2010
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
3
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
4
formatter_profile=_core
4
formatter_profile=_core
5
formatter_settings_version=11
5
formatter_settings_version=11
6
org.eclipse.jdt.ui.ignorelowercasenames=true
6
org.eclipse.jdt.ui.ignorelowercasenames=true
7
org.eclipse.jdt.ui.importorder=;
7
org.eclipse.jdt.ui.importorder=;
8
org.eclipse.jdt.ui.ondemandthreshold=3
8
org.eclipse.jdt.ui.ondemandthreshold=12
9
org.eclipse.jdt.ui.staticondemandthreshold=99
9
org.eclipse.jdt.ui.staticondemandthreshold=99
10
sp_cleanup.add_default_serial_version_id=true
10
sp_cleanup.add_default_serial_version_id=true
11
sp_cleanup.add_generated_serial_version_id=false
11
sp_cleanup.add_generated_serial_version_id=false
(-)plugin.properties (+1 lines)
Lines 19-24 Link Here
19
expoint.templates.name = Extension Templates
19
expoint.templates.name = Extension Templates
20
expoint.samples.name = Code Samples
20
expoint.samples.name = Code Samples
21
expoint.osgiLauncher.name = OSGi Launcher
21
expoint.osgiLauncher.name = OSGi Launcher
22
expoint.bundleImportPages.name = Bundle Import Pages
22
23
23
RunPDELaunchShortcut.description=Runs a separate Eclipse application
24
RunPDELaunchShortcut.description=Runs a separate Eclipse application
24
DebugPDELaunchShortcut.description=Debugs a separate Eclipse application
25
DebugPDELaunchShortcut.description=Debugs a separate Eclipse application
(-)plugin.xml (-1 / +10 lines)
Lines 20-25 Link Here
20
   <extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
20
   <extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
21
   <extension-point id="targetProvisioners" name="%extension-point.name.0" schema="schema/targetProvisioners.exsd"/>
21
   <extension-point id="targetProvisioners" name="%extension-point.name.0" schema="schema/targetProvisioners.exsd"/>
22
   <extension-point id="launchShortcuts" name="%extension-point.name.1" schema="schema/launchShortcuts.exsd"/>
22
   <extension-point id="launchShortcuts" name="%extension-point.name.1" schema="schema/launchShortcuts.exsd"/>
23
   <extension-point id="bundleImportPages" name="%expoint.bundleImportPages.name" schema="schema/bundleImportPages.exsd"/>
23
24
24
<!-- Extensions -->
25
<!-- Extensions -->
25
   <extension
26
   <extension
Lines 2024-2028 Link Here
2024
            id="org.eclipse.pde.launching.ORGANIZE_MANIFESTS"
2025
            id="org.eclipse.pde.launching.ORGANIZE_MANIFESTS"
2025
            plugin="org.eclipse.pde.launching">
2026
            plugin="org.eclipse.pde.launching">
2026
      </statusHandler>
2027
      </statusHandler>
2027
   </extension>	
2028
   </extension>
2029
 <extension
2030
       point="org.eclipse.pde.ui.bundleImportPages">
2031
    <page
2032
          bundleImporter="org.eclipse.pde.core.cvs.importer"
2033
          class="org.eclipse.pde.internal.ui.wizards.imports.CVSBundleImportPage"
2034
          id="org.eclipse.pde.ui.cvs.import.page">
2035
    </page>
2036
 </extension>	
2028
</plugin>
2037
</plugin>
(-)schema/bundleImportPages.exsd (+144 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.ui" id="bundleImportPages" name="%expoint.bundleImportPages.name"/>
7
      </appInfo>
8
      <documentation>
9
         A bundle import page provides a wizard page that can be used in the Plug-in import wizard to configure settings for bundles to be imported by a &lt;code&gt;org.eclipse.pde.core.bundleImporters&lt;/code&gt; extension.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="page" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="page">
51
      <complexType>
52
         <attribute name="id" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  unique identifier for this bundle import page
56
               </documentation>
57
            </annotation>
58
         </attribute>
59
         <attribute name="class" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  Fully qualified name of a Java class providing an implementation of &lt;code&gt;org.eclipse.pde.ui.IBundeImportWizardPage&lt;/code&gt;.
63
               </documentation>
64
               <appInfo>
65
                  <meta.attribute kind="java" basedOn=":org.eclipse.pde.ui.IBundeImportWizardPage"/>
66
               </appInfo>
67
            </annotation>
68
         </attribute>
69
         <attribute name="bundleImporter" type="string" use="required">
70
            <annotation>
71
               <documentation>
72
                  Identifier of the &lt;code&gt;org.eclipse.pde.core.bundleImporters&lt;/code&gt; extension that this page provides a user interface for.
73
               </documentation>
74
               <appInfo>
75
                  <meta.attribute kind="identifier" basedOn="org.eclipse.pde.core.bundleImporters/importer/@id"/>
76
               </appInfo>
77
            </annotation>
78
         </attribute>
79
      </complexType>
80
   </element>
81
82
   <annotation>
83
      <appInfo>
84
         <meta.section type="since"/>
85
      </appInfo>
86
      <documentation>
87
         3.6
88
      </documentation>
89
   </annotation>
90
91
   <annotation>
92
      <appInfo>
93
         <meta.section type="examples"/>
94
      </appInfo>
95
      <documentation>
96
         The following is an example of a bundle import wizard page extension.
97
98
&lt;p&gt;
99
&lt;pre&gt;
100
 &lt;extension point=&quot;org.eclipse.pde.core.bundleImporters&quot;&gt;
101
  &lt;importer
102
   id=&quot;com.example.ExampleIdentifier&quot;
103
   class=&quot;com.example.ExampleBundleImportWizardpage&quot;
104
   bundleImporter=&quot;com.example.bundleImporter&quot;&gt;
105
  &lt;/importer&gt;
106
 &lt;/extension&gt;
107
&lt;/pre&gt;
108
&lt;/p&gt;
109
      </documentation>
110
   </annotation>
111
112
   <annotation>
113
      <appInfo>
114
         <meta.section type="apiinfo"/>
115
      </appInfo>
116
      <documentation>
117
         Value of a page&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.ui.IBundeImportWizardPage&lt;/b&gt;.
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="implementation"/>
124
      </appInfo>
125
      <documentation>
126
         PDE provides a wizard page for editing properties of bundles that can be imported by the CVS bundle importer.
127
      </documentation>
128
   </annotation>
129
130
   <annotation>
131
      <appInfo>
132
         <meta.section type="copyright"/>
133
      </appInfo>
134
      <documentation>
135
         Copyright (c) 2010 IBM Corporation and others.
136
&lt;br&gt;
137
All rights reserved. This program and the accompanying materials are made 
138
available under the terms of the Eclipse Public License v1.0 which 
139
accompanies this distribution, and is available at 
140
&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;.
141
      </documentation>
142
   </annotation>
143
144
</schema>
(-)src/org/eclipse/pde/internal/ui/IPDEUIConstants.java (+5 lines)
Lines 50-53 Link Here
50
	 */
50
	 */
51
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
51
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
52
52
53
	/**
54
	 * Extension point identifier for <code>org.eclipse.pde.ui.bundleImportPages</code>.
55
	 */
56
	public static final String EXTENSION_POINT_BUNDLE_IMPORT_PAGES = PLUGIN_ID + ".bundleImportPages"; //$NON-NLS-1$
57
53
}
58
}
(-)src/org/eclipse/pde/internal/ui/PDEUIMessages.java (+8 lines)
Lines 2304-2309 Link Here
2304
2304
2305
	public static String PluginImportWizardFirstPage_2;
2305
	public static String PluginImportWizardFirstPage_2;
2306
2306
2307
	public static String PluginImportWizardFirstPage_3;
2308
2307
	public static String LauncherUtils_title;
2309
	public static String LauncherUtils_title;
2308
2310
2309
	public static String RemoveLazyLoadingDirectiveResolution_remove;
2311
	public static String RemoveLazyLoadingDirectiveResolution_remove;
Lines 2546-2551 Link Here
2546
2548
2547
	public static String CompilersConfigurationTab_buildPropertiesErrors;
2549
	public static String CompilersConfigurationTab_buildPropertiesErrors;
2548
2550
2551
	public static String CVSBundleImportPage_0;
2552
2553
	public static String CVSBundleImportPage_1;
2554
2555
	public static String CVSBundleImportPage_2;
2556
2549
	public static String PluginsView_description;
2557
	public static String PluginsView_description;
2550
2558
2551
	public static String LocationSection_0;
2559
	public static String LocationSection_0;
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (+4 lines)
Lines 1056-1061 Link Here
1056
PluginImportWizardFirstPage_0=Tar&get definition:
1056
PluginImportWizardFirstPage_0=Tar&get definition:
1057
PluginImportWizardFirstPage_1=Reading contents
1057
PluginImportWizardFirstPage_1=Reading contents
1058
PluginImportWizardFirstPage_2=A target definition must be selected
1058
PluginImportWizardFirstPage_2=A target definition must be selected
1059
PluginImportWizardFirstPage_3=Projects from a &repository
1059
PluginContentPage_appQuestion=Would you like to create a rich client application?
1060
PluginContentPage_appQuestion=Would you like to create a rich client application?
1060
PluginContentPage_enable_api_analysis=Enable API Analy&sis
1061
PluginContentPage_enable_api_analysis=Enable API Analy&sis
1061
PluginContentMergeViewer_title=Plug-in Source Compare
1062
PluginContentMergeViewer_title=Plug-in Source Compare
Lines 2223-2228 Link Here
2223
ControlValidationUtility_errorMsgValueNotExternalized=The specified value is not externalized
2224
ControlValidationUtility_errorMsgValueNotExternalized=The specified value is not externalized
2224
ControlValidationUtility_errorMsgKeyNotFound=The specified key is not present in the plug-in's properties file
2225
ControlValidationUtility_errorMsgKeyNotFound=The specified key is not present in the plug-in's properties file
2225
ControlValidationUtility_errorMsgFilterInvalidSyntax=The specified platform filter contains invalid syntax
2226
ControlValidationUtility_errorMsgFilterInvalidSyntax=The specified platform filter contains invalid syntax
2227
CVSBundleImportPage_0=Import Projects from CVS
2228
CVSBundleImportPage_1=Import CVS projects corresponding to plug-ins and fragments in the file system.
2229
CVSBundleImportPage_2=Import from &HEAD
2226
PackageFinder_taskName=Searching class files for package references
2230
PackageFinder_taskName=Searching class files for package references
2227
2231
2228
UpdateSplashHandlerInModelAction_nameEmbedded=Embedded
2232
UpdateSplashHandlerInModelAction_nameEmbedded=Embedded
(-)src/org/eclipse/pde/internal/ui/wizards/imports/BaseImportWizardSecondPage.java (-3 / +26 lines)
Lines 17-32 Link Here
17
import org.eclipse.jface.wizard.WizardPage;
17
import org.eclipse.jface.wizard.WizardPage;
18
import org.eclipse.pde.core.IModelProviderEvent;
18
import org.eclipse.pde.core.IModelProviderEvent;
19
import org.eclipse.pde.core.IModelProviderListener;
19
import org.eclipse.pde.core.IModelProviderListener;
20
import org.eclipse.pde.core.plugin.*;
20
import org.eclipse.pde.core.plugin.IFragment;
21
import org.eclipse.pde.core.plugin.IFragmentModel;
22
import org.eclipse.pde.core.plugin.IPlugin;
23
import org.eclipse.pde.core.plugin.IPluginImport;
24
import org.eclipse.pde.core.plugin.IPluginLibrary;
25
import org.eclipse.pde.core.plugin.IPluginModel;
26
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
import org.eclipse.pde.internal.core.ClasspathUtilCore;
27
import org.eclipse.pde.internal.core.ClasspathUtilCore;
22
import org.eclipse.pde.internal.core.PDECore;
28
import org.eclipse.pde.internal.core.PDECore;
23
import org.eclipse.pde.internal.ui.*;
29
import org.eclipse.pde.internal.ui.PDEPlugin;
30
import org.eclipse.pde.internal.ui.PDEUIMessages;
31
import org.eclipse.pde.internal.ui.SWTFactory;
24
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
32
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
25
import org.eclipse.pde.internal.ui.wizards.ListUtil;
33
import org.eclipse.pde.internal.ui.wizards.ListUtil;
26
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.*;
37
import org.eclipse.swt.widgets.Button;
38
import org.eclipse.swt.widgets.Composite;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Table;
41
import org.eclipse.swt.widgets.TableItem;
30
import org.osgi.framework.Version;
42
import org.osgi.framework.Version;
31
43
32
public abstract class BaseImportWizardSecondPage extends WizardPage implements IModelProviderListener {
44
public abstract class BaseImportWizardSecondPage extends WizardPage implements IModelProviderListener {
Lines 37-42 Link Here
37
	protected PluginImportWizardFirstPage fPage1;
49
	protected PluginImportWizardFirstPage fPage1;
38
	protected IPluginModelBase[] fModels = new IPluginModelBase[0];
50
	protected IPluginModelBase[] fModels = new IPluginModelBase[0];
39
	private Object fImportSource;
51
	private Object fImportSource;
52
	private int fImportType;
40
	protected Button fAddFragmentsButton;
53
	protected Button fAddFragmentsButton;
41
	private Button fAutoBuildButton;
54
	private Button fAutoBuildButton;
42
	protected TableViewer fImportListViewer;
55
	protected TableViewer fImportListViewer;
Lines 108-113 Link Here
108
		if (fRefreshNeeded) {
121
		if (fRefreshNeeded) {
109
			fRefreshNeeded = false;
122
			fRefreshNeeded = false;
110
			fImportSource = fPage1.getImportSource();
123
			fImportSource = fPage1.getImportSource();
124
			fImportType = fPage1.getImportType();
111
			return true;
125
			return true;
112
		}
126
		}
113
		Object currSource = fPage1.getImportSource();
127
		Object currSource = fPage1.getImportSource();
Lines 115-120 Link Here
115
			fImportSource = fPage1.getImportSource();
129
			fImportSource = fPage1.getImportSource();
116
			return true;
130
			return true;
117
		}
131
		}
132
		// If the import type was changed to/from repository need refresh to filter available models
133
		int currType = fPage1.getImportType();
134
		if (currType != fImportType) {
135
			if (currType == PluginImportOperation.IMPORT_FROM_REPOSITORY || fImportType == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
136
				fImportType = currType;
137
				return true;
138
			}
139
			fImportType = currType;
140
		}
118
		return fPage1.isRefreshNeeded();
141
		return fPage1.isRefreshNeeded();
119
	}
142
	}
120
143
(-)src/org/eclipse/pde/internal/ui/wizards/imports/CVSBundleImportPage.java (+87 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.imports;
12
13
import org.eclipse.pde.internal.ui.PDEUIMessages;
14
15
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.pde.core.importing.BundleImportDescription;
17
import org.eclipse.pde.internal.core.importing.CvsBundleImportDescription;
18
import org.eclipse.pde.internal.ui.SWTFactory;
19
import org.eclipse.pde.ui.IBundeImportWizardPage;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Composite;
23
24
/**
25
 *
26
 */
27
public class CVSBundleImportPage extends WizardPage implements IBundeImportWizardPage {
28
29
	private BundleImportDescription[] descriptions;
30
31
	private Button useHead;
32
33
	/**
34
	 * Constructs the page.
35
	 */
36
	public CVSBundleImportPage() {
37
		super("cvs", PDEUIMessages.CVSBundleImportPage_0, null); //$NON-NLS-1$
38
		setDescription(PDEUIMessages.CVSBundleImportPage_1);
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
43
	 */
44
	public void createControl(Composite parent) {
45
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
46
		useHead = SWTFactory.createCheckButton(comp, PDEUIMessages.CVSBundleImportPage_2, null, false, 1);
47
		setControl(comp);
48
		setPageComplete(true);
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
53
	 */
54
	public void setVisible(boolean visible) {
55
		super.setVisible(visible);
56
		setPageComplete(true);
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.pde.ui.IBundeImportWizardPage#finish()
61
	 */
62
	public boolean finish() {
63
		if (useHead.getSelection()) {
64
			// modify tags on bundle import descriptions
65
			for (int i = 0; i < descriptions.length; i++) {
66
				CvsBundleImportDescription description = (CvsBundleImportDescription) descriptions[i];
67
				description.setTag(null);
68
			}
69
		}
70
		return true;
71
	}
72
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.pde.ui.IBundeImportWizardPage#getSelection()
75
	 */
76
	public BundleImportDescription[] getSelection() {
77
		return descriptions;
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.pde.ui.IBundeImportWizardPage#setSelection(org.eclipse.pde.core.importing.BundleImportDescription[])
82
	 */
83
	public void setSelection(BundleImportDescription[] descriptions) {
84
		this.descriptions = descriptions;
85
	}
86
87
}
(-)src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java (-25 / +88 lines)
Lines 12-32 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.*;
15
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Enumeration;
18
import java.util.HashMap;
19
import java.util.HashSet;
20
import java.util.Hashtable;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
import java.util.Map.Entry;
25
import java.util.Set;
16
import java.util.zip.ZipException;
26
import java.util.zip.ZipException;
17
import java.util.zip.ZipFile;
27
import java.util.zip.ZipFile;
18
import org.eclipse.core.resources.*;
28
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.runtime.*;
29
import org.eclipse.core.resources.IFolder;
30
import org.eclipse.core.resources.IProject;
31
import org.eclipse.core.resources.IProjectDescription;
32
import org.eclipse.core.resources.IResource;
33
import org.eclipse.core.resources.IncrementalProjectBuilder;
34
import org.eclipse.core.resources.ResourcesPlugin;
35
import org.eclipse.core.resources.WorkspaceJob;
36
import org.eclipse.core.runtime.CoreException;
37
import org.eclipse.core.runtime.IPath;
38
import org.eclipse.core.runtime.IProgressMonitor;
39
import org.eclipse.core.runtime.IStatus;
40
import org.eclipse.core.runtime.MultiStatus;
41
import org.eclipse.core.runtime.NullProgressMonitor;
42
import org.eclipse.core.runtime.Path;
43
import org.eclipse.core.runtime.Platform;
44
import org.eclipse.core.runtime.Status;
45
import org.eclipse.core.runtime.SubProgressMonitor;
20
import org.eclipse.core.runtime.jobs.Job;
46
import org.eclipse.core.runtime.jobs.Job;
21
import org.eclipse.jdt.core.*;
47
import org.eclipse.jdt.core.IClasspathEntry;
48
import org.eclipse.jdt.core.JavaCore;
49
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jface.window.Window;
50
import org.eclipse.jface.window.Window;
23
import org.eclipse.osgi.service.resolver.BundleDescription;
51
import org.eclipse.osgi.service.resolver.BundleDescription;
24
import org.eclipse.osgi.util.ManifestElement;
52
import org.eclipse.osgi.util.ManifestElement;
25
import org.eclipse.osgi.util.NLS;
53
import org.eclipse.osgi.util.NLS;
26
import org.eclipse.pde.core.build.IBuild;
54
import org.eclipse.pde.core.build.IBuild;
27
import org.eclipse.pde.core.build.IBuildEntry;
55
import org.eclipse.pde.core.build.IBuildEntry;
28
import org.eclipse.pde.core.plugin.*;
56
import org.eclipse.pde.core.importing.BundleImportDescription;
29
import org.eclipse.pde.internal.core.*;
57
import org.eclipse.pde.core.importing.IBundleImporter;
58
import org.eclipse.pde.core.plugin.IPluginBase;
59
import org.eclipse.pde.core.plugin.IPluginLibrary;
60
import org.eclipse.pde.core.plugin.IPluginModelBase;
61
import org.eclipse.pde.core.plugin.PluginRegistry;
62
import org.eclipse.pde.internal.core.ClasspathComputer;
63
import org.eclipse.pde.internal.core.ClasspathUtilCore;
64
import org.eclipse.pde.internal.core.PDECore;
65
import org.eclipse.pde.internal.core.SourceLocationManager;
30
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
66
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
31
import org.eclipse.pde.internal.core.bundle.WorkspaceBundleModel;
67
import org.eclipse.pde.internal.core.bundle.WorkspaceBundleModel;
32
import org.eclipse.pde.internal.core.ibundle.IBundle;
68
import org.eclipse.pde.internal.core.ibundle.IBundle;
Lines 38-44 Link Here
38
import org.eclipse.team.core.RepositoryProvider;
74
import org.eclipse.team.core.RepositoryProvider;
39
import org.eclipse.team.core.TeamException;
75
import org.eclipse.team.core.TeamException;
40
import org.eclipse.ui.progress.UIJob;
76
import org.eclipse.ui.progress.UIJob;
41
import org.eclipse.ui.wizards.datatransfer.*;
77
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
78
import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
79
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
42
import org.osgi.framework.BundleException;
80
import org.osgi.framework.BundleException;
43
81
44
/**
82
/**
Lines 51-56 Link Here
51
	public static final int IMPORT_BINARY = 1;
89
	public static final int IMPORT_BINARY = 1;
52
	public static final int IMPORT_BINARY_WITH_LINKS = 2;
90
	public static final int IMPORT_BINARY_WITH_LINKS = 2;
53
	public static final int IMPORT_WITH_SOURCE = 3;
91
	public static final int IMPORT_WITH_SOURCE = 3;
92
	public static final int IMPORT_FROM_REPOSITORY = 4;
54
93
55
	private static final String DEFAULT_SOURCE_DIR = "src"; //$NON-NLS-1$
94
	private static final String DEFAULT_SOURCE_DIR = "src"; //$NON-NLS-1$
56
	private static final String DEFAULT_LIBRARY_NAME = "."; //$NON-NLS-1$
95
	private static final String DEFAULT_LIBRARY_NAME = "."; //$NON-NLS-1$
Lines 60-65 Link Here
60
	private Hashtable fProjectClasspaths = new Hashtable();
99
	private Hashtable fProjectClasspaths = new Hashtable();
61
	private boolean fForceAutobuild;
100
	private boolean fForceAutobuild;
62
101
102
	// used when importing from a repository
103
	private Map fImportDescriptions;
104
63
	/**
105
	/**
64
	 * Used to find source locations when not found in default locations.
106
	 * Used to find source locations when not found in default locations.
65
	 * Possibly <code>null</code>
107
	 * Possibly <code>null</code>
Lines 117-144 Link Here
117
			if (monitor.isCanceled()) {
159
			if (monitor.isCanceled()) {
118
				return Status.CANCEL_STATUS;
160
				return Status.CANCEL_STATUS;
119
			}
161
			}
162
			// TODO: more than one importer
120
163
121
			for (int i = 0; i < fModels.length; i++) {
164
			if (fImportType == IMPORT_FROM_REPOSITORY) {
122
				monitor.setTaskName(NLS.bind(PDEUIMessages.PluginImportOperation_Importing_plugin, fModels[i].getPluginBase().getId()));
165
				Iterator iterator = fImportDescriptions.entrySet().iterator();
123
				try {
166
				while (iterator.hasNext()) {
124
					importPlugin(fModels[i], fImportType, new SubProgressMonitor(monitor, 1));
167
					Entry entry = (Entry) iterator.next();
125
				} catch (CoreException e) {
168
					IBundleImporter importer = (IBundleImporter) entry.getKey();
126
					multiStatus.merge(e.getStatus());
169
					BundleImportDescription[] descriptions = (BundleImportDescription[]) entry.getValue();
170
					importer.performImport(descriptions, new SubProgressMonitor(monitor, descriptions.length));
127
				}
171
				}
128
				if (monitor.isCanceled()) {
172
			} else {
173
				for (int i = 0; i < fModels.length; i++) {
174
					monitor.setTaskName(NLS.bind(PDEUIMessages.PluginImportOperation_Importing_plugin, fModels[i].getPluginBase().getId()));
129
					try {
175
					try {
130
						setClasspaths(new SubProgressMonitor(monitor, 3));
176
						importPlugin(fModels[i], fImportType, new SubProgressMonitor(monitor, 1));
131
					} catch (JavaModelException e) {
177
					} catch (CoreException e) {
132
						/* Do nothing as we are already cancelled */
178
						multiStatus.merge(e.getStatus());
179
					}
180
					if (monitor.isCanceled()) {
181
						try {
182
							setClasspaths(new SubProgressMonitor(monitor, 3));
183
						} catch (JavaModelException e) {
184
							/* Do nothing as we are already cancelled */
185
						}
186
						return Status.CANCEL_STATUS;
133
					}
187
					}
134
					return Status.CANCEL_STATUS;
135
				}
188
				}
136
			}
189
				monitor.setTaskName(PDEUIMessages.PluginImportOperation_Set_up_classpaths);
137
			monitor.setTaskName(PDEUIMessages.PluginImportOperation_Set_up_classpaths);
190
				try {
138
			try {
191
					setClasspaths(new SubProgressMonitor(monitor, 1));
139
				setClasspaths(new SubProgressMonitor(monitor, 1));
192
				} catch (JavaModelException e) {
140
			} catch (JavaModelException e) {
193
					multiStatus.merge(e.getStatus());
141
				multiStatus.merge(e.getStatus());
194
				}
142
			}
195
			}
143
			if (!ResourcesPlugin.getWorkspace().isAutoBuilding() && fForceAutobuild)
196
			if (!ResourcesPlugin.getWorkspace().isAutoBuilding() && fForceAutobuild)
144
				runBuildJob();
197
				runBuildJob();
Lines 166-174 Link Here
166
				ArrayList pluginsWithSameSymbolicName = (ArrayList) workspacePluginMap.get(symbolicName);
219
				ArrayList pluginsWithSameSymbolicName = (ArrayList) workspacePluginMap.get(symbolicName);
167
				if (pluginsWithSameSymbolicName == null) {
220
				if (pluginsWithSameSymbolicName == null) {
168
					pluginsWithSameSymbolicName = new ArrayList();
221
					pluginsWithSameSymbolicName = new ArrayList();
222
					workspacePluginMap.put(symbolicName, pluginsWithSameSymbolicName);
169
				}
223
				}
170
				pluginsWithSameSymbolicName.add(plugin);
224
				pluginsWithSameSymbolicName.add(plugin);
171
				workspacePluginMap.put(symbolicName, pluginsWithSameSymbolicName);
172
			}
225
			}
173
			monitor.worked(1);
226
			monitor.worked(1);
174
227
Lines 259-264 Link Here
259
	 * environment is supported and also checks if the project already exists and 
312
	 * environment is supported and also checks if the project already exists and 
260
	 * needs to be replaced.
313
	 * needs to be replaced.
261
	 * @param model model representing the plugin to import
314
	 * @param model model representing the plugin to import
315
	 * @param instructions instructions for how to import from repository
262
	 * @param monitor progress monitor
316
	 * @param monitor progress monitor
263
	 * @throws CoreException if a problem occurs while importing a plugin
317
	 * @throws CoreException if a problem occurs while importing a plugin
264
	 */
318
	 */
Lines 1146-1149 Link Here
1146
		return new File(model.getInstallLocation()).isFile();
1200
		return new File(model.getInstallLocation()).isFile();
1147
	}
1201
	}
1148
1202
1203
	/**
1204
	 * Sets the import descriptions to use when importing from a repository.
1205
	 * 
1206
	 * @param descriptions map of {@link IBundleImporter} to arrays of {@link BundleImportDescription}.
1207
	 */
1208
	public void setImportDescriptions(Map descriptions) {
1209
		fImportDescriptions = descriptions;
1210
	}
1211
1149
}
1212
}
(-)src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java (-11 / +37 lines)
Lines 10-29 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.imports;
11
package org.eclipse.pde.internal.ui.wizards.imports;
12
12
13
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
13
import java.util.HashSet;
14
14
import java.util.Iterator;
15
import java.util.*;
15
import java.util.Map;
16
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.*;
18
import org.eclipse.debug.core.DebugPlugin;
19
import org.eclipse.jface.dialogs.*;
19
import org.eclipse.debug.core.ILaunch;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchManager;
22
import org.eclipse.jface.dialogs.IDialogConstants;
23
import org.eclipse.jface.dialogs.IDialogSettings;
24
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.wizard.IWizardPage;
26
import org.eclipse.jface.wizard.IWizardPage;
22
import org.eclipse.jface.wizard.Wizard;
27
import org.eclipse.jface.wizard.Wizard;
23
import org.eclipse.osgi.service.resolver.BundleDescription;
28
import org.eclipse.osgi.service.resolver.BundleDescription;
24
import org.eclipse.pde.core.plugin.IPluginModelBase;
29
import org.eclipse.pde.core.plugin.IPluginModelBase;
25
import org.eclipse.pde.internal.core.SourceLocationManager;
30
import org.eclipse.pde.internal.core.SourceLocationManager;
26
import org.eclipse.pde.internal.ui.*;
31
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
32
import org.eclipse.pde.internal.ui.PDEPlugin;
33
import org.eclipse.pde.internal.ui.PDEPluginImages;
34
import org.eclipse.pde.internal.ui.PDEUIMessages;
27
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.ui.IImportWizard;
36
import org.eclipse.ui.IImportWizard;
29
import org.eclipse.ui.IWorkbench;
37
import org.eclipse.ui.IWorkbench;
Lines 84-90 Link Here
84
				return false;
92
				return false;
85
93
86
		}
94
		}
87
		doImportOperation(getShell(), page1.getImportType(), models, page2.forceAutoBuild(), launchedConfiguration > 0, page1.getAlternateSourceLocations());
95
		// finish contributed pages
96
		if (!page1.finishPages()) {
97
			return false;
98
		}
99
		doImportOperation(getShell(), page1.getImportType(), models, page2.forceAutoBuild(), launchedConfiguration > 0, page1.getAlternateSourceLocations(), page1.getImportDescriptions());
88
		return true;
100
		return true;
89
	}
101
	}
90
102
Lines 129-135 Link Here
129
	}
141
	}
130
142
131
	public static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild) {
143
	public static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild) {
132
		doImportOperation(shell, importType, models, forceAutobuild, false, null);
144
		doImportOperation(shell, importType, models, forceAutobuild, false, null, null);
133
	}
145
	}
134
146
135
	/**
147
	/**
Lines 143-150 Link Here
143
	 * 	source locations should be used (from active target platform).
155
	 * 	source locations should be used (from active target platform).
144
	 *  
156
	 *  
145
	 */
157
	 */
146
	private static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild, boolean launchedConfiguration, SourceLocationManager alternateSource) {
158
	private static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild, boolean launchedConfiguration, SourceLocationManager alternateSource, Map importerToDescriptions) {
147
		PluginImportOperation job = new PluginImportOperation(models, importType, forceAutobuild);
159
		PluginImportOperation job = new PluginImportOperation(models, importType, forceAutobuild);
160
		job.setImportDescriptions(importerToDescriptions);
148
		job.setAlternateSource(alternateSource);
161
		job.setAlternateSource(alternateSource);
149
		job.setPluginsInUse(launchedConfiguration);
162
		job.setPluginsInUse(launchedConfiguration);
150
		job.setRule(ResourcesPlugin.getWorkspace().getRoot());
163
		job.setRule(ResourcesPlugin.getWorkspace().getRoot());
Lines 159-172 Link Here
159
			}
172
			}
160
			return page2;
173
			return page2;
161
		}
174
		}
175
		if (page.equals(page3)) {
176
			return page1.getNextPage(page);
177
		}
162
		return null;
178
		return null;
163
	}
179
	}
164
180
165
	public IWizardPage getPreviousPage(IWizardPage page) {
181
	public IWizardPage getPreviousPage(IWizardPage page) {
166
		return page.equals(page1) ? null : page1;
182
		if (page.equals(page1)) {
183
			return null;
184
		}
185
		if (page.equals(page2) || page.equals(page3)) {
186
			return page1;
187
		}
188
		IWizardPage prev = page1.getPreviousPage(page);
189
		if (prev == null) {
190
			return page3;
191
		}
192
		return prev;
167
	}
193
	}
168
194
169
	public boolean canFinish() {
195
	public boolean canFinish() {
170
		return !page1.isCurrentPage() && page1.getNextPage().isPageComplete();
196
		return !page1.isCurrentPage() && page1.getNextPage().isPageComplete() && page1.arePagesComplete();
171
	}
197
	}
172
}
198
}
(-)src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizardDetailedPage.java (-9 / +50 lines)
Lines 13-43 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.pde.internal.ui.wizards.imports;
14
package org.eclipse.pde.internal.ui.wizards.imports;
15
15
16
import java.util.*;
16
import java.util.ArrayList;
17
import java.util.HashMap;
18
import java.util.HashSet;
17
import java.util.List;
19
import java.util.List;
20
import java.util.Set;
18
import java.util.regex.Pattern;
21
import java.util.regex.Pattern;
19
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
21
import org.eclipse.jface.dialogs.Dialog;
26
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.dialogs.IDialogSettings;
27
import org.eclipse.jface.dialogs.IDialogSettings;
23
import org.eclipse.jface.viewers.*;
28
import org.eclipse.jface.viewers.DoubleClickEvent;
29
import org.eclipse.jface.viewers.IDoubleClickListener;
30
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.jface.viewers.ISelectionChangedListener;
32
import org.eclipse.jface.viewers.IStructuredContentProvider;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.jface.viewers.SelectionChangedEvent;
35
import org.eclipse.jface.viewers.TableViewer;
36
import org.eclipse.jface.viewers.Viewer;
37
import org.eclipse.jface.viewers.ViewerFilter;
24
import org.eclipse.osgi.util.NLS;
38
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.pde.core.plugin.IPluginModelBase;
39
import org.eclipse.pde.core.plugin.IPluginModelBase;
26
import org.eclipse.pde.internal.core.PDECore;
40
import org.eclipse.pde.internal.core.PDECore;
27
import org.eclipse.pde.internal.core.WorkspaceModelManager;
41
import org.eclipse.pde.internal.core.WorkspaceModelManager;
28
import org.eclipse.pde.internal.core.plugin.AbstractPluginModelBase;
42
import org.eclipse.pde.internal.core.plugin.AbstractPluginModelBase;
29
import org.eclipse.pde.internal.core.util.PatternConstructor;
43
import org.eclipse.pde.internal.core.util.PatternConstructor;
30
import org.eclipse.pde.internal.ui.*;
44
import org.eclipse.pde.internal.ui.IHelpContextIds;
45
import org.eclipse.pde.internal.ui.PDEPlugin;
46
import org.eclipse.pde.internal.ui.PDEUIMessages;
47
import org.eclipse.pde.internal.ui.SWTFactory;
31
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
48
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
32
import org.eclipse.pde.internal.ui.util.SWTUtil;
49
import org.eclipse.pde.internal.ui.util.SWTUtil;
33
import org.eclipse.pde.internal.ui.util.SourcePluginFilter;
50
import org.eclipse.pde.internal.ui.util.SourcePluginFilter;
34
import org.eclipse.pde.internal.ui.wizards.ListUtil;
51
import org.eclipse.pde.internal.ui.wizards.ListUtil;
35
import org.eclipse.swt.SWT;
52
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.custom.ScrolledComposite;
53
import org.eclipse.swt.custom.ScrolledComposite;
37
import org.eclipse.swt.events.*;
54
import org.eclipse.swt.events.ModifyEvent;
55
import org.eclipse.swt.events.ModifyListener;
56
import org.eclipse.swt.events.SelectionAdapter;
57
import org.eclipse.swt.events.SelectionEvent;
38
import org.eclipse.swt.layout.GridData;
58
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridLayout;
59
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.widgets.*;
60
import org.eclipse.swt.widgets.Button;
61
import org.eclipse.swt.widgets.Composite;
62
import org.eclipse.swt.widgets.Group;
63
import org.eclipse.swt.widgets.Label;
64
import org.eclipse.swt.widgets.Table;
65
import org.eclipse.swt.widgets.TableItem;
66
import org.eclipse.swt.widgets.Text;
41
import org.eclipse.ui.PlatformUI;
67
import org.eclipse.ui.PlatformUI;
42
import org.eclipse.ui.progress.WorkbenchJob;
68
import org.eclipse.ui.progress.WorkbenchJob;
43
import org.osgi.framework.Version;
69
import org.osgi.framework.Version;
Lines 57-62 Link Here
57
	private VersionFilter fVersionFilter;
83
	private VersionFilter fVersionFilter;
58
	private AvailableFilter fAvailableFilter;
84
	private AvailableFilter fAvailableFilter;
59
	private SourcePluginFilter fSourceFilter;
85
	private SourcePluginFilter fSourceFilter;
86
	private ViewerFilter fRepositoryFilter;
60
	// fSelected is used to track the selection in a hash set so we can efficiently
87
	// fSelected is used to track the selection in a hash set so we can efficiently
61
	// filter selected items out of the available item list
88
	// filter selected items out of the available item list
62
	private Set fSelected;
89
	private Set fSelected;
Lines 71-76 Link Here
71
98
72
	private static final String SETTINGS_SHOW_LATEST = "showLatestPluginsOnly"; //$NON-NLS-1$
99
	private static final String SETTINGS_SHOW_LATEST = "showLatestPluginsOnly"; //$NON-NLS-1$
73
100
101
	private class RepositoryFilter extends ViewerFilter {
102
		/* (non-Javadoc)
103
		 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
104
		 */
105
		public boolean select(Viewer viewer, Object parentElement, Object element) {
106
			if (fPage1.getImportType() == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
107
				return fPage1.repositoryModels.contains(element);
108
			}
109
			return true;
110
		}
111
	}
112
74
	private class AvailableFilter extends ViewerFilter {
113
	private class AvailableFilter extends ViewerFilter {
75
		private Pattern fPattern;
114
		private Pattern fPattern;
76
115
Lines 201-206 Link Here
201
			fAvailableListViewer.addFilter(fVersionFilter);
240
			fAvailableListViewer.addFilter(fVersionFilter);
202
		}
241
		}
203
		fAvailableListViewer.addFilter(fSourceFilter);
242
		fAvailableListViewer.addFilter(fSourceFilter);
243
		fRepositoryFilter = new RepositoryFilter();
244
		fAvailableListViewer.addFilter(fRepositoryFilter);
204
245
205
		fFilterJob = new WorkbenchJob("FilterJob") { //$NON-NLS-1$
246
		fFilterJob = new WorkbenchJob("FilterJob") { //$NON-NLS-1$
206
			public IStatus runInUIThread(IProgressMonitor monitor) {
247
			public IStatus runInUIThread(IProgressMonitor monitor) {
Lines 403-412 Link Here
403
444
404
	public void setVisible(boolean visible) {
445
	public void setVisible(boolean visible) {
405
		super.setVisible(visible);
446
		super.setVisible(visible);
406
		if (visible)
447
		if (visible) {
407
			fFilterText.setFocus();
448
			fFilterText.setFocus();
408
		setPageComplete(visible && fImportListViewer.getTable().getItemCount() > 0);
449
			setPageComplete(fImportListViewer.getTable().getItemCount() > 0);
409
450
		}
410
	}
451
	}
411
452
412
	protected void refreshPage() {
453
	protected void refreshPage() {
(-)src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizardFirstPage.java (-18 / +269 lines)
Lines 14-39 Link Here
14
import java.lang.reflect.InvocationTargetException;
14
import java.lang.reflect.InvocationTargetException;
15
import java.net.MalformedURLException;
15
import java.net.MalformedURLException;
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.*;
17
import java.util.ArrayList;
18
import java.util.Collections;
19
import java.util.Comparator;
20
import java.util.HashMap;
21
import java.util.HashSet;
22
import java.util.Iterator;
18
import java.util.List;
23
import java.util.List;
19
import org.eclipse.core.runtime.*;
24
import java.util.Map;
25
import java.util.Map.Entry;
26
import java.util.Set;
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.IConfigurationElement;
29
import org.eclipse.core.runtime.IExtensionPoint;
30
import org.eclipse.core.runtime.IPath;
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.core.runtime.Path;
33
import org.eclipse.core.runtime.Platform;
34
import org.eclipse.core.runtime.SubProgressMonitor;
20
import org.eclipse.jface.dialogs.Dialog;
35
import org.eclipse.jface.dialogs.Dialog;
21
import org.eclipse.jface.dialogs.IDialogSettings;
36
import org.eclipse.jface.dialogs.IDialogSettings;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
37
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.jface.preference.*;
38
import org.eclipse.jface.preference.IPreferenceNode;
39
import org.eclipse.jface.preference.PreferenceDialog;
40
import org.eclipse.jface.preference.PreferenceManager;
24
import org.eclipse.jface.window.Window;
41
import org.eclipse.jface.window.Window;
42
import org.eclipse.jface.wizard.IWizardPage;
43
import org.eclipse.jface.wizard.Wizard;
25
import org.eclipse.jface.wizard.WizardPage;
44
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.pde.core.plugin.*;
45
import org.eclipse.pde.core.importing.BundleImportDescription;
27
import org.eclipse.pde.internal.core.*;
46
import org.eclipse.pde.core.importing.IBundleImporter;
28
import org.eclipse.pde.internal.core.target.provisional.*;
47
import org.eclipse.pde.core.plugin.IPluginBase;
29
import org.eclipse.pde.internal.ui.*;
48
import org.eclipse.pde.core.plugin.IPluginModelBase;
49
import org.eclipse.pde.core.plugin.PluginRegistry;
50
import org.eclipse.pde.core.plugin.TargetPlatform;
51
import org.eclipse.pde.internal.core.ICoreConstants;
52
import org.eclipse.pde.internal.core.PDECore;
53
import org.eclipse.pde.internal.core.PDEPreferencesManager;
54
import org.eclipse.pde.internal.core.PDEState;
55
import org.eclipse.pde.internal.core.SourceLocationKey;
56
import org.eclipse.pde.internal.core.SourceLocationManager;
57
import org.eclipse.pde.internal.core.project.BundleProjectService;
58
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
59
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
60
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
61
import org.eclipse.pde.internal.core.target.provisional.ITargetHandle;
62
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
63
import org.eclipse.pde.internal.ui.IHelpContextIds;
64
import org.eclipse.pde.internal.ui.IPDEUIConstants;
65
import org.eclipse.pde.internal.ui.PDEPlugin;
66
import org.eclipse.pde.internal.ui.PDEUIMessages;
67
import org.eclipse.pde.internal.ui.SWTFactory;
30
import org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferenceNode;
68
import org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferenceNode;
69
import org.eclipse.pde.ui.IBundeImportWizardPage;
31
import org.eclipse.swt.SWT;
70
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.custom.BusyIndicator;
71
import org.eclipse.swt.custom.BusyIndicator;
33
import org.eclipse.swt.events.*;
72
import org.eclipse.swt.events.ModifyEvent;
73
import org.eclipse.swt.events.ModifyListener;
74
import org.eclipse.swt.events.SelectionAdapter;
75
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.layout.GridData;
76
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridLayout;
77
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.widgets.*;
78
import org.eclipse.swt.widgets.Button;
79
import org.eclipse.swt.widgets.Combo;
80
import org.eclipse.swt.widgets.Composite;
81
import org.eclipse.swt.widgets.DirectoryDialog;
82
import org.eclipse.swt.widgets.Group;
83
import org.eclipse.swt.widgets.Shell;
37
import org.eclipse.ui.PlatformUI;
84
import org.eclipse.ui.PlatformUI;
38
import org.osgi.framework.Version;
85
import org.osgi.framework.Version;
39
86
Lines 65-70 Link Here
65
	private Button binaryButton;
112
	private Button binaryButton;
66
	private Button binaryWithLinksButton;
113
	private Button binaryWithLinksButton;
67
	private Button sourceButton;
114
	private Button sourceButton;
115
	private Button repositoryButton;
68
116
69
	public static String TARGET_PLATFORM = "targetPlatform"; //$NON-NLS-1$
117
	public static String TARGET_PLATFORM = "targetPlatform"; //$NON-NLS-1$
70
	private IPluginModelBase[] models = new IPluginModelBase[0];
118
	private IPluginModelBase[] models = new IPluginModelBase[0];
Lines 75-80 Link Here
75
	private PDEState state;
123
	private PDEState state;
76
	private boolean canceled = false;
124
	private boolean canceled = false;
77
125
126
	/**
127
	 * Models that can be imported from a repository
128
	 */
129
	protected Set repositoryModels = new HashSet();
130
131
	/**
132
	 * Maps bundle importers to import instructions
133
	 */
134
	private Map importerToInstructions = new HashMap();
135
136
	/**
137
	 * Map of bundle importer extension id to associated wizard page
138
	 */
139
	private Map importIdToWizardPage = new HashMap();
140
141
	/**
142
	 * Array of next wizard pages (in order)
143
	 */
144
	private List nextPages = new ArrayList();
145
78
	public PluginImportWizardFirstPage(String name) {
146
	public PluginImportWizardFirstPage(String name) {
79
		super(name);
147
		super(name);
80
		setTitle(PDEUIMessages.ImportWizard_FirstPage_title);
148
		setTitle(PDEUIMessages.ImportWizard_FirstPage_title);
Lines 120-125 Link Here
120
		binaryButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_binary);
188
		binaryButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_binary);
121
		binaryWithLinksButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_binaryLinks);
189
		binaryWithLinksButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_binaryLinks);
122
		sourceButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_source);
190
		sourceButton = SWTFactory.createRadioButton(options, PDEUIMessages.ImportWizard_FirstPage_source);
191
		repositoryButton = SWTFactory.createRadioButton(options, PDEUIMessages.PluginImportWizardFirstPage_3);
123
	}
192
	}
124
193
125
	/**
194
	/**
Lines 156-163 Link Here
156
			binaryButton.setSelection(true);
225
			binaryButton.setSelection(true);
157
		} else if (importType == PluginImportOperation.IMPORT_BINARY_WITH_LINKS) {
226
		} else if (importType == PluginImportOperation.IMPORT_BINARY_WITH_LINKS) {
158
			binaryWithLinksButton.setSelection(true);
227
			binaryWithLinksButton.setSelection(true);
159
		} else {
228
		} else if (importType == PluginImportOperation.IMPORT_WITH_SOURCE) {
160
			sourceButton.setSelection(true);
229
			sourceButton.setSelection(true);
230
		} else {
231
			repositoryButton.setSelection(true);
161
		}
232
		}
162
233
163
		boolean scan = true;
234
		boolean scan = true;
Lines 384-390 Link Here
384
		if (binaryWithLinksButton.getSelection()) {
455
		if (binaryWithLinksButton.getSelection()) {
385
			return PluginImportOperation.IMPORT_BINARY_WITH_LINKS;
456
			return PluginImportOperation.IMPORT_BINARY_WITH_LINKS;
386
		}
457
		}
387
458
		if (repositoryButton.getSelection()) {
459
			return PluginImportOperation.IMPORT_FROM_REPOSITORY;
460
		}
388
		return PluginImportOperation.IMPORT_WITH_SOURCE;
461
		return PluginImportOperation.IMPORT_WITH_SOURCE;
389
	}
462
	}
390
463
Lines 481-493 Link Here
481
554
482
	/**
555
	/**
483
	 * Resolves the target platform
556
	 * Resolves the target platform
557
	 * @param type import type
484
	 */
558
	 */
485
	private void resolveTargetPlatform() {
559
	private void resolveTargetPlatform(final int type) {
486
		IRunnableWithProgress op = new IRunnableWithProgress() {
560
		IRunnableWithProgress op = new IRunnableWithProgress() {
487
			public void run(IProgressMonitor monitor) {
561
			public void run(IProgressMonitor monitor) throws InvocationTargetException {
488
				models = PluginRegistry.getExternalModels();
562
				models = PluginRegistry.getExternalModels();
489
				state = PDECore.getDefault().getModelManager().getState();
563
				state = PDECore.getDefault().getModelManager().getState();
490
				alternateSource = null;
564
				alternateSource = null;
565
				try {
566
					buildImportDescriptions(monitor, type);
567
				} catch (CoreException e) {
568
					throw new InvocationTargetException(e);
569
				}
491
				monitor.done();
570
				monitor.done();
492
			}
571
			}
493
		};
572
		};
Lines 516-522 Link Here
516
			}
595
			}
517
			ITargetDefinition target = service.newTarget(); // temporary target
596
			ITargetDefinition target = service.newTarget(); // temporary target
518
			target.setBundleContainers(new IBundleContainer[] {container});
597
			target.setBundleContainers(new IBundleContainer[] {container});
519
			resolveTargetDefinition(target);
598
			resolveTargetDefinition(target, getImportType());
520
		}
599
		}
521
	}
600
	}
522
601
Lines 524-533 Link Here
524
	 * Resolves the plug-in locations for a target definition.
603
	 * Resolves the plug-in locations for a target definition.
525
	 * 
604
	 * 
526
	 * @param target target definition
605
	 * @param target target definition
606
	 * @param type import operation type
527
	 */
607
	 */
528
	private void resolveTargetDefinition(final ITargetDefinition target) {
608
	private void resolveTargetDefinition(final ITargetDefinition target, final int type) {
529
		IRunnableWithProgress op = new IRunnableWithProgress() {
609
		IRunnableWithProgress op = new IRunnableWithProgress() {
530
			public void run(IProgressMonitor monitor) {
610
			public void run(IProgressMonitor monitor) throws InvocationTargetException {
531
				monitor.beginTask(PDEUIMessages.PluginImportWizardFirstPage_1, 100);
611
				monitor.beginTask(PDEUIMessages.PluginImportWizardFirstPage_1, 100);
532
				SubProgressMonitor pm = new SubProgressMonitor(monitor, 50);
612
				SubProgressMonitor pm = new SubProgressMonitor(monitor, 50);
533
				target.resolve(pm);
613
				target.resolve(pm);
Lines 567-572 Link Here
567
					}
647
					}
568
				}
648
				}
569
				alternateSource = new AlternateSourceLocations((IPluginModelBase[]) sourceModels.toArray(new IPluginModelBase[sourceModels.size()]), (IResolvedBundle[]) sourceBundles.toArray(new IResolvedBundle[sourceBundles.size()]));
649
				alternateSource = new AlternateSourceLocations((IPluginModelBase[]) sourceModels.toArray(new IPluginModelBase[sourceModels.size()]), (IResolvedBundle[]) sourceBundles.toArray(new IResolvedBundle[sourceBundles.size()]));
650
				try {
651
					buildImportDescriptions(pm, type);
652
				} catch (CoreException e) {
653
					throw new InvocationTargetException(e);
654
				}
570
				pm.done();
655
				pm.done();
571
				canceled = monitor.isCanceled();
656
				canceled = monitor.isCanceled();
572
				monitor.done();
657
				monitor.done();
Lines 580-595 Link Here
580
		}
665
		}
581
	}
666
	}
582
667
668
	private void buildImportDescriptions(IProgressMonitor monitor, int type) throws CoreException {
669
		// build import instructions
670
		BundleProjectService service = (BundleProjectService) BundleProjectService.getDefault();
671
		repositoryModels.clear();
672
		importerToInstructions.clear();
673
		nextPages.clear();
674
		if (type == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
675
			if (models != null) {
676
				importerToInstructions = service.getImportDescriptions(models);
677
				Iterator iterator = importerToInstructions.entrySet().iterator();
678
				while (iterator.hasNext()) {
679
					if (!monitor.isCanceled()) {
680
						Entry entry = (Entry) iterator.next();
681
						BundleImportDescription[] descriptions = (BundleImportDescription[]) entry.getValue();
682
						for (int i = 0; i < descriptions.length; i++) {
683
							repositoryModels.add(descriptions[i].getProperty(BundleProjectService.PLUGIN));
684
						}
685
					}
686
				}
687
			}
688
			if (!monitor.isCanceled()) {
689
				// contributed wizard pages
690
				Iterator iterator = importerToInstructions.entrySet().iterator();
691
				while (iterator.hasNext()) {
692
					Entry entry = (Entry) iterator.next();
693
					IBundleImporter importer = (IBundleImporter) entry.getKey();
694
					IBundeImportWizardPage page = (IBundeImportWizardPage) importIdToWizardPage.get(importer.getId());
695
					if (page == null) {
696
						page = getPage(importer.getId());
697
						if (page != null) {
698
							importIdToWizardPage.put(importer.getId(), page);
699
							((Wizard) getWizard()).addPage(page);
700
						}
701
					}
702
					if (page != null) {
703
						nextPages.add(page);
704
						page.setSelection((BundleImportDescription[]) entry.getValue());
705
					}
706
				}
707
			}
708
		}
709
		if (monitor.isCanceled()) {
710
			importerToInstructions.clear();
711
			repositoryModels.clear();
712
			nextPages.clear();
713
		}
714
	}
715
716
	/**
717
	 * Returns whether the contributed pages are complete.
718
	 * 
719
	 * @return whether the contributed pages are complete
720
	 */
721
	boolean arePagesComplete() {
722
		Iterator iterator = nextPages.iterator();
723
		while (iterator.hasNext()) {
724
			IBundeImportWizardPage page = (IBundeImportWizardPage) iterator.next();
725
			if (!page.isPageComplete()) {
726
				return false;
727
			}
728
		}
729
		return true;
730
	}
731
732
	/**
733
	 * Finishes contributed pages.
734
	 * 
735
	 * @return whether finish was successful
736
	 */
737
	boolean finishPages() {
738
		Iterator iterator = nextPages.iterator();
739
		while (iterator.hasNext()) {
740
			IBundeImportWizardPage page = (IBundeImportWizardPage) iterator.next();
741
			if (!page.finish()) {
742
				return false;
743
			}
744
		}
745
		return true;
746
	}
747
748
	/**
749
	 * Returns a map of importers to their bundle import descriptions to process.
750
	 * 
751
	 * @return map of bundle import descriptions to process, by importers
752
	 */
753
	Map getImportDescriptions() {
754
		Map map = new HashMap();
755
		if (getImportType() == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
756
			IBundleImporter[] importers = ((BundleProjectService) BundleProjectService.getDefault()).getBundleImporters();
757
			for (int i = 0; i < importers.length; i++) {
758
				IBundleImporter importer = importers[i];
759
				if (importerToInstructions.containsKey(importer)) {
760
					IBundeImportWizardPage page = (IBundeImportWizardPage) importIdToWizardPage.get(importer.getId());
761
					if (page != null && nextPages.contains(page)) {
762
						map.put(importer, page.getSelection());
763
					}
764
				}
765
			}
766
		}
767
		return map;
768
	}
769
770
	/**
771
	 * Returns the next page to display or <code>null</code> if none.
772
	 * 
773
	 * @param page current page
774
	 * @return next page or <code>null</code>
775
	 */
776
	IWizardPage getNextPage(IWizardPage page) {
777
		if (nextPages.isEmpty()) {
778
			return null;
779
		}
780
		if (page instanceof IBundeImportWizardPage) {
781
			int index = nextPages.indexOf(page);
782
			if (index >= 0 && index < (nextPages.size() - 2)) {
783
				return (IWizardPage) nextPages.get(index + 1);
784
			}
785
		}
786
		if (page instanceof PluginImportWizardDetailedPage) {
787
			return (IWizardPage) nextPages.get(0);
788
		}
789
		return null;
790
	}
791
792
	/**
793
	 * Returns the previous page to display or <code>null</code> if none.
794
	 * 
795
	 * @param page current page
796
	 * @return previous page or <code>null</code>
797
	 */
798
	IWizardPage getPreviousPage(IWizardPage page) {
799
		if (page instanceof IBundeImportWizardPage) {
800
			int index = nextPages.indexOf(page);
801
			if (index > 0) {
802
				return (IWizardPage) nextPages.get(index - 1);
803
			}
804
		}
805
		return null;
806
	}
807
808
	/**
809
	 * Creates and returns a wizard page associated with the given bundle importer extension identifier
810
	 * or <code>null</code> of none.
811
	 * 
812
	 * @param importerId org.eclipse.pde.core.bundleImporters extension identifier
813
	 * @return associated bundle import wizard page or <code>null</code>
814
	 */
815
	private IBundeImportWizardPage getPage(String importerId) {
816
		IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(IPDEUIConstants.EXTENSION_POINT_BUNDLE_IMPORT_PAGES);
817
		if (point != null) {
818
			IConfigurationElement[] infos = point.getConfigurationElements();
819
			for (int i = 0; i < infos.length; i++) {
820
				IConfigurationElement element = infos[i];
821
				String id = element.getAttribute("bundleImporter"); //$NON-NLS-1$
822
				if (id != null && importerId.equals(id)) {
823
					try {
824
						return (IBundeImportWizardPage) element.createExecutableExtension("class"); //$NON-NLS-1$
825
					} catch (CoreException e) {
826
						PDEPlugin.log(e);
827
					}
828
				}
829
			}
830
		}
831
		return null;
832
	}
833
583
	/**
834
	/**
584
	 * @return the complete set of {@link IPluginModelBase}s for the given drop location
835
	 * @return the complete set of {@link IPluginModelBase}s for the given drop location
585
	 */
836
	 */
586
	public IPluginModelBase[] getModels() {
837
	public IPluginModelBase[] getModels() {
587
		switch (getImportOrigin()) {
838
		switch (getImportOrigin()) {
588
			case FROM_ACTIVE_PLATFORM :
839
			case FROM_ACTIVE_PLATFORM :
589
				resolveTargetPlatform();
840
				resolveTargetPlatform(getImportType());
590
				break;
841
				break;
591
			case FROM_TARGET_DEFINITION :
842
			case FROM_TARGET_DEFINITION :
592
				resolveTargetDefinition(getTargetDefinition());
843
				resolveTargetDefinition(getTargetDefinition(), getImportType());
593
				break;
844
				break;
594
			case FROM_DIRECTORY :
845
			case FROM_DIRECTORY :
595
				resolveArbitraryLocation(getDropLocation());
846
				resolveArbitraryLocation(getDropLocation());
(-)src/org/eclipse/pde/ui/IBundeImportWizardPage.java (+54 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.ui;
12
13
import org.eclipse.jface.wizard.IWizardPage;
14
import org.eclipse.pde.core.importing.BundleImportDescription;
15
16
/**
17
 * A wizard page contributed by a <code>org.eclipse.pde.ui.bundleImportPages</code>
18
 * extension.
19
 * 
20
 * @since 3.6
21
 *
22
 */
23
public interface IBundeImportWizardPage extends IWizardPage {
24
	/**
25
	 * Called when the import wizard is closed by selecting 
26
	 * the finish button.
27
	 * Implementers may store the page result (new/changed bundle
28
	 * import descriptions in getSelection) here.
29
	 * 
30
	 * @return if the operation was successful. The wizard will only close
31
	 * when <code>true</code> is returned.
32
	 */
33
	public boolean finish();
34
35
	/**
36
	 * Returns the bundle import descriptions edited or created on the page 
37
	 * after the wizard has closed.
38
	 * Returns bundle import descriptions initially set using 
39
	 * <code>setSelection</code>if the wizard has not been 
40
	 * closed yet.
41
	 * 
42
	 * @return the bundle import descriptions edited or created on the page.
43
	 */
44
	public BundleImportDescription[] getSelection();
45
46
	/**
47
	 * Sets the bundle import descriptions to be edited on the page.
48
	 * The passed descriptions can be edited and should be 
49
	 * returned in getSelection().
50
	 * 
51
	 * @param descriptions the bundle import descriptions edited on the page.
52
	 */
53
	public void setSelection(BundleImportDescription[] descriptions);
54
}
(-)src/org/eclipse/pde/ui/tests/AllPDETests.java (+3 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.tests;
11
package org.eclipse.pde.ui.tests;
12
12
13
import org.eclipse.pde.ui.tests.project.BundleImporterTests;
14
13
import junit.framework.Test;
15
import junit.framework.Test;
14
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
15
import org.eclipse.pde.ui.tests.ee.ExportBundleTests;
17
import org.eclipse.pde.ui.tests.ee.ExportBundleTests;
Lines 47-52 Link Here
47
		suite.addTest(AllLogViewTests.suite());
49
		suite.addTest(AllLogViewTests.suite());
48
		suite.addTest(ProjectCreationTests.suite());
50
		suite.addTest(ProjectCreationTests.suite());
49
		suite.addTest(BundleRootTests.suite());
51
		suite.addTest(BundleRootTests.suite());
52
		suite.addTest(BundleImporterTests.suite());
50
		return suite;
53
		return suite;
51
	}
54
	}
52
55
(-)src/org/eclipse/pde/ui/tests/project/BundleImporterTests.java (+130 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.tests.project;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import junit.framework.*;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.pde.core.importing.BundleImportDescription;
18
import org.eclipse.pde.core.importing.IBundleImporter;
19
import org.eclipse.pde.internal.core.ICoreConstants;
20
import org.eclipse.pde.internal.core.importing.CvsBundleImportDescription;
21
import org.eclipse.pde.internal.core.project.BundleProjectService;
22
23
/**
24
 * Tests for bundle importer extensions.
25
 * 
26
 * @since 3.6
27
 */
28
public class BundleImporterTests extends TestCase {
29
	
30
	public static Test suite() {
31
		return new TestSuite(BundleImporterTests.class);
32
	}
33
	
34
	/**
35
	 * Returns the CVS importer or <code>null</code>
36
	 * 
37
	 * @return CVS importer or <code>null</code>
38
	 */
39
	protected IBundleImporter getCVSImporter() {
40
		IBundleImporter[] importers = ((BundleProjectService)BundleProjectService.getDefault()).getBundleImporters();
41
		for (int i = 0; i < importers.length; i++) {
42
			if (importers[i].getId().equals("org.eclipse.pde.core.cvs.importer")) {
43
				return importers[i];
44
			}
45
		}
46
		return null;
47
	}
48
	
49
	/**
50
	 * Tests that a project can be created from a reference with no tag or project attributes.
51
	 * 
52
	 * @throws CoreException
53
	 */
54
	public void testProjectSCMURL() throws CoreException {
55
		IBundleImporter handler = getCVSImporter();
56
		assertNotNull("Missing CVS source reference handler", handler);
57
		
58
		String header = "scm:cvs:pserver:dev.eclipse.org:/cvsroot/rt:org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher";
59
		Map manifest = new HashMap();
60
		manifest.put(ICoreConstants.ECLIPSE_SOURCE_REFERENCES, header);
61
		BundleImportDescription[] descriptions = handler.validateImport(new Map[]{manifest});
62
		
63
		assertEquals("Wrong number of descriptions", 1, descriptions.length);
64
		BundleImportDescription bid = descriptions[0];
65
		assertTrue("Wrong kind of description", bid instanceof CvsBundleImportDescription);
66
		CvsBundleImportDescription cvsDes = (CvsBundleImportDescription) bid;
67
		assertEquals("org.eclipse.equinox.p2.publisher", cvsDes.getProject());
68
		assertNull("Wrong tag", cvsDes.getTag());
69
		assertEquals("pserver", cvsDes.getProtocol());
70
		assertEquals("dev.eclipse.org", cvsDes.getServer());
71
		assertEquals("/cvsroot/rt", cvsDes.getPath());
72
		assertEquals("org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher", cvsDes.getModule());
73
		
74
	}
75
	
76
	/**
77
	 * Tests that a project can be created from a reference with a tag attribute.
78
	 * 
79
	 * @throws CoreException
80
	 */
81
	public void testProjectSCMURLwithTagAndProject() throws CoreException {
82
		IBundleImporter handler = getCVSImporter();
83
		assertNotNull("Missing CVS source reference handler", handler);
84
		
85
		String header = "scm:cvs:pserver:dev.eclipse.org:/cvsroot/rt:org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher;tag=v20100215;project=one.two.three";
86
		Map manifest = new HashMap();
87
		manifest.put(ICoreConstants.ECLIPSE_SOURCE_REFERENCES, header);
88
		BundleImportDescription[] descriptions = handler.validateImport(new Map[]{manifest});
89
		
90
		assertEquals("Wrong number of descriptions", 1, descriptions.length);
91
		BundleImportDescription bid = descriptions[0];
92
		assertTrue("Wrong kind of description", bid instanceof CvsBundleImportDescription);
93
		CvsBundleImportDescription cvsDes = (CvsBundleImportDescription) bid;
94
		assertEquals("one.two.three", cvsDes.getProject());
95
		assertEquals("v20100215", cvsDes.getTag());
96
		assertEquals("pserver", cvsDes.getProtocol());
97
		assertEquals("dev.eclipse.org", cvsDes.getServer());
98
		assertEquals("/cvsroot/rt", cvsDes.getPath());
99
		assertEquals("org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher", cvsDes.getModule());
100
		
101
	}	
102
	
103
	/**
104
	 * Tests that a project can be created from a reference with a project attribute.
105
	 * 
106
	 * @throws CoreException
107
	 */
108
	public void testProjectSCMURLwithProject() throws CoreException {
109
		IBundleImporter handler = getCVSImporter();
110
		assertNotNull("Missing CVS source reference handler", handler);
111
		
112
		String header = "scm:cvs:pserver:dev.eclipse.org:/cvsroot/rt:org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher;project=a.b.c";
113
		Map manifest = new HashMap();
114
		manifest.put(ICoreConstants.ECLIPSE_SOURCE_REFERENCES, header);
115
		BundleImportDescription[] descriptions = handler.validateImport(new Map[]{manifest});
116
		
117
		assertEquals("Wrong number of descriptions", 1, descriptions.length);
118
		BundleImportDescription bid = descriptions[0];
119
		assertTrue("Wrong kind of description", bid instanceof CvsBundleImportDescription);
120
		CvsBundleImportDescription cvsDes = (CvsBundleImportDescription) bid;
121
		assertEquals("a.b.c", cvsDes.getProject());
122
		assertNull(cvsDes.getTag());
123
		assertEquals("pserver", cvsDes.getProtocol());
124
		assertEquals("dev.eclipse.org", cvsDes.getServer());
125
		assertEquals("/cvsroot/rt", cvsDes.getPath());
126
		assertEquals("org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher", cvsDes.getModule());
127
		
128
	}	
129
130
}

Return to bug 195729