public class ResourceSaveIndicator extends java.lang.Object implements IResourceSaveIndicator
This implementation also encapsulate a ResourceSetListener whose behavior can be assimilated to an object changed listener since when it is notified (synchronously, at the end of a transaction) it asks affected resources (i.e. resources containing model modifications) to be marked as dirty. Once created, that listener is added as a resource set listener on the editing domain this indicator is associated to.
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.emf.transaction.ResourceSetListener |
objectChangedListener
The listener that is notified when a model is modified.
|
Constructor and Description |
---|
ResourceSaveIndicator(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addTransactionalEditingDomainListeners()
Adds the object changed listener on the
editing domain this indicator is
associated to.
|
protected org.eclipse.emf.transaction.ResourceSetListener |
createObjectChangedListener()
Creates the listener that must be used as object changed listener in
order to ask affected resources to be marked as dirty.
|
void |
dispose() |
protected java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getAffectedResources(org.eclipse.emf.transaction.ResourceSetChangeEvent event)
Returns the
resource s that are affected by given resource set change event. |
java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getDirtyResources()
Returns all
resource s in underlying editing domain which are currently
dirty. |
boolean |
handleResourceChanged(org.eclipse.emf.ecore.resource.Resource resource) |
boolean |
handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource) |
boolean |
handleResourceMoved(org.eclipse.emf.ecore.resource.Resource resource,
org.eclipse.emf.common.util.URI newURI) |
boolean |
isDirty(org.eclipse.emf.ecore.resource.Resource resource)
Determines if the given
resource is dirty. |
boolean |
isSaved(org.eclipse.emf.common.util.URI uri)
Test if the
resource behind given URI has just been saved. |
protected void |
removeTransactionalEditingDomainListeners()
Removes the object changed listener from the
editing domain this indicator is
associated to.
|
void |
setDirty(org.eclipse.emf.ecore.resource.Resource resource)
Makes the given
resource dirty. |
void |
setSaved(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
Clears dirty state of given collection of
resource s and remembers them as having just been
saved. |
void |
setSaved(org.eclipse.emf.ecore.resource.Resource resource)
Clears dirty state of given
resource and remembers it as having just been saved. |
void |
unsetDirty(org.eclipse.emf.ecore.resource.Resource resource)
Makes the given
resource un-dirty. |
protected org.eclipse.emf.transaction.ResourceSetListener objectChangedListener
public ResourceSaveIndicator(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
Asks for the creation and the add of a listener on the specified editing domain. This listener is a ResourceSetListener and can be seen as an object changed listener since it will be notified each time a model is modified.
editingDomain
- The editing domain this indicator must be associated to.public void dispose()
dispose
in interface org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate
protected void addTransactionalEditingDomainListeners()
protected void removeTransactionalEditingDomainListeners()
protected org.eclipse.emf.transaction.ResourceSetListener createObjectChangedListener()
This listener is a ResourceSetListener whose notification filters are:
protected java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getAffectedResources(org.eclipse.emf.transaction.ResourceSetChangeEvent event)
resource
s that are affected by given resource set change event.event
- The resource set change event
to be evaluated.public boolean handleResourceChanged(org.eclipse.emf.ecore.resource.Resource resource)
handleResourceChanged
in interface org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate
public boolean handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource)
handleResourceDeleted
in interface org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate
public boolean handleResourceMoved(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.emf.common.util.URI newURI)
handleResourceMoved
in interface org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate
public boolean isDirty(org.eclipse.emf.ecore.resource.Resource resource)
IResourceSaveIndicator
resource
is dirty. A resource
is considered dirty if
its content has been modified but not been saved yet.isDirty
in interface IResourceSaveIndicator
resource
- The resource
to be investigated.true
if specified resource
is dirty, or false
otherwise.IResourceSaveIndicator.setDirty(Resource)
,
IResourceSaveIndicator.getDirtyResources()
,
IResourceSaveIndicator.setSaved(Resource)
public void setDirty(org.eclipse.emf.ecore.resource.Resource resource)
IResourceSaveIndicator
resource
dirty.setDirty
in interface IResourceSaveIndicator
resource
- The resource
to be handled.IResourceSaveIndicator.isDirty(Resource)
,
IResourceSaveIndicator.unsetDirty(Resource)
,
IResourceSaveIndicator.getDirtyResources()
public void unsetDirty(org.eclipse.emf.ecore.resource.Resource resource)
IResourceSaveIndicator
resource
un-dirty.unsetDirty
in interface IResourceSaveIndicator
resource
- The resource
to be handled.IResourceSaveIndicator.isDirty(Resource)
,
IResourceSaveIndicator.setDirty(Resource)
,
IResourceSaveIndicator.getDirtyResources()
public java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getDirtyResources()
IResourceSaveIndicator
resource
s in underlying editing domain
which are currently
dirty.getDirtyResources
in interface IResourceSaveIndicator
resource
s with are currently dirty, or and empty collection if no
dirty resources exist.IResourceSaveIndicator.isDirty(Resource)
,
IResourceSaveIndicator.setDirty(Resource)
,
IResourceSaveIndicator.setSaved(Collection)
public boolean isSaved(org.eclipse.emf.common.util.URI uri)
IResourceSaveIndicator
resource
behind given URI
has just been saved. This method typically needs
to be called when an resource change event
indicates that the content of the
file
behind given URI
has changed. Based on the returned result the caller can determine if
a resource change event
is just a consequence of a preceding save operation or if
the file
's content has been changed otherwise (e.g., via a text editor or some other tool affecting
the resource
in its serialized form).isSaved
in interface IResourceSaveIndicator
uri
- The URI
of the resource
to be investigated.true
if given resource
has just been saved, or false
otherwise.IResourceSaveIndicator.setSaved(Resource)
,
IResourceSaveIndicator.setSaved(Collection)
public void setSaved(org.eclipse.emf.ecore.resource.Resource resource)
IResourceSaveIndicator
resource
and remembers it as having just been saved. This method
needs to be called by all clients which perform a save operation of some resource
right after
the save operation has been completed. Clients can then call IResourceSaveIndicator.isSaved(URI)
to determine if subsequently
raised resource change event
s are just a consequence of the preceding save operation
or if the underlying file
's content has been changed otherwise (e.g., via a text editor or some
other tool affecting the resource
in its serialized form).setSaved
in interface IResourceSaveIndicator
resource
- The resource
to be handled.IResourceSaveIndicator.isDirty(Resource)
,
IResourceSaveIndicator.isSaved(URI)
,
IResourceSaveIndicator.setSaved(Collection)
public void setSaved(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
IResourceSaveIndicator
resource
s and remembers them as having just been
saved. This method needs to be called by all clients which perform a save operation of some collection of
resource
s right after the save operation has been completed. Clients can then call
IResourceSaveIndicator.isSaved(URI)
to determine if subsequently raised resource change event
s are
just a consequence of the preceding save operation or if the underlying file
s' content has been
changed otherwise (e.g., via a text editor or some other tool affecting the resource
in its
serialized form).setSaved
in interface IResourceSaveIndicator
IResourceSaveIndicator.isDirty(Resource)
,
IResourceSaveIndicator.isSaved(URI)
,
IResourceSaveIndicator.setSaved(Collection)