|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.workspace.util.WorkspaceSynchronizer
public final class WorkspaceSynchronizer
A utility object that listens to workspace resource changes to synchronize the state of an EMF resource set with the workspace.
The default behaviour on workspace resource deletions is to unload the corresponding EMF resource. The default behaviour on resource changes is to unload and reload the corresponding EMF resource, unless the resource path has changed (by move or rename), in which case it is simply unloaded.
To customize the behaviour of the synchronizer, initialize it with a
delegate
that provides the required
behaviour. For example, it might be more user-friendly to prompt the user
before taking drastic measures.
Whether implemented by a delegate or not, the synchronization algorithm is invoked asynchronously (as a job) and in a read-only transaction on the synchronizer's editing domain. This ensures timely completion of the workspace's event dispatching and exclusive access to the resource set according to the transaction protocol. Also, the job is scheduled on the workspace rule, so that the delegate call-backs are free to read or modify any resources that they may need.
Nested Class Summary | |
---|---|
static interface |
WorkspaceSynchronizer.Delegate
Call-back interface for an object to which a WorkspaceSynchronizer
delegates the algorithms for handling different kinds of resource
changes. |
Constructor Summary | |
---|---|
WorkspaceSynchronizer(TransactionalEditingDomain domain)
Initializes me with the editing domain for which I synchronize resources, using the default change-handling behaviour. |
|
WorkspaceSynchronizer(TransactionalEditingDomain domain,
WorkspaceSynchronizer.Delegate delegate)
Initializes me with the editing domain for which I synchronize resources, using the specified delegate to handle resource changes. |
Method Summary | |
---|---|
void |
dispose()
Disposes me, in particular disconnecting me from the workspace so that I no longer respond to resource change events. |
TransactionalEditingDomain |
getEditingDomain()
Queries the editing domain whose resources I synchronize with the workspace. |
static IFile |
getFile(Resource resource)
Obtains the workspace file corresponding to the specified resource, if it has a platform-resource URI. |
static IFile |
getUnderlyingFile(Resource resource)
Obtains the workspace file underlying the specified resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkspaceSynchronizer(TransactionalEditingDomain domain)
I immediately start listening for workspace resource changes.
domain
- my domain (must not be null
)public WorkspaceSynchronizer(TransactionalEditingDomain domain, WorkspaceSynchronizer.Delegate delegate)
I immediately start listening for workspace resource changes.
domain
- my domain (must not be null
)delegate
- the delegate that handles my resource changes, or
null
to get the default behaviourMethod Detail |
---|
public TransactionalEditingDomain getEditingDomain()
public void dispose()
public static IFile getFile(Resource resource)
null
, may nonetheless not actually exist (as the file is
just a handle).
Note that, if the resource is in an archive (such as a ZIP file)
then it does not map to a workspace file. In this case, however, the
workspace file (if any) corresponding to the containing archive can be
obtained via the getUnderlyingFile(Resource)
method.
resource
- an EMF resource
null
if the
resource's URI is not a platform-resource URIgetUnderlyingFile(Resource)
public static IFile getUnderlyingFile(Resource resource)
archive
scheme, the
authority is considered instead.
If the URI has a file scheme, it's looked up in the workspace, just as
in the getFile(Resource)
method.
Otherwise, a platform scheme is assumed.
Note that the resulting file, if not
null
, may nonetheless not actually exist (as the file is
just a handle).
resource
- an EMF resource
null
if the
resource's URI is not a platform-resource URIgetFile(Resource)
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |