Skip to content

Commit

Permalink
[558271] Handle scenario diagram navigation from State elements
Browse files Browse the repository at this point in the history
Bug: 558271
Change-Id: I60ed091ef26c0ed328fb8c7481b724e2adf5d9df
Signed-off-by: Arnaud Dieumegard <[email protected]>
  • Loading branch information
arnauddieumegard committed Dec 13, 2019
1 parent 42645de commit b9abdb5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -33,9 +34,11 @@
import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.description.DAnnotation;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.polarsys.capella.common.data.modellingcore.AbstractType;
import org.polarsys.capella.common.data.modellingcore.AbstractTypedElement;
import org.polarsys.capella.core.data.capellacore.CapellaElement;
import org.polarsys.capella.core.data.cs.BlockArchitecture;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.data.information.AbstractInstance;
import org.polarsys.capella.core.diagram.helpers.naming.DAnnotationSourceConstants;
import org.polarsys.kitalpha.doc.gen.business.core.preference.helper.DocgenDiagramPreferencesHelper;
import org.polarsys.kitalpha.doc.gen.business.core.scope.GenerationGlobalScope;
Expand Down Expand Up @@ -123,8 +126,18 @@ private static EList<EObject> resolveReferencedElements(EObject element) {
EList<EObject> objects = new BasicEList<EObject>();
objects.add(element);
// If we have a Component then we look also for Parts
if (element instanceof Component) {
objects.addAll(((Component)element).getAbstractTypedElements());
if (element instanceof AbstractType) {
List<AbstractTypedElement> ates = ((AbstractType)element).getAbstractTypedElements();
objects.addAll(ates);
// Then we look for InstanceRoles for these parts
for (EObject ate : ates) {
if (element instanceof AbstractInstance) {
objects.addAll(((AbstractInstance)ate).getRepresentingInstanceRoles());
}
}
}
if (element instanceof AbstractInstance) {
objects.addAll(((AbstractInstance)element).getRepresentingInstanceRoles());
}
return objects;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2019 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -12,8 +12,10 @@

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.polarsys.capella.core.data.capellacommon.AbstractState;
import org.polarsys.capella.core.data.capellacore.NamedElement;
import org.polarsys.capella.core.data.cs.ExchangeItemAllocation;
import org.polarsys.capella.core.data.fa.AbstractFunction;
import org.polarsys.capella.core.data.fa.FunctionalChainInvolvement;
import org.polarsys.capella.core.data.information.AbstractEventOperation;
import org.polarsys.capella.core.data.interaction.Execution;
Expand Down Expand Up @@ -72,7 +74,14 @@ public EObject getSemanticElement(DDiagramElement element) {
return null;
}
if (target instanceof StateFragment) {
return ((StateFragment) target).getRelatedAbstractFunction();
AbstractState aState = ((StateFragment) target).getRelatedAbstractState();
if (aState != null) {
return aState;
}
AbstractFunction aFunction = ((StateFragment) target).getRelatedAbstractFunction();
if (aFunction != null) {
return aFunction;
}
}
if (target instanceof FunctionalChainInvolvement) {
return ((FunctionalChainInvolvement) target).getInvolvedElement();
Expand Down

0 comments on commit b9abdb5

Please sign in to comment.