Interface IWorkspaceRoot
- All Superinterfaces:
IAdaptable
,IContainer
,IResource
,ISchedulingRule
- It cannot be moved or copied
- It always exists.
- Deleting the root deletes all of the children under the root but leaves the root itself
- It is always local.
- It is never a phantom.
Workspace roots implement the IAdaptable
interface;
extensions are managed by the platform's adapter manager.
- See Also:
- Restriction:
- This interface is not intended to be implemented by clients.
- Restriction:
- This interface is not intended to be extended by clients.
-
Field Summary
Fields inherited from interface org.eclipse.core.resources.IContainer
DO_NOT_CHECK_EXISTENCE, EXCLUDE_DERIVED, INCLUDE_HIDDEN, INCLUDE_PHANTOMS, INCLUDE_TEAM_PRIVATE_MEMBERS
Fields inherited from interface org.eclipse.core.resources.IResource
ALLOW_MISSING_LOCAL, ALWAYS_DELETE_PROJECT_CONTENT, AVOID_NATURE_CONFIG, BACKGROUND_REFRESH, CHECK_ANCESTORS, DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO, DERIVED, FILE, FOLDER, FORCE, HIDDEN, KEEP_HISTORY, NEVER_DELETE_PROJECT_CONTENT, NONE, NULL_STAMP, PROJECT, REPLACE, ROOT, SHALLOW, TEAM_PRIVATE, VIRTUAL
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(boolean deleteContent, boolean force, IProgressMonitor monitor) Deletes everything in the workspace except the workspace root resource itself.findContainersForLocation
(IPath location) Deprecated.findContainersForLocationURI
(URI location) Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given URI.findContainersForLocationURI
(URI location, int memberFlags) Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given URI.IFile[]
findFilesForLocation
(IPath location) Deprecated.usefindFilesForLocationURI(URI)
insteadIFile[]
findFilesForLocationURI
(URI location) Returns the handles of all files that are mapped to the given URI.IFile[]
findFilesForLocationURI
(URI location, int memberFlags) Returns the handles of all files that are mapped to the given URI.getContainerForLocation
(IPath location) Returns a handle to the workspace root, project or folder which is mapped to the given path in the local file system, ornull
if none.getFileForLocation
(IPath location) Returns a handle to the file which is mapped to the given path in the local file system, ornull
if none.getProject
(String name) Returns a handle to the project resource with the given name which is a child of this root.IProject[]
Returns the collection of projects which exist under this root.IProject[]
getProjects
(int memberFlags) Returns the collection of projects which exist under this root.Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
Methods inherited from interface org.eclipse.core.resources.IContainer
createFilter, exists, findDeletedMembersWithHistory, findMember, findMember, findMember, findMember, getDefaultCharset, getDefaultCharset, getFile, getFilters, getFolder, members, members, members, setDefaultCharset, setDefaultCharset
Methods inherited from interface org.eclipse.core.resources.IResource
accept, accept, accept, accept, accept, clearHistory, copy, copy, copy, copy, createMarker, createMarker, createProxy, delete, delete, deleteMarkers, equals, exists, findMarker, findMarkers, findMaxProblemSeverity, getFileExtension, getFullPath, getLocalTimeStamp, getLocation, getLocationURI, getMarker, getModificationStamp, getName, getParent, getPathVariableManager, getPersistentProperties, getPersistentProperty, getProject, getProjectRelativePath, getRawLocation, getRawLocationURI, getResourceAttributes, getSessionProperties, getSessionProperty, getType, getWorkspace, isAccessible, isDerived, isDerived, isHidden, isHidden, isLinked, isLinked, isLocal, isPhantom, isReadOnly, isSynchronized, isTeamPrivateMember, isTeamPrivateMember, isVirtual, move, move, move, move, refreshLocal, revertModificationStamp, setDerived, setDerived, setHidden, setLocal, setLocalTimeStamp, setPersistentProperty, setReadOnly, setResourceAttributes, setSessionProperty, setTeamPrivateMember, touch
Methods inherited from interface org.eclipse.core.runtime.jobs.ISchedulingRule
contains, isConflicting
-
Method Details
-
delete
Deletes everything in the workspace except the workspace root resource itself.This is a convenience method, fully equivalent to:
delete( (deleteContent ? IResource.ALWAYS_DELETE_PROJECT_CONTENT : IResource.NEVER_DELETE_PROJECT_CONTENT ) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event.
This method is long-running; progress and cancellation are provided by the given progress monitor.
- Parameters:
deleteContent
- a flag controlling how whether content is aggressively deletedforce
- a flag controlling whether resources that are not in sync with the local file system will be toleratedmonitor
- a progress monitor, ornull
if progress reporting is not desired- Throws:
CoreException
- if this method fails. Reasons include:- A project could not be deleted.
- A project's contents could not be deleted.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
OperationCanceledException
- if the operation is canceled. Cancelation can occur even if no progress monitor is provided.- See Also:
-
findContainersForLocation
Deprecated.usefindContainersForLocationURI(URI)
insteadReturns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given path in the local file system. Returns an empty array if there are none.If the path maps to the platform working location, the returned object will be a single element array consisting of an object of type
ROOT
.If the path maps to a project, the resulting array will contain a resource of type
PROJECT
, along with any linked folders that share the same location. Otherwise the resulting array will contain folders (typeFOLDER
).The path should be absolute; a relative path will be treated as absolute. The path segments need not be valid names; a trailing separator is ignored. The resulting resources may not currently exist.
The result will omit team private members and hidden resources. The result will omit resources within team private members or hidden containers.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
- Parameters:
location
- a path in the local file system- Returns:
- the corresponding containers in the workspace, or an empty array if none
- Since:
- 2.1
-
findContainersForLocationURI
Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given URI. Returns an empty array if there are none.If the path maps to the platform working location, the returned object will be a single element array consisting of an object of type
ROOT
.If the path maps to a project, the resulting array will contain a resource of type
PROJECT
, along with any linked folders that share the same location. Otherwise the resulting array will contain folders (typeFOLDER
).The URI must be absolute; its segments need not be valid names; a trailing separator is ignored. The resulting resources may not currently exist.
The result will omit team private members and hidden resources. The result will omit resources within team private member sor hidden containers.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
This is a convenience method, fully equivalent to
findContainersForLocationURI(location, IResource.NONE)
.- Parameters:
location
- a URI path into some file system- Returns:
- the corresponding containers in the workspace, or an empty array if none
- Since:
- 3.2
-
findContainersForLocationURI
Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given URI. Returns an empty array if there are none.If the
IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
flag is specified in the member flags, team private members will be included along with the others. If theIContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
flag is not specified (recommended), the result will omit any team private member resources.If the
IContainer.INCLUDE_HIDDEN
flag is specified in the member flags, hidden members will be included along with the others. If theIContainer.INCLUDE_HIDDEN
flag is not specified (recommended), the result will omit any hidden member resources.The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
- Parameters:
location
- a URI path into some file systemmemberFlags
- bit-wise or of member flag constants (IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
andIContainer.INCLUDE_HIDDEN
) indicating which members are of interest- Returns:
- the corresponding files in the workspace, or an empty array if none
- Since:
- 3.5
-
findFilesForLocation
Deprecated.usefindFilesForLocationURI(URI)
insteadReturns the handles of all files that are mapped to the given path in the local file system. Returns an empty array if there are none. The path should be absolute; a relative path will be treated as absolute. The path segments need not be valid names. The resulting files may not currently exist.The result will omit any team private member and hidden resources. The result will omit resources within team private member or hidden containers.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
- Parameters:
location
- a path in the local file system- Returns:
- the corresponding files in the workspace, or an empty array if none
- Since:
- 2.1
-
findFilesForLocationURI
Returns the handles of all files that are mapped to the given URI. Returns an empty array if there are none. The URI must be absolute; its path segments need not be valid names. The resulting files may not currently exist.The result will omit any team private member and hidden resources. The result will omit resources within team private member or hidden containers.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
This is a convenience method, fully equivalent to
findFilesForLocationURI(location, IResource.NONE)
.- Parameters:
location
- a URI path into some file system- Returns:
- the corresponding files in the workspace, or an empty array if none
- Since:
- 3.2
-
findFilesForLocationURI
Returns the handles of all files that are mapped to the given URI. Returns an empty array if there are none. The URI must be absolute; its path segments need not be valid names. The resulting files may not currently exist.If the
IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
flag is specified in the member flags, team private members will be included along with the others. If theIContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
flag is not specified (recommended), the result will omit any team private member resources.If the
IContainer.INCLUDE_HIDDEN
flag is specified in the member flags, hidden members will be included along with the others. If theIContainer.INCLUDE_HIDDEN
flag is not specified (recommended), the result will omit any hidden member resources.The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
- Parameters:
location
- a URI path into some file systemmemberFlags
- bit-wise or of member flag constants (IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS
andIContainer.INCLUDE_HIDDEN
) indicating which members are of interest- Returns:
- the corresponding files in the workspace, or an empty array if none
- Since:
- 3.5
-
getContainerForLocation
Returns a handle to the workspace root, project or folder which is mapped to the given path in the local file system, ornull
if none. If the path maps to the platform working location, the returned object will be of typeROOT
. If the path maps to a project, the resulting object will be of typePROJECT
; otherwise the resulting object will be a folder (typeFOLDER
). The path should be absolute; a relative path will be treated as absolute. The path segments need not be valid names; a trailing separator is ignored. The resulting resource may not currently exist.This method returns null when the given file system location is not equal to or under the location of any existing project in the workspace, or equal to the location of the platform working location.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
This method prefers a container whose path has a minimal number of segments. I.e. a container in a nested project is preferred over a container in an enclosing project.
Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method
findContainersForLocation
.- Parameters:
location
- a path in the local file system- Returns:
- the corresponding project or folder in the workspace,
or
null
if none
-
getFileForLocation
Returns a handle to the file which is mapped to the given path in the local file system, ornull
if none. The path should be absolute; a relative path will be treated as absolute. The path segments need not be valid names. The resulting file may not currently exist.This method returns null when the given file system location is not under the location of any existing project in the workspace.
The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.
This method prefers a file whose path has a minimal number of segments. I.e. a file in a nested project is preferred over a file in an enclosing project.
Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method
findFilesForLocation
.- Parameters:
location
- a path in the local file system- Returns:
- the corresponding file in the workspace,
or
null
if none
-
getProject
Returns a handle to the project resource with the given name which is a child of this root. The given name must be a valid path segment as defined byIPath.isValidSegment(String)
.Note: This method deals exclusively with resource handles, independent of whether the resources exist in the workspace. With the exception of validating that the name is a valid path segment, validation checking of the project name is not done when the project handle is constructed; rather, it is done automatically as the project is created.
- Parameters:
name
- the name of the project- Returns:
- a project resource handle
- See Also:
-
getProjects
IProject[] getProjects()Returns the collection of projects which exist under this root. The projects can be open or closed.This is a convenience method, fully equivalent to
getProjects(IResource.NONE)
. Hidden projects are not included.- Returns:
- an array of projects
- See Also:
-
getProjects
Returns the collection of projects which exist under this root. The projects can be open or closed.If the
IContainer.INCLUDE_HIDDEN
flag is specified in the member flags, hidden projects will be included along with the others. If theIContainer.INCLUDE_HIDDEN
flag is not specified (recommended), the result will omit any hidden projects.- Parameters:
memberFlags
- bit-wise or of member flag constants indicating which projects are of interest (onlyIContainer.INCLUDE_HIDDEN
is currently applicable)- Returns:
- an array of projects
- Since:
- 3.4
- See Also:
-
findContainersForLocationURI(URI)
instead