Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Philipp Steghöfer2020-10-14 10:54:43 +0000
committerJan-Philipp Steghöfer2020-10-14 10:54:43 +0000
commit354d80cd414ccdc1a15a23c4027755d42d74882a (patch)
tree27a43530399083d15feb461f6562a887ea2248d8
parente3296bf9f96bece613f9f05dae645007a81b2052 (diff)
downloadorg.eclipse.capra-354d80cd414ccdc1a15a23c4027755d42d74882a.tar.gz
org.eclipse.capra-354d80cd414ccdc1a15a23c4027755d42d74882a.tar.xz
org.eclipse.capra-354d80cd414ccdc1a15a23c4027755d42d74882a.zip
Fixed a bug where selected element was not displayed in trace viewers
In some circumstances, the selected element, e.g., in the Papyrus diagram editor, was not displayed in the trace viewers, e.g., in the PlantUML View. Instead, a different element that is a child of the selected element was displayed. This was due to the fact that EMFHelper.linearize() put the root of the element tree last in the list. This commit fixes the behaviour. The change also reorders the elements in the traceability matrix view to show the container first and contained elements afterwards. Change-Id: I7af69ddee4198444241bd5d0bd085eeee05380a7
-rw-r--r--bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/EMFHelper.java5
-rw-r--r--tests/org.eclipse.capra.testsuite/src/org/eclipse/capra/testsuite/TestTraceabiltyMatrix.java10
2 files changed, 8 insertions, 7 deletions
diff --git a/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/EMFHelper.java b/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/EMFHelper.java
index 78c70d9c..34b590ef 100644
--- a/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/EMFHelper.java
+++ b/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/EMFHelper.java
@@ -154,7 +154,8 @@ public class EMFHelper {
/**
* Linearizes a tree to a list. The function checks if the provided parameter is
- * of type {@link EObject} and linearizes only if that is the case.
+ * of type {@link EObject} and linearizes only if that is the case. The root of
+ * the tree will always be the first element in the list.
*
* @param object the object to linearize
* @return a list of {@link EObject}s originally contained in the tree structure
@@ -165,8 +166,8 @@ public class EMFHelper {
ArrayList<EObject> elementList = new ArrayList<EObject>();
if (object instanceof EObject) {
EObject root = (EObject) object;
- root.eAllContents().forEachRemaining(element -> elementList.add(element));
elementList.add(root);
+ root.eAllContents().forEachRemaining(element -> elementList.add(element));
}
return elementList;
}
diff --git a/tests/org.eclipse.capra.testsuite/src/org/eclipse/capra/testsuite/TestTraceabiltyMatrix.java b/tests/org.eclipse.capra.testsuite/src/org/eclipse/capra/testsuite/TestTraceabiltyMatrix.java
index cd729af9..da578a8d 100644
--- a/tests/org.eclipse.capra.testsuite/src/org/eclipse/capra/testsuite/TestTraceabiltyMatrix.java
+++ b/tests/org.eclipse.capra.testsuite/src/org/eclipse/capra/testsuite/TestTraceabiltyMatrix.java
@@ -75,11 +75,11 @@ public class TestTraceabiltyMatrix {
private static final String EXPECTED_TEXT_FOR_SELECTED_PACKAGES_TRANSITIVE = "@startuml" + LINE_SEPARATOR + "salt"
+ LINE_SEPARATOR + "{#" + LINE_SEPARATOR
- + ".|A : EClass|AA : EClass|modelA : EPackage|B : EClass|BB : EClass|modelB : EPackage" + LINE_SEPARATOR
- + "A : EClass |. |. |. |X |. |." + LINE_SEPARATOR + "AA : EClass |. |. |. |. |X |." + LINE_SEPARATOR
- + "modelA : EPackage |. |. |. |. |. |X" + LINE_SEPARATOR + "B : EClass |X |. |. |. |. |." + LINE_SEPARATOR
- + "BB : EClass |. |X |. |. |. |." + LINE_SEPARATOR + "modelB : EPackage |. |. |X |. |. |." + LINE_SEPARATOR
- + "}" + LINE_SEPARATOR + LINE_SEPARATOR + "@enduml" + LINE_SEPARATOR;
+ + ".|modelA : EPackage|A : EClass|AA : EClass|modelB : EPackage|B : EClass|BB : EClass" + LINE_SEPARATOR
+ + "modelA : EPackage |. |. |. |X |. |." + LINE_SEPARATOR + "A : EClass |. |. |. |. |X |." + LINE_SEPARATOR
+ + "AA : EClass |. |. |. |. |. |X" + LINE_SEPARATOR + "modelB : EPackage |X |. |. |. |. |." + LINE_SEPARATOR
+ + "B : EClass |. |X |. |. |. |." + LINE_SEPARATOR + "BB : EClass |. |. |X |. |. |." + LINE_SEPARATOR + "}"
+ + LINE_SEPARATOR + LINE_SEPARATOR + "@enduml" + LINE_SEPARATOR;
private static final String EXPECTED_TEXT_FOR_SELECTED_CLASSES = "@startuml" + LINE_SEPARATOR + "salt"
+ LINE_SEPARATOR + "{#" + LINE_SEPARATOR + ".|A : EClass|B : EClass|AA : EClass|BB : EClass"

Back to the top