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 by 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.

  • 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 (never null).
    • removeDirtyStateSupport

      public void removeDirtyStateSupport(DirtyStateEditorSupport.IDirtyStateEditorSupportClient client)
      Removes dirty editor support for given client.
      Parameters:
      client - DirtyStateEditorSupport.IDirtyStateEditorSupportClient instance (never null).
    • notifyChanged

      public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
      Specified by:
      notifyChanged in interface org.eclipse.emf.common.notify.Adapter
      Overrides:
      notifyChanged in class org.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 (never null).
    • 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 interface org.eclipse.xtext.resource.IResourceDescription.Event.Listener
      Parameters:
      event - IResourceDescription.Event instance (never null).
    • 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 (never null).
    • 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 (newver null).
      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 (never null)
      event - (never null)
      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