Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Constant2019-09-20 05:26:16 -0400
committerOlivier Constant2019-09-20 05:26:16 -0400
commit03a19c82b1421612ff6a2644f78d8f7d522287f1 (patch)
tree7b61a60e2d32086141f14e97f0ddb7bc6db4a8cb
parent8a2f3d2273031ac2803efe32990de3db33e8c1a6 (diff)
downloadorg.eclipse.emf.diffmerge.core-master.tar.gz
org.eclipse.emf.diffmerge.core-master.tar.xz
org.eclipse.emf.diffmerge.core-master.zip
Simple changes in Sirius extensionHEADmaster
Change-Id: I884c0c0a5f027d7a07dbb1b5a188cc5ce2118da5 Signed-off-by: Olivier Constant <olivier.constant@thalesgroup.com>
-rw-r--r--plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusDiffPolicy.java8
-rw-r--r--plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMatchPolicy.java6
-rw-r--r--plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMergePolicy.java44
-rw-r--r--plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java28
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusComparisonMethod.java9
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusDiffMergeLabelProvider.java12
6 files changed, 67 insertions, 40 deletions
diff --git a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusDiffPolicy.java b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusDiffPolicy.java
index bd4ec0fe..9251d70c 100644
--- a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusDiffPolicy.java
+++ b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusDiffPolicy.java
@@ -109,8 +109,9 @@ public class SiriusDiffPolicy extends GMFDiffPolicy {
// Ignore certain transient elements (OK because no cross-ref)
EObject element = match_p
.get(match_p.getUncoveredRole().opposite());
- if (element != null)
+ if (element != null) {
result = !UNSIGNIFICANT_TYPES.contains(element.eClass());
+ }
}
return result;
}
@@ -122,10 +123,11 @@ public class SiriusDiffPolicy extends GMFDiffPolicy {
public boolean coverValue(Object value_p, EAttribute attribute_p) {
boolean result;
if (IGNORING_EMPTY_STRING_ATTRIBUTES.contains(attribute_p)
- && ((String) value_p).length() == 0)
+ && ((String) value_p).length() == 0) {
result = false;
- else
+ } else {
result = super.coverValue(value_p, attribute_p);
+ }
return result;
}
diff --git a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMatchPolicy.java b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMatchPolicy.java
index 37b645ea..b82cf1c8 100644
--- a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMatchPolicy.java
+++ b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMatchPolicy.java
@@ -152,8 +152,9 @@ public class SiriusMatchPolicy extends GMFMatchPolicy {
String result = null;
if (element_p instanceof DView) {
Viewpoint viewpoint = ((DView) element_p).getViewpoint();
- if (viewpoint != null)
+ if (viewpoint != null) {
result = viewpoint.getName();
+ }
} else if (element_p instanceof DRepresentationDescriptor) {
result = ((DRepresentationDescriptor) element_p).getName();
} else if (element_p instanceof DRepresentation && scope_p instanceof SiriusScope) {
@@ -169,8 +170,9 @@ public class SiriusMatchPolicy extends GMFMatchPolicy {
result = "ANNOTATION_" + annotation.getSource(); //$NON-NLS-1$
}
}
- if (result == null)
+ if (result == null) {
result = super.getName(element_p, scope_p);
+ }
return result;
}
diff --git a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMergePolicy.java b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMergePolicy.java
index 04760e2a..a771ef0e 100644
--- a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMergePolicy.java
+++ b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusMergePolicy.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.sirius.diagram.DDiagramElement;
-import org.eclipse.sirius.viewpoint.DAnalysis;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DView;
@@ -74,9 +73,15 @@ public class SiriusMergePolicy extends GMFMergePolicy {
}
}
} else if (container == null) {
- DRepresentationDescriptor descriptor = getDescriptor(element_p, scope_p);
- if (descriptor != null)
+ DRepresentationDescriptor descriptor;
+ if (scope_p instanceof SiriusScope) {
+ descriptor = ((SiriusScope)scope_p).getRepresentationDescriptor(element_p);
+ } else {
+ descriptor = SiriusScope.getRepresentationDescriptorByExploration(element_p, scope_p);
+ }
+ if (descriptor != null) {
group_p.add(descriptor);
+ }
}
}
@@ -92,14 +97,17 @@ public class SiriusMergePolicy extends GMFMergePolicy {
// Semantic element -> DSemanticDecorators
extendSemanticElementAdditionGroup(group_p, element_p, scope_p);
// Sirius 4.1: Retrieve the diagram while merging the descriptor
- if (element_p instanceof DRepresentationDescriptor)
+ if (element_p instanceof DRepresentationDescriptor) {
extendDescriptorAdditionGroup(group_p, (DRepresentationDescriptor)element_p, scope_p);
+ }
// Sirius 4.1: Retrieve the descriptor while merging the diagram
- if (element_p instanceof DRepresentation)
+ if (element_p instanceof DRepresentation) {
extendDRepresentationAdditionGroup(group_p, (DRepresentation)element_p, scope_p);
+ }
// Sirius/GMF consistency: GMF driven by Sirius
- if (element_p instanceof DDiagramElement)
+ if (element_p instanceof DDiagramElement) {
extendGMFAdditionGroupSemanticTarget(group_p, element_p, scope_p);
+ }
}
/**
@@ -117,8 +125,9 @@ public class SiriusMergePolicy extends GMFMergePolicy {
for (EStructuralFeature.Setting setting :
crAdapter.getNonNavigableInverseReferences(element_p, false)) {
if (setting.getEStructuralFeature() ==
- ViewpointPackage.eINSTANCE.getDSemanticDecorator_Target())
+ ViewpointPackage.eINSTANCE.getDSemanticDecorator_Target()) {
group_p.add(setting.getEObject());
+ }
}
}
}
@@ -135,27 +144,6 @@ public class SiriusMergePolicy extends GMFMergePolicy {
}
/**
- * Return the descriptor for the given representation within the given scope, if any
- * @param representation_p a non-null representation
- * @param scope_p a non-null scope
- * @return a potentially null descriptor
- */
- protected DRepresentationDescriptor getDescriptor(
- DRepresentation representation_p, IFeaturedModelScope scope_p) {
- for (EObject root : scope_p.getContents()) {
- if (root instanceof DAnalysis) {
- for (DView view : ((DAnalysis)root).getOwnedViews()) {
- for (DRepresentationDescriptor descriptor : view.getOwnedRepresentationDescriptors()) {
- if (descriptor.getRepresentation() == representation_p)
- return descriptor;
- }
- }
- }
- }
- return null;
- }
-
- /**
* @see org.eclipse.emf.diffmerge.gmf.GMFMergePolicy#isSingleMandatory(org.eclipse.emf.ecore.EReference)
*/
@Override
diff --git a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
index 515361ab..c69d18d1 100644
--- a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
+++ b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
@@ -21,6 +21,7 @@ import java.util.Map;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.api.scopes.IModelScope;
import org.eclipse.emf.diffmerge.gmf.GMFScope;
import org.eclipse.emf.diffmerge.structures.common.FArrayList;
import org.eclipse.emf.ecore.EObject;
@@ -40,6 +41,7 @@ import org.eclipse.sirius.viewpoint.DAnalysis;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
+import org.eclipse.sirius.viewpoint.DView;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
import org.eclipse.sirius.viewpoint.description.style.StylePackage;
@@ -253,6 +255,9 @@ public class SiriusScope extends GMFScope {
if (result == null) {
DRepresentationQuery rep2descQuery = new DRepresentationQuery(representation_p);
result = rep2descQuery.getRepresentationDescriptor();
+ if (result == null) {
+ result = getRepresentationDescriptorByExploration(representation_p, this);
+ }
if (result != null) {
registerRepresentationDescriptor(result);
}
@@ -261,6 +266,29 @@ public class SiriusScope extends GMFScope {
}
/**
+ * Find and return the descriptor for the given representation, if any, by simple exploration
+ * of the given scope. It is assumed that Sirius DAnalyses are roots of the scope.
+ * The scope does not have to be a Sirius scope.
+ * @param representation_p a non-null representation
+ * @return a potentially null descriptor
+ */
+ public static DRepresentationDescriptor getRepresentationDescriptorByExploration(
+ DRepresentation representation_p, IModelScope scope_p) {
+ for (EObject root : scope_p.getContents()) {
+ if (root instanceof DAnalysis) {
+ for (DView view : ((DAnalysis)root).getOwnedViews()) {
+ for (DRepresentationDescriptor descriptor : view.getOwnedRepresentationDescriptors()) {
+ if (descriptor.getRepresentation() == representation_p) {
+ return descriptor;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* Return a session resource of the scope, if any
* @return a potentially null resource
*/
diff --git a/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusComparisonMethod.java b/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusComparisonMethod.java
index c49f6d59..6956afe4 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusComparisonMethod.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusComparisonMethod.java
@@ -114,8 +114,9 @@ public class SiriusComparisonMethod extends GMFComparisonMethod {
if (isThreeWay() && _roleToSession.get(Role.ANCESTOR) != null) {
// One of them is for the ancestor: use the other
Session sideSession = _roleToSession.get(Role.TARGET);
- if (sideSession == null)
+ if (sideSession == null) {
sideSession = _roleToSession.get(Role.REFERENCE);
+ }
result = sideSession.getTransactionalEditingDomain(); // sideSession cannot be null
} else {
// The two sessions are for the left and right sides:
@@ -160,8 +161,9 @@ public class SiriusComparisonMethod extends GMFComparisonMethod {
@Override
protected EditingDomain doGetEditingDomain() {
EditingDomain result = checkSessions();
- if (result == null && isVerbose())
+ if (result == null && isVerbose()) {
showNoEditingDomainWarning();
+ }
return result;
}
@@ -193,8 +195,9 @@ public class SiriusComparisonMethod extends GMFComparisonMethod {
Session roleSession = _roleToSession.get(role_p);
if (roleSession != null) {
EditingDomain sessionDomain = roleSession.getTransactionalEditingDomain();
- if (sessionDomain != null)
+ if (sessionDomain != null) {
result = sessionDomain.getResourceSet();
+ }
}
}
return result;
diff --git a/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusDiffMergeLabelProvider.java b/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusDiffMergeLabelProvider.java
index 76b75c3b..b4073a7a 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusDiffMergeLabelProvider.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui.sirius/src/org/eclipse/emf/diffmerge/ui/sirius/SiriusDiffMergeLabelProvider.java
@@ -43,8 +43,9 @@ public class SiriusDiffMergeLabelProvider extends GMFDiffMergeLabelProvider {
* @return a non-null object
*/
public static SiriusDiffMergeLabelProvider getInstance() {
- if (__instance == null)
+ if (__instance == null) {
__instance = new SiriusDiffMergeLabelProvider();
+ }
return __instance;
}
@@ -73,8 +74,9 @@ public class SiriusDiffMergeLabelProvider extends GMFDiffMergeLabelProvider {
protected String getDAnalysisText(DAnalysis element_p) {
String result = null;
Resource resource = element_p.eResource();
- if (resource != null && resource.getURI() != null)
+ if (resource != null && resource.getURI() != null) {
result = URI.decode(resource.getURI().lastSegment());
+ }
return result;
}
@@ -112,8 +114,9 @@ public class SiriusDiffMergeLabelProvider extends GMFDiffMergeLabelProvider {
Viewpoint viewpoint = element_p.getViewpoint();
if (viewpoint != null) {
result = MessageTranslator.INSTANCE.getMessage(viewpoint, viewpoint.getLabel());
- if (result == null)
+ if (result == null) {
result = viewpoint.getName();
+ }
}
return result;
}
@@ -170,8 +173,9 @@ public class SiriusDiffMergeLabelProvider extends GMFDiffMergeLabelProvider {
} else if (element_p instanceof RGBValues) {
result = getRGBValuesText((RGBValues)element_p);
}
- if (result == null)
+ if (result == null) {
result = super.getText(element_p);
+ }
return result;
}

Back to the top