Class ModelTransformationsManager
- java.lang.Object
-
- com.nomagic.magicdraw.modeltransformations.ModelTransformationsManager
-
@OpenApiAll public final class ModelTransformationsManager extends java.lang.ObjectModelTransformationsManager organizes process of application of model transformation. This class is responsible for Undo/redo commands etc.Use this class as singleton.
-
-
Field Summary
Fields Modifier and Type Field Description private static ModelTransformationsManagermInstanceThe instance of model transformations manager.private java.util.List<ModelTransformationInfo>mTransformationsThe collection of registered model transformations.private static java.lang.StringPROPS_ENCODINGprivate booleanupdateTransformationTestresets to false after each invocation of updateTransform
-
Constructor Summary
Constructors Modifier Constructor Description privateModelTransformationsManager()The private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTransformation(ModelTransformationInfo info)Adds the given model transformation in registered model transformations collection.private static java.util.List<Element>collectNumberables(com.nomagic.magicdraw.autoid.AutoIdManager manager, java.util.Collection<Element> elements)Collects all owned elements that are customized for auto Numberingprivate static booleandoTransform(ModelTransformationsWizardInformation wi, ModelTransformationInfo mti, Task task, Project project)booleandoTransformation(ModelTransformationsWizardInformation wi, ModelTransformationInfo mti)booleandoUpdateTransformation(ModelTransformationInfo mti_final, Package transformedPackage_final, boolean sync_final, PropertyManager prop)static ModelTransformationsManagergetInstance()Returns a shared instance of model transformations manager.ModelTransformationInfogetTransformationInfoByName(java.lang.String transformationName)Returns transformation info by transformation namejava.util.Collection<ModelTransformationInfo>getTransformations()Returns all registered model transformations.private static TypeMapProfilegetTypeMapProfile(Package typeProfilePackage, ModelTransformationsWizardInformation wi)static voidloadTransformationProperties(Style style, ModelTransformationsWizardInformation wi, Project project)static StyleloadTransformationProperties(Package transformedPackage, ModelTransformationsWizardInformation wi)private static voidpreLoadDiagrams(java.util.Collection<BaseElement> elementsInScope, ModelTransformationInfo mti)voidremoveTransformation(ModelTransformationInfo info)Removes the given model transformation from registered collection of model transformations.voidsaveTransformationProperties(ModelTransformationsWizardInformation wizardInformation)private voidserializePropertyManager(java.io.OutputStream stream, PropertyManager propertiesToSave, java.lang.String transformationName, java.lang.String destinationElementID, boolean syncFinal)booleantransform(java.util.List<? extends BaseElement> selectedElements)Displays transformation wizard and runs transformationprivate static voidupdateNumbers(Package targetPackage, java.util.Collection<Element> filteredElements)Renumber the elements that were transformedvoidupdateProperties(PropertyManager source, PropertyManager propertiesToUpdate)booleanupdateTransformation(Package transformed)Checks for already applied transformations, sets the right one and runs transformation updatebooleanupdateTransformation(Package transformed, boolean testingMode)
-
-
-
Field Detail
-
PROPS_ENCODING
private static final java.lang.String PROPS_ENCODING
- See Also:
- Constant Field Values
-
mInstance
private static final ModelTransformationsManager mInstance
The instance of model transformations manager.
-
mTransformations
private final java.util.List<ModelTransformationInfo> mTransformations
The collection of registered model transformations.
-
updateTransformationTest
private boolean updateTransformationTest
resets to false after each invocation of updateTransform
-
-
Method Detail
-
getInstance
public static ModelTransformationsManager getInstance()
Returns a shared instance of model transformations manager.- Returns:
- instance of model transformations manager.
-
addTransformation
public void addTransformation(ModelTransformationInfo info)
Adds the given model transformation in registered model transformations collection.- Parameters:
info- the give transformation to add.
-
removeTransformation
public void removeTransformation(ModelTransformationInfo info)
Removes the given model transformation from registered collection of model transformations.- Parameters:
info- the given transformation to remove.
-
getTransformations
public java.util.Collection<ModelTransformationInfo> getTransformations()
Returns all registered model transformations.- Returns:
- a collection of registered model transformations.
-
getTransformationInfoByName
@CheckForNull public ModelTransformationInfo getTransformationInfoByName(java.lang.String transformationName)
Returns transformation info by transformation name- Parameters:
transformationName- transformation name- Returns:
- transformation info
-
transform
public boolean transform(java.util.List<? extends BaseElement> selectedElements)
Displays transformation wizard and runs transformation- Parameters:
selectedElements- list of elements to transform- Returns:
- true if transformation was successful
-
doTransformation
public boolean doTransformation(ModelTransformationsWizardInformation wi, ModelTransformationInfo mti)
-
doTransform
private static boolean doTransform(ModelTransformationsWizardInformation wi, ModelTransformationInfo mti, Task task, Project project) throws ReadOnlyElementException
- Parameters:
wi- model wizard infomti- model transformation infotask- execution taskproject- project- Returns:
- true if transform was without errors
- Throws:
ReadOnlyElementException- if model is read-only
-
updateTransformation
public boolean updateTransformation(Package transformed, boolean testingMode)
-
updateTransformation
public boolean updateTransformation(Package transformed)
Checks for already applied transformations, sets the right one and runs transformation update- Parameters:
transformed- list of elements to transform- Returns:
- true if transformation update was successful
-
doUpdateTransformation
public boolean doUpdateTransformation(ModelTransformationInfo mti_final, Package transformedPackage_final, boolean sync_final, @CheckForNull PropertyManager prop)
-
updateProperties
public void updateProperties(PropertyManager source, PropertyManager propertiesToUpdate)
-
serializePropertyManager
private void serializePropertyManager(java.io.OutputStream stream, PropertyManager propertiesToSave, java.lang.String transformationName, java.lang.String destinationElementID, boolean syncFinal) throws java.lang.Exception- Throws:
java.lang.Exception
-
loadTransformationProperties
@CheckForNull public static Style loadTransformationProperties(Package transformedPackage, ModelTransformationsWizardInformation wi)
-
loadTransformationProperties
public static void loadTransformationProperties(Style style, ModelTransformationsWizardInformation wi, Project project)
-
getTypeMapProfile
@CheckForNull private static TypeMapProfile getTypeMapProfile(Package typeProfilePackage, ModelTransformationsWizardInformation wi)
-
saveTransformationProperties
public void saveTransformationProperties(ModelTransformationsWizardInformation wizardInformation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
preLoadDiagrams
private static void preLoadDiagrams(java.util.Collection<BaseElement> elementsInScope, ModelTransformationInfo mti)
-
updateNumbers
private static void updateNumbers(@CheckForNull Package targetPackage, java.util.Collection<Element> filteredElements)Renumber the elements that were transformed- Parameters:
targetPackage- the resulting transformation Package, null if in PlacefilteredElements- the originally selected elements
-
collectNumberables
private static java.util.List<Element> collectNumberables(com.nomagic.magicdraw.autoid.AutoIdManager manager, java.util.Collection<Element> elements)
Collects all owned elements that are customized for auto Numbering- Parameters:
manager- the autoId Managerelements- search these elements for children that are numberable- Returns:
- the Numberable elements
-
-