diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AltFragmentTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AltFragmentTemplate.mtl deleted file mode 100644 index d0ee8dacd93beb35fa06cbba384bd8da6322af05..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AltFragmentTemplate.mtl +++ /dev/null @@ -1,288 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] - -[module AltFragmentTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public AltFragmentTemplate(combFrag : CombinedFragment, index : Integer, globalvars : Set(String), startPlace : String, startX : Integer, startY : Integer)] - [let altFragmentName : String = combFrag.name] - [let operands : OrderedSet(InteractionOperand) = combFrag.operand] - [let x : Integer = 50] - [let y : Integer = 250*index] - [comment places and activities/] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[altFragmentName/]_failed</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+750/]</int> - <int id="y">[y+operands->size()*75/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment this is the end place /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">End[altFragmentName/]</string>[setStartPlace('End'.concat(altFragmentName))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+250/]</int>[setStartX(x+250)/] - <int id="y">[y+operands->size()*75/]</int>[setStartY(y+operands->size()*75)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[altFragmentName/]Activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">[operands->size()/]</int> - <vector id="CaseDistributions"> - [for (operand : InteractionOperand | operands)] - [let predicate : String = getPredicate(operand)] - <string id="[i-1/]">return([predicate/]);</string>[addToGlobalVars(predicate, globalvars)/] - [/let] - [/for] - </vector>[resetPredicateList()/] - </class> - </class> - [comment iterate over the operands/] - [for (operand : InteractionOperand | operands)] - [let attack : Message = getOperandAttack(operand)] - [comment places/] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+250/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+450/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </class> - </class> - [comment TODO: is it possible to model success prob?/] - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - <string id="0">return([attack.name/]_success_prob);\t// Attack succeeds</string> - <string id="1">return(1.0 - [attack.name/]_success_prob);\t// Attack fails</string> - </vector>[addToGlobalVars(attack.name.concat('_success_prob'), globalvars)/] - </class> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+650/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment edges/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[altFragmentName/]Activity</string> - <string id="FinishVertex">End[altFragmentName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y - getAltOffset(operands->size()-i, operands->size())/]</int> - </point> - <point id="1"> - <int id="x">[x+250/]</int> - <int id="y">[y+operands->size()*75/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[altFragmentName/]Activity</string> - <string id="FinishVertex">[attack.name/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y - getAltOffset(operands->size()-i, operands->size())/]</int> - </point> - <point id="1"> - <int id="x">[x+250/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]</string> - <string id="FinishVertex">[attack.name/]_activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+250/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - <point id="1"> - <int id="x">[x+450/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]_activity</string> - <string id="FinishVertex">[attack.name/]_success</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y+75*(i-1)-15/]</int> - </point> - <point id="1"> - <int id="x">[x+650/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]_activity</string> - <string id="FinishVertex">[altFragmentName/]_failed</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y+75*(i-1)/]</int> - </point> - <point id="1"> - <int id="x">[x+750/]</int> - <int id="y">[y+operands->size()*75/]</int> - </point> - </vector> - </class> - [/let] - [/for] - [comment: start place is previous fragment end place/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[startPlace/]</string> - <string id="FinishVertex">[altFragmentName/]Activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[startX/]</int> - <int id="y">[startY/]</int> - </point> - <point id="1"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/let] - [/let] - [/let] - [/let] -[/template] - -[query public getPredicate(operand : InteractionOperand) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getPredicate(org.eclipse.uml2.uml.InteractionOperand)', Sequence{operand})/] - -[query public getOperandAttack(operand : InteractionOperand) : Message = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getOperandAttack(org.eclipse.uml2.uml.InteractionOperand)', Sequence{operand})/] - -[query public resetPredicateList(ctx : OclAny) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'resetPredicateList()', Sequence{})/] - -[query public getAltOffset(index : Integer, size : Integer) : Integer = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAltOffset(java.lang.Integer, java.lang.Integer)', Sequence{index, size})/] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate.java deleted file mode 100644 index fcb0782649807a811b5ca113009a87e9cdeb98fb..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'AtomicComponentTemplate' generation module. - * - * @generated - */ -public class AtomicComponentTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/atomicComponentTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "atomicComponentTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public AtomicComponentTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public AtomicComponentTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public AtomicComponentTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - AtomicComponentTemplate generator = new AtomicComponentTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate_sanmodel.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate_sanmodel.java index b651c90fbafaf50a7948a7a5f1be326c1d74dc58..a3a1557c0fb089e07775f78fdb09308d08ef7b89 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate_sanmodel.java +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AtomicComponentTemplate_sanmodel.java @@ -340,9 +340,6 @@ public class AtomicComponentTemplate_sanmodel extends AbstractAcceleoGenerator { @Override public void registerPackages(ResourceSet resourceSet) { super.registerPackages(resourceSet); - if (!isInWorkspace(org.polarsys.chess.mobius.model.SAN.SANModelPackage.class)) { - resourceSet.getPackageRegistry().put(org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE.getNsURI(), org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE); - } /* * If you want to change the content of this method, do NOT forget to change the "@generated" diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.java deleted file mode 100644 index 419d411fd9da3942fa05b341ee264efb93759499..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'AttackScenarioTemplate' generation module. - * - * @generated - */ -public class AttackScenarioTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/AttackScenarioTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "AttackScenarioTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public AttackScenarioTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public AttackScenarioTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public AttackScenarioTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - AttackScenarioTemplate generator = new AttackScenarioTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.mtl deleted file mode 100644 index 48b7120ddbcf9a4e4c79d190fd71436f8262a123..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/AttackScenarioTemplate.mtl +++ /dev/null @@ -1,439 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module AttackScenarioTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] -[import org::polarsys::chess::mobius::templates::SingleAttackTemplate /] -[import org::polarsys::chess::mobius::templates::AltFragmentTemplate /] -[import org::polarsys::chess::mobius::templates::OptFragmentTemplate /] -[import org::polarsys::chess::mobius::templates::LoopFragmentTemplate /] -[import org::polarsys::chess::mobius::templates::DelayTemplate /] - -[template public AttackScenarioTemplate(model : Model, scenarioQN : String)] - [comment @main /] - [let scenarioName : String = getNameFromQN(scenarioQN)] - [file (scenarioName.concat('.san'), false, 'UTF-8')] - [let globalvars : Set(String) = getEmptyStringSet()] - [let x : Integer = 50] - [let y : Integer = 100] - [comment the first part is the "start" attack fragment /] -<?xml version="1.0" encoding="ISO-8859-1"?> -<class id="Mobius.AtomicModels.San.SanInterface"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseInterfaceClass"> - <int id="ClassVersion">3</int> - <string id="ModelName">[scenarioName/]</string> - <class id="Mobius.AtomicModels.San.SanInfoClass"> - <int id="ClassVersion">5</int> - <class id="Mobius.BaseClasses.BaseInfoClass"> - <int id="ClassVersion">2</int> - </class> - <class id="Mobius.AtomicModels.San.SanTypeManager"> - <int id="ClassVersion">1</int> - <int id="typeListModelSize">0</int> - </class> - <string id="CustomInitialization"></string> - </class> - <class id="Mobius.AtomicModels.San.SanEditor"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseEditorClass"> - <int id="ClassVersion">3</int> - <boolean id="HasPanel">true</boolean> - <class id="Mobius.BaseClasses.BasePanelClass"> - <int id="ClassVersion">2</int> - <point id="Size of Panel"> - <int id="x">1000</int> - <int id="y">1000</int> - </point> - <double id="ZoomFactor">1.0</double> - <boolean id="ShowGridEnabled">true</boolean> - <int id="ShowGridStep">10</int> - <boolean id="SnapGridEnabled">true</boolean> - <int id="SnapGridStep">10</int> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">Idle</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">1</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]Attempted</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 300/]</int> - <int id="y">[y/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment the "launched" place is the end/] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]Launched</string>[setStartPlace(scenarioName.concat('Launched'))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 600/]</int>[setStartX(x+600)/] - <int id="y">[y - 50/]</int>[setStartY(y+50)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]Blocked</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 600/]</int> - <int id="y">[y + 50/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.OutputGatePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]OutputGate</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 250/]</int> - <int id="y">[y - 50/]</int> - </point> - </class> - <boolean id="MirrorImage">false</boolean> - <string id="Function"> - Idle->Mark() = 1;\t// Implies continuous attacks with giv - en intensity; - </string> - </class> - <class id="Mobius.AtomicModels.San.TimedActivityPanelObject"> - <int id="ClassVersion">2</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]_AttackActivity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 150/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">1</int> - <vector id="CaseDistributions"> - <string id="0"></string> - </vector> - </class> - <class id="Mobius.BaseClasses.Distributions.DistributionFunction"> - <int id="ClassVersion">1</int> - <string id="Name">Exponential</string> - <vector id="MetaParameters"> - </vector> - <vector id="Parameters"> - [let attack_scenario_freq : String = getAttackScenarioFrequency(model, scenarioName)] - [if (attack_scenario_freq.size() = 0)] - <string id="0">return([scenarioName/]_intensity);</string>[addToGlobalVars(scenarioName.concat('_intensity'), globalvars)/] - [else] - <string id="0">return([attack_scenario_freq/]);</string> - [/if] - [/let] - </vector> - </class> - <string id="Activation"></string> - <string id="Reactivation"></string> - </class> - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]_BlockActivity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 450/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - [let attack_scenario_prob : String = getAttackScenarioProbSuccess(model, scenarioName)] - [if (attack_scenario_prob.size() = 0)] - <string id="0">return([scenarioName/]_succ_prob);</string> - <string id="1">return(1.0 - [scenarioName/]_succ_prob);\t\t// Attacked blocked.</string>[addToGlobalVars(scenarioName.concat('_succ_prob'), globalvars)/] - [else] - <string id="0">return([attack_scenario_prob/]);</string> - <string id="1">return([getAttackScenarioProbUnsuccess(model, attack_scenario_prob)/]);\t\t// Attacked blocked.</string> - [/if] - [/let] - </vector> - </class> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[scenarioName/]_AttackActivity</string> - <string id="FinishVertex">[scenarioName/]Attempted</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[scenarioName/]_BlockActivity</string> - <string id="FinishVertex">[scenarioName/]Launched</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+600/]</int> - <int id="y">[y-50/]/</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[scenarioName/]_BlockActivity</string> - <string id="FinishVertex">[scenarioName/]Blocked</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+600/]</int> - <int id="y">[y+50/]/</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[scenarioName/]_AttackActivity</string> - <string id="FinishVertex">[scenarioName/]OutputGate</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x + 250/]</int> - <int id="y">[y-50/]/</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">Idle</string> - <string id="FinishVertex">[scenarioName/]_AttackActivity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[scenarioName/]Attempted</string> - <string id="FinishVertex">[scenarioName/]_BlockActivity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+300/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+450/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [comment now read the ordered list of element and generate the fragments accordingly /] - [let scenario : Interaction = getScenario(model, scenarioName)] - [let orderedList : Sequence(NamedElement) = getOrderedAttacksAndFragments(scenario)] - [for (elem : NamedElement | orderedList)] - [comment compute current start place x and y/] - [let startPlace : String = getStartPlace()] - [let startX : Integer = getStartX()] - [let startY : Integer = getStartY()] - [comment a Message -> single attack /] - [if (elem.oclIsTypeOf(Message))] - [SingleAttackTemplate(elem.oclAsType(Message), i, globalvars, startPlace, startX, startY)/] - [/if] - [comment a CombinedFragment -> alt/opt/loop fragment /] - [if (elem.oclIsTypeOf(CombinedFragment))] - [let combFrag : CombinedFragment = elem.oclAsType(CombinedFragment)] - [let operator : String = combFrag.interactionOperator.toString()] - [if (operator.equalsIgnoreCase('alt'))] - [AltFragmentTemplate(combFrag, i, globalvars, startPlace, startX, startY)/] - [elseif (operator.equalsIgnoreCase('opt'))] - [OptFragmentTemplate(combFrag, i, globalvars, startPlace, startX, startY)/] - [elseif (operator.equalsIgnoreCase('loop'))] - [LoopFragmentTemplate(combFrag, i, globalvars, startPlace, startX, startY)/] - [/if] - [/let] - [/let] - [/if] - [comment a DurationConstraint -> delay /] - [if (elem.oclIsTypeOf(DurationConstraint))] - [DelayTemplate(elem.oclAsType(DurationConstraint), i, globalvars, startPlace, startX, startY)/] - [/if] - [/let] - [/let] - [/let] - [/for] - [/let] - [/let] - </class> - <vector id="LocalGlobalNamesList"> - [for (globalvar : String | globalvars)] - <string id="[i-1/]">[globalvar/]</string> - [/for] - </vector> - <vector id="LocalGlobalTypesList"> - [for (globalvar : String | globalvars)] - <string id="[i-1/]">[getVarType(model, globalvar)/]</string> - [/for] - </vector> - <boolean id="DisplayToolTips">true</boolean> - </class> - </class> - <boolean id="Valid">true</boolean> - </class> -</class> - [/let] - [/let] - [/let] - [/file] - [/let] -[/template] - -[query public getPlaces(block : Classifier) : Sequence(State) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getPlaces(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivities(block : Classifier) : Sequence(Transition) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getActivities(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivityName(tr : Transition) : String = tr.source.name + '__' + tr.target.name/] - -[query public getRate(tr : Transition) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getRate(org.eclipse.uml2.uml.Transition)', Sequence{tr})/] - -[query public getScenario(model : Model, scenarioName : String) : Interaction = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getScenario(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, scenarioName})/] - -[query public getOrderedAttacksAndFragments(scenario : Interaction) : Sequence(NamedElement) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getOrderedAttacksAndFragments(org.eclipse.uml2.uml.Interaction)', Sequence{scenario})/] - -[query public addToCurrentAlt(attack : Message) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'addToCurrentAlt(org.eclipse.uml2.uml.Message)', Sequence{attack})/] - -[query public clearCurrentAlt(ctx : OclAny) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'clearCurrentAlt()', Sequence{})/] - -[query public isCurrentAltEmpty(ctx : OclAny) : Boolean = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'isCurrentAltEmpty()', Sequence{})/] - -[query public getAttackScenarioFrequency(model : Model, scenarioName : String) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttackScenarioFrequency(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, scenarioName})/] - -[query public getAttackScenarioProbSuccess(model : Model, scenarioName : String) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttackScenarioProbSuccess(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, scenarioName})/] - -[query public getAttackScenarioProbUnsuccess(model : Model, probSuccess : String) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttackScenarioProbUnsuccess(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, probSuccess})/] - -[query public getVarType(model : Model, globalvar : String) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getVarType(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, globalvar})/] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate.java deleted file mode 100644 index 2797f994a702a6c38715f0d3d996c8f0cd359853..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'ComposedComponentTemplate' generation module. - * - * @generated - */ -public class ComposedComponentTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/composedComponentTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "composedComponentTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public ComposedComponentTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public ComposedComponentTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public ComposedComponentTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - ComposedComponentTemplate generator = new ComposedComponentTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate_sanmodel.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate_sanmodel.java index f74dab35ba55797ccde57e13fda26f574277bfe7..fc804c7753673dc0f0e18fa8b83b6e931905ba7f 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate_sanmodel.java +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ComposedComponentTemplate_sanmodel.java @@ -340,9 +340,6 @@ public class ComposedComponentTemplate_sanmodel extends AbstractAcceleoGenerator @Override public void registerPackages(ResourceSet resourceSet) { super.registerPackages(resourceSet); - if (!isInWorkspace(org.polarsys.chess.mobius.model.SAN.SANModelPackage.class)) { - resourceSet.getPackageRegistry().put(org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE.getNsURI(), org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE); - } /* * If you want to change the content of this method, do NOT forget to change the "@generated" diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/DelayTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/DelayTemplate.mtl deleted file mode 100644 index 2c7d976da6a16ebec9e0b17e75770d2c0d784703..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/DelayTemplate.mtl +++ /dev/null @@ -1,125 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module DelayTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public DelayTemplate(durConstr : DurationConstraint, index : Integer, globalvars : Set(String), startPlace : String, startX : Integer, startY : Integer)] - [let delayName : String = durConstr.name] - [let x : Integer = 50] - [let y : Integer = 250*index] - [comment places and activities /] - [comment this is the end place /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">End[delayName/]</string>[setStartPlace('End'.concat(delayName))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+300/]</int>[setStartX(x+300)/] - <int id="y">[y/]</int>[setStartX(y)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.TimedActivityPanelObject"> - <int id="ClassVersion">2</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[delayName/]Activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">1</int> - <vector id="CaseDistributions"> - <string id="0"></string> - </vector> - </class> - <class id="Mobius.BaseClasses.Distributions.DistributionFunction"> - <int id="ClassVersion">1</int> - <string id="Name">Exponential</string> - <vector id="MetaParameters"> - </vector> - <vector id="Parameters"> - [let delay_rate : String = getDelay(durConstr)] - <string id="0">return([delay_rate/]);</string>[addToGlobalVars(delay_rate, globalvars)/] - [/let] - </vector> - </class> - <string id="Activation"></string> - <string id="Reactivation"></string> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[delayName/]Activity</string> - <string id="FinishVertex">End[delayName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [comment: start place is previous fragment end place/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[startPlace/]</string> - <string id="FinishVertex">[delayName/]Activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[startX/]</int> - <int id="y">[startY/]</int> - </point> - <point id="1"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/let] - [/let] - [/let] -[/template] - -[query public getDelay(durConstr : DurationConstraint) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getDelay(org.eclipse.uml2.uml.DurationConstraint)', Sequence{durConstr})/] diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/LoopFragmentTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/LoopFragmentTemplate.mtl deleted file mode 100644 index 261c7028c97da79cd07dec1e331328fe19b45c8c..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/LoopFragmentTemplate.mtl +++ /dev/null @@ -1,353 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module LoopFragmentTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] -[import org::polarsys::chess::mobius::templates::AltFragmentTemplate /] - -[template public LoopFragmentTemplate(combFrag : CombinedFragment, index : Integer, globalvars : Set(String), startPlace : String, startX : Integer, startY : Integer)] - [let loopFragmentName : String = combFrag.name] - [let operand : InteractionOperand = combFrag.operand->first()] - [let attack : Message = getOperandAttack(operand)] - [let x : Integer = 50] - [let y : Integer = 300*index] - [comment places, activities and gates /] - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">SetUp[loopFragmentName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+200/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">1</int> - <vector id="CaseDistributions"> - <string id="0"></string> - </vector> - </class> - </class> - <class id="Mobius.AtomicModels.San.OutputGatePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]SetCounter</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+250/]</int> - <int id="y">[y-50/]</int> - </point> - </class> - [let counter : String = getLoopCounter(operand)] - <boolean id="MirrorImage">false</boolean>[addToGlobalVars(counter, globalvars)/] - <string id="Function">[loopFragmentName/]Counter->Mark() = [counter/];</string> - [/let] - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]Counter</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+475/]</int> - <int id="y">[y-50/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]_loop</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+350/]</int> - <int id="y">[y/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.TimedActivityPanelObject"> - <int id="ClassVersion">2</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]_loop_delay</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+525/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - [comment TODO: is it possible to model success prob?/] - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - <string id="0">return([attack.name/]_success_prob);\t// Attack succeeds</string> - <string id="1">return(1.0 - [attack.name/]_success_prob);\t// Attack fails</string> - </vector>[addToGlobalVars(attack.name.concat('_success_prob'), globalvars)/] - </class> - <class id="Mobius.BaseClasses.Distributions.DistributionFunction"> - <int id="ClassVersion">1</int> - <string id="Name">Exponential</string> - <vector id="MetaParameters"> - </vector> - <vector id="Parameters"> - <string id="0">return([loopFragmentName/]_attack_delay);</string> - </vector>[addToGlobalVars(loopFragmentName.concat('_attack_delay'), globalvars)/] - </class> - <string id="Activation"></string> - <string id="Reactivation"></string> - </class> - [comment this is the end place /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">End[loopFragmentName/]</string>[setStartPlace('End'.concat(loopFragmentName))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+800/]</int>[setStartX(x+800)/] - <int id="y">[y/]</int>[setStartY(y)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.OutputGatePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+675/]</int> - <int id="y">[y-25/]</int> - </point> - </class> - <boolean id="MirrorImage">false</boolean> - <string id="Function"> - [loopFragmentName/]Counter->Mark()--;\nif([loopFragmentName/]Counter->Mark() > 0) - \n {\n [attack.name/]_success->Mark()++;\t// Add an attack. - This place may be shared among many instances.\n\t\t\t\t\t - // The token will be taken by one of the instances: - they will compete for the token.\n [loopFragmentName/]_loop->Mar - k() = 1;\t// Continue with the loop\n }\nelse\n End[loopFragmentName/] - ->Mark() = 1;\t// Exit from the loop - </string> - </class> - <class id="Mobius.AtomicModels.San.OutputGatePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[loopFragmentName/]_blocked</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+675/]</int> - <int id="y">[y+25/]</int> - </point> - </class> - <boolean id="MirrorImage">false</boolean> - <string id="Function"> - [loopFragmentName/]Counter->Mark()--;\nif([loopFragmentName/]Counter->Mark() > 0) - \n {\n// This is the branch which corresponds to unsuccessf - ul attacks on component.\n// Hence no token is added to att - ack place \n [loopFragmentName/]_loop->Mark() = 1;\t// Continue - with the loop\n }\nelse\n End[loopFragmentName/]->Mark() = 1;\t/ - / Exit from the loop - </string> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+800/]</int> - <int id="y">[y-50/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment edges /] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">SetUp[loopFragmentName/]</string> - <string id="FinishVertex">[loopFragmentName/]SetCounter</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+200/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+250/]</int> - <int id="y">[y-50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">SetUp[loopFragmentName/]</string> - <string id="FinishVertex">[loopFragmentName/]_loop</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+200/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+350/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[loopFragmentName/]_loop</string> - <string id="FinishVertex">[loopFragmentName/]_loop_delay</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+350/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+525/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[loopFragmentName/]_loop_delay</string> - <string id="FinishVertex">[loopFragmentName/]_success</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+525/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+675/]</int> - <int id="y">[y+25/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[loopFragmentName/]_loop_delay</string> - <string id="FinishVertex">[loopFragmentName/]_blocked</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+525/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+675/]</int> - <int id="y">[y+25/]</int> - </point> - </vector> - </class> - [comment: start place is previous fragment end place/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[startPlace/]</string> - <string id="FinishVertex">SetUp[loopFragmentName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[startX/]</int> - <int id="y">[startY/]</int> - </point> - <point id="1"> - <int id="x">[x+200/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/let] - [/let] - [/let] - [/let] - [/let] -[/template] - -[query public getLoopCounter(operand : InteractionOperand) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getLoopCounter(org.eclipse.uml2.uml.InteractionOperand)', Sequence{operand})/] diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/OptFragmentTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/OptFragmentTemplate.mtl deleted file mode 100644 index 0aecbadd8cf4863ae1c8d6b6499557a7688e662c..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/OptFragmentTemplate.mtl +++ /dev/null @@ -1,271 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module OptFragmentTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] -[import org::polarsys::chess::mobius::templates::AltFragmentTemplate /] - -[template public OptFragmentTemplate(combFrag : CombinedFragment, index : Integer, globalvars : Set(String), startPlace : String, startX : Integer, startY : Integer)] - [let optFragmentName : String = combFrag.name] - [let operand : InteractionOperand = combFrag.operand->first()] - [let attack : Message = getOperandAttack(operand)] - [let x : Integer = 50] - [let y : Integer = 250*index] - [comment an opt fragment is very much alike an alt one, but with just a single operand/] - [comment this is the end place /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">End[optFragmentName/]</string>[setStartPlace('End'.concat(optFragmentName))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+250/]</int>[setStartX(x+250)/] - <int id="y">[y+50/]</int>[setStartY(y+50)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment other places and activities/] - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[optFragmentName/]Activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - [let predicate : String = getPredicate(operand)] - <string id="0">return([predicate/]);</string>[addToGlobalVars(predicate, globalvars)/] - <string id="0">return(1.0 - [predicate/]);</string> - [/let] - </vector>[resetPredicateList()/] - </class> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+250/]</int> - <int id="y">[y/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+450/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - [comment TODO: is it possible to model success prob?/] - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - <string id="0">return([attack.name/]_success_prob);\t// Attack succeeds</string> - <string id="1">return(1.0 - [attack.name/]_success_prob);\t// Attack fails</string> - </vector>[addToGlobalVars(attack.name.concat('_success_prob'), globalvars)/] - </class> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+600/]</int> - <int id="y">[y-25/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attack.name/]_failed</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+600/]</int> - <int id="y">[y+25/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]_activity</string> - <string id="FinishVertex">[attack.name/]_success</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+600/]</int> - <int id="y">[y-25/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]_activity</string> - <string id="FinishVertex">[attack.name/]_failed</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+450/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+600/]</int> - <int id="y">[y+25/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attack.name/]</string> - <string id="FinishVertex">[attack.name/]_activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+250/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+450/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[optFragmentName/]Activity</string> - <string id="FinishVertex">End[optFragmentName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+250/]</int> - <int id="y">[y+50/]</int>> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[optFragmentName/]Activity</string> - <string id="FinishVertex">[attack.name/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+250/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [comment: start place is previous fragment end place/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[startPlace/]</string> - <string id="FinishVertex">[optFragmentName/]Activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[startX/]</int> - <int id="y">[startY/]</int> - </point> - <point id="1"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/let] - [/let] - [/let] - [/let] - [/let] -[/template] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate.java deleted file mode 100644 index 44269c54a76eae2a41d0127088ff58594fccfb61..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'ProjectFileTemplate' generation module. - * - * @generated - */ -public class ProjectFileTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/projectFileTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "projectFileTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public ProjectFileTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public ProjectFileTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public ProjectFileTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - ProjectFileTemplate generator = new ProjectFileTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate_sanmodel.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate_sanmodel.java index b44f69cb019b5d6cfac0c22950fd93f251a1d074..5cc8e47d6cd85cc885fdff7eca5e5659b8bdc046 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate_sanmodel.java +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/ProjectFileTemplate_sanmodel.java @@ -340,9 +340,6 @@ public class ProjectFileTemplate_sanmodel extends AbstractAcceleoGenerator { @Override public void registerPackages(ResourceSet resourceSet) { super.registerPackages(resourceSet); - if (!isInWorkspace(org.polarsys.chess.mobius.model.SAN.SANModelPackage.class)) { - resourceSet.getPackageRegistry().put(org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE.getNsURI(), org.polarsys.chess.mobius.model.SAN.SANModelPackage.eINSTANCE); - } /* * If you want to change the content of this method, do NOT forget to change the "@generated" diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/RewardTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/RewardTemplate.java deleted file mode 100644 index 749811b7feb33274740ace5259d48915c3ea5228..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/RewardTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'RewardTemplate' generation module. - * - * @generated - */ -public class RewardTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/RewardTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "RewardTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public RewardTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public RewardTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public RewardTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - RewardTemplate generator = new RewardTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.java deleted file mode 100644 index 669a64af47dac36179702eb7645af53cdf602b37..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'AttackTemplate' generation module. - * - * @generated - */ -public class SingleAttackTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/attackSimpleTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "attackSimpleTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public SingleAttackTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public SingleAttackTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public SingleAttackTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - SingleAttackTemplate generator = new SingleAttackTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.mtl deleted file mode 100644 index 52225415c4c2392b5ba2a330abe552eff40434f1..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/SingleAttackTemplate.mtl +++ /dev/null @@ -1,201 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module SingleAttackTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public SingleAttackTemplate(attack : Message, index : Integer, globalvars : Set(String), startPlace : String, startX : Integer, startY : Integer)] - [let attackName : String = attack.name] - [let x : Integer = 50] - [let y : Integer = 250*index] - [comment places and activities /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackName/]_failed</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+300/]</int> - <int id="y">[y+50/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackName/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+300/]</int> - <int id="y">[y-50/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - [comment end place /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">End[attackName/]</string>[setStartPlace('End'.concat(attackName))/] - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+300/]</int>[setStartX(x+300)/] - <int id="y">[y+100/]</int>[setStartY(y+100)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackName/]_activity</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </class> - </class> - [comment TODO: is it possible to model success prob?/] - <int id="NumberOfCases">2</int> - <vector id="CaseDistributions"> - <string id="0">return([attackName/]_success_prob);\t// Attack succeeds</string> - <string id="1">return(1.0 - [attackName/]_success_prob);\t// Attack fails</string> - </vector>[addToGlobalVars(attackName.concat('_success_prob'), globalvars)/] - </class> - </class> - [comment edges /] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackName/]_activity</string> - <string id="FinishVertex">[attackName/]_failed</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y+50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackName/]_activity</string> - <string id="FinishVertex">[attackName/]_success</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y-50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackName/]_activity</string> - <string id="FinishVertex">End[attackName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y+100/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackName/]_activity</string> - <string id="FinishVertex">End[attackName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x+150/]</int> - <int id="y">[y-15/]</int> - </point> - <point id="1"> - <int id="x">[x+300/]</int> - <int id="y">[y+100/]</int> - </point> - </vector> - </class> - [comment: start place is previous fragment end place/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[startPlace/]</string> - <string id="FinishVertex">[attackName/]_activity</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[startX/]</int> - <int id="y">[startY/]</int> - </point> - <point id="1"> - <int id="x">[x+150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/let] - [/let] - [/let] -[/template] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/VulnerableComponentsTemplate.java b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/VulnerableComponentsTemplate.java deleted file mode 100644 index f0181972adb1c84f8ac1adb4fe1f6824337dab72..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/VulnerableComponentsTemplate.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Obeo. - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.polarsys.chess.mobius.templates; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; -import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; -import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Monitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Entry point of the 'VulnerableComponentsTemplate' generation module. - * - * @generated - */ -public class VulnerableComponentsTemplate extends AbstractAcceleoGenerator { - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/polarsys/chess/mobius/templates/vulnerableComponentsTemplate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "vulnerableComponentsTemplate" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - * - * @generated - */ - private List<String> propertiesFiles = new ArrayList<String>(); - - /** - * Allows the public constructor to be used. Note that a generator created - * this way cannot be used to launch generations before one of - * {@link #initialize(EObject, File, List)} or - * {@link #initialize(URI, File, List)} is called. - * <p> - * The main reason for this constructor is to allow clients of this - * generation to call it from another Java file, as it allows for the - * retrieval of {@link #getProperties()} and - * {@link #getGenerationListeners()}. - * </p> - * - * @generated - */ - public VulnerableComponentsTemplate() { - // Empty implementation - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param modelURI - * URI where the model on which this generator will be used is located. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or - * the model cannot be loaded. - * @generated - */ - public VulnerableComponentsTemplate(URI modelURI, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(modelURI, targetFolder, arguments); - } - - /** - * This allows clients to instantiates a generator with all required information. - * - * @param model - * We'll iterate over the content of this element to find Objects matching the first parameter - * of the template we need to call. - * @param targetFolder - * This will be used as the output folder for this generation : it will be the base path - * against which all file block URLs will be resolved. - * @param arguments - * If the template which will be called requires more than one argument taken from the model, - * pass them here. - * @throws IOException - * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. - * @generated - */ - public VulnerableComponentsTemplate(EObject model, File targetFolder, - List<? extends Object> arguments) throws IOException { - initialize(model, targetFolder, arguments); - } - - /** - * This can be used to launch the generation from a standalone application. - * - * @param args - * Arguments of the generation. - * @generated - */ - public static void main(String[] args) { - try { - if (args.length < 2) { - System.out.println("Arguments not valid : {model, folder}."); - } else { - URI modelURI = URI.createFileURI(args[0]); - File folder = new File(args[1]); - - List<String> arguments = new ArrayList<String>(); - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * Add in this list all the arguments used by the starting point of the generation - * If your main template is called on an element of your model and a String, you can - * add in "arguments" this "String" attribute. - */ - - VulnerableComponentsTemplate generator = new VulnerableComponentsTemplate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new properties, add them in "propertiesFiles" - * You can add the absolute path of a properties files, or even a project relative path. - * If you want to add another "protocol" for your properties files, please override - * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. - * The behavior of the properties loader service is explained in the Acceleo documentation - * (Help -> Help Contents). - */ - - for (int i = 2; i < args.length; i++) { - generator.addPropertiesFile(args[i]); - } - - generator.doGenerate(new BasicMonitor()); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Launches the generation described by this instance. - * - * @param monitor - * This will be used to display progress information to the user. - * @throws IOException - * This will be thrown if any of the output files cannot be saved to disk. - * @generated - */ - @Override - public void doGenerate(Monitor monitor) throws IOException { - /* - * TODO if you wish to change the generation as a whole, override this. The default behavior should - * be sufficient in most cases. If you want to change the content of this method, do NOT forget to - * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, - * any compilation of the Acceleo module with the main template that has caused the creation of this - * class will revert your modifications. If you encounter a problem with an unresolved proxy during the - * generation, you can remove the comments in the following instructions to check for problems. Please - * note that those instructions may have a significant impact on the performances. - */ - - //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); - - /* - * If you want to check for potential errors in your models before the launch of the generation, you - * use the code below. - */ - - //if (model != null && model.eResource() != null) { - // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors(); - // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { - // System.err.println(diagnostic.toString()); - // } - //} - - super.doGenerate(monitor); - } - - /** - * If this generator needs to listen to text generation events, listeners can be returned from here. - * - * @return List of listeners that are to be notified when text is generated through this launch. - * @generated - */ - @Override - public List<IAcceleoTextGenerationListener> getGenerationListeners() { - List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners(); - /* - * TODO if you need to listen to generation event, add listeners to the list here. If you want to change - * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method - * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template - * that has caused the creation of this class will revert your modifications. - */ - return listeners; - } - - /** - * If you need to change the way files are generated, this is your entry point. - * <p> - * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates - * files on the fly. If you only need to preview the results, return a new - * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of - * the running Eclipse and can be used standalone. - * </p> - * <p> - * If you need the file generation to be aware of the workspace (A typical example is when you wanna - * override files that are under clear case or any other VCS that could forbid the overriding), then - * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. - * <b>Note</b>, however, that this <b>cannot</b> be used standalone. - * </p> - * <p> - * All three of these default strategies support merging through JMerge. - * </p> - * - * @return The generation strategy that is to be used for generations launched through this launcher. - * @generated - */ - @Override - public IAcceleoGenerationStrategy getGenerationStrategy() { - return super.getGenerationStrategy(); - } - - /** - * This will be called in order to find and load the module that will be launched through this launcher. - * We expect this name not to contain file extension, and the module to be located beside the launcher. - * - * @return The name of the module that is to be launched. - * @generated - */ - @Override - public String getModuleName() { - return MODULE_FILE_NAME; - } - - /** - * If the module(s) called by this launcher require properties files, return their qualified path from - * here.Take note that the first added properties files will take precedence over subsequent ones if they - * contain conflicting keys. - * - * @return The list of properties file we need to add to the generation context. - * @see java.util.ResourceBundle#getBundle(String) - * @generated - */ - @Override - public List<String> getProperties() { - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * - * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse - * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties - * files to the "propertiesFiles" list: - * - * final String prefix = "platform:/plugin/"; - * final String pluginName = "org.eclipse.acceleo.module.sample"; - * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; - * final String fileName = "default.properties"; - * propertiesFiles.add(prefix + pluginName + packagePath + fileName); - * - * With this mechanism, you can load properties files from your plugin or from another plugin. - * - * You may want to load properties files from the file system, for that you need to add the absolute path of the file: - * - * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); - * - * If you want to let your users add properties files located in the same folder as the model: - * - * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { - * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); - * } - * - * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). - */ - return propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated - * @since 3.1 - */ - @Override - public void addPropertiesFile(String propertiesFile) { - this.propertiesFiles.add(propertiesFile); - } - - /** - * This will be used to get the list of templates that are to be launched by this launcher. - * - * @return The list of templates to call on the module {@link #getModuleName()}. - * @generated - */ - @Override - public String[] getTemplateNames() { - return TEMPLATE_NAMES; - } - - /** - * This can be used to update the resource set's package registry with all needed EPackages. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerPackages(ResourceSet resourceSet) { - super.registerPackages(resourceSet); - if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { - resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); - } - - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * If you need additional package registrations, you can register them here. The following line - * (in comment) is an example of the package registration for UML. - * - * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to - * register is in the workspace. - * - * To register a package properly, please follow the following conventions: - * - * If the package is located in another plug-in, already installed in Eclipse. The following content should - * have been generated at the beginning of this method. Do not register the package using this mechanism if - * the metamodel is located in the workspace. - * - * if (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } - * - * If the package is located in another project in your workspace, the plugin containing the package has not - * been register by EMF and Acceleo should register it automatically. If you want to use the generator in - * stand alone, the regular registration (seen a couple lines before) is needed. - * - * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). - */ - } - - /** - * This can be used to update the resource set's resource factory registry with all needed factories. - * - * @param resourceSet - * The resource set which registry has to be updated. - * @generated - */ - @Override - public void registerResourceFactories(ResourceSet resourceSet) { - super.registerResourceFactories(resourceSet); - /* - * If you want to change the content of this method, do NOT forget to change the "@generated" - * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation - * of the Acceleo module with the main template that has caused the creation of this class will - * revert your modifications. - */ - - /* - * TODO If you need additional resource factories registrations, you can register them here. the following line - * (in comment) is an example of the resource factory registration for UML. - * - * If you want to use the generator in stand alone, the resource factory registration will be required. - * - * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - -} diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate.mtl deleted file mode 100644 index 584fbda13da15dfa48bf4596859c231b4071ba61..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate.mtl +++ /dev/null @@ -1,465 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module atomicComponentTemplate('http://www.eclipse.org/uml2/3.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public atomicComponentTemplate(model : Model, componentQN : String){ - BlockQN : String = 'SysML::Blocks::Block'; - ErrorModelBehaviorQN : String = 'CHESS::Dependability::DependableComponent::ErrorModelBehavior'; - NormalStateQN : String = 'CHESS::Dependability::ThreatsPropagation::NormalState'; - ErrorStateQN : String = 'CHESS::Dependability::ThreatsPropagation::ErrorState'; - CompromisedStateQN : String = 'CHESS::Dependability::ThreatsPropagation::CompromisedState'; - InternalFaultQN : String = 'CHESS::Dependability::ThreatsPropagation::InternalFault'; - AttackQN : String = 'CHESS::Dependability::ThreatsPropagation::Attack'; -}] - - [comment @main /] - [let componentName : String = getNameFromQN(componentQN)] - [file (componentName.concat('.san'), false, 'UTF-8')] - [let globalvars : Set(String) = getEmptyStringSet()] - [let placeX : Integer = 0] - [let placeY : Integer = 75] - [let activityX : Integer = 50] - [let activityY : Integer = 150] - [let attackX : Integer = 100] - [let attackY : Integer = 200] -<?xml version="1.0" encoding="ISO-8859-1"?> -<class id="Mobius.AtomicModels.San.SanInterface"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseInterfaceClass"> - <int id="ClassVersion">3</int> - <string id="ModelName">[componentName/]</string> - <class id="Mobius.AtomicModels.San.SanInfoClass"> - <int id="ClassVersion">5</int> - <class id="Mobius.BaseClasses.BaseInfoClass"> - <int id="ClassVersion">2</int> - </class> - <class id="Mobius.AtomicModels.San.SanTypeManager"> - <int id="ClassVersion">1</int> - <int id="typeListModelSize">0</int> - </class> - <string id="CustomInitialization"></string> - </class> - <class id="Mobius.AtomicModels.San.SanEditor"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseEditorClass"> - <int id="ClassVersion">3</int> - <boolean id="HasPanel">true</boolean> - <class id="Mobius.BaseClasses.BasePanelClass"> - <int id="ClassVersion">2</int> - <point id="Size of Panel"> - <int id="x">900</int> - <int id="y">400</int> - </point> - <double id="ZoomFactor">1.0</double> - <boolean id="ShowGridEnabled">true</boolean> - <int id="ShowGridStep">10</int> - <boolean id="SnapGridEnabled">true</boolean> - <int id="SnapGridStep">10</int> - [let atomicBlocks : Sequence(Classifier) = getAtomicBlocks(model)] - [let atomicBlock : Classifier = getBlockFromQN(atomicBlocks, componentQN)] - [if(atomicBlock.getAppliedStereotype(ErrorModelBehaviorQN)->notEmpty())] - [let places : Sequence(State) = getPlaces(atomicBlock)] - [for (place : State | places)] - [comment places /] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[place.name/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - [comment: TODO save X and Y of the normal place/] - <int id="x">[placeX + i*150/]</int> [setOkX(placeX + i*150)/] - <int id="y">[placeY/]</int> [setOkY(placeY)/] - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - [comment normal place starts with one token /] - [if(place.getAppliedStereotype(NormalStateQN)->notEmpty())] - <int id="InitialState">1</int> - [else] - <int id="InitialState">0</int> - [/if] - </class> - [/for] - [/let] - [let activities : Sequence(Transition) = getActivities(atomicBlock)] - [for (activity : Transition | activities)] - [if(activity.getAppliedStereotype(InternalFaultQN)->notEmpty())] - [comment an internalFault transition is a TimedActivity with a rate /] - [let timedActivityName : String = getActivityName(activity)] - <class id="Mobius.AtomicModels.San.TimedActivityPanelObject"> - <int id="ClassVersion">2</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[timedActivityName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">1</int> - <vector id="CaseDistributions"> - <string id="0"></string> - </vector> - </class> - [comment TODO? always Exponential for the moment/] - [let rate : String = getRate(activity)] - <class id="Mobius.BaseClasses.Distributions.DistributionFunction"> - <int id="ClassVersion">1</int> - <string id="Name">Exponential</string> - <vector id="MetaParameters"> - </vector> - <vector id="Parameters"> - [if (rate.size() = 0)] - [comment global variable/] - [addToGlobalVars(timedActivityName.concat('Rate'), globalvars)/] - <string id="0">[timedActivityName/]Rate</string> - [else] - <string id="0">[rate/]</string> - [/if] - </vector> - </class> - [/let] - <string id="Activation"></string> - <string id="Reactivation"></string> - </class> - [comment links for the timed activity/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[timedActivityName/]</string> - <string id="FinishVertex">[activity.target.name/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - <point id="1"> - <int id="x">[placeX + i*150/]</int> - <int id="y">[placeY/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[activity.source.name/]</string> - <string id="FinishVertex">[timedActivityName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[placeX + i*150/]</int> - <int id="y">[placeY/]</int> - </point> - <point id="1"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - </vector> - </class> - [/let] - [/if] - [if(activity.getAppliedStereotype(AttackQN)->notEmpty())] - [comment an Attack transition is an instantaneous activity /] - [let instActivityName : String = getActivityName(activity)] - <class id="Mobius.AtomicModels.San.InstantaneousActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.AtomicModels.San.ActivityPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.ExtendedBaseVertexClass"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[instActivityName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - </class> - </class> - <int id="NumberOfCases">1</int> - <vector id="CaseDistributions"> - <string id="0"></string> - </vector> - </class> - </class> - [comment links for the instantaneous activity/] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[instActivityName/]</string> - <string id="FinishVertex">[activity.target.name/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - <point id="1"> - <int id="x">[placeX + i*150/]</int> - <int id="y">[placeY/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[activity.source.name/]</string> - <string id="FinishVertex">[instActivityName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[placeX + i*150/]</int> - <int id="y">[placeY/]</int> - </point> - <point id="1"> - <int id="x">[activityX + i*150/]</int> - <int id="y">[activityY/]</int> - </point> - </vector> - </class> - [comment TODO WIP: for each attack success: - add one place for attack_success, - add one place for attack_confirmed, - add an input attack_gate, - connect attack_success with attack_gate, - connect OK(normal state) with attack_gate, - connect attack_confirmed with attack_gate, - connect attack_confirmed with instActivityName/] - [let attackSuccPlaceNames : Sequence(String) = getAttackSuccName(activity)] - [let outerIndex : Integer = i] - [let normalStateName : String = getNormalState(atomicBlock).name] - [for (attackSuccPlaceName : String | attackSuccPlaceNames)] - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackSuccPlaceName/]_success</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 100 /]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.PlacePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackSuccPlaceName/]_confirmed</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY/]</int> - </point> - </class> - <boolean id="ReadOnly">false</boolean> - <boolean id="ConstantMarking">true</boolean> - <int id="InitialState">0</int> - </class> - <class id="Mobius.AtomicModels.San.InputGatePanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[attackSuccPlaceName/]Gate</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 50/]</int> - </point> - </class> - <boolean id="MirrorImage">false</boolean> - <string id="Predicate"> - [comment predicate and function/] - ([attackSuccPlaceName/]_success->Mark() > 0) && ([normalStateName/]->Mar - k() > 0) && ([attackSuccPlaceName/]_confirmed->Mark() == 0)) - </string> - <string id="Function">[attackSuccPlaceName/]_confirmed->Mark() = 1;</string> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackSuccPlaceName/]_success</string> - <string id="FinishVertex">[attackSuccPlaceName/]Gate</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 100 /]</int> - </point> - <point id="1"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[normalStateName/]</string> - <string id="FinishVertex">[attackSuccPlaceName/]Gate</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[getOkX()/]</int> - <int id="y">[getOkY()/]</int> - </point> - <point id="1"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackSuccPlaceName/]_confirmed</string> - <string id="FinishVertex">[attackSuccPlaceName/]Gate</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY/]</int> - </point> - <point id="1"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY + 50/]</int> - </point> - </vector> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[attackSuccPlaceName/]_confirmed</string> - <string id="FinishVertex">[instActivityName/]</string> - <boolean id="Arrows">true</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[attackX + outerIndex*150 + i*50/]</int> - <int id="y">[attackY/]</int> - </point> - <point id="1"> - <int id="x">[activityX + outerIndex*150/]</int> - <int id="y">[activityY/]</int> - </point> - </vector> - </class> - [/for] - [/let] - [/let] - [/let] - [/let] - [/if] - [/for] - [/let] - [/if] - [/let] - [/let] - </class> - <vector id="LocalGlobalNamesList"> - [for (globalvar : String | globalvars)] - <string id="[i/]">[globalvar/]</string> - [/for] - </vector> - <vector id="LocalGlobalTypesList"> - [for (globalvar : String | globalvars)] - <string id="[i/]">double</string> - [/for] - </vector> - <boolean id="DisplayToolTips">true</boolean> - </class> - </class> - <boolean id="Valid">true</boolean> - </class> -</class> - [/let] - [/let] - [/let] - [/let] - [/let] - [/let] - [/let] - [/file] - [/let] -[/template] - -[query public getPlaces(block : Classifier) : Sequence(State) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getPlaces(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivities(block : Classifier) : Sequence(Transition) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getActivities(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivityName(tr : Transition) : String = tr.source.name + '__' + tr.target.name/] - -[query public getRate(tr : Transition) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getRate(org.eclipse.uml2.uml.Transition)', Sequence{tr})/] - -[query public getAttackSuccName(tr : Transition) : Sequence(String) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttackSuccName(org.eclipse.uml2.uml.Transition)', Sequence{tr})/] - -[query public getNormalState(block : Classifier) : State = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getNormalState(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getOkX(ctx : OclAny) : Integer = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getOkX()', Sequence{})/] - -[query public getOkY(ctx : OclAny) : Integer = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getOkY()', Sequence{})/] - -[query public setOkX(okX : Integer) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setOkX(java.lang.Integer)', Sequence{okX})/] - -[query public setOkY(okY : Integer) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setOkY(java.lang.Integer)', Sequence{okY})/] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate_sanmodel.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate_sanmodel.mtl index 79e7e68b7466f085b8bfa1ae569fa7fbd83c914f..0dc6f71ab70696b74f95be42f6894ba0992930fb 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate_sanmodel.mtl +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/atomicComponentTemplate_sanmodel.mtl @@ -15,7 +15,7 @@ /] [comment encoding = UTF-8 /] [module atomicComponentTemplate_sanmodel('http://www.polarsys.org/chess/SAN')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] +[import org::polarsys::chess::mobius::templates::projectFileTemplate_sanmodel /] [template public atomicComponentTemplate_sanmodel(sanModel : SANModel, componentQN : String)] diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate.mtl deleted file mode 100644 index 1b8bf9e88c3d8c29bbe5cf7679a710ebc70f7bc5..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate.mtl +++ /dev/null @@ -1,206 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module composedComponentTemplate('http://www.eclipse.org/uml2/5.0.0/UML')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public composedComponentTemplate(model : Model, componentQN : String){ - BlockQN : String = 'SysML::Blocks::Block'; -}] - - [comment @main /] - [let componentName : String = getNameFromQN(componentQN)] - [file (componentName.concat('.cmp'), false, 'UTF-8')] - [let globalvars : Set(String) = getEmptyStringSet()] - [let x : Integer = 75] - [let y : Integer = 50] -<?xml version="1.0" encoding="ISO-8859-1"?> -<class id="Mobius.ComposedModels.RepJoin.RepJoinInterface"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseInterfaceClass"> - <int id="ClassVersion">3</int> - <string id="ModelName">[componentName/]</string> - <class id="Mobius.BaseClasses.BaseInfoClass"> - <int id="ClassVersion">2</int> - </class> - <class id="Mobius.BaseClasses.BaseEditorClass"> - <int id="ClassVersion">3</int> - <boolean id="HasPanel">true</boolean> - <class id="Mobius.BaseClasses.BasePanelClass"> - <int id="ClassVersion">2</int> - <point id="Size of Panel"> - <int id="x">500</int> - <int id="y">400</int> - </point> - <double id="ZoomFactor">1.0</double> - <boolean id="ShowGridEnabled">true</boolean> - <int id="ShowGridStep">10</int> - <boolean id="SnapGridEnabled">true</boolean> - <int id="SnapGridStep">10</int> - [comment join node /] - <class id="Mobius.ComposedModels.Common.JoinPanelObject"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[componentName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - </class> - <int id="SharingInfoSize">0</int> - </class> - [comment submodels /] - [let composedBlocks : Sequence(Classifier) = getComposedBlocks(model)] - [let parent : Classifier = getBlockFromQN(composedBlocks, componentQN)] - [for (subsystem : Classifier | getSubsystems(parent))] - <class id="Mobius.ComposedModels.Common.AtomicPanelObject"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[subsystem.name/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y/]</int> - </point> - </class> - <string id="Model Name">[subsystem.name/]</string> - </class> - [comment rep(s), if any/] - [if(isReplicated(subsystem, parent))] - <class id="Mobius.ComposedModels.RepJoin.RepPanelObject"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">Rep[subsystem.name/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y + 50/]</int> - </point> - </class> - <string id="RepCount">Num[subsystem.name/]</string> - <int id="SharingInfoSize">0</int> - </class> - [addToGlobalVars('Num'.concat(subsystem.name), globalvars)/] - [/if] - [/for] - [comment links /] - [for (subsystem : Classifier | getSubsystems(parent))] - [if(isReplicated(subsystem, parent))] - [comment link join to rep /] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[componentName/]</string> - <string id="FinishVertex">Rep[subsystem.name/]</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y + 50/]</int> - </point> - </vector> - </class> - [comment link rep to subsys /] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">Rep[subsystem.name/]</string> - <string id="FinishVertex">[subsystem.name/]</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y + 50/]</int> - </point> - <point id="1"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [else] - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">[componentName/]</string> - <string id="FinishVertex">[subsystem.name/]</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - <point id="1"> - <int id="x">[x + 150*i/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/if] - [/for] - [/let] - [/let] - </class> - <vector id="LocalGlobalNamesList"> - [for (globalvar : String | globalvars)] - <string id="[i/]">[globalvar/]</string> - [/for] - </vector> - <vector id="LocalGlobalTypesList"> - [for (globalvar : String | globalvars)] - <string id="[i/]">short</string> - [/for] - </vector> - <boolean id="DisplayToolTips">true</boolean> - </class> - <boolean id="Valid">true</boolean> - </class> -</class> - [/let] - [/let] - [/let] - [/file] - [/let] -[/template] - -[query public getSubsystems(parent : Classifier) : Sequence(Classifier) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getSubsystems(org.eclipse.uml2.uml.Classifier)', Sequence{parent})/] - -[query public isReplicated(block : Classifier, parent : Classifier) : Boolean = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'isReplicated(org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Classifier)', Sequence{block, parent})/] - -[comment [query public getReplication(block : Classifier, parent : Classifier) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getReplication(org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Classifier)', Sequence{block, parent})/] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate_sanmodel.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate_sanmodel.mtl index 2ba67e2d4ec452f0fd8d5df6df6b0731b690d7a4..44fc87350b8d8e48ea2d3015fbc47383c7d6f5a6 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate_sanmodel.mtl +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/composedComponentTemplate_sanmodel.mtl @@ -15,7 +15,7 @@ /] [comment encoding = UTF-8 /] [module composedComponentTemplate_sanmodel('http://www.polarsys.org/chess/SAN')/] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] +[import org::polarsys::chess::mobius::templates::projectFileTemplate_sanmodel /] [template public composedComponentTemplate_sanmodel(sanModel : SANModel, componentQN : String){ BlockQN : String = 'SysML::Blocks::Block'; @@ -158,7 +158,6 @@ [/if] [/for] </class> - [comment addToGlobalVars('Num'.concat(node.name.replaceAll('\\.', '_')), globalvars)/] [/if] [for (var : GlobalVariable | node.globalVariable)] [addToGlobalVars(var.name.replaceAll('\\.', '_'), globalvars)/] diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate.mtl deleted file mode 100644 index 9b48267fb0ce54a6bd45107495210a79fd6b4b03..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate.mtl +++ /dev/null @@ -1,113 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* Contributors: -* Intecs Solutions - Initial API and implementation -* -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module projectFileTemplate('http://www.eclipse.org/uml2/5.0.0/UML')/] - - -[template public projectFileTemplate(model : Model, projectName : String)] - - [comment @main /] - [file (projectName.concat('.prj'), false, 'UTF-8')] -<?xml version="1.0" encoding="ASCII"?> -<models:Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:models="http://www.mobius.illinois.edu/projects" name="[projectName/]" lastSavedVersion="2.5.9.201902201008"> - [let atomicBlocks : Sequence(Classifier) = getAtomicBlocks(model)] - [for (block : Classifier | atomicBlocks)] - <atomic key="[block.name/]"> - <value name="[block.name/]" type="SAN Model"/> - </atomic> - [/for] - [/let] - [let attackScenarios : Sequence(Interaction) = getAttackScenarios(model)] - [for (scenario : Interaction | attackScenarios)] - <atomic key="[scenario.name/]"> - <value name="[scenario.name/]" type="SAN Model"/> - </atomic> - [/for] - [/let] - [let composedBlocks : Sequence(Classifier) = getComposedBlocks(model)] - [for (block : Classifier | composedBlocks)] - <composed key="[block.name/]"> - <value name="[block.name/]" category="Composed" type="Rep/Join Model"/> - </composed> - [/for] - [/let] - [comment vulnerable Components/] - [let vulnerableComponents : Set(Classifier) = getVulnerableComponents(model)] - [for (block : Classifier | vulnerableComponents)] - <composed key="Vulnerable[block.name/]"> - <value name="Vulnerable[block.name/]" category="Composed" type="Rep/Join Model"/> - </composed> - [/for] - [/let] -</models:Project> - [/file] -[/template] - -[query public getNameFromQN(qualifiedName : String) : String = qualifiedName.substring(qualifiedName.lastIndex(':')+1)/] - -[query public getAtomicBlocks(model : Model) : Sequence(Classifier) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAtomicBlocks()', Sequence{model})/] - -[query public getComposedBlocks(model : Model) : Sequence(Classifier) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getComposedBlocks()', Sequence{model})/] - -[query public getAttacks(model : Model) : Sequence(Message) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttacks()', Sequence{model})/] - -[query public getAttackScenarios(model : Model) : Sequence(Interaction) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAttackScenarios()', Sequence{model})/] - -[query public getVulnerableComponents(model : Model) : Set(Classifier) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getVulnerableComponents()', Sequence{model})/] - -[query public getBlockFromQN(blocks : Sequence(Classifier), qualifiedName : String) : Classifier = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getBlockFromQN(java.util.List, java.lang.String)', Sequence{blocks, qualifiedName})/] - -[query public getEmptyStringSet(traceCtx : OclAny) : Set(String) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getEmptyStringSet()', Sequence{}) /] - -[query public addToGlobalVars(name : String, globalvars : Set(String)) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'addToGlobalVars(java.lang.String, java.util.Set)', Sequence{name, globalvars}) /] - -[query public getPlaces(block : Classifier) : Sequence(State) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getPlaces(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivities(block : Classifier) : Sequence(Transition) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getActivities(org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getActivityName(tr : Transition) : String = tr.source.name + '__' + tr.target.name/] - -[query public getRate(tr : Transition) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getRate(org.eclipse.uml2.uml.Transition)', Sequence{tr})/] - -[comment to handle start place of fragments in a sequence diagram /] -[query public getStartPlace(ctx : OclAny) : String = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getStartPlace()', Sequence{})/] - -[query public getStartX(ctx : OclAny) : Integer = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getStartX()', Sequence{})/] - -[query public getStartY(ctx : OclAny) : Integer = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getStartY()', Sequence{})/] - -[query public setStartPlace(startPlace : String) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartPlace(java.lang.String)', Sequence{startPlace})/] - -[query public setStartX(startX : Integer) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartX(java.lang.Integer)', Sequence{startX})/] - -[query public setStartY(startY : Integer) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartY(java.lang.Integer)', Sequence{startY})/] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate_sanmodel.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate_sanmodel.mtl index b0fa0f194344a19bc3d182c71c7000db398a18a6..2ad40a45c5cb4936d5856d00580572c97be41350 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate_sanmodel.mtl +++ b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/projectFileTemplate_sanmodel.mtl @@ -64,4 +64,10 @@ invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartPlace(java invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartX(java.lang.Integer)', Sequence{startX})/] [query public setStartY(startY : Integer) : OclAny = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartY(java.lang.Integer)', Sequence{startY})/] \ No newline at end of file +invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'setStartY(java.lang.Integer)', Sequence{startY})/] + +[query public getEmptyStringSet(traceCtx : OclAny) : Set(String) = +invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getEmptyStringSet()', Sequence{}) /] + +[query public addToGlobalVars(name : String, globalvars : Set(String)) : OclAny = +invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'addToGlobalVars(java.lang.String, java.util.Set)', Sequence{name, globalvars}) /] \ No newline at end of file diff --git a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/vulnerableComponentsTemplate.mtl b/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/vulnerableComponentsTemplate.mtl deleted file mode 100644 index 83084b944ee02a04441e2974616466172c700928..0000000000000000000000000000000000000000 --- a/plugins/mobius/org.polarsys.chess.mobius/src/org/polarsys/chess/mobius/templates/vulnerableComponentsTemplate.mtl +++ /dev/null @@ -1,181 +0,0 @@ -[comment -/********************************************************************* -* Copyright (c) 2019 Intecs Solutions SpA -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -**********************************************************************/ -/] -[comment encoding = UTF-8 /] -[module vulnerableComponentsTemplate('http://www.eclipse.org/uml2/5.0.0/UML')] -[import org::polarsys::chess::mobius::templates::projectFileTemplate /] - -[template public vulnerableComponentsTemplate(model : Model, componentQN : String)] -[comment @main/] - [let componentName : String = getNameFromQN(componentQN)] - [file ('Vulnerable'.concat(componentName.concat('.cmp')), false, 'UTF-8')] - [let x : Integer = 100] - [let y : Integer = 150] -<?xml version="1.0" encoding="ISO-8859-1"?> -<class id="Mobius.ComposedModels.RepJoin.RepJoinInterface"> - <int id="ClassVersion">1</int> - <class id="Mobius.BaseClasses.BaseInterfaceClass"> - <int id="ClassVersion">3</int> - <string id="ModelName">Vulnerable[componentName/]</string> - <class id="Mobius.BaseClasses.BaseInfoClass"> - <int id="ClassVersion">2</int> - </class> - <class id="Mobius.BaseClasses.BaseEditorClass"> - <int id="ClassVersion">3</int> - <boolean id="HasPanel">true</boolean> - <class id="Mobius.BaseClasses.BasePanelClass"> - <int id="ClassVersion">2</int> - <point id="Size of Panel"> - <int id="x">500</int> - <int id="y">400</int> - </point> - <double id="ZoomFactor">1.0</double> - <boolean id="ShowGridEnabled">true</boolean> - <int id="ShowGridStep">10</int> - <boolean id="SnapGridEnabled">true</boolean> - <int id="SnapGridStep">10</int> - [comment stuff goes here /] - [let atomicBlocks : Sequence(Classifier) = getAtomicBlocks(model)] - [let block : Classifier = getBlockFromQN(atomicBlocks, componentQN)] - [let scenarios : Sequence(String) = getBlockAttackScenarios(block)] - <class id="Mobius.ComposedModels.Common.JoinPanelObject"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">Vulnerable[componentName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">100</int> - <int id="y">50</int> - </point> - </class> - [comment shared variables/] - [let allBlockAttacks : Sequence(String) = getAllBlockAttacks(block)] - <int id="SharingInfoSize">[allBlockAttacks->size()/]</int> - [/let] - [for(scenarioName : String | scenarios)] - [let attacks : Sequence(String) = getBlockAttacks(block, scenarioName)] - [for(attackName : String | attacks)] - <string id="NewSharedObjName">[attackName/]_success</string> - <string id="Function"></string> - <int id="FunctionIndex">-1</int> - <boolean id="actionFlag">false</boolean> - <vector id="FullAccessPathStrings"> - <string id="0">[componentName/]->[attackName/]_success</string> - <string id="1">[scenarioName/]->[attackName/]_success</string> - </vector> - [/for] - [/let] - [/for] - </class> - [comment the affected component /] - <class id="Mobius.ComposedModels.Common.AtomicPanelObject"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[componentName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - </class> - <string id="Model Name">[componentName/]</string> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">Vulnerable[componentName/]</string> - <string id="FinishVertex">[componentName/]</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">100</int> - <int id="y">50</int> - </point> - <point id="1"> - <int id="x">[x/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [comment the attack scenarios /] - [for(scenarioName : String | scenarios)] - <class id="Mobius.ComposedModels.Common.AtomicPanelObject"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BaseVertexClass"> - <int id="ClassVersion">3</int> - <class id="Mobius.BaseClasses.BasePanelObjectClass"> - <int id="ClassVersion">5</int> - <string id="Name">[scenarioName/]</string> - <boolean id="ContainsLabel">true</boolean> - <boolean id="IsLabelShown">true</boolean> - </class> - <point id="CenterPoint"> - <int id="x">[x + i*150/]</int> - <int id="y">[y/]</int> - </point> - </class> - <string id="Model Name">[scenarioName/]</string> - </class> - <class id="Mobius.BaseClasses.BaseEdgeClass"> - <int id="ClassVersion">3</int> - <int id="LineType">0</int> - <string id="StartVertex">Vulnerable[componentName/]</string> - <string id="FinishVertex">[scenarioName/]</string> - <boolean id="Arrows">false</boolean> - <vector id="PointList"> - <point id="0"> - <int id="x">100</int> - <int id="y">50</int> - </point> - <point id="1"> - <int id="x">[x + i*150/]</int> - <int id="y">[y/]</int> - </point> - </vector> - </class> - [/for] - [/let] - [/let] - [/let] - </class> - <vector id="LocalGlobalNamesList"> - </vector> - <vector id="LocalGlobalTypesList"> - </vector> - <boolean id="DisplayToolTips">true</boolean> - </class> - <boolean id="Valid">true</boolean> - </class> -</class> - [/let] - [/let] - [/file] - [/let] -[/template] - -[query public getAllBlockAttacks(block : Classifier) : Sequence(String) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getAllBlockAttacks( org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getBlockAttackScenarios(block : Classifier) : Sequence(String) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getBlockAttackScenarios( org.eclipse.uml2.uml.Classifier)', Sequence{block})/] - -[query public getBlockAttacks(block : Classifier, scenarioName : String) : Sequence(String) = -invoke('org.polarsys.chess.mobius.utils.TransformationUtil', 'getBlockAttacks( org.eclipse.uml2.uml.Classifier, java.lang.String)', Sequence{block, scenarioName})/] diff --git a/plugins/mobius/org.polarsys.chess.mobius/transformations/CHESS2SAN.qvto b/plugins/mobius/org.polarsys.chess.mobius/transformations/CHESS2SAN.qvto index 053834c064c9cfffcca22f2021c79a7d550150e6..fe983be1101b162d97527af8a0e9190543cd899c 100644 --- a/plugins/mobius/org.polarsys.chess.mobius/transformations/CHESS2SAN.qvto +++ b/plugins/mobius/org.polarsys.chess.mobius/transformations/CHESS2SAN.qvto @@ -821,6 +821,10 @@ mapping UML::CombinedFragment::UMLAltFragment2SAN(inout atomicNode : SAN::Atomic operands -> forEach(operand){ i:= i+1; var attack : Message = operand.getOperationAttack(ownerInteraction); + if (attack = null){ + log("*********WARNING: "+self.name+" -> no attack for operand : "+operand.name); + continue; + }; var attackPlace : SAN::Place := object SAN::Place{name:=attack.name;x:=x1+250;y:=y1+75*(i-1)}; atomicNode.place += attackPlace; @@ -830,7 +834,7 @@ mapping UML::CombinedFragment::UMLAltFragment2SAN(inout atomicNode : SAN::Atomic attackInstActivity._case += "return("+attack.name+"_success_prob);\t// Attack succeeds"; attackInstActivity._case += "return(1.0 - "+attack.name+"_success_prob);\t// Attack fails"; atomicNode.addDoubleGlobalVariable(attack.name.concat('_success_prob'), atomicNode); - + //I need a map for the success place to be able to retrieve later for the shared variables creation... //TODO should I use a mapping (instance, message)->place? var successPlace : SAN::Place := attack.map UMLAttackMessage2AttackSuccessPlaceScenario(atomicNode); @@ -1499,7 +1503,7 @@ query UML::Class::initAttackScenario(){ var analysis : CHESS::StateBasedAnalysis::SANAnalysis := self.getStereotypeApplication(SANANALYSIS_STEREOTYPE).oclAsType(CHESS::StateBasedAnalysis::SANAnalysis); --log("attack scenario QN : "+analysis.condition); - var workloads : Set(MARTE::GQAMMARTE_AnalysisModel::GQAM::GaWorkloadBehavior) := analysis.workload->asSet(); + var workloads : Set(MARTE::GQAM::GaWorkloadBehavior) := analysis.workload->asSet(); workloads -> forEach(workload){ var named :=workload.base_NamedElement;