Skip to content

Commit

Permalink
[2189] After clone diagram the referencing , Current ans Referenced
Browse files Browse the repository at this point in the history
element are not copied
In this commit :
-Wa had the DAnnotation in the DRepresentationDescriptor after the copy
of DRepresentationDescriptor


Change-Id: I3a595e14bafc6718b141b6209667c93fc44ae928
Signed-off-by: Joacquim Esabe <joacquim.esabe@laposte.net>
  • Loading branch information
Joacquim Esabe committed Sep 17, 2018
1 parent a9098c3 commit 1749d8f
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -13,17 +13,18 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.description.DAnnotation;
import org.polarsys.capella.common.mdsofa.common.constant.ICommonConstants;
import org.polarsys.capella.common.mdsofa.common.helper.StringHelper;
import org.polarsys.capella.core.model.handler.helpers.RepresentationHelper;
Expand Down Expand Up @@ -162,6 +163,11 @@ public void execute() {
}
// Copy all representations.
for (DRepresentationDescriptor descriptor : _descriptors) {
// Copy all the Dannotation of DRepresentationDescriptor
Copier copier = new Copier();
Collection<DAnnotation> results = copier.copyAll(descriptor.getEAnnotations());
copier.copyReferences();

DRepresentation representation = descriptor.getRepresentation();
if (representation instanceof DSemanticDecorator) {
// Get target semantic element.
Expand All @@ -174,6 +180,8 @@ public void execute() {
DRepresentationDescriptor copyRepresentationDescriptor = RepresentationHelper
.getRepresentationDescriptor(session, copyRepresentation);
if (copyRepresentationDescriptor != null) {
// put the list of copy Dannotation in the copied DRepresentationDescriptor
copyRepresentationDescriptor.getEAnnotations().addAll(results);
// Retain copied reference.
_clones.add(copyRepresentationDescriptor);
}
Expand All @@ -196,7 +204,8 @@ protected String getCloneName(DRepresentation representation, Session session) {
String cloneName = StringHelper.formatMessage(message,
new Object[] { ICommonConstants.EMPTY_STRING, representation.getName() });
boolean cloneNameFound = false;
Collection<DRepresentationDescriptor> allDescriptors = DialectManager.INSTANCE.getAllRepresentationDescriptors(session);
Collection<DRepresentationDescriptor> allDescriptors = DialectManager.INSTANCE
.getAllRepresentationDescriptors(session);
int i = 1;
while (!cloneNameFound) {
boolean collision = false;
Expand Down

0 comments on commit 1749d8f

Please sign in to comment.