Package com.nomagic.magicdraw.utils
Class StateChangeHandler
- java.lang.Object
-
- com.nomagic.magicdraw.utils.StateChangeHandler
-
@OpenApi public class StateChangeHandler extends java.lang.Object
Class handling state changes in model and symbols.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
com.nomagic.magicdraw.utils.StateChangeHandler.ConcurrentModificationDetectingSet<E>
A set which helps to detect concurrent modifications from different threadsstatic class
StateChangeHandler.DirtyType
Defines how much dirty is project.static class
com.nomagic.magicdraw.utils.StateChangeHandler.ResourceChangeTrackingAdapter
private class
com.nomagic.magicdraw.utils.StateChangeHandler.StateChangeNonMaskedPropertyChangeListener
-
Field Summary
Fields Modifier and Type Field Description private com.nomagic.magicdraw.utils.StateChangeHandler.ConcurrentModificationDetectingSet<java.lang.String>
changedElementsIDS
private com.nomagic.ci.persistence.local.partitioning.DirtyResourceSupportService
dirtyFlagService
private java.util.Map<IProject,StateChangeHandler.DirtyType>
dirtyProjects
private boolean
enable
private boolean
eventDeliveryStopped
private java.util.List<com.nomagic.magicdraw.utils.StatusChangeHandlerListener>
listeners
private java.util.Collection<java.lang.String>
loadedChangedElementsIDS
private static org.apache.logging.log4j.Logger
LOGGER
private boolean
mAutoSaveDirty
private com.nomagic.magicdraw.utils.StateChangeHandler.ResourceChangeTrackingAdapter
mResourceChangeTrackingAdapter
private Project
project
private java.lang.Runnable
uiUpdater
-
Constructor Summary
Constructors Constructor Description StateChangeHandler(Project project)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener)
Adds specified listener.void
addToLoadedChangedElementsIDS(java.util.Collection<java.lang.String> ids)
private void
appendInternalProfilingElementsOwners(java.util.Collection<java.lang.String> applyTo, java.util.Collection<java.lang.String> ids)
private boolean
areElementsDirty(IAttachedProject project)
void
clearDirty()
Clear dirty state of this handlervoid
clearDirty(IProject part)
Marks all elements as non dirty.private void
clearDirtyInternal(IProject part)
java.util.Collection<java.lang.String>
getAllChangedElementsIDS()
java.util.Collection<java.lang.String>
getChangedElementsIDS()
StateChangeHandler.DirtyType
getDirtyType(IProject project)
private static Element
getInternalProfilingElementOwner(BaseElement element)
void
handleViewChange(PresentationElement view)
Marks object diagram as dirty.boolean
isAutoSaveDirty()
boolean
isDirty(IProject project)
boolean
isDirty(BaseElement element)
Returns true if given element has been modified and is not yet saved.boolean
isDirty(org.eclipse.emf.ecore.resource.Resource resource)
Check if given resource is dirty in the given project context.private boolean
isDirtyWithoutLoaded(BaseElement element)
private void
notify(java.util.function.Consumer<com.nomagic.magicdraw.utils.StatusChangeHandlerListener> action)
private void
removeIfFromModule(IAttachedProject md, java.util.Iterator<java.lang.String> iterator)
private void
removeIfNotFromModule(java.util.Iterator<java.lang.String> iterator)
void
removeListener(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener)
Removes the specified listener.void
reSetDirty(IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType)
private void
reSetDirtyInternal(IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType)
void
setAutoSaveDirty(boolean autoSaveDirty)
void
setChangedElementsIDS(java.util.Collection<java.lang.String> ids)
void
setDirty(boolean dirty, BaseElement element)
Marks element as changed/unchanged.void
setDirty(com.nomagic.ci.persistence.features.FeatureDataSet fd, boolean dirty)
Marks given resource dirtyvoid
setDirty(IProject project, boolean dirty)
void
setDirty(IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType)
void
setDirty(org.eclipse.emf.ecore.resource.Resource resource, boolean dirty)
Marks given resource dirtyprivate void
setDirtyInternal(boolean dirty, BaseElement element)
Marks element as changed/unchanged.private void
setDirtyInternal(IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType)
boolean
setEnable(boolean enable)
Enables or disabled handlervoid
trackModificationForResource(org.eclipse.emf.ecore.resource.Resource resource)
Registers URI for which default dirty resource tracking will be enabled.private void
updateUI()
-
-
-
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
-
dirtyProjects
private final java.util.Map<IProject,StateChangeHandler.DirtyType> dirtyProjects
-
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 flagelement
- element
-
setDirtyInternal
private void setDirtyInternal(boolean dirty, BaseElement element)
Marks element as changed/unchanged.- Parameters:
dirty
- dirty flagelement
- 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 ifResource.isModified()
==false
, this method can returntrue
- 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)
-
setDirty
public void setDirty(IProject project, boolean dirty, @CheckForNull StateChangeHandler.DirtyType dirtyType)
-
setDirtyInternal
private void setDirtyInternal(IProject project, boolean dirty, @CheckForNull StateChangeHandler.DirtyType dirtyType)
-
isDirty
public boolean isDirty(IProject project)
-
getDirtyType
@CheckForNull public StateChangeHandler.DirtyType getDirtyType(IProject project)
-
reSetDirty
public void reSetDirty(IProject project, boolean dirty, @CheckForNull StateChangeHandler.DirtyType dirtyType)
-
reSetDirtyInternal
private void reSetDirtyInternal(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
-
-