public final class ExtendedPlatform
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
IS_ECLIPSE_RUNNING |
static boolean |
IS_RESOURCES_BUNDLE_AVAILABLE |
static int |
LIMIT_INDIVIDUAL_RESOURCES_SCHEDULING_RULE |
Modifier and Type | Method and Description |
---|---|
static void |
addNature(org.eclipse.core.resources.IProject project,
java.lang.String natureId,
org.eclipse.core.runtime.IProgressMonitor monitor)
Adds specified
nature to given project . |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createCreateSchedulingRule(org.eclipse.core.resources.IResource resource)
Creates a
scheduling rule required for creating the given resource . |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createModifySchedulingRule(java.util.Collection<org.eclipse.core.resources.IFile> files)
Creates a
scheduling rule required for modifying the given collection of file s. |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createModifySchedulingRule(org.eclipse.core.resources.IResource resource)
Creates a
scheduling rule required for modifying the given resource . |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveNewSchedulingRule(java.util.Collection<org.eclipse.core.runtime.IPath> filePaths)
Creates a
scheduling rule required for saving the new file s with the given
collection of path s. |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveNewSchedulingRule(org.eclipse.core.runtime.IPath filePath)
Creates a
scheduling rule required for saving the new file with given
path . |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveNewSchedulingRule(org.eclipse.core.resources.IResource resource)
Creates a
scheduling rule required for saving the given new resource . |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveSchedulingRule(org.eclipse.core.resources.IResource resource)
Creates a
scheduling rule required for saving the given resource . |
static java.lang.String |
createUniqueFileName(org.eclipse.core.runtime.IPath containerFullPath,
java.lang.String candidateFileName)
Creates a file name that is unique among the names of the files present in
container with
given containerFullPath . |
static org.eclipse.core.runtime.IPath |
createUniquePath(org.eclipse.core.runtime.IPath candidatePath,
java.util.Collection<org.eclipse.core.runtime.IPath> allocatedPaths)
Creates a unique
path starting from given candidatePath making sure that the result is
different from any of the provided allocatedPaths . |
static java.util.Collection<org.eclipse.core.resources.IFile> |
getAllFiles(org.eclipse.core.resources.IFolder folder)
Returns all
file s contained in the folder . |
static java.util.Collection<org.eclipse.core.resources.IFile> |
getAllFiles(org.eclipse.core.resources.IProject project,
boolean deeply)
Returns all files of a project.
|
static java.util.Collection<org.eclipse.core.resources.IProject> |
getAllReferencedProjects(org.eclipse.core.resources.IProject project)
Returns a collection containing all the projects that are
referenced by the specified project and recursively all the projects that are referenced by the projects that are
referenced by the given
project . |
static java.util.Collection<org.eclipse.core.resources.IProject> |
getAllReferencingProjects(org.eclipse.core.resources.IProject project)
Returns a collection containing all the projects that are
referencing the specified project and recursively all the projects that are referencing the projects that are
referencing by the given
project . |
static java.util.Collection<java.lang.String> |
getContentTypeFileExtensions(java.lang.String contentTypeId)
Returns a set of file extensions supported by content-type with given id.
|
static java.lang.String |
getContentTypeId(java.io.File file)
Returns the content-type identifier of the specified file.
|
static java.lang.String |
getContentTypeId(org.eclipse.core.resources.IFile file)
Returns the content-type identifier of the specified file.
|
static java.lang.String |
getFeatureVersion()
Returns the feature version of the running instance of the Eclipse platform (e.g., 3.4 for Eclipse 3.4, 3.5 for
Eclipse 3.5).
|
static int |
getFeatureVersionOrdinal()
Returns an ordinal for the feature version of the running instance of the Eclipse platform (e.g., 34 for Eclipse
3.4, 35 for Eclipse 3.5).
|
static org.eclipse.core.resources.IProject |
getFirstRootProject(org.eclipse.core.resources.IProject project)
Returns the root project to which the given
project contributes. |
static org.eclipse.core.resources.IResource[] |
getMembersSafely(org.eclipse.core.resources.IContainer container)
Encapsulated method
IContainer.members() in order to keep as much robustness as possible. |
static java.util.Set<org.eclipse.core.resources.IProject> |
getProjectGroup(org.eclipse.core.resources.IProject project,
boolean includeReferencingProjects)
Computes a group of projects.
|
static java.util.Collection<org.eclipse.core.resources.IProject> |
getProjects(java.lang.String natureId)
Returns the projects in the workspace which have the given nature associated with them.
|
static org.eclipse.core.resources.IProject[] |
getReferencedProjectsSafely(org.eclipse.core.resources.IProject project)
Encapsulated method
IProject.getReferencedProjects() in order to keep as much robustness as possible. |
static org.eclipse.core.resources.IProject[] |
getReferencingProjectsSafely(org.eclipse.core.resources.IProject project)
Encapsulated method
IProject.getReferencingProjects() in order to keep as much robustness as possible. |
static java.util.Collection<org.eclipse.core.resources.IProject> |
getRootProjects()
Returns all root projects in the workspace.
|
static boolean |
hasCachedContentTypeId(org.eclipse.core.resources.IFile file) |
static boolean |
isBundleAvailable(java.lang.String pluginId) |
static boolean |
isContentTypeApplicable(java.lang.String contentTypeId,
org.eclipse.core.resources.IFile file)
Returns wether the given content type is applicable to the passed in file.
|
static boolean |
isPlatformPrivateResource(org.eclipse.core.resources.IResource resource)
Returns whether given
resource is platform private (i.e., a team private resource, project
description file, or project properties folder or file). |
static boolean |
isProjectDescriptionFile(org.eclipse.core.resources.IResource resource)
Indicates if given
resource is a project description file, i.e. |
static boolean |
isProjectPropertiesFile(org.eclipse.core.resources.IResource resource)
Indicates if given
resource is a project properties file, i.e. |
static boolean |
isProjectPropertiesFolder(org.eclipse.core.resources.IResource resource)
Indicates if given
resource is a project properties folder, i.e. |
static boolean |
isRootProject(org.eclipse.core.resources.IProject project)
Returns wheather the given
IProject is a root project. |
static boolean |
isSynchronized(org.eclipse.core.resources.IResource resource)
Checks wether the resource is in-sync with the file system and updates its out-of-sync marker accordingly.
|
static boolean |
isTeamPrivateResource(org.eclipse.core.resources.IResource resource)
Returns whether given
resource is team private (i.e., a resource marked for internal usage by
CVS or SVN only). |
static boolean |
isTeamPrivateResource(org.eclipse.core.resources.IResource resource,
int options)
Returns whether given
resource is team private (i.e., a resource marked for internal usage by
CVS or SVN only). |
static org.osgi.framework.Bundle |
loadBundle(java.lang.String symbolicName)
Returns the active bundle matching specified symbolic name that has the highest version.
|
static org.osgi.framework.Bundle |
loadContributorBundle(org.eclipse.core.runtime.IConfigurationElement contribution)
Returns the contributing bundle for a given
contribution . |
static void |
performGarbageCollection()
Performs a full garbage collection to free heap memory space.
|
static void |
persistContentTypeIdProperties(java.util.Collection<org.eclipse.core.resources.IFile> files,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
persistContentTypeIdProperties(org.eclipse.core.resources.IProject project,
boolean includeReferencedProjects,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
removeCachedContentTypeId(org.eclipse.core.resources.IFile file) |
static void |
removeNature(org.eclipse.core.resources.IProject project,
java.lang.String natureId,
org.eclipse.core.runtime.IProgressMonitor monitor)
Removes specified
nature from given project . |
static void |
safeClose(java.io.InputStream in)
Closes a stream and ignores any resulting exception.
|
static void |
safeClose(java.io.OutputStream out)
Closes a stream and ignores any resulting exception.
|
static void |
setCachedContentTypeId(org.eclipse.core.resources.IFile file,
java.lang.String contentTypeId) |
static org.eclipse.core.runtime.QualifiedName |
toQualifedName(java.lang.String name)
Converts the specified name into a qualified name.
|
public static final int LIMIT_INDIVIDUAL_RESOURCES_SCHEDULING_RULE
public static final boolean IS_ECLIPSE_RUNNING
public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE
public static java.lang.String getFeatureVersion()
public static int getFeatureVersionOrdinal()
public static boolean isBundleAvailable(java.lang.String pluginId)
public static org.osgi.framework.Bundle loadBundle(java.lang.String symbolicName)
symbolicName
- Symbolic name of bundle to be loaded.Platform.getBundle(String)
public static final org.osgi.framework.Bundle loadContributorBundle(org.eclipse.core.runtime.IConfigurationElement contribution)
contribution
.contribution
- The contribution whose contributor bundle must be returnedpublic static org.eclipse.core.runtime.jobs.ISchedulingRule createModifySchedulingRule(org.eclipse.core.resources.IResource resource)
scheduling rule
required for modifying the given resource
.resource
- The resource
to be modified.scheduling rule
or null
if no such could be created.public static org.eclipse.core.runtime.jobs.ISchedulingRule createModifySchedulingRule(java.util.Collection<org.eclipse.core.resources.IFile> files)
scheduling rule
required for modifying the given collection of file
s.files
- The collection of file
s to be modified.scheduling rule
or null
if provided collection of
file
s is empty or no such could be created for some other reason.public static org.eclipse.core.runtime.jobs.ISchedulingRule createCreateSchedulingRule(org.eclipse.core.resources.IResource resource)
scheduling rule
required for creating the given resource
.resource
- The resource
to be created.scheduling rule
or null
if no such could be created.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveNewSchedulingRule(org.eclipse.core.resources.IResource resource)
scheduling rule
required for saving the given new resource
.resource
- The new resource
to be saved.scheduling rule
or null
if no such could be created.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveNewSchedulingRule(org.eclipse.core.runtime.IPath filePath)
scheduling rule
required for saving the new file
with given
path
.filePath
- The path
of the new file
to be saved.scheduling rule
or null
if no such could be created.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveNewSchedulingRule(java.util.Collection<org.eclipse.core.runtime.IPath> filePaths)
scheduling rule
required for saving the new file
s with the given
collection of path
s.filePaths
- The collection of IPath
s of the new file
s to be saved.scheduling rule
or null
if provided collection of
path
s is empty or no such could be created for some other reason.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveSchedulingRule(org.eclipse.core.resources.IResource resource)
scheduling rule
required for saving the given resource
.resource
- The resource
to be saved.scheduling rule
or null
if no such could be created.public static boolean isProjectDescriptionFile(org.eclipse.core.resources.IResource resource)
resource
is a project description file, i.e. a file named ".project" located
directly under the root of a project.resource
- The resource
to be investigated.true
if given resource
is a project description file, or
false
otherwise.public static boolean isProjectPropertiesFolder(org.eclipse.core.resources.IResource resource)
resource
is a project properties folder, i.e. a folder named ".settings"
located directly under the root of a project.resource
- The resource
to be investigated.true
if given resource
is a project properties folder, or
false
otherwise.public static boolean isProjectPropertiesFile(org.eclipse.core.resources.IResource resource)
resource
is a project properties file, i.e. a *.prefs file in a folder named
".settings" and located directly under the root of a project.resource
- The resource
to be investigated.true
if given resource
is a project properties file, or false
otherwise.public static boolean isTeamPrivateResource(org.eclipse.core.resources.IResource resource)
resource
is team private (i.e., a resource marked for internal usage by
CVS or SVN only).
This is a convenience method, fully equivalent to isTeamPrivateResource(resource, IResource.NONE)
.
true
if given resource
is team private, or false
otherwise.IResource#isTeamPrivateMember(boolean)
public static boolean isTeamPrivateResource(org.eclipse.core.resources.IResource resource, int options)
resource
is team private (i.e., a resource marked for internal usage by
CVS or SVN only).
The #CHECK_ANCESTORS
option flag indicates whether this method should consider ancestor
resource
s in its calculation. If the IResource.CHECK_ANCESTORS
flag is present, this method will return
true
if given resource
, or any parent resource
, is team private.
If the IResource.CHECK_ANCESTORS
option flag is not specified, this method returns false for children of
team private resources.
options
- Bit-wise OR of option flag constants (only IResource.CHECK_ANCESTORS
is applicable).true
if given resource
is team private, or false
otherwise.IResource#isTeamPrivateMember(boolean)
,
IResource.CHECK_ANCESTORS
public static boolean isPlatformPrivateResource(org.eclipse.core.resources.IResource resource)
resource
is platform private (i.e., a team private resource, project
description file, or project properties folder or file).true
if given resource
is platform private, or false
otherwise.IResource#isTeamPrivateMember(boolean)
public static final java.util.Collection<org.eclipse.core.resources.IFile> getAllFiles(org.eclipse.core.resources.IFolder folder)
file
s contained in the folder
. The folder
is searched
recursively. Thus, file
s contained in descending folder
s are also returned.folder
- The folder
owning the file
s to return.file
s owned by the given folder
(and its descendant
folder
s).public static final java.util.Collection<org.eclipse.core.resources.IFile> getAllFiles(org.eclipse.core.resources.IProject project, boolean deeply)
project
- The project whose files must be returned.deeply
- If set to true
also the files from referenced projects are returned.deeply
flag.public static final org.eclipse.core.resources.IResource[] getMembersSafely(org.eclipse.core.resources.IContainer container)
IContainer.members()
in order to keep as much robustness as possible.container
- The container whose members must be returned.public static org.eclipse.core.resources.IProject[] getReferencedProjectsSafely(org.eclipse.core.resources.IProject project)
IProject.getReferencedProjects()
in order to keep as much robustness as possible.project
- The project whose referenced projects must be returned.IProject.getReferencedProjects()
public static org.eclipse.core.resources.IProject[] getReferencingProjectsSafely(org.eclipse.core.resources.IProject project)
IProject.getReferencingProjects()
in order to keep as much robustness as possible.project
- The project whose referencing projects must be returned.IProject.getReferencingProjects()
public static java.util.Set<org.eclipse.core.resources.IProject> getProjectGroup(org.eclipse.core.resources.IProject project, boolean includeReferencingProjects)
project
- A project whose scope will be computed.includeReferencingProjects
- If true
also includes projects that reference the given project.public static java.util.Collection<org.eclipse.core.resources.IProject> getAllReferencedProjects(org.eclipse.core.resources.IProject project)
project
.project
- The project whose all referenced projects must be returned.project
.public static java.util.Collection<org.eclipse.core.resources.IProject> getAllReferencingProjects(org.eclipse.core.resources.IProject project)
project
.project
- The project whose all referencing projects must be returned.project
.public static boolean isRootProject(org.eclipse.core.resources.IProject project)
IProject
is a root project. Root projects are projects which are not
referenced from another project. From a root project an entire model can be loaded.project
- The project to be evaluated.public static org.eclipse.core.resources.IProject getFirstRootProject(org.eclipse.core.resources.IProject project)
project
contributes. Root projects are projects which
are not referenced from another project. From a root project an entire model can be loaded.
If the given project
has more than one root project the first one found will be returned. If the
provided project
is a root project itself it is returned.
project
- The project for which the root project is to be determined.project
.public static java.util.Collection<org.eclipse.core.resources.IProject> getRootProjects()
getFirstRootProject(IProject)
public static java.util.Collection<org.eclipse.core.resources.IProject> getProjects(java.lang.String natureId)
natureId
- An identifier specifying the nature of the projects to be returned.public static java.lang.String createUniqueFileName(org.eclipse.core.runtime.IPath containerFullPath, java.lang.String candidateFileName)
container
with
given containerFullPath
.containerFullPath
- candidateFileName
- public static org.eclipse.core.runtime.IPath createUniquePath(org.eclipse.core.runtime.IPath candidatePath, java.util.Collection<org.eclipse.core.runtime.IPath> allocatedPaths)
path
starting from given candidatePath
making sure that the result is
different from any of the provided allocatedPaths
. In case that given candidatePath
already is unique wrt provided allocatedPaths
the candidatePath
is returned as is.
Otherwise the candidatePath
is made unique by appending an appropriate number to its last segment.
Any file extension present on the candiatePath
is be preserved.candidatePath
- The candidate path
from which a unique path is to be created.allocatedPaths
- The path
s from which the created path should be different.path
that is unique wrt provided allocatedPaths
.public static java.lang.String getContentTypeId(org.eclipse.core.resources.IFile file) throws org.eclipse.core.runtime.CoreException
In order to prevent performance losses, the content type id is cached as a session property on the file.
It is then possible to retrieve that content type id later by calling
IResource.getSessionProperty(QualifiedName) where qualifiedName
can be computed by
using toQualifedName(String) and specifying
IExtendedPlatformConstants.RESOURCE_PROPERTY_CONTENT_TYPE_ID as name
.
file
- The file whose content-type identifier must be returned.file
or null
if no such could be
determined.org.eclipse.core.runtime.CoreException
public static java.lang.String getContentTypeId(java.io.File file) throws java.io.IOException
file
- The file whose content-type identifier must be returned.file
or null
if no such could be
determined.java.io.IOException
public static boolean hasCachedContentTypeId(org.eclipse.core.resources.IFile file)
public static void setCachedContentTypeId(org.eclipse.core.resources.IFile file, java.lang.String contentTypeId)
public static void persistContentTypeIdProperties(org.eclipse.core.resources.IProject project, boolean includeReferencedProjects, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void persistContentTypeIdProperties(java.util.Collection<org.eclipse.core.resources.IFile> files, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void removeCachedContentTypeId(org.eclipse.core.resources.IFile file)
public static java.util.Collection<java.lang.String> getContentTypeFileExtensions(java.lang.String contentTypeId)
contentTypeId
- The content-type id for which the supported file extensions are to be retrieved.public static boolean isContentTypeApplicable(java.lang.String contentTypeId, org.eclipse.core.resources.IFile file)
contentTypeId
- The identifier of the content type to check for applicabilityfile
- The file to check for applicabilityPlatform.getContentTypeManager()
,
IContentType.isAssociatedWith(String)
public static org.eclipse.core.runtime.QualifiedName toQualifedName(java.lang.String name)
name
- The name to convert.name
.public static void addNature(org.eclipse.core.resources.IProject project, java.lang.String natureId, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
nature
to given project
.project
- The project
to be handled.natureId
- The id of the project nature
to be added.monitor
- A progress monitor
, or null
if progress reporting is not
desired.org.eclipse.core.runtime.CoreException
- If the project
does not exist or is not open.public static void removeNature(org.eclipse.core.resources.IProject project, java.lang.String natureId, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
nature
from given project
.project
- The project
to be handled.natureId
- The id of the project nature
to be removed.monitor
- A progress monitor
, or null
if progress reporting is not
desired.org.eclipse.core.runtime.CoreException
- If the project
does not exist or is not open.public static void safeClose(java.io.InputStream in)
public static void safeClose(java.io.OutputStream out)
public static final void performGarbageCollection()
Runs garbage collector in a separate thread to be sure that it can reclaim heap space of objects that have been disposed in the current thread.
public static boolean isSynchronized(org.eclipse.core.resources.IResource resource)
markerJob
- the marker job that will be used to asynchronously create or delete markersresource
- the resource to checkIResourceSyncMarker.RESOURCE_SYNC_PROBLEM