org.eclipse.xtext.ui.editor
Class DirtyStateEditorSupport

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.DirtyStateEditorSupport
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.VerifyListener, org.eclipse.swt.internal.SWTEventListener, IResourceDescription.Event.Listener, IXtextModelListener

public class DirtyStateEditorSupport
extends java.lang.Object
implements IXtextModelListener, IResourceDescription.Event.Listener, org.eclipse.swt.events.VerifyListener

Author:
Sebastian Zarnekow - Initial contribution and API, Jan Koehnlein

Nested Class Summary
static interface DirtyStateEditorSupport.IConcurrentEditingCallback
          Allows to mock the user decision in unit tests.
static interface DirtyStateEditorSupport.IDirtyStateEditorSupportClient
          Minimal required interface for clients.
static class DirtyStateEditorSupport.InteractiveConcurrentEditingQuestion
           
protected  class DirtyStateEditorSupport.UpdateEditorStateJob
           
 
Constructor Summary
DirtyStateEditorSupport()
           
 
Method Summary
protected  java.util.Collection<org.eclipse.emf.ecore.resource.Resource> collectAffectedResources(XtextResource resource, IResourceDescription.Event event)
           
protected  ChangedResourceDescriptionDelta createDelta(IResourceDescription.Delta delta, IResourceDescription.Delta prev)
           
protected  DirtyStateEditorSupport.UpdateEditorStateJob createUpdateEditorJob()
           
 void descriptionsChanged(IResourceDescription.Event event)
           The source will invoce this method to announce changed resource.
 boolean doVerify()
           
 DirtyStateEditorSupport.IConcurrentEditingCallback getConcurrentEditingWarningDialog()
           
 DocumentBasedDirtyResource getDirtyResource()
           
 IDirtyStateManager getDirtyStateManager()
           
 IStateChangeEventBroker getStateChangeEventBroker()
           
 boolean haveEObjectDescriptionsChanged(IResourceDescription newDescription)
           
protected  void initDirtyResource(IXtextDocument document)
           
 void initializeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
           
protected  boolean isConcurrentEditingIgnored()
           
protected  boolean isDirty()
           
 boolean isEditingPossible(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
           
protected  boolean isReparseRequired(XtextResource resource, IResourceDescription.Event event)
           
 void markEditorClean(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
           
 void modelChanged(XtextResource resource)
           
 void removeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
           
 void scheduleUpdateEditorJob(IResourceDescription.Event event)
           
 void setConcurrentEditingWarningDialog(DirtyStateEditorSupport.IConcurrentEditingCallback concurrentEditingWarningDialog)
           
 void setDirtyResource(DocumentBasedDirtyResource dirtyResource)
           
 void setDirtyStateManager(IDirtyStateManager dirtyStateManager)
           
 void setStateChangeEventBroker(IStateChangeEventBroker stateChangeEventBroker)
           
 void verifyText(org.eclipse.swt.events.VerifyEvent e)
          Sent when the text is about to be modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirtyStateEditorSupport

public DirtyStateEditorSupport()
Method Detail

initializeDirtyStateSupport

public void initializeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)

verifyText

public void verifyText(org.eclipse.swt.events.VerifyEvent e)
Description copied from interface: org.eclipse.swt.events.VerifyListener
Sent when the text is about to be modified.

A verify event occurs after the user has done something to modify the text (typically typed a key), but before the text is modified. The doit field in the verify event indicates whether or not to modify the text.

Specified by:
verifyText in interface org.eclipse.swt.events.VerifyListener
Parameters:
e - an event containing information about the verify

doVerify

public boolean doVerify()

isEditingPossible

public boolean isEditingPossible(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)

isConcurrentEditingIgnored

protected boolean isConcurrentEditingIgnored()

initDirtyResource

protected void initDirtyResource(IXtextDocument document)

removeDirtyStateSupport

public void removeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)

markEditorClean

public void markEditorClean(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)

descriptionsChanged

public void descriptionsChanged(IResourceDescription.Event event)
Description copied from interface: IResourceDescription.Event.Listener

The source will invoce this method to announce changed resource. The event will never be null. However, it may contain an empty list of deltas.

Listeners are free to remove themselves from the sender of the event or add other listeners. However added listeners will not be informed about the current change.

This event may be fired asynchronously. It is ensured that the changed resources will provide the content as it was when the change has been announced to the sender of the event.

Specified by:
descriptionsChanged in interface IResourceDescription.Event.Listener
Parameters:
event - the fired event. Will never be null.

scheduleUpdateEditorJob

public void scheduleUpdateEditorJob(IResourceDescription.Event event)

createUpdateEditorJob

protected DirtyStateEditorSupport.UpdateEditorStateJob createUpdateEditorJob()

modelChanged

public void modelChanged(XtextResource resource)
Specified by:
modelChanged in interface IXtextModelListener

haveEObjectDescriptionsChanged

public boolean haveEObjectDescriptionsChanged(IResourceDescription newDescription)

collectAffectedResources

protected java.util.Collection<org.eclipse.emf.ecore.resource.Resource> collectAffectedResources(XtextResource resource,
                                                                                                 IResourceDescription.Event event)

isReparseRequired

protected boolean isReparseRequired(XtextResource resource,
                                    IResourceDescription.Event event)

isDirty

protected boolean isDirty()

createDelta

protected ChangedResourceDescriptionDelta createDelta(IResourceDescription.Delta delta,
                                                      IResourceDescription.Delta prev)

getDirtyStateManager

public IDirtyStateManager getDirtyStateManager()

setDirtyStateManager

public void setDirtyStateManager(IDirtyStateManager dirtyStateManager)

getStateChangeEventBroker

public IStateChangeEventBroker getStateChangeEventBroker()

setStateChangeEventBroker

public void setStateChangeEventBroker(IStateChangeEventBroker stateChangeEventBroker)

setConcurrentEditingWarningDialog

public void setConcurrentEditingWarningDialog(DirtyStateEditorSupport.IConcurrentEditingCallback concurrentEditingWarningDialog)

getConcurrentEditingWarningDialog

public DirtyStateEditorSupport.IConcurrentEditingCallback getConcurrentEditingWarningDialog()

setDirtyResource

public void setDirtyResource(DocumentBasedDirtyResource dirtyResource)

getDirtyResource

public DocumentBasedDirtyResource getDirtyResource()