Class StateChangeHandler


  • @OpenApi
    public class StateChangeHandler
    extends java.lang.Object
    Class handling state changes in model and symbols.
    • Field Detail

      • LOGGER

        private static final org.apache.logging.log4j.Logger LOGGER
      • changedElementsIDS

        private final com.nomagic.magicdraw.utils.StateChangeHandler.ConcurrentModificationDetectingSet<java.lang.String> changedElementsIDS
      • loadedChangedElementsIDS

        private final java.util.Collection<java.lang.String> loadedChangedElementsIDS
      • project

        private final Project project
      • uiUpdater

        @CheckForNull
        private java.lang.Runnable uiUpdater
      • enable

        private volatile boolean enable
      • eventDeliveryStopped

        private volatile boolean eventDeliveryStopped
      • listeners

        private final java.util.List<com.nomagic.magicdraw.utils.StatusChangeHandlerListener> listeners
      • mAutoSaveDirty

        private boolean mAutoSaveDirty
      • mResourceChangeTrackingAdapter

        private final com.nomagic.magicdraw.utils.StateChangeHandler.ResourceChangeTrackingAdapter mResourceChangeTrackingAdapter
      • dirtyFlagService

        private final com.nomagic.ci.persistence.local.partitioning.DirtyResourceSupportService dirtyFlagService
    • Constructor Detail

      • StateChangeHandler

        public StateChangeHandler​(Project project)
    • Method Detail

      • addListener

        public void addListener​(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener)
        Adds specified listener.
        Parameters:
        listener - a new listener.
      • removeListener

        public void removeListener​(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener)
        Removes the specified listener.
        Parameters:
        listener - the listener which should be removed.
      • notify

        private void notify​(java.util.function.Consumer<com.nomagic.magicdraw.utils.StatusChangeHandlerListener> action)
      • areElementsDirty

        private boolean areElementsDirty​(IAttachedProject project)
        Parameters:
        project - module
        Returns:
        true if module is editable and was not saved after edit.
      • setEnable

        public boolean setEnable​(boolean enable)
        Enables or disabled handler
        Parameters:
        enable - true if changes should be registered, false otherwise
        Returns:
        previous state
      • handleViewChange

        public void handleViewChange​(PresentationElement view)
        Marks object diagram as dirty.
        Parameters:
        view - symbol to mark as dirty
      • clearDirty

        public void clearDirty()
        Clear dirty state of this handler
      • clearDirty

        public void clearDirty​(@CheckForNull
                               IProject part)
        Marks all elements as non dirty.
        Parameters:
        part - part part to clear. Can be null. If null clears everything. In other case clears only module, or project.
      • clearDirtyInternal

        private void clearDirtyInternal​(@CheckForNull
                                        IProject part)
      • removeIfFromModule

        private void removeIfFromModule​(IAttachedProject md,
                                        java.util.Iterator<java.lang.String> iterator)
      • removeIfNotFromModule

        private void removeIfNotFromModule​(java.util.Iterator<java.lang.String> iterator)
      • updateUI

        private void updateUI()
      • setDirty

        public void setDirty​(boolean dirty,
                             BaseElement element)
        Marks element as changed/unchanged.
        Parameters:
        dirty - dirty flag
        element - element
      • setDirtyInternal

        private void setDirtyInternal​(boolean dirty,
                                      BaseElement element)
        Marks element as changed/unchanged.
        Parameters:
        dirty - dirty flag
        element - element
      • getInternalProfilingElementOwner

        @CheckForNull
        private static Element getInternalProfilingElementOwner​(BaseElement element)
      • setDirty

        public void setDirty​(@Nonnull
                             org.eclipse.emf.ecore.resource.Resource resource,
                             boolean dirty)
        Marks given resource dirty
        Parameters:
        resource - target element which will become dirty
      • setDirty

        public void setDirty​(@Nonnull
                             com.nomagic.ci.persistence.features.FeatureDataSet fd,
                             boolean dirty)
        Marks given resource dirty
        Parameters:
        fd - target element which will become dirty
      • isDirty

        public boolean isDirty​(@Nonnull
                               org.eclipse.emf.ecore.resource.Resource resource)
        Check if given resource is dirty in the given project context. Even if Resource.isModified() == false, this method can return true
        Returns:
        true if resource is dirty
      • isDirty

        @OpenApi
        public boolean isDirty​(BaseElement element)
        Returns true if given element has been modified and is not yet saved.
        Parameters:
        element - element
        Returns:
        true if element is dirty
      • isDirtyWithoutLoaded

        private boolean isDirtyWithoutLoaded​(BaseElement element)
      • setChangedElementsIDS

        public void setChangedElementsIDS​(java.util.Collection<java.lang.String> ids)
      • getAllChangedElementsIDS

        public java.util.Collection<java.lang.String> getAllChangedElementsIDS()
        Returns:
        changed during this session + loaded changed ids.
      • getChangedElementsIDS

        public java.util.Collection<java.lang.String> getChangedElementsIDS()
      • addToLoadedChangedElementsIDS

        public void addToLoadedChangedElementsIDS​(java.util.Collection<java.lang.String> ids)
      • appendInternalProfilingElementsOwners

        private void appendInternalProfilingElementsOwners​(java.util.Collection<java.lang.String> applyTo,
                                                           java.util.Collection<java.lang.String> ids)
      • setDirty

        public void setDirty​(IProject project,
                             boolean dirty)
      • isDirty

        public boolean isDirty​(IProject project)
      • isAutoSaveDirty

        public boolean isAutoSaveDirty()
      • setAutoSaveDirty

        public void setAutoSaveDirty​(boolean autoSaveDirty)
      • trackModificationForResource

        public void trackModificationForResource​(@Nonnull
                                                 org.eclipse.emf.ecore.resource.Resource resource)
        Registers URI for which default dirty resource tracking will be enabled.

        Note, this mechanism is based on EMF track changes

        Parameters:
        resource - resource to track changes