Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 214195 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/sandbox/tests/AllSandboxTests.java (+1 lines)
Lines 32-37 Link Here
32
		suite.addTestSuite(ActiveHierarchyTest.class);
32
		suite.addTestSuite(ActiveHierarchyTest.class);
33
		suite.addTestSuite(ActiveSearchTest.class);
33
		suite.addTestSuite(ActiveSearchTest.class);
34
		suite.addTestSuite(StatisticsReportingTest.class);
34
		suite.addTestSuite(StatisticsReportingTest.class);
35
		suite.addTestSuite(EclipseTaskRepositoryLinkProviderTest.class);
35
36
36
		// web connector tests
37
		// web connector tests
37
		suite.addTestSuite(NamedPatternTest.class);
38
		suite.addTestSuite(NamedPatternTest.class);
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 34-41 Link Here
34
 org.eclipse.mylyn.web.tasks,
34
 org.eclipse.mylyn.web.tasks,
35
 org.apache.commons.httpclient,
35
 org.apache.commons.httpclient,
36
 org.eclipse.mylyn.commons.net,
36
 org.eclipse.mylyn.commons.net,
37
 org.eclipse.mylyn.tasks.tests;bundle-version="0.0.0"
37
 org.eclipse.mylyn.tasks.tests,
38
 org.eclipse.pde.core
38
Bundle-ActivationPolicy: lazy
39
Bundle-ActivationPolicy: lazy
39
Bundle-RequiredExecutionEnvironment: J2SE-1.5
40
Bundle-RequiredExecutionEnvironment: J2SE-1.5
40
Export-Package: org.eclipse.mylyn.sandbox.tests;x-internal:=true,
41
Export-Package: org.eclipse.mylyn.sandbox.tests;x-internal:=true,
42
 org.eclipse.mylyn.sandbox.tests.util;x-internal:=true,
41
 org.eclipse.mylyn.tasks.tests.web;x-internal:=true
43
 org.eclipse.mylyn.tasks.tests.web;x-internal:=true
(-)src/org/eclipse/mylyn/sandbox/tests/EclipseTaskRepositoryLinkProviderTest.java (+124 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Eugene Kuleshov 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
 *     Eugene Kuleshov - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.sandbox.tests;
13
14
import junit.framework.TestCase;
15
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
18
import org.eclipse.mylyn.sandbox.tests.util.PdeProject;
19
import org.eclipse.mylyn.tasks.core.TaskRepository;
20
21
/**
22
 * @author Eugene Kuleshov
23
 */
24
public class EclipseTaskRepositoryLinkProviderTest extends TestCase {
25
26
	public void testEclipsePluginProject() throws Exception {
27
		TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs");
28
		assertNotNull("Eclipse.org repository is not found", repo1);
29
30
		String mf = "Manifest-Version: 1.0\n" + //
31
				"Bundle-ManifestVersion: 2\n" + //
32
				"Bundle-Name: Mylyn PDE Tests 1\n" + // 
33
				"Bundle-SymbolicName: org.eclipse.mylyn.pde.tests1\n" + // 
34
				"Bundle-Version: 1.0.0\n" + //
35
				"Bundle-Vendor: Eclipse.org\n" + // 
36
				"Bundle-RequiredExecutionEnvironment: J2SE-1.3\n";
37
38
		PdeProject pdeProject = new PdeProject("eclipsePluginProject");
39
		pdeProject.createPlugin(mf);
40
41
		IProject project = pdeProject.getProject();
42
43
		TasksUiPlugin tasksUiPlugin = TasksUiPlugin.getDefault();
44
45
		TaskRepository repo2 = tasksUiPlugin.getRepositoryForResource(project);
46
		assertEquals(repo1, repo2);
47
48
		assertFalse(tasksUiPlugin.canSetRepositoryForResource(project));
49
50
		pdeProject.delete();
51
	}
52
53
	public void testAcmePluginProject() throws Exception {
54
		TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs");
55
		assertNotNull("Eclipse.org repository is not found", repo1);
56
57
		String mf = "Manifest-Version: 1.0\n" + //
58
				"Bundle-ManifestVersion: 2\n" + //
59
				"Bundle-Name: Mylyn PDE Tests 2\n" + //
60
				"Bundle-SymbolicName: org.eclpse.mylyn.pde.tests2\n" + // 
61
				"Bundle-Version: 1.0.0\n" + //
62
				"Bundle-Vendor: Acme.org\n" + //
63
				"Bundle-RequiredExecutionEnvironment: J2SE-1.3\n";
64
65
		PdeProject pdeProject = new PdeProject("acmePluginProject");
66
		pdeProject.createPlugin(mf);
67
68
		TaskRepository repo2 = TasksUiPlugin.getDefault().getRepositoryForResource(pdeProject.getProject());
69
70
		pdeProject.delete();
71
72
		assertNull("Not expected to find repository " + repo2, repo2);
73
	}
74
75
	public void testEclipseFeatureProject() throws Exception {
76
		TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs");
77
		assertNotNull("Eclipse.org repository is not found", repo1);
78
79
		String feature = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + // 
80
				"<feature\n" + //
81
				"      id=\"org.eclipse.mylyn.pde.tests2_feature\"\n" + // 
82
				"      label=\"Mylyn PDE Test Feature 2\"\n" + //
83
				"      version=\"2.3.0.qualifier\"\n" + //
84
				"      provider-name=\"Eclipse.org\">" + //
85
				"</feature>";
86
87
		PdeProject pdeProject = new PdeProject("eclipseFeatureProject");
88
		pdeProject.createFeature(feature);
89
90
		IProject project = pdeProject.getProject();
91
92
		TasksUiPlugin tasksUiPlugin = TasksUiPlugin.getDefault();
93
94
		TaskRepository repo2 = tasksUiPlugin.getRepositoryForResource(project);
95
		assertEquals(repo1, repo2);
96
97
		assertFalse(tasksUiPlugin.canSetRepositoryForResource(project));
98
99
		pdeProject.delete();
100
	}
101
102
	public void testAcmeFeatureProject() throws Exception {
103
		TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs");
104
		assertNotNull("Eclipse.org repository is not found", repo1);
105
106
		String feature = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + // 
107
				"<feature\n" + //
108
				"      id=\"org.eclipse.mylyn.pde.tests2_feature\"\n" + // 
109
				"      label=\"Mylyn PDE Test Feature 2\"\n" + //
110
				"      version=\"2.3.0.qualifier\"\n" + //
111
				"      provider-name=\"Acme.org\">" + //
112
				"</feature>";
113
114
		PdeProject pdeProject = new PdeProject("acmeFeatureProject");
115
		pdeProject.createFeature(feature);
116
117
		TaskRepository repo2 = TasksUiPlugin.getDefault().getRepositoryForResource(pdeProject.getProject());
118
119
		pdeProject.delete();
120
121
		assertNull("Not expected to find repository " + repo2, repo2);
122
	}
123
124
}
(-)src/org/eclipse/mylyn/sandbox/tests/util/PdeProject.java (+114 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Eugene Kuleshov 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
 *     Eugene Kuleshov - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.sandbox.tests.util;
13
14
import java.io.ByteArrayInputStream;
15
16
import org.eclipse.core.internal.events.BuildCommand;
17
import org.eclipse.core.resources.ICommand;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFolder;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IProjectDescription;
22
import org.eclipse.core.resources.IWorkspaceRoot;
23
import org.eclipse.core.resources.IncrementalProjectBuilder;
24
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.jdt.core.JavaCore;
27
import org.eclipse.pde.internal.core.natures.PDE;
28
29
/**
30
 * @author Eugene Kuleshov
31
 */
32
public class PdeProject {
33
34
	private final IProject project;
35
36
	public PdeProject(String name) throws CoreException {
37
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
38
		project = root.getProject(name);
39
		project.create(null);
40
		project.open(null);
41
	}
42
43
	public IProject getProject() {
44
		return project;
45
	}
46
47
	public void createPlugin(String mf) throws CoreException {
48
		setPluginNature();
49
50
		IProject project = getProject();
51
52
		IFolder folder = project.getFolder("META-INF");
53
		if (!folder.exists()) {
54
			folder.create(true, false, null);
55
		}
56
57
		IFile file = folder.getFile("MANIFEST.MF");
58
		if (!file.exists()) {
59
			file.create(new ByteArrayInputStream(mf.getBytes()), true, null);
60
		}
61
62
		project.build(IncrementalProjectBuilder.FULL_BUILD, null);
63
	}
64
65
	public void createFeature(String feature) throws CoreException {
66
		setFeatureNature();
67
68
		IProject project = getProject();
69
70
		IFile file = project.getFile("feature.xml");
71
		if (!file.exists()) {
72
			file.create(new ByteArrayInputStream(feature.getBytes()), true, null);
73
		}
74
75
		project.build(IncrementalProjectBuilder.FULL_BUILD, null);
76
	}
77
78
	public void setPluginNature() throws CoreException {
79
		IProjectDescription description = project.getDescription();
80
81
		description.setNatureIds(new String[] { PDE.PLUGIN_NATURE, JavaCore.NATURE_ID });
82
83
		BuildCommand javaBuildCommand = new BuildCommand();
84
		javaBuildCommand.setBuilderName(JavaCore.BUILDER_ID);
85
86
		BuildCommand manifestBuildCommand = new BuildCommand();
87
		manifestBuildCommand.setName(PDE.MANIFEST_BUILDER_ID);
88
89
		BuildCommand schemaBuildCommand = new BuildCommand();
90
		schemaBuildCommand.setName(PDE.SCHEMA_BUILDER_ID);
91
92
		description.setBuildSpec(new ICommand[] { javaBuildCommand, manifestBuildCommand, schemaBuildCommand });
93
94
		project.setDescription(description, null);
95
	}
96
97
	public void setFeatureNature() throws CoreException {
98
		IProjectDescription description = project.getDescription();
99
100
		description.setNatureIds(new String[] { PDE.FEATURE_NATURE });
101
102
		BuildCommand featureBuildCommand = new BuildCommand();
103
		featureBuildCommand.setName(PDE.FEATURE_BUILDER_ID);
104
105
		description.setBuildSpec(new ICommand[] { featureBuildCommand });
106
107
		project.setDescription(description, null);
108
	}
109
110
	public void delete() throws CoreException {
111
		getProject().delete(true, true, null);
112
	}
113
114
}
(-)plugin.xml (+8 lines)
Lines 511-515 Link Here
511
	 </objectContribution>
511
	 </objectContribution>
512
  </extension>
512
  </extension>
513
  -->
513
  -->
514
515
   <extension point="org.eclipse.mylyn.tasks.ui.projectLinkProviders">
516
      <linkProvider
517
          id="org.eclipse.mylyn.sandbox.ui.eclipsePluginRepositoryLinkProvider"
518
          class="org.eclipse.mylyn.internal.sandbox.ui.EclipseTaskRepositoryLinkProvider"
519
          name="Eclipse.org Plugin Link"
520
          order="2000"/>
521
   </extension>  
514
   
522
   
515
</plugin>
523
</plugin>
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 31-37 Link Here
31
 org.eclipse.mylyn.resources.ui;bundle-version="[3.0.0,4.0.0)",
31
 org.eclipse.mylyn.resources.ui;bundle-version="[3.0.0,4.0.0)",
32
 org.eclipse.mylyn.ide.ant;bundle-version="[3.0.0,4.0.0)",
32
 org.eclipse.mylyn.ide.ant;bundle-version="[3.0.0,4.0.0)",
33
 org.eclipse.mylyn.pde.ui;bundle-version="[3.0.0,4.0.0)",
33
 org.eclipse.mylyn.pde.ui;bundle-version="[3.0.0,4.0.0)",
34
 org.eclipse.core.expressions
34
 org.eclipse.core.expressions,
35
 org.eclipse.pde.core
35
Bundle-ActivationPolicy: lazy
36
Bundle-ActivationPolicy: lazy
36
Bundle-Vendor: Eclipse.org
37
Bundle-Vendor: Eclipse.org
37
Export-Package: org.eclipse.mylyn.internal.sandbox.ui;x-internal:=true,
38
Export-Package: org.eclipse.mylyn.internal.sandbox.ui;x-internal:=true,
(-)src/org/eclipse/mylyn/internal/sandbox/ui/EclipseTaskRepositoryLinkProvider.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Eugene Kuleshov 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
 *     Eugene Kuleshov - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.sandbox.ui;
13
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
17
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
18
import org.eclipse.mylyn.tasks.core.TaskRepository;
19
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
20
import org.eclipse.pde.core.IModel;
21
import org.eclipse.pde.core.plugin.IPluginModelBase;
22
import org.eclipse.pde.core.plugin.PluginRegistry;
23
import org.eclipse.pde.internal.core.PDECore;
24
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
25
import org.eclipse.pde.internal.core.natures.PDE;
26
27
/**
28
 * Task repository link provider for Eclipse.org PDE projects
29
 * 
30
 * @author Eugene Kuleshov
31
 */
32
// TODO could use extension point to declare mapping for 3rd party plugin providers
33
public class EclipseTaskRepositoryLinkProvider extends AbstractTaskRepositoryLinkProvider {
34
35
	@Override
36
	public TaskRepository getTaskRepository(IResource resource, IRepositoryManager repositoryManager) {
37
		IProject project = resource.getProject();
38
		if (PDE.hasPluginNature(project)) {
39
			IPluginModelBase pluginModel = PluginRegistry.findModel(project);
40
			if (pluginModel != null) {
41
				String providerName = pluginModel.getPluginBase().getProviderName();
42
				return getTaskRepository(providerName, pluginModel, repositoryManager);
43
			}
44
		} else if (PDE.hasFeatureNature(project)) {
45
			IFeatureModel featureModel = PDECore.getDefault().getFeatureModelManager().getFeatureModel(project);
46
			if (featureModel != null) {
47
				String providerName = featureModel.getFeature().getProviderName();
48
				return getTaskRepository(providerName, featureModel, repositoryManager);
49
			}
50
		} else if (PDE.hasUpdateSiteNature(project)) {
51
			// TODO could use referenced features to lookup task repository
52
		}
53
		return null;
54
	}
55
56
	private TaskRepository getTaskRepository(String providerName, IModel model, IRepositoryManager repositoryManager) {
57
		if (providerName.startsWith("%")) {
58
			providerName = model.getResourceString(providerName);
59
		}
60
		if ("Eclipse.org".equals(providerName)) {
61
			return repositoryManager.getRepository(BugzillaCorePlugin.CONNECTOR_KIND, "https://bugs.eclipse.org/bugs");
62
		}
63
		return null;
64
	}
65
66
}

Return to bug 214195