diff options
author | Ed Seidewitz | 2015-05-01 03:05:27 +0000 |
---|---|---|
committer | Ed Seidewitz | 2015-05-01 03:05:27 +0000 |
commit | 6ac95d923fc70588112711cf30c0f77df35c5ed3 (patch) | |
tree | 3dcfbe6c9f4c5ab9c7d9a81dea5dd625b7b076fe /plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus | |
parent | cc88d6908ec79067b10a704693a92eb145984079 (diff) | |
download | org.eclipse.papyrus-6ac95d923fc70588112711cf30c0f77df35c5ed3.tar.gz org.eclipse.papyrus-6ac95d923fc70588112711cf30c0f77df35c5ed3.tar.xz org.eclipse.papyrus-6ac95d923fc70588112711cf30c0f77df35c5ed3.zip |
Preserved textual representation comments when updating an element from
a stub.
Change-Id: Id667c40a00ebbb7389063427d66fdd039b05c207
Signed-off-by: Ed Seidewitz <ed-s@modeldriven.com>
Diffstat (limited to 'plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus')
-rw-r--r-- | plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/ModelMerge.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/ModelMerge.java b/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/ModelMerge.java index 47656f48ef2..5ad1c35e8cb 100644 --- a/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/ModelMerge.java +++ b/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/ModelMerge.java @@ -29,6 +29,7 @@ import org.eclipse.uml2.uml.Behavior; import org.eclipse.uml2.uml.BehavioralFeature; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.DataType; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.Enumeration; @@ -44,6 +45,8 @@ import org.eclipse.uml2.uml.Signal; import org.eclipse.uml2.uml.Stereotype; public class ModelMerge { + + private static final String TEXTUAL_REPRESENTATION_STEREOTYPE_NAME = "ActionLanguage::TextualRepresentation"; protected List<EObject> originalElements = new BasicEList<EObject>(); protected List<EObject> replacementElements = new BasicEList<EObject>(); @@ -223,13 +226,43 @@ public class ModelMerge { protected void updateClassifier(Classifier target, Classifier source) { this.addReplacement(source, target); updateStereotypes(target, source); - setList(target.getOwnedComments(), source.getOwnedComments()); setList(target.getGeneralizations(), source.getGeneralizations()); setList(target.getTemplateBindings(), source.getTemplateBindings()); target.setName(nameOf(source)); target.setVisibility(source.getVisibility()); target.setIsAbstract(source.isAbstract()); target.setOwnedTemplateSignature(source.getOwnedTemplateSignature()); + if (notStub(source)) { + setList(target.getOwnedComments(), source.getOwnedComments()); + } else { + List<Comment> targetComments = target.getOwnedComments(); + List<Comment> sourceComments = source.getOwnedComments(); + + Comment targetTextualRepresentation = getTextualRepresentation(targetComments); + if (targetTextualRepresentation != null) { + targetComments.remove(targetTextualRepresentation); + } + + Comment sourceTextualRepresentation = getTextualRepresentation(sourceComments); + if (sourceTextualRepresentation != null) { + sourceComments.remove(sourceTextualRepresentation); + } + + setList(targetComments, sourceComments); + + if (targetTextualRepresentation != null) { + targetComments.add(targetTextualRepresentation); + } + } + } + + protected static Comment getTextualRepresentation(List<Comment> comments) { + for (Comment comment: comments) { + if (comment.getAppliedStereotype(TEXTUAL_REPRESENTATION_STEREOTYPE_NAME) != null) { + return comment; + } + } + return null; } protected void updateMultiplicityElement(MultiplicityElement target, MultiplicityElement source) { |