Class NatureUtils
java.lang.Object
net.ssehub.easy.producer.eclipse.persistency.eclipse.NatureUtils
Some utility methods for natures.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrevents this class from being instantiated from outside. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddNature(org.eclipse.core.resources.IProject project, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) Adds a nature to the given project.static voidensureBuilder(org.eclipse.core.resources.IProject project, String includeBuilder, String excludeBuilder, org.eclipse.core.runtime.IProgressMonitor monitor) Ensures a builder, while removing another one.static booleanReturns whether at least one of the given natures is defined on the given project.static voidremoveNature(org.eclipse.core.resources.IProject project, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) Removes a nature from the given project.static voidsetNatureFilter(Predicate<String> filter) Allows filtering out natures.
-
Field Details
-
natureFilter
-
-
Constructor Details
-
NatureUtils
private NatureUtils()Prevents this class from being instantiated from outside.
-
-
Method Details
-
hasNature
public static boolean hasNature(org.eclipse.core.resources.IProject project, String... natures) throws org.eclipse.core.runtime.CoreException Returns whether at least one of the given natures is defined on the given project. Filtered out natures are always found.- Parameters:
project- the project to check the nature onnatures- the natures to be checked- Returns:
trueif at least one nature innaturesis a nature ofproject,falseelse- Throws:
org.eclipse.core.runtime.CoreException- ifprojectdoes not exist or is not open
-
ensureBuilder
public static void ensureBuilder(org.eclipse.core.resources.IProject project, String includeBuilder, String excludeBuilder, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Ensures a builder, while removing another one.- Parameters:
project- the project to check the builders onincludeBuilder- the builder id to includeexcludeBuilder- the builder id to excludemonitor- an optional progress monitor (may be null)- Throws:
org.eclipse.core.runtime.CoreException- ifprojectdoes not exist or is not open
-
addNature
public static void addNature(org.eclipse.core.resources.IProject project, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Adds a nature to the given project. Filtered out natures are not added.- Parameters:
project- the project to add the nature tonature- the nature to be addedmonitor- an optional progress monitor (may be null)- Throws:
org.eclipse.core.runtime.CoreException- ifprojectdoes not exist or is not open
-
removeNature
public static void removeNature(org.eclipse.core.resources.IProject project, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Removes a nature from the given project. Filtered out natures are not removed.- Parameters:
project- the project to remove the nature fromnature- the nature to be removemonitor- an optional progress monitor (may be null)- Throws:
org.eclipse.core.runtime.CoreException- ifprojectdoes not exist or is not open
-
setNatureFilter
Allows filtering out natures. [testing].- Parameters:
filter- the nature filter
-