diff options
author | Christian W. Damus | 2016-05-04 19:58:27 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-05-09 12:03:52 +0000 |
commit | 0ee6cc3b8e341468b0bf84fb640fd55df878d9c1 (patch) | |
tree | e3088ceab727f39a82e1ddf878dc06e032de1b79 /plugins | |
parent | b6b24ff95f21a3852a200190927bd721728c706c (diff) | |
download | org.eclipse.papyrus-0ee6cc3b8e341468b0bf84fb640fd55df878d9c1.tar.gz org.eclipse.papyrus-0ee6cc3b8e341468b0bf84fb640fd55df878d9c1.tar.xz org.eclipse.papyrus-0ee6cc3b8e341468b0bf84fb640fd55df878d9c1.zip |
Bug 493030: [Viewpoints] Contributions to parent viewpoint are not considered
https://bugs.eclipse.org/bugs/show_bug.cgi?id=493030
Also include in the active viewpoints the viewpoints that are
contributed to the parent chain of the selected viewpoint, not just
the contributions to the selected viewpoint, itself.
Change-Id: I9b993b47a1eef3104f0aad78c3c5943e2a14c6fb
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java index 979cbc43027..432acd71b8d 100644 --- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java +++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013, 2015 CEA LIST, Christian W. Damus, and others. + * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others. * * * All rights reserved. This program and the accompanying materials @@ -10,7 +10,7 @@ * Contributors: * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - bug 422257 - * Christian W. Damus - bug 463156 + * Christian W. Damus - bugs 463156, 493030 * *****************************************************************************/ package org.eclipse.papyrus.infra.viewpoints.policy; @@ -442,27 +442,38 @@ public class PolicyChecker { /** - * Builds the <code>applicableViewpoints</code> member from the selected viewpoint and all its contribution + * Builds the <code>applicableViewpoints</code> member from the selected viewpoint. */ private void buildApplicableViewpoints() { applicableViewpoints = new ArrayList<PapyrusViewpoint>(); buildApplicableViewpoints(selectedViewpoint); - for (PapyrusViewpoint vp : getContributionsTo(selectedViewpoint)) { - buildApplicableViewpoints(vp); - } } /** - * Builds the <code>applicableViewpoints</code> member from the given viewpoint by adding it, as well as its parent + * Builds the <code>applicableViewpoints</code> member from the given viewpoint by adding it, + * as well as its parents and its and all its contributions, recursively * - * @param from - * The top viewpoint + * @param vp + * the viewpoint to add */ - private void buildApplicableViewpoints(PapyrusViewpoint from) { - PapyrusViewpoint vp = from; - while (vp != null) { + private void buildApplicableViewpoints(PapyrusViewpoint vp) { + // Guard against cycles, redundant contributions, contributions having the + // same parent, and other ways of repeating the processing of any viewpoint + if (!applicableViewpoints.contains(vp)) { + // This viewpoint applicableViewpoints.add(vp); - vp = vp.getParent(); + + // Its contributions, recursively. Process these first because they + // are more likely to be more pertinent to the selected stakeholder + // than the inherited viewpoint(s) + for (PapyrusViewpoint contrib : getContributionsTo(vp)) { + buildApplicableViewpoints(contrib); + } + + // Its parents, recursively + if ((vp.getParent() != null) && !vp.getParent().eIsProxy()) { + buildApplicableViewpoints(vp.getParent()); + } } } |