[529044] Adding an operations folder code generator option.

Signed-off-by: Sebastien Revol <sebastien.revol@cea.fr>
diff --git a/plugins/org.eclipse.uml2.codegen.ecore.ui/plugin.properties b/plugins/org.eclipse.uml2.codegen.ecore.ui/plugin.properties
index 2264d99..c349f39 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore.ui/plugin.properties
+++ b/plugins/org.eclipse.uml2.codegen.ecore.ui/plugin.properties
@@ -1,4 +1,4 @@
-# Copyright (c) 2005, 2009 IBM Corporation, Embarcadero Technologies, and others.
+# Copyright (c) 2005, 2018 IBM Corporation, Embarcadero Technologies, CEA, and others.
 # 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
@@ -7,8 +7,8 @@
 # Contributors: 
 #   IBM - initial API and implementation
 #   Kenn Hussey (Embarcadero Technologies) - 208016, 204200
+#   Sebastien Revol (CEA) - 529044
 #
-# $Id: plugin.properties,v 1.9 2009/04/07 18:24:53 jbruck Exp $
 
 # NLS_MESSAGEFORMAT_VAR
 
@@ -60,3 +60,4 @@
 #_UI_Unknown_type = Object
 
 _UI_GenFeature_pluralizationException_feature = Pluralization Exception
+_UI_GenModel_operationsFolder_feature = Operations Folder
diff --git a/plugins/org.eclipse.uml2.codegen.ecore.ui/src/org/eclipse/uml2/codegen/ecore/genmodel/provider/GenModelItemProvider.java b/plugins/org.eclipse.uml2.codegen.ecore.ui/src/org/eclipse/uml2/codegen/ecore/genmodel/provider/GenModelItemProvider.java
index f8b5c06..0d73f0f 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore.ui/src/org/eclipse/uml2/codegen/ecore/genmodel/provider/GenModelItemProvider.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore.ui/src/org/eclipse/uml2/codegen/ecore/genmodel/provider/GenModelItemProvider.java
@@ -9,6 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (CEA) - 414970
  *   Kenn Hussey - 522703
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.provider;
@@ -66,6 +67,7 @@
 			addCacheAdapterSupportPropertyDescriptor(object);
 			addSafeStringsPropertyDescriptor(object);
 			addInvariantPrefixPropertyDescriptor(object);
+			addOperationsFolderPropertyDescriptor(object);
 		}
 		return itemPropertyDescriptors;
 	}
@@ -171,6 +173,26 @@
 	}
 
 	/**
+	 * This adds a property descriptor for the Operations Folder feature.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected void addOperationsFolderPropertyDescriptor(Object object) {
+		itemPropertyDescriptors.add(createItemPropertyDescriptor(
+			((ComposeableAdapterFactory) adapterFactory)
+				.getRootAdapterFactory(),
+			getResourceLocator(),
+			getString("_UI_GenModel_operationsFolder_feature"), //$NON-NLS-1$
+			getString("_UI_PropertyDescriptor_description", //$NON-NLS-1$
+				"_UI_GenModel_operationsFolder_feature", "_UI_GenModel_type"), //$NON-NLS-1$ //$NON-NLS-2$
+			GenModelPackage.Literals.GEN_MODEL__OPERATIONS_FOLDER, true, false,
+			false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+			getString("_UI_UML2PropertyCategory"), //$NON-NLS-1$
+			null));
+	}
+
+	/**
 	 * This returns the label text for the adapted class.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -198,6 +220,7 @@
 			case GenModelPackage.GEN_MODEL__CACHE_ADAPTER_SUPPORT :
 			case GenModelPackage.GEN_MODEL__SAFE_STRINGS :
 			case GenModelPackage.GEN_MODEL__INVARIANT_PREFIX :
+			case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
 				fireNotifyChanged(new ViewerNotification(notification,
 					notification.getNotifier(), false, true));
 				return;
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.ecore b/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.ecore
index 8e272b7..fb3f636 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.ecore
+++ b/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.ecore
@@ -19,6 +19,7 @@
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="cacheAdapterSupport" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"/>
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="safeStrings" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"/>
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="invariantPrefix" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="operationsFolder" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
   </eClassifiers>
   <eClassifiers xsi:type="ecore:EClass" name="GenOperation" eSuperTypes="platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.ecore#//GenOperation #//GenTypedElement">
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="cacheAdapterScope" eType="#//GenCacheAdapterScope"/>
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.genmodel b/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.genmodel
index 85a3693..049053d 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.genmodel
+++ b/plugins/org.eclipse.uml2.codegen.ecore/model/GenModel.genmodel
@@ -33,6 +33,7 @@
       <genFeatures createChild="false" propertyCategory="UML2" ecoreFeature="ecore:EAttribute GenModel.ecore#//GenModel/cacheAdapterSupport"/>
       <genFeatures createChild="false" propertyCategory="UML2" ecoreFeature="ecore:EAttribute GenModel.ecore#//GenModel/safeStrings"/>
       <genFeatures createChild="false" propertyCategory="UML2" ecoreFeature="ecore:EAttribute GenModel.ecore#//GenModel/invariantPrefix"/>
+      <genFeatures createChild="false" propertyCategory="UML2" ecoreFeature="ecore:EAttribute GenModel.ecore#//GenModel/operationsFolder"/>
     </genClasses>
     <genClasses image="false" ecoreClass="GenModel.ecore#//GenOperation">
       <genFeatures createChild="false" propertyCategory="UML2" ecoreFeature="ecore:EAttribute GenModel.ecore#//GenOperation/cacheAdapterScope"/>
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModel.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModel.java
index 8b37380..c26ecc7 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModel.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015 IBM Corporation, CEA, and others.
+ * Copyright (c) 2005, 2018 IBM Corporation, CEA, and others.
  * 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
@@ -8,6 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *   Kenn Hussey (CEA) - 451350
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel;
@@ -26,6 +27,7 @@
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#isCacheAdapterSupport <em>Cache Adapter Support</em>}</li>
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#isSafeStrings <em>Safe Strings</em>}</li>
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#getInvariantPrefix <em>Invariant Prefix</em>}</li>
+ *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#getOperationsFolder <em>Operations Folder</em>}</li>
  * </ul>
  *
  * @see org.eclipse.uml2.codegen.ecore.genmodel.GenModelPackage#getGenModel()
@@ -165,4 +167,30 @@
 	 */
 	void setInvariantPrefix(String value);
 
+	/**
+	 * Returns the value of the '<em><b>Operations Folder</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <p>
+	 * If the meaning of the '<em>Operations Folder</em>' attribute isn't clear,
+	 * there really should be more of a description here...
+	 * </p>
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Operations Folder</em>' attribute.
+	 * @see #setOperationsFolder(String)
+	 * @see org.eclipse.uml2.codegen.ecore.genmodel.GenModelPackage#getGenModel_OperationsFolder()
+	 * @model
+	 * @generated
+	 */
+	String getOperationsFolder();
+
+	/**
+	 * Sets the value of the '{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#getOperationsFolder <em>Operations Folder</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @param value the new value of the '<em>Operations Folder</em>' attribute.
+	 * @see #getOperationsFolder()
+	 * @generated
+	 */
+	void setOperationsFolder(String value);
+
 } // GenModel
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModelPackage.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModelPackage.java
index 9c228a0..dfd6a99 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModelPackage.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenModelPackage.java
@@ -10,6 +10,7 @@
  *   Kenn Hussey (Embarcadero Technologies) - 204200, 208016, 247980
  *   Kenn Hussey - 286329, 522703
  *   Kenn Hussey (CEA) - 351777, 397324, 414970, 451350
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel;
@@ -1632,6 +1633,16 @@
 		+ 4;
 
 	/**
+	 * The feature id for the '<em><b>Operations Folder</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int GEN_MODEL__OPERATIONS_FOLDER = org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.GEN_MODEL_FEATURE_COUNT
+		+ 5;
+
+	/**
 	 * The number of structural features of the '<em>Gen Model</em>' class.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -1639,7 +1650,7 @@
 	 * @ordered
 	 */
 	int GEN_MODEL_FEATURE_COUNT = org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.GEN_MODEL_FEATURE_COUNT
-		+ 5;
+		+ 6;
 
 	/**
 	 * The meta object id for the '{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenOperationImpl <em>Gen Operation</em>}' class.
@@ -2339,6 +2350,17 @@
 	EAttribute getGenModel_InvariantPrefix();
 
 	/**
+	 * Returns the meta object for the attribute '{@link org.eclipse.uml2.codegen.ecore.genmodel.GenModel#getOperationsFolder <em>Operations Folder</em>}'.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the meta object for the attribute '<em>Operations Folder</em>'.
+	 * @see org.eclipse.uml2.codegen.ecore.genmodel.GenModel#getOperationsFolder()
+	 * @see #getGenModel()
+	 * @generated
+	 */
+	EAttribute getGenModel_OperationsFolder();
+
+	/**
 	 * Returns the meta object for class '{@link org.eclipse.uml2.codegen.ecore.genmodel.GenOperation <em>Gen Operation</em>}'.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -2587,6 +2609,15 @@
 			.getGenModel_InvariantPrefix();
 
 		/**
+		 * The meta object literal for the '<em><b>Operations Folder</b></em>' attribute feature.
+		 * <!-- begin-user-doc -->
+		 * <!-- end-user-doc -->
+		 * @generated
+		 */
+		EAttribute GEN_MODEL__OPERATIONS_FOLDER = eINSTANCE
+			.getGenModel_OperationsFolder();
+
+		/**
 		 * The meta object literal for the '{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenOperationImpl <em>Gen Operation</em>}' class.
 		 * <!-- begin-user-doc -->
 		 * <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapter.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapter.java
new file mode 100644
index 0000000..41e0578
--- /dev/null
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapter.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018 CEA and others.
+ * 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:
+ *   Sebastien Revol (CEA) - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.codegen.ecore.genmodel.generator;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.UniqueEList;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.uml2.codegen.ecore.genmodel.GenModel;
+import org.eclipse.uml2.codegen.ecore.genmodel.util.UML2GenModelUtil;
+
+public class GenModelGeneratorAdapter
+		extends
+		org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter {
+
+	public GenModelGeneratorAdapter(
+			GeneratorAdapterFactory generatorAdapterFactory) {
+		super(generatorAdapterFactory);
+
+	}
+
+	@Override
+	protected Diagnostic generateModel(Object object, Monitor monitor) {
+		super.generateModel(object, monitor);
+
+		String operationFolderPathString = UML2GenModelUtil
+			.getOperationsFolderPath((GenModel) object);
+		if (operationFolderPathString != null) {
+			IPath operationModelPath = new Path(operationFolderPathString);
+			IWorkspace workspace = ResourcesPlugin.getWorkspace();
+			IProject modelProject = workspace.getRoot()
+				.getProject(operationModelPath.segment(0));
+
+			IJavaProject javaProject = JavaCore.create(modelProject);
+
+			try {
+				List<IClasspathEntry> classpathEntries = new UniqueEList<IClasspathEntry>() {
+
+					private static final long serialVersionUID = 1L;
+
+					@Override
+					public boolean contains(Object object) {
+						if (super.contains(object)) {
+							return true;
+						} else if (object instanceof IClasspathEntry) {
+							IClasspathEntry classpathEntry = (IClasspathEntry) object;
+							if (classpathEntry
+								.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+								IPath path = classpathEntry.getPath();
+								for (int i = 0; i < size; ++i) {
+									IClasspathEntry otherClasspathEntry = get(
+										i);
+									if (otherClasspathEntry
+										.getEntryKind() == IClasspathEntry.CPE_CONTAINER
+										&& path.equals(
+											otherClasspathEntry.getPath())) {
+										return true;
+									}
+								}
+							}
+						}
+						return false;
+					}
+				};
+
+				IClasspathEntry operationFolderEntry = JavaCore
+					.newSourceEntry(operationModelPath);
+				classpathEntries
+					.addAll(Arrays.asList(javaProject.getRawClasspath()));
+				classpathEntries.add(operationFolderEntry);
+
+				javaProject.setRawClasspath(
+					classpathEntries
+						.toArray(new IClasspathEntry[classpathEntries.size()]),
+					BasicMonitor.toIProgressMonitor(monitor));
+
+			} catch (JavaModelException e) {
+				//should never happen hopefully... 
+			}
+
+		}
+
+		return Diagnostic.OK_INSTANCE;
+	}
+}
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapterFactory.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapterFactory.java
index 5361307..455cd46 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapterFactory.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/GenModelGeneratorAdapterFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 IBM Corporation, CEA and others.
  * 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
@@ -7,8 +7,8 @@
  *
  * Contributors:
  *   IBM - initial API and implementation
+ *   Sebastien Revol (CEA) - 529044
  *
- * $Id: GenModelGeneratorAdapterFactory.java,v 1.3 2007/01/16 18:06:33 khussey Exp $
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.generator;
 
@@ -49,4 +49,13 @@
 		return genPackageGeneratorAdapter;
 	}
 
+	
+	@Override
+	public Adapter createGenModelAdapter() {
+		if (genModelGeneratorAdapter == null) {
+			genModelGeneratorAdapter = new GenModelGeneratorAdapter(this);
+		}
+		
+		return genModelGeneratorAdapter;
+	}
 }
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/UML2GenClassGeneratorAdapter.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/UML2GenClassGeneratorAdapter.java
index cd978af..a887215 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/UML2GenClassGeneratorAdapter.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/generator/UML2GenClassGeneratorAdapter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008 IBM Corporation, Embarcadero Technologies, and others.
+ * Copyright (c) 2006, 2018 IBM Corporation, Embarcadero Technologies, CEA, and others.
  * 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
@@ -8,8 +8,8 @@
  * Contributors:
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 206636
+ *   Sebastien Revol (CEA) - 529044
  *
- * $Id: UML2GenClassGeneratorAdapter.java,v 1.3 2008/03/21 00:22:59 khussey Exp $
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.generator;
 
@@ -73,7 +73,7 @@
 				"_UI_GeneratingJavaClass_message", new Object[]{genClass //$NON-NLS-1$
 					.getQualifiedOperationsClassName()});
 			monitor.subTask(message);
-			generateJava(genClass.getGenModel().getModelDirectory(),
+			generateJava(UML2GenModelUtil.getOperationsFolderPath(genClass.getGenModel()),
 				UML2GenModelUtil.getOperationsPackageName(genPackage), genClass
 					.getOperationsClassName(), getJETEmitter(
 					getJETEmitterDescriptors(), OPERATIONS_CLASS_ID), null,
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelImpl.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelImpl.java
index 03c1228..a3b5c37 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelImpl.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelImpl.java
@@ -10,6 +10,7 @@
  *   Kenn Hussey (Embarcadero Technologies) - 208016, 247980
  *   Kenn Hussey - 284809, 522703
  *   Kenn Hussey (CEA) - 358792, 351777, 382637, 212765, 451350
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.impl;
@@ -51,6 +52,7 @@
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenModelImpl#isCacheAdapterSupport <em>Cache Adapter Support</em>}</li>
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenModelImpl#isSafeStrings <em>Safe Strings</em>}</li>
  *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenModelImpl#getInvariantPrefix <em>Invariant Prefix</em>}</li>
+ *   <li>{@link org.eclipse.uml2.codegen.ecore.genmodel.impl.GenModelImpl#getOperationsFolder <em>Operations Folder</em>}</li>
  * </ul>
  *
  * @generated
@@ -160,6 +162,26 @@
 	protected String invariantPrefix = INVARIANT_PREFIX_EDEFAULT;
 
 	/**
+	 * The default value of the '{@link #getOperationsFolder() <em>Operations Folder</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getOperationsFolder()
+	 * @generated
+	 * @ordered
+	 */
+	protected static final String OPERATIONS_FOLDER_EDEFAULT = null;
+
+	/**
+	 * The cached value of the '{@link #getOperationsFolder() <em>Operations Folder</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getOperationsFolder()
+	 * @generated
+	 * @ordered
+	 */
+	protected String operationsFolder = OPERATIONS_FOLDER_EDEFAULT;
+
+	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
 	 * @generated
@@ -324,6 +346,30 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
+	public String getOperationsFolder() {
+		return operationsFolder;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void setOperationsFolder(String newOperationsFolder) {
+		String oldOperationsFolder = operationsFolder;
+		operationsFolder = newOperationsFolder;
+		if (eNotificationRequired())
+			eNotify(new ENotificationImpl(this, Notification.SET,
+				GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER
+					+ EOFFSET_CORRECTION,
+				oldOperationsFolder, operationsFolder));
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
 	@Override
 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
 		switch (featureID - EOFFSET_CORRECTION) {
@@ -337,6 +383,8 @@
 				return isSafeStrings();
 			case GenModelPackage.GEN_MODEL__INVARIANT_PREFIX :
 				return getInvariantPrefix();
+			case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
+				return getOperationsFolder();
 		}
 		return super.eGet(featureID, resolve, coreType);
 	}
@@ -364,6 +412,9 @@
 			case GenModelPackage.GEN_MODEL__INVARIANT_PREFIX :
 				setInvariantPrefix((String) newValue);
 				return;
+			case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
+				setOperationsFolder((String) newValue);
+				return;
 		}
 		super.eSet(featureID, newValue);
 	}
@@ -391,6 +442,9 @@
 			case GenModelPackage.GEN_MODEL__INVARIANT_PREFIX :
 				setInvariantPrefix(INVARIANT_PREFIX_EDEFAULT);
 				return;
+			case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
+				setOperationsFolder(OPERATIONS_FOLDER_EDEFAULT);
+				return;
 		}
 		super.eUnset(featureID);
 	}
@@ -419,6 +473,10 @@
 				return INVARIANT_PREFIX_EDEFAULT == null
 					? invariantPrefix != null
 					: !INVARIANT_PREFIX_EDEFAULT.equals(invariantPrefix);
+			case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
+				return OPERATIONS_FOLDER_EDEFAULT == null
+					? operationsFolder != null
+					: !OPERATIONS_FOLDER_EDEFAULT.equals(operationsFolder);
 		}
 		return super.eIsSet(featureID);
 	}
@@ -454,6 +512,9 @@
 				case GenModelPackage.GEN_MODEL__INVARIANT_PREFIX :
 					return GenModelPackage.GEN_MODEL__INVARIANT_PREFIX
 						+ EOFFSET_CORRECTION;
+				case GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER :
+					return GenModelPackage.GEN_MODEL__OPERATIONS_FOLDER
+						+ EOFFSET_CORRECTION;
 				default :
 					return -1;
 			}
@@ -482,6 +543,8 @@
 		result.append((eFlags & SAFE_STRINGS_EFLAG) != 0);
 		result.append(", invariantPrefix: "); //$NON-NLS-1$
 		result.append(invariantPrefix);
+		result.append(", operationsFolder: "); //$NON-NLS-1$
+		result.append(operationsFolder);
 		result.append(')');
 		return result.toString();
 	}
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelPackageImpl.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelPackageImpl.java
index 0d60d2b..5dfa4ed 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelPackageImpl.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenModelPackageImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018 IBM Corporation, Embarcadero Technologies, and others.
+ * Copyright (c) 2005, 2018 IBM Corporation, Embarcadero Technologies, CEA, and others.
  * 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
@@ -9,6 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 204200, 208016, 247980
  *   Kenn Hussey - 522703
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.impl;
@@ -352,6 +353,15 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
+	public EAttribute getGenModel_OperationsFolder() {
+		return (EAttribute) genModelEClass.getEStructuralFeatures().get(5);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
 	public EClass getGenOperation() {
 		return genOperationEClass;
 	}
@@ -471,6 +481,7 @@
 		createEAttribute(genModelEClass, GEN_MODEL__CACHE_ADAPTER_SUPPORT);
 		createEAttribute(genModelEClass, GEN_MODEL__SAFE_STRINGS);
 		createEAttribute(genModelEClass, GEN_MODEL__INVARIANT_PREFIX);
+		createEAttribute(genModelEClass, GEN_MODEL__OPERATIONS_FOLDER);
 
 		genOperationEClass = createEClass(GEN_OPERATION);
 		createEAttribute(genOperationEClass,
@@ -608,6 +619,10 @@
 			theEcorePackage.getEString(), "invariantPrefix", null, 0, 1, //$NON-NLS-1$
 			GenModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
 			!IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEAttribute(getGenModel_OperationsFolder(),
+			theEcorePackage.getEString(), "operationsFolder", null, 0, 1, //$NON-NLS-1$
+			GenModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
+			!IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		initEClass(genOperationEClass, GenOperation.class, "GenOperation", //$NON-NLS-1$
 			!IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
index 7b19838..e8868a3 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013 IBM Corporation, Embarcadero Technologies, CEA, and others.
+ * Copyright (c) 2005, 2018 IBM Corporation, Embarcadero Technologies, CEA, and others.
  * 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
@@ -9,6 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 208016, 206636
  *   Kenn Hussey (CEA) - 394623, 212765
+ *   Sebastien Revol (CEA) - 529044
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.util;
@@ -16,6 +17,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.emf.codegen.ecore.genmodel.GenAnnotation;
 import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
 import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
@@ -103,6 +106,26 @@
 				.isSafeStrings();
 	}
 
+	public static String getOperationsFolder(GenModel genModel) {
+		return genModel instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenModel
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel) genModel)
+				.getOperationsFolder()
+			: null;
+	}
+
+	public static String getOperationsFolderPath(GenModel genModel) {
+		String modelDirectory = genModel.getModelDirectory();
+		String result = modelDirectory;
+		String operationsFolder = getOperationsFolder(genModel);
+		if (operationsFolder != null && modelDirectory != null) {
+			IPath modelDirectoryPath = new Path(modelDirectory);
+			result = modelDirectoryPath
+				.removeLastSegments(modelDirectoryPath.segmentCount() - 1)
+				.append(operationsFolder).toString();
+		}
+		return result;
+	}
+
 	// GenPackage utilities
 
 	public static boolean isResourceInterfaces(GenPackage genPackage) {