Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.core.internal.resources
Class Workspace  view Workspace download Workspace.java

java.lang.Object
  extended byorg.eclipse.core.runtime.PlatformObject
      extended byorg.eclipse.core.internal.resources.Workspace
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, ICoreConstants, org.eclipse.core.resources.IWorkspace

public class Workspace
extends org.eclipse.core.runtime.PlatformObject
implements org.eclipse.core.resources.IWorkspace, ICoreConstants


Nested Class Summary
 
Nested classes inherited from class org.eclipse.core.resources.IWorkspace
org.eclipse.core.resources.IWorkspace.ProjectOrder
 
Field Summary
protected  WorkManager _workManager
          Work manager should never be accessed directly because accessor asserts that workspace is still open.
protected  AliasManager aliasManager
           
protected  org.eclipse.core.internal.events.BuildManager buildManager
           
protected  org.eclipse.core.resources.IProject[] buildOrder
           
protected  CharsetManager charsetManager
           
protected  ContentDescriptionManager contentDescriptionManager
           
protected  boolean crashed
          indicates if the workspace crashed in a previous session
static boolean DEBUG
           
protected  org.eclipse.core.resources.IWorkspaceRoot defaultRoot
           
protected  WorkspacePreferences description
           
protected  org.eclipse.core.internal.localstore.FileSystemResourceManager fileSystemManager
           
protected  java.util.HashSet lifecycleListeners
           
protected  LocalMetaArea localMetaArea
           
protected  MarkerManager markerManager
           
protected  org.eclipse.core.resources.team.IMoveDeleteHook moveDeleteHook
          The currently installed Move/Delete hook.
protected  NatureManager natureManager
           
protected  long nextMarkerId
           
protected  long nextModificationStamp
           
protected  long nextNodeId
           
protected  org.eclipse.core.internal.events.NotificationManager notificationManager
           
protected  boolean openFlag
           
protected  org.eclipse.core.internal.watson.ElementTree operationTree
           
protected  PathVariableManager pathVariableManager
           
protected  org.eclipse.core.internal.properties.PropertyManager propertyManager
           
protected static java.lang.String REFRESH_ON_STARTUP
           
protected  org.eclipse.core.internal.refresh.RefreshManager refreshManager
           
private  org.eclipse.core.resources.IResourceRuleFactory ruleFactory
          Scheduling rule factory
protected  SaveManager saveManager
           
protected  boolean shouldValidate
          File modification validation.
protected  Synchronizer synchronizer
           
protected  org.eclipse.core.resources.team.TeamHook teamHook
          The currently installed team hook.
protected  org.eclipse.core.internal.watson.ElementTree tree
           
protected  java.lang.Thread treeLocked
          This field is used to control access to the workspace tree during resource change notifications.
protected  org.eclipse.core.resources.IFileModificationValidator validator
          The currently installed file modification validator.
 
Fields inherited from interface org.eclipse.core.resources.IWorkspace
AVOID_UPDATE
 
Fields inherited from interface org.eclipse.core.internal.resources.ICoreConstants
EMPTY_FILE_STATES, EMPTY_PROJECT_ARRAY, EMPTY_RESOURCE_ARRAY, FIRST_INTERNAL_ERROR, FIRST_INTERNAL_INFO, FIRST_INTERNAL_WARNING, I_NULL_SYNC_INFO, I_UNKNOWN_SYNC_INFO, K_BUILD_MAP, LAST_INTERNAL_ERROR, LAST_INTERNAL_INFO, LAST_INTERNAL_WARNING, M_CONTENT_CACHE, M_DEFAULT_CONTENT_DESCRIPTION, M_DERIVED, M_LINK, M_LOCAL_EXISTS, M_MARKERS_SNAP_DIRTY, M_NO_CONTENT_DESCRIPTION, M_OPEN, M_PHANTOM, M_SYNCINFO_SNAP_DIRTY, M_TEAM_PRIVATE_MEMBER, M_TYPE, M_TYPE_START, M_USED, MINIMUM_FILE_SEGMENT_LENGTH, MINIMUM_FOLDER_SEGMENT_LENGTH, MSG_EVENTS_BUILDING_0, MSG_EVENTS_ERRORS, MSG_RESOURCES_UPDATING, NULL_FLAG, OPERATION_FAILED, PROJECT_SEGMENT_LENGTH, WORKSPACE_TREE_VERSION_1, WORKSPACE_TREE_VERSION_2
 
Constructor Summary
Workspace()
           
 
Method Summary
protected  void aboutToBuild()
          Indicates that a build is about to occur.
 void addLifecycleListener(org.eclipse.core.internal.events.ILifecycleListener listener)
          Adds a listener for internal workspace lifecycle events.
 void addResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener)
          Adds the given listener for resource change events to this workspace.
 void addResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener, int eventMask)
          Adds the given listener for the specified resource change events to this workspace.
 org.eclipse.core.resources.ISavedState addSaveParticipant(org.eclipse.core.runtime.Plugin plugin, org.eclipse.core.resources.ISaveParticipant participant)
          Registers the given plug-in's workspace save participant, and returns an object describing the workspace state at the time of the last save in which the plug-in participated.
 void beginOperation(boolean createNewTree)
           
protected  void broadcastChanges(int type, boolean lockTree)
           
protected  void broadcastEvent(org.eclipse.core.internal.events.LifecycleEvent event)
          Broadcasts an internal workspace lifecycle event to interested internal listeners.
 void build(int trigger, org.eclipse.core.runtime.IProgressMonitor monitor)
          Builds all projects in this workspace.
 void checkpoint(boolean build)
          Checkpoints the operation currently in progress.
static boolean clear(java.io.File root)
          Deletes all the files and directories from the given root down (inclusive).
static boolean clearChildren(java.io.File root)
          Deletes all the files and directories from the given root down, except for the root itself.
 void close(org.eclipse.core.runtime.IProgressMonitor monitor)
          Closes this workspace; ignored if this workspace is not open.
private  org.eclipse.core.resources.IWorkspace.ProjectOrder computeFullProjectOrder()
          Computes the global total ordering of all open projects in the workspace based on project references.
 org.eclipse.core.resources.IProject[][] computePrerequisiteOrder(org.eclipse.core.resources.IProject[] targets)
          Deprecated. Replaced by IWorkspace.computeProjectOrder, which produces a more usable result when there are cycles in project reference graph.
private  org.eclipse.core.resources.IProject[][] computePrerequisiteOrder1(org.eclipse.core.resources.IProject[] projects)
           
 org.eclipse.core.resources.IWorkspace.ProjectOrder computeProjectOrder(org.eclipse.core.resources.IProject[] projects)
          Computes a total ordering of the given projects based on both static and dynamic project references.
 org.eclipse.core.runtime.IStatus copy(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath destination, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Copies the given sibling resources so that they are located as members of the resource at the given path; the names of the copies are the same as the corresponding originals.
 org.eclipse.core.runtime.IStatus copy(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath destination, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Copies the given sibling resources so that they are located as members of the resource at the given path; the names of the copies are the same as the corresponding originals.
protected  void copyTree(org.eclipse.core.resources.IResource source, org.eclipse.core.runtime.IPath destination, int depth, int updateFlags, boolean keepSyncInfo)
           
 int countResources(org.eclipse.core.runtime.IPath root, int depth, boolean phantom)
          Returns the number of resources in a subtree of the resource tree.
 ResourceInfo createResource(org.eclipse.core.resources.IResource resource, boolean phantom)
           
 ResourceInfo createResource(org.eclipse.core.resources.IResource resource, boolean phantom, boolean overwrite)
           
 ResourceInfo createResource(org.eclipse.core.resources.IResource resource, ResourceInfo info, boolean phantom, boolean overwrite)
           
 ResourceInfo createResource(org.eclipse.core.resources.IResource resource, ResourceInfo info, boolean phantom, boolean overwrite, boolean keepSyncInfo)
           
static WorkspaceDescription defaultWorkspaceDescription()
           
 org.eclipse.core.runtime.IStatus delete(org.eclipse.core.resources.IResource[] resources, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Deletes the given resources.
 org.eclipse.core.runtime.IStatus delete(org.eclipse.core.resources.IResource[] resources, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Deletes the given resources.
 void deleteMarkers(org.eclipse.core.resources.IMarker[] markers)
          Removes the given markers from the resources with which they are associated.
(package private)  void deleteResource(org.eclipse.core.resources.IResource resource)
          Delete the given resource from the current tree of the receiver.
 void dumpStats()
          For debugging purposes only.
 void endOperation(org.eclipse.core.runtime.jobs.ISchedulingRule rule, boolean build, org.eclipse.core.runtime.IProgressMonitor monitor)
          End an operation (group of resource changes).
protected  void flushBuildOrder()
          Flush the build order cache for the workspace.
 void forgetSavedTree(java.lang.String pluginId)
          Forgets any resource tree being saved for the plug-in with the given name.
 AliasManager getAliasManager()
           
 org.eclipse.core.internal.events.BuildManager getBuildManager()
          Returns this workspace's build manager
 org.eclipse.core.resources.IProject[] getBuildOrder()
          Returns the order in which open projects in this workspace will be built.
 CharsetManager getCharsetManager()
           
 ContentDescriptionManager getContentDescriptionManager()
           
 java.util.Map getDanglingReferences()
          Finds all dangling project references in this workspace.
 org.eclipse.core.resources.IWorkspaceDescription getDescription()
          Returns the workspace description.
 org.eclipse.core.internal.watson.ElementTree getElementTree()
          Returns the current element tree for this workspace
 org.eclipse.core.internal.localstore.FileSystemResourceManager getFileSystemManager()
           
 MarkerManager getMarkerManager()
          Returns the marker manager for this workspace
 LocalMetaArea getMetaArea()
           
protected  org.eclipse.core.resources.team.IMoveDeleteHook getMoveDeleteHook()
           
 org.eclipse.core.resources.IProjectNatureDescriptor getNatureDescriptor(java.lang.String natureId)
          Returns the nature descriptor with the given unique identifier, or null if there is no such nature.
 org.eclipse.core.resources.IProjectNatureDescriptor[] getNatureDescriptors()
          Returns all nature descriptors known to this workspace.
 NatureManager getNatureManager()
          Returns the nature manager for this workspace.
 org.eclipse.core.internal.events.NotificationManager getNotificationManager()
           
 org.eclipse.core.resources.IPathVariableManager getPathVariableManager()
          Returns the path variable manager for this workspace.
 org.eclipse.core.internal.properties.PropertyManager getPropertyManager()
           
 org.eclipse.core.internal.refresh.RefreshManager getRefreshManager()
          Returns the refresh manager for this workspace
 ResourceInfo getResourceInfo(org.eclipse.core.runtime.IPath path, boolean phantom, boolean mutable)
          Returns the resource info for the identified resource.
 org.eclipse.core.resources.IWorkspaceRoot getRoot()
          Returns the root resource of this workspace.
 org.eclipse.core.resources.IResourceRuleFactory getRuleFactory()
          Returns a factory for obtaining scheduling rules prior to modifying resources in the workspace.
 SaveManager getSaveManager()
           
 org.eclipse.core.resources.ISynchronizer getSynchronizer()
          Returns the synchronizer for this workspace.
protected  org.eclipse.core.resources.team.TeamHook getTeamHook()
          Returns the installed team hook.
 WorkManager getWorkManager()
          We should not have direct references to this field.
protected  void initializeMoveDeleteHook()
          A move/delete hook hasn't been initialized.
protected  void initializeTeamHook()
          A team hook hasn't been initialized.
protected  void initializeValidator()
          A file modification validator hasn't been initialized.
 WorkspaceDescription internalGetDescription()
           
 boolean isAutoBuilding()
          Returns whether this workspace performs auto-builds.
private static boolean isDuplicate(java.lang.Object[] array, int position)
          Returns true if the object at the specified position has any other copy in the given array.
 boolean isOpen()
           
protected  boolean isOverlapping(org.eclipse.core.runtime.IPath location1, org.eclipse.core.runtime.IPath location2, boolean bothDirections)
          Returns true if the given file system locations overlap.
 boolean isTreeLocked()
          Returns whether the workspace tree is currently locked.
protected  void linkTrees(org.eclipse.core.runtime.IPath path, org.eclipse.core.internal.watson.ElementTree[] newTrees)
          Link the given tree into the receiver's tree at the specified resource.
 org.eclipse.core.resources.IProjectDescription loadProjectDescription(org.eclipse.core.runtime.IPath path)
          Reads the project description file (".project") from the given location in the local file system.
 org.eclipse.core.runtime.IStatus move(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath destination, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Moves the given sibling resources so that they are located as members of the resource at the given path; the names of the new members are the same.
 org.eclipse.core.runtime.IStatus move(org.eclipse.core.resources.IResource[] resources, org.eclipse.core.runtime.IPath destination, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Moves the given sibling resources so that they are located as members of the resource at the given path; the names of the new members are the same.
(package private)  void move(Resource source, org.eclipse.core.runtime.IPath destination, int depth, int updateFlags, boolean keepSyncInfo)
          Moves this resource's subtree to the destination.
protected  ResourceInfo newElement(int type)
          Create and return a new tree element of the given type.
 org.eclipse.core.resources.IProjectDescription newProjectDescription(java.lang.String projectName)
          Creates and returns a new project description for a project with the given name.
 Resource newResource(org.eclipse.core.runtime.IPath path, int type)
           
 org.eclipse.core.internal.watson.ElementTree newWorkingTree()
          Opens a new mutable element tree layer, thus allowing modifications to the tree.
protected  long nextMarkerId()
          Returns the next, previously unassigned, marker id.
 long nextModificationStamp()
           
 long nextNodeId()
           
 org.eclipse.core.runtime.IStatus open(org.eclipse.core.runtime.IProgressMonitor monitor)
          Opens this workspace using the data at its location in the local file system.
 void prepareOperation(org.eclipse.core.runtime.jobs.ISchedulingRule rule, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called before checking the pre-conditions of an operation.
protected  boolean refreshRequested()
           
 void removeResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener)
          Removes the given resource change listener from this workspace.
 void removeSaveParticipant(org.eclipse.core.runtime.Plugin plugin)
          Removes the workspace save participant for the given plug-in from this workspace.
 void run(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.IProgressMonitor monitor)
          Runs the given action as an atomic workspace operation.
 void run(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.jobs.ISchedulingRule rule, int options, org.eclipse.core.runtime.IProgressMonitor monitor)
          Runs the given action as an atomic workspace operation.
 org.eclipse.core.runtime.IStatus save(boolean full, org.eclipse.core.runtime.IProgressMonitor monitor)
          Saves this workspace's valuable state on disk.
 void setCrashed(boolean value)
           
 void setDescription(org.eclipse.core.resources.IWorkspaceDescription value)
          Sets the workspace description.
 void setTreeLocked(boolean locked)
           
 void setWorkspaceLock(org.eclipse.core.resources.WorkspaceLock lock)
          Sets the lock to use for controlling write access to this workspace.
protected  void shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 java.lang.String[] sortNatureSet(java.lang.String[] natureIds)
          Returns a copy of the given set of natures sorted in prerequisite order.
protected  void startup(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 java.lang.String toDebugString()
          Returns a string representation of this working state's structure suitable for debug purposes.
 void updateModificationStamp(ResourceInfo info)
           
 org.eclipse.core.runtime.IStatus validateEdit(org.eclipse.core.resources.IFile[] files, java.lang.Object context)
          Advises that the caller intends to modify the contents of the given files in the near future and asks whether modifying all these files would be reasonable.
 org.eclipse.core.runtime.IStatus validateLinkLocation(org.eclipse.core.resources.IResource resource, org.eclipse.core.runtime.IPath unresolvedLocation)
          Validates the given path as the location of the given resource on disk.
 org.eclipse.core.runtime.IStatus validateName(java.lang.String segment, int type)
          Validates the given string as the name of a resource valid for one of the given types.
 org.eclipse.core.runtime.IStatus validateNatureSet(java.lang.String[] natureIds)
          Validates that each of the given natures exists, and that all nature constraints are satisfied within the given set.
 org.eclipse.core.runtime.IStatus validatePath(org.eclipse.core.runtime.IPath path, int type, boolean lastSegmentOnly)
          Validates that the given workspace path is valid for the given type.
 org.eclipse.core.runtime.IStatus validatePath(java.lang.String path, int type)
          Validates the given string as a path for a resource of the given type(s).
 org.eclipse.core.runtime.IStatus validateProjectLocation(org.eclipse.core.resources.IProject context, org.eclipse.core.runtime.IPath unresolvedLocation)
          Validates the given path as the location of the given project on disk.
protected  void validateSave(org.eclipse.core.resources.IFile file)
          Internal method.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

DEBUG

public static boolean DEBUG

REFRESH_ON_STARTUP

protected static final java.lang.String REFRESH_ON_STARTUP
See Also:
Constant Field Values

description

protected WorkspacePreferences description

localMetaArea

protected LocalMetaArea localMetaArea

openFlag

protected boolean openFlag

tree

protected org.eclipse.core.internal.watson.ElementTree tree

operationTree

protected org.eclipse.core.internal.watson.ElementTree operationTree

saveManager

protected SaveManager saveManager

buildManager

protected org.eclipse.core.internal.events.BuildManager buildManager

natureManager

protected NatureManager natureManager

notificationManager

protected org.eclipse.core.internal.events.NotificationManager notificationManager

fileSystemManager

protected org.eclipse.core.internal.localstore.FileSystemResourceManager fileSystemManager

pathVariableManager

protected PathVariableManager pathVariableManager

propertyManager

protected org.eclipse.core.internal.properties.PropertyManager propertyManager

markerManager

protected MarkerManager markerManager

contentDescriptionManager

protected ContentDescriptionManager contentDescriptionManager

_workManager

protected WorkManager _workManager
Work manager should never be accessed directly because accessor asserts that workspace is still open.


aliasManager

protected AliasManager aliasManager

charsetManager

protected CharsetManager charsetManager

refreshManager

protected org.eclipse.core.internal.refresh.RefreshManager refreshManager

nextNodeId

protected long nextNodeId

nextModificationStamp

protected long nextModificationStamp

nextMarkerId

protected long nextMarkerId

synchronizer

protected Synchronizer synchronizer

buildOrder

protected org.eclipse.core.resources.IProject[] buildOrder

defaultRoot

protected org.eclipse.core.resources.IWorkspaceRoot defaultRoot

lifecycleListeners

protected final java.util.HashSet lifecycleListeners

ruleFactory

private org.eclipse.core.resources.IResourceRuleFactory ruleFactory
Scheduling rule factory


shouldValidate

protected boolean shouldValidate
File modification validation. If it is true and validator is null, we try/initialize validator first time through. If false, there is no validator.


validator

protected org.eclipse.core.resources.IFileModificationValidator validator
The currently installed file modification validator.


moveDeleteHook

protected org.eclipse.core.resources.team.IMoveDeleteHook moveDeleteHook
The currently installed Move/Delete hook.


teamHook

protected org.eclipse.core.resources.team.TeamHook teamHook
The currently installed team hook.


treeLocked

protected java.lang.Thread treeLocked
This field is used to control access to the workspace tree during resource change notifications. It tracks which thread, if any, is in the middle of a resource change notification. This is used to cause attempts to modify the workspace during notifications to fail.


crashed

protected boolean crashed
indicates if the workspace crashed in a previous session

Constructor Detail

Workspace

public Workspace()
Method Detail

aboutToBuild

protected void aboutToBuild()
                     throws org.eclipse.core.runtime.CoreException
Indicates that a build is about to occur. Broadcasts the necessary deltas before the build starts. Note that this will cause POST_BUILD to be automatically done at the end of the operation in which the build occurs.


addLifecycleListener

public void addLifecycleListener(org.eclipse.core.internal.events.ILifecycleListener listener)
Adds a listener for internal workspace lifecycle events. There is no way to remove lifecycle listeners.


addResourceChangeListener

public void addResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Adds the given listener for resource change events to this workspace. Has no effect if an identical listener is already registered.

This method is equivalent to:

 addResourceChangeListener(listener, IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE);
 

Specified by:
addResourceChangeListener in interface org.eclipse.core.resources.IWorkspace

addResourceChangeListener

public void addResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener,
                                      int eventMask)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Adds the given listener for the specified resource change events to this workspace. Has no effect if an identical listener is already registered for these events. After completion of this method, the given listener will be registered for exactly the specified events. If they were previously registered for other events, they will be deregistered.

Once registered, a listener starts receiving notification of changes to resources in the workspace. The resource deltas in the resource change event are rooted at the workspace root. Most resource change notifications occur well after the fact; the exception is pre-notification of impending project closures and deletions. The listener continues to receive notifications until it is replaced or removed.

Listeners can listen for several types of event as defined in IResourceChangeEvent. Clients are free to register for any number of event types however if they register for more than one, it is their responsibility to ensure they correctly handle the case where the same resource change shows up in multiple notifications. Clients are guaranteed to receive only the events for which they are registered.

Specified by:
addResourceChangeListener in interface org.eclipse.core.resources.IWorkspace

addSaveParticipant

public org.eclipse.core.resources.ISavedState addSaveParticipant(org.eclipse.core.runtime.Plugin plugin,
                                                                 org.eclipse.core.resources.ISaveParticipant participant)
                                                          throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Registers the given plug-in's workspace save participant, and returns an object describing the workspace state at the time of the last save in which the plug-in participated.

Once registered, the workspace save participant will actively participate in the saving of this workspace.

Specified by:
addSaveParticipant in interface org.eclipse.core.resources.IWorkspace

beginOperation

public void beginOperation(boolean createNewTree)
                    throws org.eclipse.core.runtime.CoreException

broadcastChanges

protected void broadcastChanges(int type,
                                boolean lockTree)
                         throws org.eclipse.core.runtime.CoreException

broadcastEvent

protected void broadcastEvent(org.eclipse.core.internal.events.LifecycleEvent event)
                       throws org.eclipse.core.runtime.CoreException
Broadcasts an internal workspace lifecycle event to interested internal listeners.


build

public void build(int trigger,
                  org.eclipse.core.runtime.IProgressMonitor monitor)
           throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Builds all projects in this workspace. Projects are built in the order specified in this workspace's description. Projects not mentioned in the order or for which the order cannot be determined are built in an undefined order after all other projects have been built. If no order is specified, the workspace computes an order determined by project references.

This method may change 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.

Specified by:
build in interface org.eclipse.core.resources.IWorkspace

checkpoint

public void checkpoint(boolean build)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Checkpoints the operation currently in progress. This method is used in the middle of a group of operations to force a background auto-build (if the build argument is true) and send an interim notification of resource change events.

When invoked in the dynamic scope of a call to the IWorkspace.run method, this method reports a single resource change event describing the net effect of all changes done to resources since the last round of notifications. When the outermost run method eventually completes, it will do another auto-build (if enabled) and report the resource changes made after this call.

This method has no effect if invoked outside the dynamic scope of a call to the IWorkspace.run method.

This method should be used under controlled circumstance (e.g., to break up extremely long-running operations).

Specified by:
checkpoint in interface org.eclipse.core.resources.IWorkspace

clear

public static boolean clear(java.io.File root)
Deletes all the files and directories from the given root down (inclusive). Returns false if we could not delete some file or an exception occurred at any point in the deletion. Even if an exception occurs, a best effort is made to continue deleting.


clearChildren

public static boolean clearChildren(java.io.File root)
Deletes all the files and directories from the given root down, except for the root itself. Returns false if we could not delete some file or an exception occurred at any point in the deletion. Even if an exception occurs, a best effort is made to continue deleting.


close

public void close(org.eclipse.core.runtime.IProgressMonitor monitor)
           throws org.eclipse.core.runtime.CoreException
Closes this workspace; ignored if this workspace is not open. The state of this workspace is not saved before the workspace is shut down.

If the workspace was saved immediately prior to closing, it will have the same set of projects (open or closed) when reopened for a subsequent session. Otherwise, closing a workspace may lose some or all of the changes made since the last save or snapshot.

Note that session properties are discarded when a workspace is closed.

This method is long-running; progress and cancellation are provided by the given progress monitor.


computePrerequisiteOrder

public org.eclipse.core.resources.IProject[][] computePrerequisiteOrder(org.eclipse.core.resources.IProject[] targets)
Deprecated. Replaced by IWorkspace.computeProjectOrder, which produces a more usable result when there are cycles in project reference graph.

Implementation of API method declared on IWorkspace.

Specified by:
computePrerequisiteOrder in interface org.eclipse.core.resources.IWorkspace

computePrerequisiteOrder1

private org.eclipse.core.resources.IProject[][] computePrerequisiteOrder1(org.eclipse.core.resources.IProject[] projects)

computeProjectOrder

public org.eclipse.core.resources.IWorkspace.ProjectOrder computeProjectOrder(org.eclipse.core.resources.IProject[] projects)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Computes a total ordering of the given projects based on both static and dynamic project references. If an existing and open project P references another existing and open project Q also included in the list, then Q should come before P in the resulting ordering. Closed and non-existent projects are ignored, and will not appear in the result. References to non-existent or closed projects are also ignored, as are any self-references. The total ordering is always consistent with the global total ordering of all open projects in the workspace.

When there are choices, the choice is made in a reasonably stable way. For example, given an arbitrary choice between two projects, the one with the lower collating project name is usually selected.

When the project reference graph contains cyclic references, it is impossible to honor all of the relationships. In this case, the result ignores as few relationships as possible. For example, if P2 references P1, P4 references P3, and P2 and P3 reference each other, then exactly one of the relationships between P2 and P3 will have to be ignored. The outcome will be either [P1, P2, P3, P4] or [P1, P3, P2, P4]. The result also contains complete details of any cycles present.

This method is time-consuming and should not be called unnecessarily. There are a very limited set of changes to a workspace that could affect the outcome: creating, renaming, or deleting a project; opening or closing a project; adding or removing a project reference.

Specified by:
computeProjectOrder in interface org.eclipse.core.resources.IWorkspace

computeFullProjectOrder

private org.eclipse.core.resources.IWorkspace.ProjectOrder computeFullProjectOrder()
Computes the global total ordering of all open projects in the workspace based on project references. If an existing and open project P references another existing and open project Q also included in the list, then Q should come before P in the resulting ordering. Closed and non- existent projects are ignored, and will not appear in the result. References to non-existent or closed projects are also ignored, as are any self- references.

When there are choices, the choice is made in a reasonably stable way. For example, given an arbitrary choice between two projects, the one with the lower collating project name is usually selected.

When the project reference graph contains cyclic references, it is impossible to honor all of the relationships. In this case, the result ignores as few relationships as possible. For example, if P2 references P1, P4 references P3, and P2 and P3 reference each other, then exactly one of the relationships between P2 and P3 will have to be ignored. The outcome will be either [P1, P2, P3, P4] or [P1, P3, P2, P4]. The result also contains complete details of any cycles present.

Since:
2.1

copy

public org.eclipse.core.runtime.IStatus copy(org.eclipse.core.resources.IResource[] resources,
                                             org.eclipse.core.runtime.IPath destination,
                                             int updateFlags,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Copies the given sibling resources so that they are located as members of the resource at the given path; the names of the copies are the same as the corresponding originals.

This method can be expressed as a series of calls to IResource.copy(IPath,int,IProgressMonitor), with "best effort" semantics:

  • Resources are copied in the order specified, using the given update flags.
  • Duplicate resources are only copied once.
  • The method fails if the resources are not all siblings.
  • The failure of an individual copy does not necessarily prevent the method from attempting to copy other resources.
  • The method fails if there are projects among the resources.
  • The method fails if the path of the resources is a prefix of the destination path.
  • This method also fails if one or more of the individual resource copy steps fails.

After successful completion, corresponding new resources will now exist as members of the resource at the given path.

The supplied path may be absolute or relative. Absolute paths fully specify the new location for the resource, including its project. Relative paths are considered to be relative to the container of the resources being copied. A trailing separator is ignored.

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resources have been added to the new parent.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Specified by:
copy in interface org.eclipse.core.resources.IWorkspace

copy

public org.eclipse.core.runtime.IStatus copy(org.eclipse.core.resources.IResource[] resources,
                                             org.eclipse.core.runtime.IPath destination,
                                             boolean force,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Copies the given sibling resources so that they are located as members of the resource at the given path; the names of the copies are the same as the corresponding originals.

This is a convenience method, fully equivalent to:

 copy(resources, destination, (force ? IResource.FORCE : IResource.NONE), monitor);
 

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resources have been added to the new parent.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Specified by:
copy in interface org.eclipse.core.resources.IWorkspace

copyTree

protected void copyTree(org.eclipse.core.resources.IResource source,
                        org.eclipse.core.runtime.IPath destination,
                        int depth,
                        int updateFlags,
                        boolean keepSyncInfo)
                 throws org.eclipse.core.runtime.CoreException

countResources

public int countResources(org.eclipse.core.runtime.IPath root,
                          int depth,
                          boolean phantom)
Returns the number of resources in a subtree of the resource tree.


createResource

public ResourceInfo createResource(org.eclipse.core.resources.IResource resource,
                                   ResourceInfo info,
                                   boolean phantom,
                                   boolean overwrite)
                            throws org.eclipse.core.runtime.CoreException

createResource

public ResourceInfo createResource(org.eclipse.core.resources.IResource resource,
                                   ResourceInfo info,
                                   boolean phantom,
                                   boolean overwrite,
                                   boolean keepSyncInfo)
                            throws org.eclipse.core.runtime.CoreException

createResource

public ResourceInfo createResource(org.eclipse.core.resources.IResource resource,
                                   boolean phantom)
                            throws org.eclipse.core.runtime.CoreException

createResource

public ResourceInfo createResource(org.eclipse.core.resources.IResource resource,
                                   boolean phantom,
                                   boolean overwrite)
                            throws org.eclipse.core.runtime.CoreException

defaultWorkspaceDescription

public static WorkspaceDescription defaultWorkspaceDescription()

delete

public org.eclipse.core.runtime.IStatus delete(org.eclipse.core.resources.IResource[] resources,
                                               int updateFlags,
                                               org.eclipse.core.runtime.IProgressMonitor monitor)
                                        throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Deletes the given resources.

This method can be expressed as a series of calls to IResource.delete(int,IProgressMonitor).

The semantics of multiple deletion are:

  • Resources are deleted in the order presented, using the given update flags.
  • Resources that do not exist are ignored.
  • An individual deletion fails if the resource still exists afterwards.
  • The failure of an individual deletion does not prevent the method from attempting to delete other resources.
  • This method fails if one or more of the individual resource deletions fails; that is, if at least one of the resources in the list still exists at the end of this method.

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.

Specified by:
delete in interface org.eclipse.core.resources.IWorkspace

delete

public org.eclipse.core.runtime.IStatus delete(org.eclipse.core.resources.IResource[] resources,
                                               boolean force,
                                               org.eclipse.core.runtime.IProgressMonitor monitor)
                                        throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Deletes the given resources.

This is a convenience method, fully equivalent to:

 delete(resources, IResource.KEEP_HISTORY | (force ? IResource.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.

Specified by:
delete in interface org.eclipse.core.resources.IWorkspace

deleteMarkers

public void deleteMarkers(org.eclipse.core.resources.IMarker[] markers)
                   throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Removes the given markers from the resources with which they are associated. Markers that do not exist are ignored.

This method changes resources; these changes will be reported in a subsequent resource change event.

Specified by:
deleteMarkers in interface org.eclipse.core.resources.IWorkspace

deleteResource

void deleteResource(org.eclipse.core.resources.IResource resource)
Delete the given resource from the current tree of the receiver. This method simply removes the resource from the tree. No cleanup or other management is done. Use IResource.delete for proper deletion. If the given resource is the root, all of its children (i.e., all projects) are deleted but the root is left.


dumpStats

public void dumpStats()
For debugging purposes only. Dumps plugin stats to console


endOperation

public void endOperation(org.eclipse.core.runtime.jobs.ISchedulingRule rule,
                         boolean build,
                         org.eclipse.core.runtime.IProgressMonitor monitor)
                  throws org.eclipse.core.runtime.CoreException
End an operation (group of resource changes). Notify interested parties that resource changes have taken place. All registered resource change listeners are notified. If autobuilding is enabled, a build is run.


flushBuildOrder

protected void flushBuildOrder()
Flush the build order cache for the workspace. Only needed if the description does not already have a build order. That is, if this is really a cache.


forgetSavedTree

public void forgetSavedTree(java.lang.String pluginId)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Forgets any resource tree being saved for the plug-in with the given name. If the plug-in id is null, all trees are forgotten.

Clients should not call this method unless they have a reason to do so. A plug-in which uses ISaveContext.needDelta in the process of a save indicates that it would like to be fed the resource delta the next time it is reactivated. If a plug-in never gets reactivated (or if it fails to successfully register to participate in workspace saves), the workspace nevertheless retains the necessary information to generate the resource delta if asked. This method allows such a long term leak to be plugged.

Specified by:
forgetSavedTree in interface org.eclipse.core.resources.IWorkspace

getAliasManager

public AliasManager getAliasManager()

getBuildManager

public org.eclipse.core.internal.events.BuildManager getBuildManager()
Returns this workspace's build manager


getBuildOrder

public org.eclipse.core.resources.IProject[] getBuildOrder()
Returns the order in which open projects in this workspace will be built.

The project build order is based on information specified in the workspace description. The projects are built in the order specified by IWorkspaceDescription.getBuildOrder; closed or non-existent projects are ignored and not included in the result. If IWorkspaceDescription.getBuildOrder is non-null, the default build order is used; again, only open projects are included in the result.

The returned value is cached in the buildOrder field.

Since:
2.1

getCharsetManager

public CharsetManager getCharsetManager()

getContentDescriptionManager

public ContentDescriptionManager getContentDescriptionManager()

getDanglingReferences

public java.util.Map getDanglingReferences()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Finds all dangling project references in this workspace. Projects which are not open are ignored. Returns a map with one entry for each open project in the workspace that has at least one dangling project reference; the value of the entry is an array of projects which are referenced by that project but do not exist in the workspace. Returns an empty Map if there are no projects in the workspace.

Specified by:
getDanglingReferences in interface org.eclipse.core.resources.IWorkspace

getDescription

public org.eclipse.core.resources.IWorkspaceDescription getDescription()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns the workspace description. This object is responsible for defining workspace preferences. The returned value is a modifiable copy but changes are not automatically applied to the workspace. In order to changes take effect, IWorkspace.setDescription needs to be called. The workspace description values are store in the preference store.

Specified by:
getDescription in interface org.eclipse.core.resources.IWorkspace

getElementTree

public org.eclipse.core.internal.watson.ElementTree getElementTree()
Returns the current element tree for this workspace


getFileSystemManager

public org.eclipse.core.internal.localstore.FileSystemResourceManager getFileSystemManager()

getMarkerManager

public MarkerManager getMarkerManager()
Returns the marker manager for this workspace


getMetaArea

public LocalMetaArea getMetaArea()

getMoveDeleteHook

protected org.eclipse.core.resources.team.IMoveDeleteHook getMoveDeleteHook()

getNatureDescriptor

public org.eclipse.core.resources.IProjectNatureDescriptor getNatureDescriptor(java.lang.String natureId)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns the nature descriptor with the given unique identifier, or null if there is no such nature.

Specified by:
getNatureDescriptor in interface org.eclipse.core.resources.IWorkspace

getNatureDescriptors

public org.eclipse.core.resources.IProjectNatureDescriptor[] getNatureDescriptors()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns all nature descriptors known to this workspace. Returns an empty array if there are no installed natures.

Specified by:
getNatureDescriptors in interface org.eclipse.core.resources.IWorkspace

getNatureManager

public NatureManager getNatureManager()
Returns the nature manager for this workspace.


getNotificationManager

public org.eclipse.core.internal.events.NotificationManager getNotificationManager()

getPathVariableManager

public org.eclipse.core.resources.IPathVariableManager getPathVariableManager()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns the path variable manager for this workspace.

Specified by:
getPathVariableManager in interface org.eclipse.core.resources.IWorkspace

getPropertyManager

public org.eclipse.core.internal.properties.PropertyManager getPropertyManager()

getRefreshManager

public org.eclipse.core.internal.refresh.RefreshManager getRefreshManager()
Returns the refresh manager for this workspace


getResourceInfo

public ResourceInfo getResourceInfo(org.eclipse.core.runtime.IPath path,
                                    boolean phantom,
                                    boolean mutable)
Returns the resource info for the identified resource. null is returned if no such resource can be found. If the phantom flag is true, phantom resources are considered. If the mutable flag is true, the info is opened for change. This method DOES NOT throw an exception if the resource is not found.


getRoot

public org.eclipse.core.resources.IWorkspaceRoot getRoot()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns the root resource of this workspace.

Specified by:
getRoot in interface org.eclipse.core.resources.IWorkspace

getRuleFactory

public org.eclipse.core.resources.IResourceRuleFactory getRuleFactory()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns a factory for obtaining scheduling rules prior to modifying resources in the workspace.

Specified by:
getRuleFactory in interface org.eclipse.core.resources.IWorkspace

getSaveManager

public SaveManager getSaveManager()

getSynchronizer

public org.eclipse.core.resources.ISynchronizer getSynchronizer()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns the synchronizer for this workspace.

Specified by:
getSynchronizer in interface org.eclipse.core.resources.IWorkspace

getTeamHook

protected org.eclipse.core.resources.team.TeamHook getTeamHook()
Returns the installed team hook. Never returns null.


getWorkManager

public WorkManager getWorkManager()
                           throws org.eclipse.core.runtime.CoreException
We should not have direct references to this field. All references should go through this method.


initializeValidator

protected void initializeValidator()
A file modification validator hasn't been initialized. Check the extension point and try to create a new validator if a user has one defined as an extension.


initializeMoveDeleteHook

protected void initializeMoveDeleteHook()
A move/delete hook hasn't been initialized. Check the extension point and try to create a new hook if a user has one defined as an extension. Otherwise use the Core's implementation as the default.


initializeTeamHook

protected void initializeTeamHook()
A team hook hasn't been initialized. Check the extension point and try to create a new hook if a user has one defined as an extension. Otherwise use the Core's implementation as the default.


internalGetDescription

public WorkspaceDescription internalGetDescription()

isAutoBuilding

public boolean isAutoBuilding()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns whether this workspace performs auto-builds.

Specified by:
isAutoBuilding in interface org.eclipse.core.resources.IWorkspace

isDuplicate

private static boolean isDuplicate(java.lang.Object[] array,
                                   int position)
Returns true if the object at the specified position has any other copy in the given array.


isOpen

public boolean isOpen()

isOverlapping

protected boolean isOverlapping(org.eclipse.core.runtime.IPath location1,
                                org.eclipse.core.runtime.IPath location2,
                                boolean bothDirections)
Returns true if the given file system locations overlap. If "bothDirections" is true, this means they are the same, or one is a proper prefix of the other. If "bothDirections" is false, this method only returns true if the locations are the same, or the first location is a prefix of the second. Returns false if the locations do not overlap Does the right thing with respect to case insensitive platforms.


isTreeLocked

public boolean isTreeLocked()
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns whether the workspace tree is currently locked. Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.

Specified by:
isTreeLocked in interface org.eclipse.core.resources.IWorkspace

linkTrees

protected void linkTrees(org.eclipse.core.runtime.IPath path,
                         org.eclipse.core.internal.watson.ElementTree[] newTrees)
Link the given tree into the receiver's tree at the specified resource.


loadProjectDescription

public org.eclipse.core.resources.IProjectDescription loadProjectDescription(org.eclipse.core.runtime.IPath path)
                                                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Reads the project description file (".project") from the given location in the local file system. This object is useful for discovering the correct name for a project before importing it into the workspace.

The returned value is writeable.

Specified by:
loadProjectDescription in interface org.eclipse.core.resources.IWorkspace

move

public org.eclipse.core.runtime.IStatus move(org.eclipse.core.resources.IResource[] resources,
                                             org.eclipse.core.runtime.IPath destination,
                                             int updateFlags,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Moves the given sibling resources so that they are located as members of the resource at the given path; the names of the new members are the same.

This method can be expressed as a series of calls to IResource.move, with "best effort" semantics:

  • Resources are moved in the order specified.
  • Duplicate resources are only moved once.
  • The force flag has the same meaning as it does on the corresponding single-resource method.
  • The method fails if the resources are not all siblings.
  • The method fails the path of any of the resources is a prefix of the destination path.
  • The failure of an individual move does not necessarily prevent the method from attempting to move other resources.
  • This method also fails if one or more of the individual resource moves fails; that is, if at least one of the resources in the list still exists at the end of this method.
  • History is kept for moved files. When projects are moved, no history is kept

After successful completion, the resources and descendents will no longer exist; but corresponding new resources will now exist as members of the resource at the given path.

The supplied path may be absolute or relative. Absolute paths fully specify the new location for the resource, including its project. Relative paths are considered to be relative to the container of the resources being moved. A trailing separator is ignored.

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resources have been removed from their parent and that corresponding resources have been added to the new parent. Additional information provided with resource delta shows that these additions and removals are pairwise related.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Specified by:
move in interface org.eclipse.core.resources.IWorkspace

move

public org.eclipse.core.runtime.IStatus move(org.eclipse.core.resources.IResource[] resources,
                                             org.eclipse.core.runtime.IPath destination,
                                             boolean force,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Moves the given sibling resources so that they are located as members of the resource at the given path; the names of the new members are the same.

This is a convenience method, fully equivalent to:

 move(resources, destination, IResource.KEEP_HISTORY | (force ? IResource.FORCE : IResource.NONE), monitor);
 

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resources have been removed from their parent and that corresponding resources have been added to the new parent. Additional information provided with resource delta shows that these additions and removals are pairwise related.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Specified by:
move in interface org.eclipse.core.resources.IWorkspace

move

void move(Resource source,
          org.eclipse.core.runtime.IPath destination,
          int depth,
          int updateFlags,
          boolean keepSyncInfo)
    throws org.eclipse.core.runtime.CoreException
Moves this resource's subtree to the destination. This operation should only be used by move methods. Destination must be a valid destination for this resource. The keepSyncInfo boolean is used to indicated whether or not the sync info should be moved from the source to the destination.


newElement

protected ResourceInfo newElement(int type)
Create and return a new tree element of the given type.


newProjectDescription

public org.eclipse.core.resources.IProjectDescription newProjectDescription(java.lang.String projectName)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Creates and returns a new project description for a project with the given name. This object is useful when creating, moving or copying projects.

The project description is initialized to:

  • the given project name
  • no references to other projects
  • an empty build spec
  • an empty comment

The returned value is writeable.

Specified by:
newProjectDescription in interface org.eclipse.core.resources.IWorkspace

newResource

public Resource newResource(org.eclipse.core.runtime.IPath path,
                            int type)

newWorkingTree

public org.eclipse.core.internal.watson.ElementTree newWorkingTree()
Opens a new mutable element tree layer, thus allowing modifications to the tree.


nextMarkerId

protected long nextMarkerId()
Returns the next, previously unassigned, marker id.


nextModificationStamp

public long nextModificationStamp()

nextNodeId

public long nextNodeId()

open

public org.eclipse.core.runtime.IStatus open(org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Opens this workspace using the data at its location in the local file system. This workspace must not be open. If the operation succeeds, the result will detail any serious (but non-fatal) problems encountered while opening the workspace. The status code will be OK if there were no problems. An exception is thrown if there are fatal problems opening the workspace, in which case the workspace is left closed.

This method is long-running; progress and cancellation are provided by the given progress monitor.


prepareOperation

public void prepareOperation(org.eclipse.core.runtime.jobs.ISchedulingRule rule,
                             org.eclipse.core.runtime.IProgressMonitor monitor)
                      throws org.eclipse.core.runtime.CoreException
Called before checking the pre-conditions of an operation. Optionally supply a scheduling rule to determine when the operation is safe to run. If a scheduling rule is supplied, this method will block until it is safe to run.


refreshRequested

protected boolean refreshRequested()

removeResourceChangeListener

public void removeResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener listener)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Removes the given resource change listener from this workspace. Has no effect if an identical listener is not registered.

Specified by:
removeResourceChangeListener in interface org.eclipse.core.resources.IWorkspace

removeSaveParticipant

public void removeSaveParticipant(org.eclipse.core.runtime.Plugin plugin)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Removes the workspace save participant for the given plug-in from this workspace. If no such participant is registered, no action is taken.

Once removed, the workspace save participant no longer actively participates in any future saves of this workspace.

Specified by:
removeSaveParticipant in interface org.eclipse.core.resources.IWorkspace

run

public void run(org.eclipse.core.resources.IWorkspaceRunnable action,
                org.eclipse.core.runtime.jobs.ISchedulingRule rule,
                int options,
                org.eclipse.core.runtime.IProgressMonitor monitor)
         throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Runs the given action as an atomic workspace operation.

After running a method that modifies resources in the workspace, registered listeners receive after-the-fact notification of what just transpired, in the form of a resource change event. This method allows clients to call a number of methods that modify resources and only have resource change event notifications reported at the end of the entire batch.

If this method is called outside the dynamic scope of another such call, this method runs the action and then reports a single resource change event describing the net effect of all changes done to resources by the action.

If this method is called in the dynamic scope of another such call, this method simply runs the action.

The supplied scheduling rule is used to determine whether this operation can be run simultaneously with workspace changes in other threads. If the scheduling rule conflicts with another workspace change that is currently running, the calling thread will be blocked until that change completes. If the action attempts to make changes to the workspace that were not specified in the scheduling rule, it will fail. If no scheduling rule is supplied, then any attempt to change resources will fail. If a non-null scheduling rule is supplied, this operation must always support cancelation in the case where this operation becomes blocked by a long running background operation.

The AVOID_UPDATE flag controls whether periodic resource change notifications should occur during the scope of this call. If this flag is specified, and no other threads modify the workspace concurrently, then all resource change notifications will be deferred until the end of this call. If this flag is not specified, the platform may decide to broadcast periodic resource change notifications during the scope of this call.

Flags other than AVOID_UPDATE are ignored.

Specified by:
run in interface org.eclipse.core.resources.IWorkspace

run

public void run(org.eclipse.core.resources.IWorkspaceRunnable action,
                org.eclipse.core.runtime.IProgressMonitor monitor)
         throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Runs the given action as an atomic workspace operation.

This is a convenience method, fully equivalent to:

 workspace.run(action, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
 

Specified by:
run in interface org.eclipse.core.resources.IWorkspace

save

public org.eclipse.core.runtime.IStatus save(boolean full,
                                             org.eclipse.core.runtime.IProgressMonitor monitor)
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Saves this workspace's valuable state on disk. Consults with all registered plug-ins so that they can coordinate the saving of their persistent state as well.

The full parameter indicates whether a full save or a snapshot is being requested. Snapshots save the workspace information that is considered hard to be recomputed in the unlikely event of a crash. It includes parts of the workspace tree, workspace and projects descriptions, markers and sync infos. Full saves are heavy weight operations which save the complete workspace state.

To ensure that all outstanding changes to the workspace have been reported to interested parties prior to saving, a full save cannot be used within the dynamic scope of an IWorkspace.run invocation. Snapshots can be called anytime and are interpreted by the workspace as a hint that a snapshot is required. The workspace will perform the snapshot when possible. Even as a hint, snapshots should only be called when necessary as they impact system performance. Although saving does not change the workspace per se, its execution is serialized like methods that write the workspace.

The workspace is comprised of several different kinds of data with varying degrees of importance. The most important data, the resources themselves and their persistent properties, are written to disk immediately; other data are kept in volatile memory and only written to disk periodically; and other data are maintained in memory and never written out. The following table summarizes what gets saved when:

  • creating or deleting resource - immediately
  • setting contents of file - immediately
  • changes to project description - immediately
  • session properties - never
  • changes to persistent properties - immediately
  • markers -save
  • synchronizer info -save
  • shape of the workspace resource tree -save
  • list of active plug-ins - never
Resource-based plug-in also have data with varying degrees of importance. Each plug-in gets to decide the policy for protecting its data, either immediately, never, or at save time. For the latter, the plug-in coordinates its actions with the workspace (see ISaveParticipant for details).

If the platform is shutdown (or crashes) after saving the workspace, any information written to disk by the last successful workspace save will be restored the next time the workspace is reopened for the next session. Naturally, information that is written to disk immediately will be as of the last time it was changed.

The workspace provides a general mechanism for keeping concerned parties apprised of any and all changes to resources in the workspace ( IResourceChangeListener). It is even possible for a plug-in to find out about changes to resources that happen between workspace sessions (see IWorkspace.addSaveParticipant).

At certain points during this method, the entire workspace resource tree must be locked to prevent resources from being changed (read access to resources is permitted).

Implementation note: The execution sequence is as follows.

  • A long-term lock on the workspace is taken out to prevent further changes to workspace until the save is done.
  • The list of saveable resource tree snapshots is initially empty.
  • A different ISaveContext object is created for each registered workspace save participant plug-in, reflecting the kind of save (ISaveContext.getKind), the previous save number in which this plug-in actively participated, and the new save number (= previous save number plus 1).
  • Each registered workspace save participant is sent prepareToSave(context), passing in its own context object.
    • Plug-in suspends all activities until further notice.
    If prepareToSave fails (throws an exception), the problem is logged and the participant is marked as unstable.
  • In dependent-before-prerequisite order, each registered workspace save participant is sent saving(context), passing in its own context object.
    • Plug-in decides whether it wants to actively participate in this save. The plug-in only needs to actively participate if some of its important state has changed since the last time it actively participated. If it does decide to actively participate, it writes its important state to a brand new file in its plug-in state area under a generated file name based on context.getStateNumber() and calls context.needStateNumber() to indicate that it has actively participated. If upon reactivation the plug-in will want a resource delta covering all changes between now and then, the plug-in should invoke context.needDelta() to request this now; otherwise, a resource delta for the intervening period will not be available on reactivation.
    If saving fails (throws an exception), the problem is logged and the participant is marked as unstable.
  • The plug-in save table contains an entry for each plug-in that has registered to participate in workspace saves at some time in the past (the list of plug-ins increases monotonically). Each entry records the save number of the last successful save in which that plug-in actively participated, and, optionally, a saved resource tree (conceptually, this is a complete tree; in practice, it is compressed into a special delta tree representation). A copy of the plug-in save table is made. Entries are created or modified for each registered plug-in to record the appropriate save number (either the previous save number, or the previous save number plus 1, depending on whether the participant was active and asked for a new number).
  • The workspace tree, the modified copy of the plug-in save table, all markers, etc. and all saveable resource tree snapshots are written to disk as one atomic operation .
  • The long-term lock on the workspace is released.
  • If the atomic save succeeded:
    • The modified copy of the plug-in save table becomes the new plug-in save table.
    • In prerequisite-before-dependent order, each registered workspace save participant is sent doneSaving(context), passing in its own context object.
      • Plug-in may perform clean up by deleting obsolete state files in its plug-in state area.
      • Plug-in resumes its normal activities.
      If doneSaving fails (throws an exception), the problem is logged and the participant is marked as unstable. (The state number in the save table is not rolled back just because of this instability.)
    • The workspace save operation returns.
  • If it failed:
    • The workspace previous state is restored.
    • In prerequisite-before-dependent order, each registered workspace save participant is sent rollback(context), passing in its own context object.
      • Plug-in may perform clean up by deleting newly-created but obsolete state file in its plug-in state area.
      • Plug-in resumes its normal activities.
      If rollback fails (throws an exception), the problem is logged and the participant is marked as unstable. (The state number in the save table is rolled back anyway.)
    • The workspace save operation fails.

After a full save, the platform can be shutdown. This will cause the Resources plug-in and all the other plug-ins to shutdown, without disturbing the saved workspace on disk.

When the platform is later restarted, activating the Resources plug-in opens the saved workspace. This reads into memory the workspace's resource tree, plug-in save table, and saved resource tree snapshots (everything that was written to disk in the atomic operation above). Later, when a plug-in gets reactivated and registers to participate in workspace saves, it is handed back the info from its entry in the plug-in save table, if it has one. It gets back the number of the last save in which it actively participated and, possibly, a resource delta.

The only source of long term garbage would come from a plug-in that never gets reactivated, or one that gets reactivated but fails to register for workspace saves. (There is no such problem with a plug-in that gets uninstalled; its easy enough to scrub its state areas and delete its entry in the plug-in save table.)

Specified by:
save in interface org.eclipse.core.resources.IWorkspace

setCrashed

public void setCrashed(boolean value)

setDescription

public void setDescription(org.eclipse.core.resources.IWorkspaceDescription value)
                    throws org.eclipse.core.runtime.CoreException
Description copied from interface: org.eclipse.core.resources.IWorkspace
Sets the workspace description. Its values are stored in the preference store.

Specified by:
setDescription in interface org.eclipse.core.resources.IWorkspace

setTreeLocked

public void setTreeLocked(boolean locked)

setWorkspaceLock

public void setWorkspaceLock(org.eclipse.core.resources.WorkspaceLock lock)
Deprecated.  

Description copied from interface: org.eclipse.core.resources.IWorkspace
Sets the lock to use for controlling write access to this workspace. The lock must only be set once.

This method is for internal use by the platform-related plug-ins. Clients should not call this method.

Specified by:
setWorkspaceLock in interface org.eclipse.core.resources.IWorkspace

shutdown

protected void shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
                 throws org.eclipse.core.runtime.CoreException

sortNatureSet

public java.lang.String[] sortNatureSet(java.lang.String[] natureIds)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Returns a copy of the given set of natures sorted in prerequisite order. For each nature, it is guaranteed that all of its prerequisites will preceed it in the resulting array.

Natures that are missing from the install or are involved in a prerequisite cycle are sorted arbitrarily. Duplicate nature IDs are removed, so the returned array may be smaller than the original.

Specified by:
sortNatureSet in interface org.eclipse.core.resources.IWorkspace

startup

protected void startup(org.eclipse.core.runtime.IProgressMonitor monitor)
                throws org.eclipse.core.runtime.CoreException

toDebugString

public java.lang.String toDebugString()
Returns a string representation of this working state's structure suitable for debug purposes.


updateModificationStamp

public void updateModificationStamp(ResourceInfo info)

validateEdit

public org.eclipse.core.runtime.IStatus validateEdit(org.eclipse.core.resources.IFile[] files,
                                                     java.lang.Object context)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Advises that the caller intends to modify the contents of the given files in the near future and asks whether modifying all these files would be reasonable. The files must all exist. This method is used to give the VCM component an opportunity to check out (or otherwise prepare) the files if required. (It is provided in this component rather than in the UI so that "core" (i.e., head-less) clients can use it. Similarly, it is located outside the VCM component for the convenience of clients that must also operate in configurations without VCM.)

A client (such as an editor) should perform a validateEdit on a file whenever it finds itself in the following position: (a) the file is marked read-only, and (b) the client believes it likely (not necessarily certain) that it will modify the file's contents at some point. A case in point is an editor that has a buffer opened on a file. When the user starts to dirty the buffer, the editor should check to see whether the file is read-only. If it is, it should call validateEdit, and can reasonably expect this call, when successful, to cause the file to become read-write. An editor should also be sensitive to a file becoming read-only again even after a successful validateEdit (e.g., due to the user checking in the file in a different view); the editor should again call validateEdit if the file is read-only before attempting to save the contents of the file.

By passing a UI context, the caller indicates that the VCM component may contact the user to help decide how best to proceed. If no UI context is provided, the VCM component will make its decision without additional interaction with the user. If OK is returned, the caller can safely assume that all of the given files haven been prepared for modification and that there is good reason to believe that IFile.setContents (or appendContents) would be successful on any of them. If the result is not OK, modifying the given files might not succeed for the reason(s) indicated.

If a shell is passed in as the context, the VCM component may bring up a dialogs to query the user or report difficulties; the shell should be used to parent any such dialogs; the caller may safely assume that the reasons for failure will have been made clear to the user. If null is passed, the user should not be contacted; any failures should be reported via the result; the caller may chose to present these to the user however they see fit. The ideal implementation of this method is transactional; no files would be affected unless the go-ahead could be given. (In practice, there may be no feasible way to ensure such changes get done atomically.)

The method calls IFileModificationValidator.validateEdit for the file modification validator (if provided by the VCM plug-in). When there is no file modification validator, this method returns a status with an IResourceStatus.READ_ONLY_LOCAL code if one of the files is read-only, and a status with an IStatus.OK code otherwise.

This method may be called from any thread. If the UI context is used, it is the responsibility of the implementor of IFileModificationValidator.validateEdit to interact with the UI context in an appropriate thread.

Specified by:
validateEdit in interface org.eclipse.core.resources.IWorkspace

validateLinkLocation

public org.eclipse.core.runtime.IStatus validateLinkLocation(org.eclipse.core.resources.IResource resource,
                                                             org.eclipse.core.runtime.IPath unresolvedLocation)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Validates the given path as the location of the given resource on disk. The path must be either an absolute file system path, or a relative path whose first segment is the name of a defined workspace path variable. In addition to the restrictions for paths in general (see IPath. isValidPath), a link location must also obey the following rules:
  • must not overlap with the platform's metadata directory
  • must not be the same as or a parent of the root directory of the project the linked resource is contained in

This method also checks that the given resource can legally become a linked resource. This includes the following restrictions:

  • must have a project as its immediate parent
  • project natures and the team hook may disallow linked resources on projects they are associated with
  • the global workspace preference to disable linking, ResourcesPlugin.PREF_DISABLE_LINKING must not be set to "true"
  • .

This method will return a status with severity IStatus.ERROR if the location does not obey the above rules. Also, this method will return a status with severity IStatus.WARNING if the location overlaps the location of any existing resource in the workspace.

Note: this method does not consider whether files or directories exist in the filesystem at the specified path.

Specified by:
validateLinkLocation in interface org.eclipse.core.resources.IWorkspace

validateName

public org.eclipse.core.runtime.IStatus validateName(java.lang.String segment,
                                                     int type)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Validates the given string as the name of a resource valid for one of the given types.

In addition to the basic restrictions on paths in general (see IPath.isValidSegment), a resource name must also obey the following rules:

  • it must not be empty
  • it must not be a single period character (".")
  • it must not contain two or more consecutive period characters
  • it must not end in a period character
  • it must not contain any characters or substrings that are not valid on the filesystem on which workspace root is located.

This validation check is done automatically as a resource is created (but not when the resource handle is constructed); this means that any resource that exists can be safely assumed to have a valid name and path. Note that the name of the workspace root resource is inherently invalid.

Specified by:
validateName in interface org.eclipse.core.resources.IWorkspace

validateNatureSet

public org.eclipse.core.runtime.IStatus validateNatureSet(java.lang.String[] natureIds)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Validates that each of the given natures exists, and that all nature constraints are satisfied within the given set.

The following conditions apply to validation of a set of natures:

  • all natures in the set exist in the plug-in registry
  • all prerequisites of each nature are present in the set
  • there are no cycles in the prerequisite graph of the set
  • there are no two natures in the set that specify one-of-nature inclusion in the same group.
  • there are no two natures in the set with the same id

An empty nature set is always valid.

Specified by:
validateNatureSet in interface org.eclipse.core.resources.IWorkspace

validatePath

public org.eclipse.core.runtime.IStatus validatePath(java.lang.String path,
                                                     int type)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Validates the given string as a path for a resource of the given type(s).

In addition to the restrictions for paths in general (see IPath.isValidPath), a resource path should also obey the following rules:

  • a resource path should be an absolute path with no device id
  • its segments should be valid names according to validateName
  • a path for the workspace root must be the canonical root path
  • a path for a project should have exactly 1 segment
  • a path for a file or folder should have more than 1 segment
  • the first segment should be a valid project name
  • the second through penultimate segments should be valid folder names
  • the last segment should be a valid name of the given type

Note: this method does not consider whether a resource at the specified path exists.

This validation check is done automatically as a resource is created (but not when the resource handle is constructed); this means that any resource that exists can be safely assumed to have a valid name and path.

Specified by:
validatePath in interface org.eclipse.core.resources.IWorkspace

validatePath

public org.eclipse.core.runtime.IStatus validatePath(org.eclipse.core.runtime.IPath path,
                                                     int type,
                                                     boolean lastSegmentOnly)
Validates that the given workspace path is valid for the given type. If lastSegmentOnly is true, it is assumed that all segments except the last one have previously been validated. This is an optimization for validating a leaf resource when it is known that the parent exists (and thus its parent path must already be valid).


validateProjectLocation

public org.eclipse.core.runtime.IStatus validateProjectLocation(org.eclipse.core.resources.IProject context,
                                                                org.eclipse.core.runtime.IPath unresolvedLocation)
Description copied from interface: org.eclipse.core.resources.IWorkspace
Validates the given path as the location of the given project on disk. The path must be either an absolute file system path, or a relative path whose first segment is the name of a defined workspace path variable. In addition to the restrictions for paths in general (see IPath. isValidPath), a location path should also obey the following rules:
  • must not overlap with another open or closed project
  • must not overlap with the platform's working directory
  • must not be the same as or a child of the location of any existing linked resource in the given project

Note: this method does not consider whether files or directories exist in the filesystem at the specified path.

Specified by:
validateProjectLocation in interface org.eclipse.core.resources.IWorkspace

validateSave

protected void validateSave(org.eclipse.core.resources.IFile file)
                     throws org.eclipse.core.runtime.CoreException
Internal method. To be called only from the following methods:
  • IFile#appendContents
  • IFile#setContents(InputStream, boolean, boolean, IProgressMonitor)
  • IFile#setContents(IFileState, boolean, boolean, IProgressMonitor)