Class StateChangeHandler

java.lang.Object
com.nomagic.magicdraw.utils.StateChangeHandler

@OpenApi public class StateChangeHandler extends Object
Class handling state changes in model and symbols.
  • Constructor Details

    • StateChangeHandler

      public StateChangeHandler(Project project)
  • Method Details

    • 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.
    • setEnable

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

      public void runWithEnabled(boolean enable, Runnable runnable)
    • callWithEnabled

      public <T> T callWithEnabled(boolean enable, Callable<T> supplier) throws Exception
      Throws:
      Exception
    • handleViewChange

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

      public void clearDirty()
      Clear dirty state of all elements.
    • clearDirty

      public void clearDirty(com.nomagic.ci.persistence.IProject iProject)
      Marks all elements from given IProject as non-dirty.
      Parameters:
      iProject - project to clear
    • setDirty

      public void setDirty(boolean dirty, com.dassault_systemes.modeler.foundation.model.ModelElement element)
      Marks element as changed/unchanged.
      Parameters:
      dirty - dirty flag
      element - element
    • setDirty

      public void setDirty(boolean dirty, AbstractDiagramPresentationElement diagram)
      Marks diagram presentation element and diagram element as changed/unchanged. Diagram and DiagramPresentationElement is always marked together. Marking diagram as dirty updates its modification time, and resets content hash.
      Parameters:
      dirty - dirty flag
      diagram - diagram
    • 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. Individual PresentationElement is not tracked, its AbstractDiagramPresentationElement is used instead.
      Parameters:
      element - element
      Returns:
      true if element is dirty
    • setChangedElementsIDS

      public void setChangedElementsIDS(Collection<String> ids)
    • getAllChangedElementsIDS

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

      public Collection<String> getChangedElementsIDS()
    • addToLoadedChangedElementsIDS

      public void addToLoadedChangedElementsIDS(Collection<String> ids)
    • setDirty

      public void setDirty(com.nomagic.ci.persistence.IProject project, boolean dirty)
    • setDirty

      public void setDirty(com.nomagic.ci.persistence.IProject project, boolean dirty, @CheckForNull StateChangeHandler.DirtyType dirtyType)
    • isDirty

      public boolean isDirty(com.nomagic.ci.persistence.IProject project)
    • getDirtyType

      @CheckForNull public StateChangeHandler.DirtyType getDirtyType(com.nomagic.ci.persistence.IProject project)
    • reSetDirty

      public void reSetDirty(com.nomagic.ci.persistence.IProject project, boolean dirty, @CheckForNull StateChangeHandler.DirtyType dirtyType)
    • 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
    • getProject

      public Project getProject()