Package com.nomagic.magicdraw.utils
Class StateChangeHandler
java.lang.Object
com.nomagic.magicdraw.utils.StateChangeHandler
Class handling state changes in model and symbols.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines how much dirty is project. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener) Adds specified listener.void<T> TcallWithEnabled(boolean enable, Callable<T> supplier) voidClear dirty state of all elements.voidclearDirty(com.nomagic.ci.persistence.IProject iProject) Marks all elements from given IProject as non-dirty.getDirtyType(com.nomagic.ci.persistence.IProject project) voidhandleViewChange(PresentationElement symbol) Marks object diagram as dirty.booleanbooleanisDirty(com.nomagic.ci.persistence.IProject project) booleanisDirty(BaseElement element) Returns true if given element has been modified and is not yet saved.booleanisDirty(org.eclipse.emf.ecore.resource.Resource resource) Check if given resource is dirty in the given project context.voidremoveListener(com.nomagic.magicdraw.utils.StatusChangeHandlerListener listener) Removes the specified listener.voidreSetDirty(com.nomagic.ci.persistence.IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType) voidrunWithEnabled(boolean enable, Runnable runnable) voidsetAutoSaveDirty(boolean autoSaveDirty) voidvoidsetDirty(boolean dirty, com.dassault_systemes.modeler.foundation.model.ModelElement element) Marks element as changed/unchanged.voidsetDirty(boolean dirty, AbstractDiagramPresentationElement diagram) Marks diagram presentation element and diagram element as changed/unchanged.voidsetDirty(com.nomagic.ci.persistence.features.FeatureDataSet fd, boolean dirty) Marks given resource dirtyvoidsetDirty(com.nomagic.ci.persistence.IProject project, boolean dirty) voidsetDirty(com.nomagic.ci.persistence.IProject project, boolean dirty, StateChangeHandler.DirtyType dirtyType) voidsetDirty(org.eclipse.emf.ecore.resource.Resource resource, boolean dirty) Marks given resource dirtybooleansetEnable(boolean enable) Enables or disabled handlervoidtrackModificationForResource(org.eclipse.emf.ecore.resource.Resource resource) Registers URI for which default dirty resource tracking will be enabled.
-
Constructor Details
-
StateChangeHandler
-
-
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
-
callWithEnabled
- Throws:
Exception
-
handleViewChange
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 flagelement- element
-
setDirty
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 flagdiagram- 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 ifResource.isModified()==false, this method can returntrue- Returns:
- true if resource is dirty
-
isDirty
Returns true if given element has been modified and is not yet saved. IndividualPresentationElementis not tracked, itsAbstractDiagramPresentationElementis used instead.- Parameters:
element- element- Returns:
- true if element is dirty
-
setChangedElementsIDS
-
getAllChangedElementsIDS
- Returns:
- changed during this session + loaded changed ids.
-
getChangedElementsIDS
-
addToLoadedChangedElementsIDS
-
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
-