Class 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
DirtyStateEditorSupport.IDirtyStateEditorSupportClient
.
Clients can decide what changes should be notified
by extending isAffected(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
calling removeDirtyStateSupport(IDirtyStateEditorSupportClient)
.
Resource given by DirtyStateEditorSupport.IDirtyStateEditorSupportClient
is managed by DirtyResource
.
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 true relinkResource(Resource)
is trigered.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
Minimal required interface for clients.static class
protected class
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
-
Field Summary
Fields inherited from class org.eclipse.emf.ecore.util.EContentAdapter
iterating
Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
target
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.void
descriptionsChanged
(org.eclipse.xtext.resource.IResourceDescription.Event event) This method is triggered when there is changes in other resources.org.eclipse.xtext.ui.editor.IDirtyStateManager
org.eclipse.xtext.ui.notification.IStateChangeEventBroker
protected void
initDirtyResource
(org.eclipse.emf.ecore.resource.Resource resource) Performs dirty resource initialization.void
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
protected boolean
isDirty()
boolean
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
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
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
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
getTarget, isAdapterForType
-
Constructor Details
-
DirtyStateEditorSupport
public DirtyStateEditorSupport()
-
-
Method Details
-
initializeDirtyStateSupport
public void initializeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client) Performs initialization of dirty editor support for given client.- Parameters:
client
-DirtyStateEditorSupport.IDirtyStateEditorSupportClient
instance (nevernull
).
-
removeDirtyStateSupport
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
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
-
setDirtyResource
-
getDirtyResource
-
setResourceDescriptions
public void setResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions resourceDescriptions) - Since:
- 2.1
-
isEditingPossible
-
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
-
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
-