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)
          Deprecated. Use haveEObjectDescriptionsChanged(IResourceDescription, org.eclipse.xtext.resource.IResourceDescription.Manager).
 boolean haveEObjectDescriptionsChanged(IResourceDescription newDescription, IResourceDescription.Manager resourceDescriptionManager)
           
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 setResourceDescriptions(IResourceDescriptions resourceDescriptions)
           
 void setStateChangeEventBroker(IStateChangeEventBroker stateChangeEventBroker)
           
 void verifyText(org.eclipse.swt.events.VerifyEvent e)
           
 
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)
Specified by:
verifyText in interface org.eclipse.swt.events.VerifyListener

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

@Deprecated
public boolean haveEObjectDescriptionsChanged(IResourceDescription newDescription)
Deprecated. Use haveEObjectDescriptionsChanged(IResourceDescription, org.eclipse.xtext.resource.IResourceDescription.Manager).


haveEObjectDescriptionsChanged

public boolean haveEObjectDescriptionsChanged(IResourceDescription newDescription,
                                              IResourceDescription.Manager resourceDescriptionManager)
Since:
2.3

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)
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

getStateChangeEventBroker

public IStateChangeEventBroker getStateChangeEventBroker()

setStateChangeEventBroker

public void setStateChangeEventBroker(IStateChangeEventBroker stateChangeEventBroker)
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

setConcurrentEditingWarningDialog

public void setConcurrentEditingWarningDialog(DirtyStateEditorSupport.IConcurrentEditingCallback concurrentEditingWarningDialog)
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

getConcurrentEditingWarningDialog

public DirtyStateEditorSupport.IConcurrentEditingCallback getConcurrentEditingWarningDialog()

setDirtyResource

public void setDirtyResource(DocumentBasedDirtyResource dirtyResource)
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

getDirtyResource

public DocumentBasedDirtyResource getDirtyResource()

setResourceDescriptions

public void setResourceDescriptions(IResourceDescriptions resourceDescriptions)
Since:
2.1
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.