From 307f0df7c79c1df96dcf4873824345a35998c12c Mon Sep 17 00:00:00 2001 From: Alberto Debiasi <adebiasi@fbk.eu> Date: Fri, 8 May 2020 18:34:27 +0200 Subject: [PATCH] Update EntityUtil.java. Change-Id: Idb3688931f36f6527f6c01f6824b0606094d34df --- .../chesscontract/util/EntityUtil.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java b/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java index 1b43ebc7e..e165db025 100644 --- a/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java +++ b/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java @@ -250,7 +250,7 @@ public class EntityUtil { } catch (PartInitException e) { } - return null; + return null; } public Model loadModel(String projectName, String fileName) { @@ -1759,26 +1759,26 @@ public class EntityUtil { } - + public Set<StateMachine> getNominalStateMachines(Model umlModel) { - + Set<StateMachine> stateMachines = new HashSet<StateMachine>(); - - - - - - - - - - - - + if (umlModel != null) { + TreeIterator<EObject> allElements = umlModel.eResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + for (Class c : classes) { + if (isNominalStateMachine(c)) { + stateMachines.add((StateMachine) c); + } + } + } + } - - - + return stateMachines; + } + public Set<StateMachine> getNominalStateMachines(UmlModel umlModel) { Set<StateMachine> stateMachines = new HashSet<StateMachine>(); @@ -2226,8 +2226,8 @@ public class EntityUtil { return ports; } - private Collection<? extends Port> getUmlPortsExceptEventsFromClass(Class umlElement, int portDirection) { - Set<Port> ports = new HashSet<Port>(); + private EList<? extends Port> getUmlPortsExceptEventsFromClass(Class umlElement, int portDirection) { + EList<Port> ports = new BasicEList<Port>(); for (Port umlPort : umlElement.getOwnedPorts()) { FlowPort fp = getFlowPort(umlPort); if ((fp.getDirection().getValue() == portDirection) && (!isEventPortAttribute(umlPort))) { @@ -3675,24 +3675,24 @@ public class EntityUtil { } } - + public Class getSystemElement(Model model) throws Exception { - - - - - + if (model != null) { + TreeIterator<EObject> allElements = model.eResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); - - - - - + for (Class c : classes) { + if (isSystem(c)) { + return c; + } + } + } + } + return null; + } - - - - /** * Returns the System component of the given package, if any. * -- GitLab