| /***************************************************************************** |
| * Copyright (c) 2019 CEA LIST, and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation |
| * |
| *****************************************************************************/ |
| |
| import org.eclipse.papyrus.interoperability.sysml16.sysml14.blackboxes.VersioningHelper; |
| import org.eclipse.papyrus.interoperability.sysml16.sysml14.SysMLDiagramsConstants; |
| |
| modeltype ecore "strict" uses 'http://www.eclipse.org/emf/2002/Ecore'; |
| modeltype UML "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML'; |
| modeltype notation "strict" uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation'; |
| modeltype style "strict" uses 'http://www.eclipse.org/papyrus/infra/gmfdiag/style'; |
| |
| /** |
| * This file provides useful method for SysML diagrams. |
| */ |
| library SysMLDiagramsUtils; |
| |
| |
| /** |
| * This allows to modify if existing the 'diagram_compatibility_version' value style, or create it if not existing. |
| **/ |
| helper setOrCreateCompatibilityVersion(inout diagram:notation::Diagram){ |
| // Search the compatibility version, if not exist, create it |
| var compatibilityVersionStyle:notation::StringValueStyle := diagram.styles->selectByType(notation::StringValueStyle)->any(curr | curr.name=DIAGRAM_COMPATIBILITY_VERSION); |
| if (compatibilityVersionStyle.oclIsUndefined()) { |
| // add style compatibility version style |
| compatibilityVersionStyle := object notation::StringValueStyle { |
| name := DIAGRAM_COMPATIBILITY_VERSION; |
| }; |
| diagram.styles+= compatibilityVersionStyle; |
| }; |
| compatibilityVersionStyle.stringValue := "1.4.0"; |
| } |
| |
| /** |
| * This allows to modify the papyrus view style to add the needed configuration. |
| **/ |
| helper addPapyrusDiagramStyleConfiguration(inout diagram:notation::Diagram, in model:UML::Model, in papyrusDiagram:String){ |
| // Search the papyrus diagram style, if not exist, create it |
| var papyrusDiagramStyle:style::PapyrusDiagramStyle := diagram.styles->selectByType(style::PapyrusDiagramStyle)->any(true); |
| if (papyrusDiagramStyle.oclIsUndefined()) { |
| // add the papyrus diagram style |
| papyrusDiagramStyle := object style::PapyrusDiagramStyle{ |
| owner := model.oclAsType(ecore::EObject); |
| }; |
| diagram.styles += papyrusDiagramStyle; |
| }; |
| papyrusDiagramStyle.diagramKindId := papyrusDiagram; |
| } |
| |
| /** |
| * This allows to get the papyrus diagram style to determinate if the diagram will be managed or not. |
| **/ |
| helper getPapyrusDiagramStyle(inout diagram:notation::Diagram) : String { |
| var resultValue:String := ""; |
| var papyrusDiagramStyle:style::PapyrusDiagramStyle := diagram.styles->selectByType(style::PapyrusDiagramStyle)->any(true); |
| if (not papyrusDiagramStyle.oclIsUndefined()) { |
| resultValue := papyrusDiagramStyle.diagramKindId; |
| }; |
| return resultValue; |
| } |