diff options
Diffstat (limited to 'sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse')
4 files changed, 0 insertions, 726 deletions
diff --git a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Activator.java b/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Activator.java deleted file mode 100644 index b65a7751dc1..00000000000 --- a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Activator.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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.eclipse.papyrus.profile.facets.generation.acceleo; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle. - */ -public class Activator extends Plugin { - - /** - * The plug-in ID. - */ - public static final String PLUGIN_ID = "org.eclipse.papyrus.facets.profile.generation.acceleo"; - - /** - * The shared instance. - */ - private static Activator plugin; - - /** - * The constructor. - */ - public Activator() { - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance. - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Generate.java b/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Generate.java deleted file mode 100644 index 23d3cf97636..00000000000 --- a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/Generate.java +++ /dev/null @@ -1,420 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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.eclipse.papyrus.profile.facets.generation.acceleo; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -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.acceleo.engine.service.AcceleoService; -import org.eclipse.acceleo.engine.service.properties.AbstractAcceleoPropertiesLoaderService; -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 'Generate' generation module. - * - * @generated - */ -public class Generate extends AbstractAcceleoGenerator { - - /** - * The name of the module. - * - * @generated - */ - public static final String MODULE_FILE_NAME = "/org/eclipse/papyrus/profile/facets/generation/acceleo/generate"; - - /** - * The name of the templates that are to be generated. - * - * @generated - */ - public static final String[] TEMPLATE_NAMES = { "generateQuery", "generateGetter", "generateSetter" }; - - /** - * The list of properties files from the launch parameters (Launch configuration). - */ - private final 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 Generate() { - // 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 Generate(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 Generate(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>(); - - /* - * 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. - */ - - Generate generator = new Generate(modelURI, folder, arguments); - - /* - * Add the properties from the launch arguments. - * If you want to programmatically add new arguments, 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 basic properties loader will look for properties in the current project if the path - * of the properties file is like this "packagea.packageb.packagec.default" for a properties - * file named default.properties, or if the path is an absolute path. With a new property - * loader you could for example, look for properties files in a bundle. - */ - - 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 (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. - * <p> - * Properties need to be in source folders, the path that we expect to get as a result of this call are of the form <package>.<properties - * file name without extension>. For example, if you have a file named "messages.properties" in package "org.eclipse.acceleo.sample", the path - * that needs be returned by a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages". - * </p> - * - * @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() { - /* - * TODO if your generation module requires access to properties files, add their qualified path to the list here. - * Properties files are expected to be in source folders, and the path here to be the qualified path as if referring - * to a Java class. For example, if you have a file named "messages.properties" in package "org.eclipse.acceleo.sample", - * the path that needs be added to this list is "org.eclipse.acceleo.sample.messages". 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 propertiesFiles; - } - - /** - * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @since 3.1 - */ - @Override - public void addPropertiesFile(final 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); - } - - /* - * TODO 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. 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. 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 (!isInWorkspace(UMLPackage.class)) { - * // The normal package registration if your metamodel is in a plugin. - * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); - * } else { - * // The package registration that will be used if the metamodel is not deployed in a plugin. - * // This should be used if your metamodel is in your workspace. - * resourceSet.getPackageRegistry().put("/myproject/myfolder/mysubfolder/MyUMLMetamodel.ecore", UMLPackage.eINSTANCE); - * } - */ - } - - /** - * 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); - /* - * 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 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. - */ - - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); - } - - private String header; - - protected String packageName; - - public void setHeader(final String header) { - this.header = header; - } - - public void setPackageName(final String packageName){ - this.packageName = packageName; - } - - - - /** - * - * @see org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator#getPropertiesLoaderService(org.eclipse.acceleo.engine.service.AcceleoService) - * - * @param acceleoService - * @return - * @notgenerated - */ - @Override - protected AbstractAcceleoPropertiesLoaderService getPropertiesLoaderService(final AcceleoService service) { - System.out.println("GetPropertiesLoaderService"); - return new AbstractAcceleoPropertiesLoaderService() { - - { - this.acceleoService = service; - } - - @Override - public void initializeService(final List<String> propertiesFiles) { - super.initializeService(propertiesFiles); - Map<String, String> myCustomProperties = new HashMap<String, String>(); - if(Generate.this.header != null) { - myCustomProperties.put("copyright", Generate.this.header); - } - if(Generate.this.packageName!=null){ - myCustomProperties.put("packageName", Generate.this.packageName); - } - service.addProperties(myCustomProperties); - } - - @Override - protected Properties alternatePropertiesLoading(final String filepath) { - System.out.println("Loading " + filepath); - - try { - Properties properties = new Properties(); - File file = new File(filepath); - properties.load(new FileInputStream(file)); - return properties; - } catch (IOException ex) { - System.err.println(ex); - ex.printStackTrace(System.err); - } - return null; - } - - - }; - } - -} diff --git a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/HasStereotypeQuery.java b/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/HasStereotypeQuery.java deleted file mode 100644 index 4af00f7e68e..00000000000 --- a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/HasStereotypeQuery.java +++ /dev/null @@ -1,59 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.profile.facets.generation.acceleo;
-
-import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
-import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
-import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- *
- * This class allows to test if a FacetSet can be used for an UML Element
- *
- */
-public class HasStereotypeQuery implements IJavaModelQuery<Element, Boolean> {
-
- /** the id of the stereotype */
- private final String stereotypeID;
-
- /**
- *
- * Constructor.
- *
- * @param stereotypeID
- */
- public HasStereotypeQuery(final String stereotypeID) {
- this.stereotypeID = stereotypeID;
- }
-
- /**
- *
- * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
- *
- * @param context
- * @param parameterValues
- * @return
- * @throws ModelQueryExecutionException
- */
- public Boolean evaluate(final Element context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
- Stereotype ste = context.getAppliedStereotype(stereotypeID);
- if(ste != null) {
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/generate.mtl b/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/generate.mtl deleted file mode 100644 index bc050150589..00000000000 --- a/sandbox/org.eclipse.papyrus.profile.facets.generation.acceleo/src/org/eclipse/papyrus/profile/facets/generation/acceleo/generate.mtl +++ /dev/null @@ -1,181 +0,0 @@ -[comment encoding = UTF-8 /] -[module generate(http://www.eclipse.org/uml2/3.0.0/UML)] - -[template public getFacetClassName(stereotype : Stereotype) post(trim())] -Has[getQualifiedName().replaceAll(':', '')/]Query -[/template] - -[template public getGetterClassName(property : Property) post(trim())] -Get[owner.oclAsType(Stereotype).name /][property.name.toUpperFirst() /] -[/template] - -[template public getSetterClassName(property : Property) post(trim())] -Set[owner.oclAsType(NamedElement).name /][property.name.toUpperFirst() /] -[/template] - -[template public getGetterFileName(property : Property) post(trim())] -[if (owner.oclIsKindOf(Stereotype))] - [getProperty('packageName').replaceAll('.','/')/]/queries/getters/[getGetterClassName()/].java -[/if] -[/template] - -[template public getSetterFileName(property : Property) post(trim())] -[if (owner.oclIsKindOf(Stereotype) and not type.oclIsKindOf(DataType))] - [getProperty('packageName').replaceAll('.','/')/]/queries/setters/[getSetterClassName()/].java -[/if] -[/template] - -[template public generateQuery(stereotype : Stereotype)] -[comment @main/] -[file (getProperty('packageName').replaceAll('.','/')+'/queries/facets/'+getFacetClassName()+'.java', false, 'UTF-8')] -[getProperty('copyright')/] -package [getProperty('packageName')/].queries.facets; - -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.uml2.uml.Element; -import org.eclipse.papyrus.profile.facets.generation.acceleo.HasStereotypeQuery; - -/** Condition Query */ -public class [getFacetClassName()/] extends HasStereotypeQuery implements IJavaModelQuery<Element, Boolean> { - - public [getFacetClassName()/]() { - super("[getQualifiedName()/]"); //$NON-NLS-1$ - } - -} - -[/file] -[/template] - -[template public generateGetter(property : Property)] -[comment @main/] -[file (getGetterFileName(), false, 'UTF-8')] -[getProperty('copyright')/] -package [getProperty('packageName')/].queries.getters; - -import java.util.Collection; - -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Stereotype; - -/** Query to get the text of the requirement */ -public class [getGetterClassName()/] implements IJavaModelQuery<[findScope()/], [findReturnType()/]> { - - public [findReturnType()/] evaluate(final [findScope()/] context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { - [if type.oclIsKindOf(DataType)] - //TODO : The generator cannot handle DataTypes correctly. You should probably edit this query - [/if] - Stereotype ste = context.getAppliedStereotype("[owner.oclAsType(Stereotype).getQualifiedName() /]"); //$NON-NLS-1$ - if(ste != null) { - Object value = context.getValue(ste, "[name /]"); //$NON-NLS-1$ - return ([findReturnType()/])value; - } - return null; - } -} - - -[/file] -[/template] - -[template public generateSetter(property : Property)] -[comment @main/] -[file (getSetterFileName(), false, 'UTF-8')] -[getProperty('copyright')/] -package [getProperty('packageName')/].queries.setters; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.emf.facet.infra.query.runtime.ModelQueryParameterValue; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.util.TransactionUtil; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Stereotype; - -/** Query to set the attribute "attrName" of a stereotypeName */ -public class [getSetterClassName() /] implements IJavaModelQueryWithEditingDomain<Class, EObject> { - - /** - * - * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject, - * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList) - * - * @param context - * @param parameterValues - * @return - * @throws ModelQueryExecutionException - */ - public EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { - //Unused - return null; - } - - /** - * - * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain#evaluate(org.eclipse.emf.ecore.EObject, - * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList, org.eclipse.emf.edit.domain.EditingDomain) - * - * @param arg0 - * @param parameter - * @param arg2 - * @return - * @throws ModelQueryExecutionException - */ - public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException { - final Stereotype ste = context.getAppliedStereotype("[owner.oclAsType(Stereotype).getQualifiedName() /]"); //$NON-NLS-1$ - if(ste != null) { - if(parameter.size() != 0) { - final ModelQueryParameterValue newValue = parameter.get(0); - if(newValue != null && newValue.getValue() instanceof String) { - Command command = null; - TransactionalEditingDomain domain = null; - if(!(editingDomain instanceof TransactionalEditingDomain)) { - //if we work with a uml file, it is possible to get a UML2AdapterFactoryEditingDomain instead of TransactionEditingDomain - domain = TransactionUtil.getEditingDomain(context); - } else { - domain = (TransactionalEditingDomain)editingDomain; - } - if(domain != null) { - command = new RecordingCommand(domain) { - - @Override - protected void doExecute() { - context.setValue(ste, "[name /]", newValue.getValue()); - } - }; - } - if(command != null && command.canExecute()) { - domain.getCommandStack().execute(command); - } - } - } - } - return context; - } -} -[/file] -[/template] - -[template public findScope(property : Property) post(trim())] - -[/template] - -[template public findReturnType(property : Property) post(trim())] -[if type.oclIsKindOf(Stereotype)] - Unknown return type (Stereotype/Facet) -[elseif type.oclIsKindOf(Enumeration)] - org.eclipse.uml2.uml.EnumerationLiteral -[elseif type.oclIsKindOf(DataType)] - org.eclipse.emf.ecore.EObject -[else] - org.eclipse.uml2.uml.[type.name /] -[/if] -[/template] |