Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-06-18 08:28:57 +0000
committercletavernie2013-06-18 08:28:57 +0000
commit711c404e4feda881a9298ff9dfd06e64e81ea779 (patch)
tree5db7afde3a077dc23cf2f0f6e0925d7b904267fd /extraplugins/uml
parent98a10df09bf572355ec8a24b4ab3bcb8016caa9c (diff)
downloadorg.eclipse.papyrus-711c404e4feda881a9298ff9dfd06e64e81ea779.tar.gz
org.eclipse.papyrus-711c404e4feda881a9298ff9dfd06e64e81ea779.tar.xz
org.eclipse.papyrus-711c404e4feda881a9298ff9dfd06e64e81ea779.zip
409711: [Compare 2] Papyrus shall provide a PostProcessor for Compare 2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=409711 Clean up code
Diffstat (limited to 'extraplugins/uml')
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/.classpath4
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/META-INF/MANIFEST.MF6
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/about.html28
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/build.properties4
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/postprocessor/PapyrusPostProcessor.java101
-rw-r--r--extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/utils/GeneralizationChangesHelper.java226
7 files changed, 217 insertions, 159 deletions
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.classpath b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.classpath
index 3d1f8e3a126..8a8f1668cdc 100644
--- a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.classpath
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.settings/org.eclipse.jdt.core.prefs b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f287d53cf45
--- /dev/null
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/META-INF/MANIFEST.MF b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/META-INF/MANIFEST.MF
index 1921285f32d..44721f115a2 100644
--- a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/META-INF/MANIFEST.MF
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/META-INF/MANIFEST.MF
@@ -6,12 +6,12 @@ Bundle-Version: 0.1.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.papyrus.compare.postprocessor
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore,
- org.eclipse.emf.compare;visibility:=reexport,
- org.eclipse.emf.compare.diagram;visibility:=reexport,
+ org.eclipse.emf.compare;bundle-version="2.1.0",
+ org.eclipse.emf.compare.diagram;bundle-version="2.1.0",
org.eclipse.uml2.uml;bundle-version="4.1.0",
org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
org.eclipse.emf.compare.rcp;bundle-version="2.1.0"
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/about.html b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/build.properties b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/build.properties
index 9e1a8bbc3f2..48325079a46 100644
--- a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/build.properties
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/build.properties
@@ -3,7 +3,9 @@
bin.includes = .,\
META-INF/,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ about.html
jars.compile.order = .
source.. = src/
output.. = bin/
+src.includes = about.html
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/postprocessor/PapyrusPostProcessor.java b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/postprocessor/PapyrusPostProcessor.java
index 9d57c0ef802..062391aecb0 100644
--- a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/postprocessor/PapyrusPostProcessor.java
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/postprocessor/PapyrusPostProcessor.java
@@ -24,49 +24,62 @@ import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.diagram.internal.extensions.NodeChange;
import org.eclipse.emf.compare.postprocessor.IPostProcessor;
import org.eclipse.papyrus.compare.utils.GeneralizationChangesHelper;
-import org.eclipse.uml2.uml.Class ;
+import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Feature;
import org.eclipse.uml2.uml.Generalization;
/**
* PostProcessor specific to integration with Papyrus.
- * Creates needed requirements between Diffs implying addition/deletion of Generalizations in a .uml model,
+ * Creates needed requirements between Diffs implying addition/deletion of Generalizations in a .uml model,
* and Diffs implying addition/deletion of graphical nodes for inherited features.
- *
+ *
*/
@SuppressWarnings("restriction")
public class PapyrusPostProcessor implements IPostProcessor {
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postMatch(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postMatch(Comparison comparison, Monitor monitor) {
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postDiff(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postDiff(Comparison comparison, Monitor monitor) {
}
- /* (non-Javadoc)
- * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postRequirements(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postRequirements(org.eclipse.emf.compare.Comparison,
+ * org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postRequirements(Comparison comparison, Monitor monitor) {
}
- /* (non-Javadoc)
- * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postEquivalences(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postEquivalences(org.eclipse.emf.compare.Comparison,
+ * org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postEquivalences(Comparison comparison, Monitor monitor) {
}
- /* (non-Javadoc)
- * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postConflicts(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postConflicts(org.eclipse.emf.compare.Comparison,
+ * org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postConflicts(Comparison comparison, Monitor monitor) {
@@ -77,60 +90,66 @@ public class PapyrusPostProcessor implements IPostProcessor {
* for Diffs implying addition/deletion of Generalizations in a .uml model, and Diffs implying addition/deletion of
* graphical nodes for inherited features.
* Requirements between those Diffs are added so that:
- * - When a merge implies deletion of a Generalization, Diffs corresponding to deletion of nodes for inherited features (requiring this Generalization) are also merged
- * - When a merge implies addition of a node for an inherited feature, Diffs corresponding to addition of a Generalization (required for the inheritance of this feature) are also merged
+ * - When a merge implies deletion of a Generalization, Diffs corresponding to deletion of nodes for inherited features (requiring this
+ * Generalization) are also merged
+ * - When a merge implies addition of a node for an inherited feature, Diffs corresponding to addition of a Generalization (required for the
+ * inheritance of this feature) are also merged
*
- * It means that merging the deletion of a node for an inherited feature does not imply merging the deletion of a Generalization (required for this inheritance), if any.
+ * It means that merging the deletion of a node for an inherited feature does not imply merging the deletion of a Generalization (required for
+ * this inheritance), if any.
*
* (non-Javadoc)
- * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postComparison(org.eclipse.emf.compare.Comparison, org.eclipse.emf.common.util.Monitor)
+ *
+ * @see org.eclipse.emf.compare.postprocessor.IPostProcessor#postComparison(org.eclipse.emf.compare.Comparison,
+ * org.eclipse.emf.common.util.Monitor)
*/
@Override
public void postComparison(Comparison comparison, Monitor monitor) {
// Construct a GeneralizationChangesHelper from the given comparison
- GeneralizationChangesHelper helper = new GeneralizationChangesHelper(comparison) ;
+ GeneralizationChangesHelper helper = new GeneralizationChangesHelper(comparison);
// Use this helper to compute requirements
this.computeRequirements(helper);
}
/**
* Adds additional requirements between Diffs classified by the given helper.
- * Requirements are added when required between Diffs implying addition/deletion of Generalizations in a .uml model,
+ * Requirements are added when required between Diffs implying addition/deletion of Generalizations in a .uml model,
* and Diffs implying addition/deletion of graphical nodes for inherited features.
*
- * @param helper A GeneralizationChangesHelper containing a pre-classification of Diffs
+ * @param helper
+ * A GeneralizationChangesHelper containing a pre-classification of Diffs
*/
protected void computeRequirements(GeneralizationChangesHelper helper) {
// Compute diff requirements related to additions of graphical nodes for inherited features
- List<Class> classesWIthNodesForInheritedFeatures_ADDED = helper.getClassesWithInheritedPropertyNode(DifferenceKind.ADD) ;
- for (Class c : classesWIthNodesForInheritedFeatures_ADDED) {
- Set<Feature> features = helper.getInheritedFeaturesWithNodeChange(c) ;
- for (Feature f : features) {
- for (Generalization generalization : helper.getGeneralizationPath(c, f)) {
- ReferenceChange generalizationAdded = helper.getGeneralizationChange(generalization) ;
- if (generalizationAdded != null) {
- NodeChange nodeAdded = helper.getFeatureNodeChange(f) ;
- if (nodeAdded != null) {
- nodeAdded.getRequires().add(generalizationAdded) ;
- generalizationAdded.getRequiredBy().add(nodeAdded) ;
+ List<Class> classesWIthNodesForInheritedFeatures_ADDED = helper.getClassesWithInheritedPropertyNode(DifferenceKind.ADD);
+ for(Class c : classesWIthNodesForInheritedFeatures_ADDED) {
+ Set<Feature> features = helper.getInheritedFeaturesWithNodeChange(c);
+ for(Feature f : features) {
+ for(Generalization generalization : helper.getGeneralizationPath(c, f)) {
+ ReferenceChange generalizationAdded = helper.getGeneralizationChange(generalization);
+ if(generalizationAdded != null) {
+ NodeChange nodeAdded = helper.getFeatureNodeChange(f);
+ if(nodeAdded != null) {
+ nodeAdded.getRequires().add(generalizationAdded);
+ generalizationAdded.getRequiredBy().add(nodeAdded);
}
}
}
}
}
-
+
// Compute diff requirements related to deletions of nodes for inherited features
- List<Class> classesWIthNodesForInheritedFeatures_DELETED = helper.getClassesWithInheritedPropertyNode(DifferenceKind.DELETE) ;
- for (Class c : classesWIthNodesForInheritedFeatures_DELETED) {
- Set<Feature> features = helper.getInheritedFeaturesWithNodeChange(c) ;
- for (Feature f : features) {
- for (Generalization generalization : helper.getGeneralizationPath(c, f)) {
- ReferenceChange generalizationDeleted = helper.getGeneralizationChange(generalization) ;
- if (generalizationDeleted != null) {
- NodeChange nodeDeleted = helper.getFeatureNodeChange(f) ;
- if (nodeDeleted != null) {
- nodeDeleted.getRequiredBy().add(generalizationDeleted) ;
- generalizationDeleted.getRequires().add(nodeDeleted) ;
+ List<Class> classesWIthNodesForInheritedFeatures_DELETED = helper.getClassesWithInheritedPropertyNode(DifferenceKind.DELETE);
+ for(Class c : classesWIthNodesForInheritedFeatures_DELETED) {
+ Set<Feature> features = helper.getInheritedFeaturesWithNodeChange(c);
+ for(Feature f : features) {
+ for(Generalization generalization : helper.getGeneralizationPath(c, f)) {
+ ReferenceChange generalizationDeleted = helper.getGeneralizationChange(generalization);
+ if(generalizationDeleted != null) {
+ NodeChange nodeDeleted = helper.getFeatureNodeChange(f);
+ if(nodeDeleted != null) {
+ nodeDeleted.getRequiredBy().add(generalizationDeleted);
+ generalizationDeleted.getRequires().add(nodeDeleted);
}
}
}
diff --git a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/utils/GeneralizationChangesHelper.java b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/utils/GeneralizationChangesHelper.java
index 7b83b140851..ea7f783d07e 100644
--- a/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/utils/GeneralizationChangesHelper.java
+++ b/extraplugins/uml/compare2/org.eclipse.papyrus.compare/src/org/eclipse/papyrus/compare/utils/GeneralizationChangesHelper.java
@@ -37,7 +37,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Helper for extracting information used by the ComparePapyrusDiagramPostProcessor,
* in order to establish requirements between Diffs representing changes on Generalization in a .uml model,
* and Diffs representing changes on nodes for inherited features in .notation model.
- *
+ *
*/
@SuppressWarnings("restriction")
public class GeneralizationChangesHelper {
@@ -45,51 +45,51 @@ public class GeneralizationChangesHelper {
/**
* The Comparison analyzed by this GeneralizationChangesHelper
*/
- protected Comparison comparison ;
+ protected Comparison comparison;
/**
* A mapping between Features and Diffs representing changes for corresponding graphical nodes,
- * in the case where these graphical nodes represent inherited features, in the context of a node
+ * in the case where these graphical nodes represent inherited features, in the context of a node
* for an inheriting classifier.
*/
- protected Map<Feature, NodeChange> displayedInheritedFeatureToNodeChange = new HashMap<Feature, NodeChange>() ;
-
+ protected Map<Feature, NodeChange> displayedInheritedFeatureToNodeChange = new HashMap<Feature, NodeChange>();
+
/**
* A mapping between Generalizations and Diffs representing addition or deletion of this generalization.
*/
- protected Map<Generalization, ReferenceChange> generalizationToReferenceChange = new HashMap<Generalization, ReferenceChange>() ;
-
+ protected Map<Generalization, ReferenceChange> generalizationToReferenceChange = new HashMap<Generalization, ReferenceChange>();
+
/**
* A mapping between pairings of Classifier/Feature to Generalization path, where a path is a List<Generalization>,
- * and represents the list of Generalization required by a given Classifier to inherit from a given Feature
+ * and represents the list of Generalization required by a given Classifier to inherit from a given Feature
*/
- protected Map<Classifier, Map<Feature, List<Generalization>>> classifierAndFeatureToGeneralizationPath = new HashMap<Classifier, Map<Feature, List<Generalization>>>() ;
-
+ protected Map<Classifier, Map<Feature, List<Generalization>>> classifierAndFeatureToGeneralizationPath = new HashMap<Classifier, Map<Feature, List<Generalization>>>();
+
/**
* The list of Classes for which there exists a Diff implying addition of a node for an inherited Feature.
* FIXME Shall work for Classifiers in general
*/
- protected List<Class> classesWithNodeForInheritedFeature_ADDED = new ArrayList<Class>() ;
-
+ protected List<Class> classesWithNodeForInheritedFeature_ADDED = new ArrayList<Class>();
+
/**
* The list of Classes for which there exists a Diff implying deletion of a node for an inherited Feature.
* FIXME Shall work for Classifiers in general
*/
- protected List<Class> classesWithNodeForInheritedFeature_DELETED = new ArrayList<Class>() ;
+ protected List<Class> classesWithNodeForInheritedFeature_DELETED = new ArrayList<Class>();
/**
- * Constructor for this helper. Instantiation of this helper implies classification of Diffs associated with the given comparison.
+ * Constructor for this helper. Instantiation of this helper implies classification of Diffs associated with the given comparison.
*
* @param comparison
*/
public GeneralizationChangesHelper(Comparison comparison) {
- this.comparison = comparison ;
+ this.comparison = comparison;
this.classifyDiffs();
}
/**
* Classify Diffs related to the context Comparison.
- * Classification consists in:
+ * Classification consists in:
* - Identifying Diffs corresponding to changes on Generalizations in the .uml model
* - identifying Diffs corresponding to changes on nodes representing inherited features in the .notation model
* - Constructing local maps and lists to ease navigation between semantic elements and classified diffs
@@ -97,14 +97,13 @@ public class GeneralizationChangesHelper {
* classesWithNodeForInheritedFeature_ADDED, classesWithNodeForInheritedFeature_DELETED)
*/
protected void classifyDiffs() {
- for (Diff difference : this.comparison.getDifferences()) {
- if (difference instanceof ReferenceChange) {
+ for(Diff difference : this.comparison.getDifferences()) {
+ if(difference instanceof ReferenceChange) {
// TODO Changes may be required in connection with the following bug:
// Bug 406405 - A macroscopic change has to be created for UML DirectedRelationship elements
- this.evaluateGeneralizationChange((ReferenceChange)difference) ;
- }
- else if (difference instanceof NodeChange) {
- this.evaluateNodeForInheritedFeatureChange((NodeChange)difference) ;
+ this.evaluateGeneralizationChange((ReferenceChange)difference);
+ } else if(difference instanceof NodeChange) {
+ this.evaluateNodeForInheritedFeatureChange((NodeChange)difference);
}
}
}
@@ -113,12 +112,13 @@ public class GeneralizationChangesHelper {
* Evaluates if the given difference concerns a change on a Generalization,
* and classifies it accordingly.
*
- * @param difference The difference being evaluated
+ * @param difference
+ * The difference being evaluated
*/
protected void evaluateGeneralizationChange(ReferenceChange difference) {
// difference is a generalization if the associated eReference is Classifier.generalization
- if (difference.getReference().equals(UMLPackage.eINSTANCE.getClassifier_Generalization())) {
- this.generalizationToReferenceChange.put((Generalization)difference.getValue(), difference) ;
+ if(difference.getReference().equals(UMLPackage.eINSTANCE.getClassifier_Generalization())) {
+ this.generalizationToReferenceChange.put((Generalization)difference.getValue(), difference);
}
}
@@ -126,54 +126,53 @@ public class GeneralizationChangesHelper {
* Evaluates if the given difference concerns a change on a node (in the .notation)
* representing an inherited feature, and classifies it accordingly.
*
- * @param difference The difference being evaluated
+ * @param difference
+ * The difference being evaluated
*/
protected void evaluateNodeForInheritedFeatureChange(NodeChange difference) {
- Feature feature = null ;
- View view = null ;
+ Feature feature = null;
+ View view = null;
// Determines if the NodeChange concerns a View for a Feature
- if (difference.getView() != null && (difference.getView() instanceof View)) {
- view = (View)difference.getView() ;
- EObject semanticElement = view.getElement() ;
- if (semanticElement == null || ! (semanticElement instanceof Feature)) {
- return ;
- }
- else {
- feature = (Feature)semanticElement ;
+ if(difference.getView() != null && (difference.getView() instanceof View)) {
+ view = (View)difference.getView();
+ EObject semanticElement = view.getElement();
+ if(semanticElement == null || !(semanticElement instanceof Feature)) {
+ return;
+ } else {
+ feature = (Feature)semanticElement;
}
}
// Determines if the View corresponds to an inherited Feature.
// Requires to retrieve the View for the Class containing this Feature
- Class class_ = null ;
- EObject viewContainer = view.eContainer() ;
- while (viewContainer != null && class_ == null) {
- if (viewContainer instanceof View) {
- EObject semanticElement = ((View)viewContainer).getElement() ;
- if (semanticElement != null && semanticElement instanceof Class) {
- class_ = (Class)semanticElement ;
+ Class class_ = null;
+ EObject viewContainer = view.eContainer();
+ while(viewContainer != null && class_ == null) {
+ if(viewContainer instanceof View) {
+ EObject semanticElement = ((View)viewContainer).getElement();
+ if(semanticElement != null && semanticElement instanceof Class) {
+ class_ = (Class)semanticElement;
}
}
- viewContainer = viewContainer.eContainer() ;
+ viewContainer = viewContainer.eContainer();
}
- if (class_ == null) {
- return ;
+ if(class_ == null) {
+ return;
}
// The difference is added to the appropriate collections if the
// corresponding feature is an inherited member of the Class
- if (class_.getInheritedMembers().contains(feature)) {
- if (difference.getKind() == DifferenceKind.ADD) {
- if (! this.classesWithNodeForInheritedFeature_ADDED.contains(class_)) {
- this.classesWithNodeForInheritedFeature_ADDED.add(class_) ;
+ if(class_.getInheritedMembers().contains(feature)) {
+ if(difference.getKind() == DifferenceKind.ADD) {
+ if(!this.classesWithNodeForInheritedFeature_ADDED.contains(class_)) {
+ this.classesWithNodeForInheritedFeature_ADDED.add(class_);
}
- }
- else if (difference.getKind() == DifferenceKind.DELETE) {
- if (! this.classesWithNodeForInheritedFeature_DELETED.contains(class_)) {
- this.classesWithNodeForInheritedFeature_DELETED.add(class_) ;
+ } else if(difference.getKind() == DifferenceKind.DELETE) {
+ if(!this.classesWithNodeForInheritedFeature_DELETED.contains(class_)) {
+ this.classesWithNodeForInheritedFeature_DELETED.add(class_);
}
}
- List<Generalization> path = this.computeGeneralizationPath(class_, feature) ;
+ List<Generalization> path = this.computeGeneralizationPath(class_, feature);
this.insertGeneralizationPath(class_, feature, path);
- this.displayedInheritedFeatureToNodeChange.put(feature, difference) ;
+ this.displayedInheritedFeatureToNodeChange.put(feature, difference);
}
}
@@ -181,57 +180,58 @@ public class GeneralizationChangesHelper {
* Returns Classes for which there are changes on nodes representing inherited properties,
* with the given difference kind.
*
- * @param kind The DifferenceKind for changes on nodes representing inherited properties
+ * @param kind
+ * The DifferenceKind for changes on nodes representing inherited properties
* @return Classes for which there are changes on nodes representing inherited properties, with the given DifferenceKind
*/
public List<Class> getClassesWithInheritedPropertyNode(DifferenceKind kind) {
- if (kind == DifferenceKind.ADD) {
- return this.classesWithNodeForInheritedFeature_ADDED ;
- }
- else if (kind == DifferenceKind.DELETE) {
- return this.classesWithNodeForInheritedFeature_DELETED ;
+ if(kind == DifferenceKind.ADD) {
+ return this.classesWithNodeForInheritedFeature_ADDED;
+ } else if(kind == DifferenceKind.DELETE) {
+ return this.classesWithNodeForInheritedFeature_DELETED;
}
// Not supposed to happen
- return new ArrayList<Class>() ;
+ return new ArrayList<Class>();
}
-
+
/**
* Returns the Generalization path which enables the given classifier to inherit from the given feature.
* If no generalization path is found, returns an empty list
*
* FIXME Currently returns the first Generalization path that matches. Since multiple inheritance is allowed in UML, there can be multiple paths
*
- * @param classifier
+ * @param classifier
* @param inherited
* @return the Generalization path which enables the given classifier to inherit from the given feature.
*/
public List<Generalization> getGeneralizationPath(Classifier classifier, Feature inherited) {
- List<Generalization> path = null ;
- Map<Feature, List<Generalization>> inheritedFeatureToPath = this.classifierAndFeatureToGeneralizationPath.get(classifier) ;
- if (inheritedFeatureToPath != null) {
- path = inheritedFeatureToPath.get(inherited) ;
+ List<Generalization> path = null;
+ Map<Feature, List<Generalization>> inheritedFeatureToPath = this.classifierAndFeatureToGeneralizationPath.get(classifier);
+ if(inheritedFeatureToPath != null) {
+ path = inheritedFeatureToPath.get(inherited);
}
- return path != null ? path : new ArrayList<Generalization>() ;
+ return path != null ? path : new ArrayList<Generalization>();
}
-
+
/**
- * From the inherited features of the given classifier, returns those for which the inherited features of
+ * From the inherited features of the given classifier, returns those for which the inherited features of
* the given classifier that are related to changes on graphical nodes.
*
* @param classifier
* @return the inherited features of the given classifier that are related to change on graphical nodes
*/
public Set<Feature> getInheritedFeaturesWithNodeChange(Classifier classifier) {
- Set<Feature> inheritedFeatures = null ;
- Map<Feature, List<Generalization>> inheritedFeatureToPath = this.classifierAndFeatureToGeneralizationPath.get(classifier) ;
- if (inheritedFeatureToPath != null) {
- inheritedFeatures = inheritedFeatureToPath.keySet() ;
+ Set<Feature> inheritedFeatures = null;
+ Map<Feature, List<Generalization>> inheritedFeatureToPath = this.classifierAndFeatureToGeneralizationPath.get(classifier);
+ if(inheritedFeatureToPath != null) {
+ inheritedFeatures = inheritedFeatureToPath.keySet();
+ }
+ if(inheritedFeatures == null) {
+ inheritedFeatures = new HashSet<Feature>();
}
- if (inheritedFeatures == null)
- inheritedFeatures = new HashSet<Feature>() ;
- return inheritedFeatures ;
+ return inheritedFeatures;
}
-
+
/**
* Returns the generalization path that enables the given classifier to inherit from the given feature.
*
@@ -242,52 +242,54 @@ public class GeneralizationChangesHelper {
* @return the generalization path that enables the given classifier to inherit from the given feature.
*/
protected List<Generalization> computeGeneralizationPath(Classifier classifier, Feature inherited) {
- Classifier featuringClassifier = inherited.getFeaturingClassifiers().get(0) ; // There is always 1 and only 1 featuring classifier
- Generalization match = null ;
- for (int i = 0 ; i < classifier.getGeneralizations().size() && match == null ; i++) {
- Generalization generalization = classifier.getGeneralizations().get(i) ;
- if (generalization.getGeneral() == featuringClassifier) {
- match = generalization ;
+ Classifier featuringClassifier = inherited.getFeaturingClassifiers().get(0); // There is always 1 and only 1 featuring classifier
+ Generalization match = null;
+ for(int i = 0; i < classifier.getGeneralizations().size() && match == null; i++) {
+ Generalization generalization = classifier.getGeneralizations().get(i);
+ if(generalization.getGeneral() == featuringClassifier) {
+ match = generalization;
}
}
- List<Generalization> path = new ArrayList<>() ;
+ List<Generalization> path = new ArrayList<Generalization>();
// if no match found, it means that the feature is not directly inherited.
// Repeat recursively on general classifiers of the classifier to construct the generalization path
- if (match == null) {
- for (int i = 0 ; i < classifier.getGeneralizations().size() && path.size() == 0 ; i++) {
- Generalization generalization = classifier.getGeneralizations().get(i) ;
- Classifier general = generalization.getGeneral() ;
- List<Generalization> remaining = this.computeGeneralizationPath(general, inherited) ;
- if (remaining.size() != 0) {
- path.add(generalization) ;
- path.addAll(remaining) ;
+ if(match == null) {
+ for(int i = 0; i < classifier.getGeneralizations().size() && path.size() == 0; i++) {
+ Generalization generalization = classifier.getGeneralizations().get(i);
+ Classifier general = generalization.getGeneral();
+ List<Generalization> remaining = this.computeGeneralizationPath(general, inherited);
+ if(remaining.size() != 0) {
+ path.add(generalization);
+ path.addAll(remaining);
}
}
+ } else {
+ path = new ArrayList<Generalization>();
+ path.add(match);
}
- else {
- path = new ArrayList<Generalization>() ;
- path.add(match) ;
- }
- return path ;
+ return path;
}
/**
* Inserts a generalization path in the local map inheritedFeatureToGeneralizationPath,
* in the context of a specific classifier (cf. classifierAndFeatureToGeneralizationPath)
*
- * @param classifier The context classifier that inherits the given feature
- * @param inherited The feature inherited following the given path, in the context of the given classifier
- * @param path The generalization path (as a List) enabling the given classifier to inherit from the given feature
+ * @param classifier
+ * The context classifier that inherits the given feature
+ * @param inherited
+ * The feature inherited following the given path, in the context of the given classifier
+ * @param path
+ * The generalization path (as a List) enabling the given classifier to inherit from the given feature
*/
protected void insertGeneralizationPath(Classifier classifier, Feature inherited, List<Generalization> path) {
- Map<Feature, List<Generalization>> inheritedFeatureToGeneralizationPath = this.classifierAndFeatureToGeneralizationPath.get(classifier) ;
- if (inheritedFeatureToGeneralizationPath == null) {
- inheritedFeatureToGeneralizationPath = new HashMap<Feature, List<Generalization>>() ;
+ Map<Feature, List<Generalization>> inheritedFeatureToGeneralizationPath = this.classifierAndFeatureToGeneralizationPath.get(classifier);
+ if(inheritedFeatureToGeneralizationPath == null) {
+ inheritedFeatureToGeneralizationPath = new HashMap<Feature, List<Generalization>>();
}
- inheritedFeatureToGeneralizationPath.put(inherited, path) ;
- this.classifierAndFeatureToGeneralizationPath.put(classifier, inheritedFeatureToGeneralizationPath) ;
+ inheritedFeatureToGeneralizationPath.put(inherited, path);
+ this.classifierAndFeatureToGeneralizationPath.put(classifier, inheritedFeatureToGeneralizationPath);
}
-
+
/**
* From the comparison object from which this helper was constructed,
* returns the ReferenceChange diff corresponding to the given Generalization, if any.
@@ -296,9 +298,9 @@ public class GeneralizationChangesHelper {
* @return the ReferenceChange diff corresponding to the given Generalization, if any.
*/
public ReferenceChange getGeneralizationChange(Generalization generalization) {
- return this.generalizationToReferenceChange.get(generalization) ;
+ return this.generalizationToReferenceChange.get(generalization);
}
-
+
/**
* From the comparison object from which this helper was constructed,
* returns the NodeChange diff corresponding to the given feature, if any.
@@ -307,6 +309,6 @@ public class GeneralizationChangesHelper {
* @return
*/
public NodeChange getFeatureNodeChange(Feature feature) {
- return this.displayedInheritedFeatureToNodeChange.get(feature) ;
+ return this.displayedInheritedFeatureToNodeChange.get(feature);
}
}

Back to the top