Class DirtyStateEditorSupport
- java.lang.Object
-
- org.eclipse.emf.common.notify.impl.AdapterImpl
-
- org.eclipse.emf.ecore.util.EContentAdapter
-
- com._1c.g5.modeling.xtext.ui.resource.DirtyStateEditorSupport
-
- All Implemented Interfaces:
org.eclipse.emf.common.notify.Adapter
,org.eclipse.emf.common.notify.Adapter.Internal
,org.eclipse.xtext.resource.IResourceDescription.Event.Listener
- Direct Known Subclasses:
MdDirtyStateEditorSupport
public class DirtyStateEditorSupport extends org.eclipse.emf.ecore.util.EContentAdapter implements org.eclipse.xtext.resource.IResourceDescription.Event.Listener
Dirty state editor support for projectional editors. This implementation registers adapter to resource provided byDirtyStateEditorSupport.IDirtyStateEditorSupportClient
. Clients can decide what changes should be notified by extendingisAffected(Notification)
.To start dirty editor supports clients should initialize it through
initializeDirtyStateSupport(IDirtyStateEditorSupportClient)
. When dirty editor support is not more needed, clients must remove it by callingremoveDirtyStateSupport(IDirtyStateEditorSupportClient)
.Resource given by
DirtyStateEditorSupport.IDirtyStateEditorSupportClient
is managed byDirtyResource
.This implementation also listens to resource description change events. If this events affected to managed resource, affected resources unloaded from resource set and if
isRelinkRequired(Resource, Event)
returns truerelinkResource(Resource)
is trigered.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DirtyStateEditorSupport.IConcurrentEditingCallback
static interface
DirtyStateEditorSupport.IDirtyStateEditorSupportClient
Minimal required interface for clients.static class
DirtyStateEditorSupport.InteractiveConcurrentEditingQuestion
protected class
DirtyStateEditorSupport.UpdateEditorStateJob
-
Constructor Summary
Constructors Constructor Description DirtyStateEditorSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<org.eclipse.emf.ecore.resource.Resource>
collectAffectedResources(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Returns resources affected by given resource description change event and managed resource.protected DirtyStateEditorSupport.UpdateEditorStateJob
createUpdateEditorJob()
void
descriptionsChanged(org.eclipse.xtext.resource.IResourceDescription.Event event)
This method is triggered when there is changes in other resources.DirtyStateEditorSupport.IConcurrentEditingCallback
getConcurrentEditingWarningDialog()
DirtyResource
getDirtyResource()
org.eclipse.xtext.ui.editor.IDirtyStateManager
getDirtyStateManager()
org.eclipse.xtext.ui.notification.IStateChangeEventBroker
getStateChangeEventBroker()
protected void
initDirtyResource(org.eclipse.emf.ecore.resource.Resource resource)
Performs dirty resource initialization.void
initializeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Performs initialization of dirty editor support for given client.protected boolean
isAffected(org.eclipse.emf.common.notify.Notification notification)
Returns if all interested sides should be notified about model changes.protected boolean
isConcurrentEditingIgnored()
protected boolean
isDirty()
boolean
isEditingPossible(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
protected boolean
isRelinkRequired(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Checks if given resource needsN to be relinked.protected boolean
isResourceRemoveAllowed(org.eclipse.emf.ecore.resource.Resource affectedResource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Checks if affected by outer changes resource can be removed from its containing resource set.void
markEditorClean(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Mark the dirty resource given by client as unmanaged.void
notifyChanged(org.eclipse.emf.common.notify.Notification notification)
protected void
relinkResource(org.eclipse.emf.ecore.resource.Resource resource)
Performs resource relinking.void
removeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Removes dirty editor support for given client.protected void
scheduleUpdateEditorJob(org.eclipse.xtext.resource.IResourceDescription.Event event)
Schedules update editor job.void
setConcurrentEditingWarningDialog(DirtyStateEditorSupport.IConcurrentEditingCallback concurrentEditingWarningDialog)
void
setDirtyResource(DirtyResource dirtyResource)
void
setDirtyStateManager(org.eclipse.xtext.ui.editor.IDirtyStateManager dirtyStateManager)
void
setResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions resourceDescriptions)
void
setStateChangeEventBroker(org.eclipse.xtext.ui.notification.IStateChangeEventBroker stateChangeEventBroker)
protected void
unloadAffectedResourcesAndRelink(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Unloads affected resources and performs given resource relinking.-
Methods inherited from class org.eclipse.emf.ecore.util.EContentAdapter
addAdapter, basicSetTarget, basicUnsetTarget, handleContainment, removeAdapter, removeAdapter, resolve, selfAdapt, setTarget, setTarget, setTarget, setTarget, unsetTarget, unsetTarget, unsetTarget, unsetTarget, unsetTarget, useRecursion
-
-
-
-
Method Detail
-
initializeDirtyStateSupport
public void initializeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Performs initialization of dirty editor support for given client.- Parameters:
client
-DirtyStateEditorSupport.IDirtyStateEditorSupportClient
instance (nevernull
).
-
removeDirtyStateSupport
public void removeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Removes dirty editor support for given client.- Parameters:
client
-DirtyStateEditorSupport.IDirtyStateEditorSupportClient
instance (nevernull
).
-
notifyChanged
public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
- Specified by:
notifyChanged
in interfaceorg.eclipse.emf.common.notify.Adapter
- Overrides:
notifyChanged
in classorg.eclipse.emf.ecore.util.EContentAdapter
-
markEditorClean
public void markEditorClean(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
Mark the dirty resource given by client as unmanaged.- Parameters:
client
-DirtyStateEditorSupport.IDirtyStateEditorSupportClient
instance (nevernull
).
-
descriptionsChanged
public void descriptionsChanged(org.eclipse.xtext.resource.IResourceDescription.Event event)
This method is triggered when there is changes in other resources.This method is not intended to call by clients.
- Specified by:
descriptionsChanged
in interfaceorg.eclipse.xtext.resource.IResourceDescription.Event.Listener
- Parameters:
event
-IResourceDescription.Event
instance (nevernull
).
-
getDirtyStateManager
public org.eclipse.xtext.ui.editor.IDirtyStateManager getDirtyStateManager()
-
setDirtyStateManager
public void setDirtyStateManager(org.eclipse.xtext.ui.editor.IDirtyStateManager dirtyStateManager)
-
getStateChangeEventBroker
public org.eclipse.xtext.ui.notification.IStateChangeEventBroker getStateChangeEventBroker()
-
setStateChangeEventBroker
public void setStateChangeEventBroker(org.eclipse.xtext.ui.notification.IStateChangeEventBroker stateChangeEventBroker)
-
setConcurrentEditingWarningDialog
public void setConcurrentEditingWarningDialog(DirtyStateEditorSupport.IConcurrentEditingCallback concurrentEditingWarningDialog)
-
getConcurrentEditingWarningDialog
public DirtyStateEditorSupport.IConcurrentEditingCallback getConcurrentEditingWarningDialog()
-
setDirtyResource
public void setDirtyResource(DirtyResource dirtyResource)
-
getDirtyResource
public DirtyResource getDirtyResource()
-
setResourceDescriptions
public void setResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions resourceDescriptions)
- Since:
- 2.1
-
isEditingPossible
public boolean isEditingPossible(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
-
scheduleUpdateEditorJob
protected void scheduleUpdateEditorJob(org.eclipse.xtext.resource.IResourceDescription.Event event)
Schedules update editor job.- Parameters:
event
-IResourceDescription.Event
instance (never ).
-
collectAffectedResources
protected Collection<org.eclipse.emf.ecore.resource.Resource> collectAffectedResources(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Returns resources affected by given resource description change event and managed resource.- Parameters:
resource
- resource managed by this dirty editor support instance.event
-IResourceDescription.Event
instance (never ).- Returns:
- affected resources (never
null
).
-
createUpdateEditorJob
protected DirtyStateEditorSupport.UpdateEditorStateJob createUpdateEditorJob()
-
initDirtyResource
protected void initDirtyResource(org.eclipse.emf.ecore.resource.Resource resource)
Performs dirty resource initialization.- Parameters:
resource
- managed by dirty state support resource (nevernull
).
-
isDirty
protected boolean isDirty()
-
isRelinkRequired
protected boolean isRelinkRequired(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Checks if given resource needsN to be relinked.- Parameters:
resource
- resource managed by dirty state editor support (newvernull
).event
-IResourceDescription.Event
instance (never ).- Returns:
- true if given resource must be relinked, false otherwise.
-
isAffected
protected boolean isAffected(org.eclipse.emf.common.notify.Notification notification)
Returns if all interested sides should be notified about model changes.This implementation returns true for all model changes, clients may override this method to provide more strict checks.
- Parameters:
notification
- model changes notification.- Returns:
- true if all interested sides should be notified about model changes, false otherwise.
-
isConcurrentEditingIgnored
protected boolean isConcurrentEditingIgnored()
-
unloadAffectedResourcesAndRelink
protected void unloadAffectedResourcesAndRelink(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Unloads affected resources and performs given resource relinking.- Parameters:
resource
- current resource.event
- resource description change event.
-
isResourceRemoveAllowed
protected boolean isResourceRemoveAllowed(org.eclipse.emf.ecore.resource.Resource affectedResource, org.eclipse.xtext.resource.IResourceDescription.Event event)
Checks if affected by outer changes resource can be removed from its containing resource set.- Parameters:
affectedResource
- the affected resource (nevernull
)event
- (nevernull
)- Returns:
- true if given resource can be removed, else returns false
-
relinkResource
protected void relinkResource(org.eclipse.emf.ecore.resource.Resource resource)
Performs resource relinking.This method is triggered when out chages affected given resource and it is need to be relinked.
- Parameters:
resource
- the resource to relink proxies in
-
-