org.eclipse.emf.emfstore.internal.client.model.impl
Class ResourcePersister

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.impl.ResourcePersister
All Implemented Interfaces:
ESCommandObserver, ESCommitObserver, ESUpdateObserver, ESObserver, ESDisposable, IdEObjectCollectionChangeObserver

public class ResourcePersister
extends Object
implements ESCommandObserver, IdEObjectCollectionChangeObserver, ESCommitObserver, ESUpdateObserver, ESDisposable

Saves any registered resources upon certain types of triggers like, for instance, update and commit.

Author:
koegel, emueller

Constructor Summary
ResourcePersister(ESLocalProject localProject)
          Constructor.
 
Method Summary
 void addDirtyStateChangeLister(IDEObjectCollectionDirtyStateListener listener)
          Add a dirty state change listener.
 void collectionDeleted(IdEObjectCollection collection)
          If the IdEObjectCollection is deleted.
 void commandCompleted(org.eclipse.emf.common.command.Command command)
          Called to notify listener about the successful completion of the given command.
 void commandFailed(org.eclipse.emf.common.command.Command command, Exception exception)
          Called to notify listener about the failure of the given command.
 void commandStarted(org.eclipse.emf.common.command.Command command)
          Called to notify listener about the start of the given command.
 void commitCompleted(ESLocalProject project, ESPrimaryVersionSpec newRevision, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the commit is completed.
 void dispose()
          Marker method for classes that need to perform clean-up tasks.
 boolean inspectChanges(ESLocalProject project, ESChangePackage changePackage, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called before the commit proceeds.
 boolean inspectChanges(ESLocalProject project, List<ESChangePackage> changePackages, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called to notify the observer about the changes that will be merged into the project space.
 boolean isDirty()
          Determine if there is resources that still need to be saved.
 void modelElementAdded(IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          Called when the eObject has been added to the collection.
 void modelElementRemoved(IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          Called when the eObject and its siblings have been removed from the collection.
 void notify(org.eclipse.emf.common.notify.Notification notification, IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          A notification on a model element of the collection occurred.
 void removeDirtyStateChangeLister(IDEObjectCollectionDirtyStateListener listener)
          Remove a dirty state change listener.
 void saveDirtyResources(boolean force)
          Save all dirty resources to disk now if auto-save is active.
 void updateCompleted(ESLocalProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the changes have been applied to the project and the update is completed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourcePersister

public ResourcePersister(ESLocalProject localProject)
Constructor.

Parameters:
localProject - the ESLocalProject that will be associated with this persister
Method Detail

commandStarted

public void commandStarted(org.eclipse.emf.common.command.Command command)
Called to notify listener about the start of the given command.

Specified by:
commandStarted in interface ESCommandObserver
Parameters:
command - the command
See Also:
ESCommandObserver.commandStarted(org.eclipse.emf.common.command.Command)

commandCompleted

public void commandCompleted(org.eclipse.emf.common.command.Command command)
Called to notify listener about the successful completion of the given command.

Specified by:
commandCompleted in interface ESCommandObserver
Parameters:
command - the command
See Also:
ESCommandObserver.commandCompleted(org.eclipse.emf.common.command.Command)

commandFailed

public void commandFailed(org.eclipse.emf.common.command.Command command,
                          Exception exception)
Called to notify listener about the failure of the given command.

Specified by:
commandFailed in interface ESCommandObserver
Parameters:
command - the command
exception - the exception that occurred
See Also:
ESCommandObserver.commandFailed(org.eclipse.emf.common.command.Command, java.lang.Exception)

saveDirtyResources

public void saveDirtyResources(boolean force)
Save all dirty resources to disk now if auto-save is active. If auto-save is disabled, clients have to programatically save the dirty resource set by setting the force parameter to true.

Parameters:
force - whether to force the saving of resources

isDirty

public boolean isDirty()
Determine if there is resources that still need to be saved.

Returns:
true if there is resource to be saved.

addDirtyStateChangeLister

public void addDirtyStateChangeLister(IDEObjectCollectionDirtyStateListener listener)
Add a dirty state change listener.

Parameters:
listener - the listener

removeDirtyStateChangeLister

public void removeDirtyStateChangeLister(IDEObjectCollectionDirtyStateListener listener)
Remove a dirty state change listener.

Parameters:
listener - the listener

notify

public void notify(org.eclipse.emf.common.notify.Notification notification,
                   IdEObjectCollection collection,
                   org.eclipse.emf.ecore.EObject modelElement)
A notification on a model element of the collection occurred. See Notification documentation for details on the notifications. This method will be called even if the given notification results from an add or remove of a model element of the project.

Specified by:
notify in interface IdEObjectCollectionChangeObserver
Parameters:
notification - the notification
collection - the collection holding the modelElement
modelElement - the model element the notification originates from
See Also:
IdEObjectCollectionChangeObserver.notify(org.eclipse.emf.common.notify.Notification, org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

modelElementAdded

public void modelElementAdded(IdEObjectCollection collection,
                              org.eclipse.emf.ecore.EObject modelElement)
Called when the eObject has been added to the collection.

Specified by:
modelElementAdded in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection to which the eObject was added
modelElement - the EObject that has been added to the collection
See Also:
IdEObjectCollectionChangeObserver.modelElementAdded(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

modelElementRemoved

public void modelElementRemoved(IdEObjectCollection collection,
                                org.eclipse.emf.ecore.EObject modelElement)
Called when the eObject and its siblings have been removed from the collection. NOTE: Note that you will NOT receive a separate notification for each sibling.

Specified by:
modelElementRemoved in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection to which the eObject was added
modelElement - the EObject that has been added to the collection
See Also:
IdEObjectCollectionChangeObserver.modelElementRemoved(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

collectionDeleted

public void collectionDeleted(IdEObjectCollection collection)
If the IdEObjectCollection is deleted.

Specified by:
collectionDeleted in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection that has been deleted
See Also:
IdEObjectCollectionChangeObserver.collectionDeleted(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection)

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              List<ESChangePackage> changePackages,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called to notify the observer about the changes that will be merged into the project space.

Specified by:
inspectChanges in interface ESUpdateObserver
Parameters:
project - the ESLocalProject that should be updated
changePackages - a list of ESChangePackages containing the update changes
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
false if the observer wants to cancel the update, true otherwise
See Also:
ESUpdateObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, java.util.List, org.eclipse.core.runtime.IProgressMonitor)

updateCompleted

public void updateCompleted(ESLocalProject project,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the changes have been applied to the project and the update is completed.

Specified by:
updateCompleted in interface ESUpdateObserver
Parameters:
project - the ESLocalProject whose update has been completed
monitor - an IProgressMonitor instance that may be used by clients to inform about progress

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              ESChangePackage changePackage,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called before the commit proceeds. A callback method to initiate the commit dialog and allow the user to confirm the changes.

Specified by:
inspectChanges in interface ESCommitObserver
Parameters:
project - the project the commit occurs on
changePackage - the ESChangePackage
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
true if the changes have been confirmed, false - otherwise.
See Also:
ESCommitObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.ESChangePackage, org.eclipse.core.runtime.IProgressMonitor)

commitCompleted

public void commitCompleted(ESLocalProject project,
                            ESPrimaryVersionSpec newRevision,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the commit is completed.

Specified by:
commitCompleted in interface ESCommitObserver
Parameters:
project - the project on which the commit has completed
newRevision - the new revision that was created by the commit
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
See Also:
ESCommitObserver.commitCompleted(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec, org.eclipse.core.runtime.IProgressMonitor)

dispose

public void dispose()
Marker method for classes that need to perform clean-up tasks.

Specified by:
dispose in interface ESDisposable
See Also:
ESDisposable.dispose()


Copyright © 2015. All Rights Reserved.