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

Collapse All | Expand All

(-)src/org/eclipse/core/tests/resources/NatureTest.java (-3 / +48 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-19 Link Here
13
import junit.framework.Test;
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
14
import junit.framework.TestSuite;
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.IJobManager;
18
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.core.tests.internal.resources.SimpleNature;
19
import org.eclipse.core.tests.internal.resources.SimpleNature;
18
20
19
/**
21
/**
Lines 59-65 Link Here
59
		try {
61
		try {
60
			IProjectDescription desc = project.getDescription();
62
			IProjectDescription desc = project.getDescription();
61
			desc.setNatureIds(natures);
63
			desc.setNatureIds(natures);
62
			int flags = IResource.KEEP_HISTORY;
64
			int flags = IResource.KEEP_HISTORY ;
63
			if (silent)
65
			if (silent)
64
				flags |= IResource.AVOID_NATURE_CONFIG;
66
				flags |= IResource.AVOID_NATURE_CONFIG;
65
			project.setDescription(desc, flags, getMonitor());
67
			project.setDescription(desc, flags, getMonitor());
Lines 214-217 Link Here
214
			}
216
			}
215
		}
217
		}
216
	}
218
	}
219
220
	/**
221
	 * Test addition of nature that requires the workspace root.
222
	 * See bugs 127562 and  128709.
223
	 */
224
	public void testBug127562Nature() {
225
		IWorkspace ws = ResourcesPlugin.getWorkspace();
226
		IProject project = ws.getRoot().getProject("Project");
227
		ensureExistsInWorkspace(project, true);
228
229
		String[][] valid = getValidNatureSets();
230
		for (int i = 0; i < valid.length; i++) {
231
			setNatures("valid: " + i, project, valid[i], false);
232
		}
233
234
		// add with AVOID_NATURE_CONFIG
235
		String[] currentSet = new String[] {NATURE_127562};
236
		setNatures("1.0", project, currentSet, false, true);
237
238
		// configure the nature using a conflicting scheduling rule
239
		IJobManager manager = Job.getJobManager();
240
		try {
241
			manager.beginRule(ws.getRuleFactory().modifyRule(project), null);
242
			project.getNature(NATURE_127562).configure();
243
			fail("2.0");
244
		} catch (CoreException ex) {
245
			fail("2.1");
246
		} catch (IllegalArgumentException ex) {
247
			// should throw this kind of exception
248
		} finally {
249
			manager.endRule(ws.getRuleFactory().modifyRule(project));
250
		}
251
252
		// configure the nature using a non-conflicting scheduling rule
253
		try {
254
			manager.beginRule(ws.getRoot(), null);
255
			project.getNature(NATURE_127562).configure();
256
		} catch (CoreException ex) {
257
			fail("3.0");
258
		} finally {
259
			manager.endRule(ws.getRoot());
260
		}
261
	}
217
}
262
}
(-)src/org/eclipse/core/tests/resources/ResourceTest.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 54-59 Link Here
54
	protected static final String NATURE_MUD = "org.eclipse.core.tests.resources.mudNature";
54
	protected static final String NATURE_MUD = "org.eclipse.core.tests.resources.mudNature";
55
	//simpleNature
55
	//simpleNature
56
	protected static final String NATURE_SIMPLE = "org.eclipse.core.tests.resources.simpleNature";
56
	protected static final String NATURE_SIMPLE = "org.eclipse.core.tests.resources.simpleNature";
57
	//notNarrowNature
58
	protected static final String NATURE_127562 = "org.eclipse.core.tests.resources.bug127562Nature";
57
	//snowNature, requires: waterNature, one-of: otherSet
59
	//snowNature, requires: waterNature, one-of: otherSet
58
	protected static final String NATURE_SNOW = "org.eclipse.core.tests.resources.snowNature";
60
	protected static final String NATURE_SNOW = "org.eclipse.core.tests.resources.snowNature";
59
	//waterNature, one-of: stateSet
61
	//waterNature, one-of: stateSet
(-)plugin.xml (+9 lines)
Lines 254-258 Link Here
254
   <enablement>
254
   <enablement>
255
      <instanceof value="org.eclipse.core.resources.IResource"/>
255
      <instanceof value="org.eclipse.core.resources.IResource"/>
256
   </enablement>
256
   </enablement>
257
</extension>
258
<extension
259
      id="bug127562Nature"
260
      point="org.eclipse.core.resources.natures">
261
   <runtime>
262
      <run
263
            class="org.eclipse.core.tests.internal.resources.Bug127562Nature">
264
      </run>
265
   </runtime>
257
</extension>            
266
</extension>            
258
</plugin>
267
</plugin>
(-)src/org/eclipse/core/tests/resources/regression/Bug_127562.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 47-53 Link Here
47
				public void run(IProgressMonitor monitor) throws CoreException {
47
				public void run(IProgressMonitor monitor) throws CoreException {
48
					project.setDescription(finalDescription, getMonitor());
48
					project.setDescription(finalDescription, getMonitor());
49
				}
49
				}
50
			}, getWorkspace().getRuleFactory().modifyRule(project), IResource.NONE, getMonitor());
50
			}, getWorkspace().getRoot(), IResource.NONE, getMonitor());
51
		} catch (CoreException e) {
51
		} catch (CoreException e) {
52
			fail("4.99", e);
52
			fail("4.99", e);
53
		}
53
		}
(-)src/org/eclipse/core/tests/internal/resources/Bug127562Nature.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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.core.tests.internal.resources;
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
16
17
/**
18
 * This nature will try to modify resources outside the project scope.
19
 */
20
public class Bug127562Nature extends TestNature {
21
	/**
22
	 * Constructor for SimpleNature.
23
	 */
24
	public Bug127562Nature() {
25
		super();
26
	}
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.core.resources.IProjectNature#configure()
30
	 */
31
	public void configure() throws CoreException {
32
		super.configure();
33
		IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("Project" + System.currentTimeMillis());
34
		p.create(null);
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.core.resources.IProjectNature#deconfigure()
39
	 */
40
	public void deconfigure() throws CoreException {
41
		super.deconfigure();
42
		IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("Project" + System.currentTimeMillis());
43
		p.create(null);
44
	}
45
}

Return to bug 128709