plugin/src/com/carrotgarden/eclipse/space/util/NatureUtil.java
/**
	 * Make sure a project has a number of required natures. If the natures are not
	 * yet present, add them now.
	 * 
	 * @throws CoreException
	 */
Make sure a project has a number of required natures. If the natures are not
yet present, add them now.


Make sure a project has a number of required natures . If the natures are not yet present add them now .
public static void ensure(final IProject project, final IProgressMonitor monitor, final String... nextNaturesArray)
			throws CoreException {
		final IProjectDescription description = project.getDescription();
		final String[] pastNaturesArray = description.getNatureIds();
		final Set<String> natureSet = new LinkedHashSet<String>();
		for (final String nature : nextNaturesArray) {
			natureSet.add(nature);
		}
		for (final String nature : pastNaturesArray) {
			natureSet.add(nature);
		}
		description.setNatureIds(natureSet.toArray(new String[natureSet.size()]));
		if (natureSet.size() > pastNaturesArray.length) {
			project.setDescription(description, monitor);
		} else {
			project.setDescription(description, IResource.AVOID_NATURE_CONFIG, monitor);
		}
	}
public static void ensure ( final IProject project , final IProgressMonitor monitor , final String ... nextNaturesArray ) throws CoreException { final IProjectDescription description = project . getDescription ( ) ; final String [ ] pastNaturesArray = description . getNatureIds ( ) ; final Set < String > natureSet = new LinkedHashSet < String > ( ) ; for ( final String nature : nextNaturesArray ) { natureSet . add ( nature ) ; } for ( final String nature : pastNaturesArray ) { natureSet . add ( nature ) ; } description . setNatureIds ( natureSet . toArray ( new String [ natureSet . size ( ) ] ) ) ; if ( natureSet . size ( ) > pastNaturesArray . length ) { project . setDescription ( description , monitor ) ; } else { project . setDescription ( description , IResource . AVOID_NATURE_CONFIG , monitor ) ; } }
Make sure a project has a number of required natures.
Make sure a project has a number of required natures .
// Plugin.logInfo("natureSet = " + natureSet); // Some natures got added // No new natures added, but need to set it to force desired // ordering