Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2013-08-11 21:19:03 +0000
committerFlorian Noyrit2013-08-11 21:19:03 +0000
commitf0c2b5c279f8c69dd54701d6f5d3f4df12159b2c (patch)
tree54315cd9cbb16bb4337b165786babb75b1f3ab33 /extraplugins
parent24279ffe3476b29f6b6563b4012a06c34c7007a8 (diff)
downloadorg.eclipse.papyrus-f0c2b5c279f8c69dd54701d6f5d3f4df12159b2c.tar.gz
org.eclipse.papyrus-f0c2b5c279f8c69dd54701d6f5d3f4df12159b2c.tar.xz
org.eclipse.papyrus-f0c2b5c279f8c69dd54701d6f5d3f4df12159b2c.zip
Initial commit of Facade feature. Facade provide ecore DSL-like API to
one or more UML profile.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/.classpath8
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/.project42
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/META-INF/MANIFEST.MF21
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.acceleo26
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.properties8
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/plugin.xml28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/FacadeCodeGenPlugin.java50
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateCodeAction.java108
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateFacadeAction.java148
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/util/EEFGeneratorAdapter.java193
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/AbstractRepresentingClass.mtl59
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/Class.mtl1020
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.java419
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.mtl159
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/LoaderClass.mtl118
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/RepresentingElementAdapter.mtl96
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/ResourceClass.mtl526
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/WrapperClass.mtl170
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eIsSet.mtl120
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eUnset.mtl44
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genDeclaredFields.mtl196
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genFeature.mtl892
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genOperation.mtl160
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/reflectiveDelegationAlternative.mtl29
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.java935
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.mtl110
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/MappingMissing.java6
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java298
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.mtl6
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.classpath7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.project28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/META-INF/MANIFEST.MF16
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/build.properties6
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/association.pngbin0 -> 702 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/associationRequired.pngbin0 -> 706 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/checked.gifbin0 -> 343 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/combinaison.pngbin0 -> 424 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/facade.pngbin0 -> 382 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusion.pngbin0 -> 627 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusionRequired.pngbin0 -> 644 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalization.pngbin0 -> 628 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalizationRequired.pngbin0 -> 583 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralization.pngbin0 -> 589 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralizationRequired.pngbin0 -> 541 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tag.pngbin0 -> 689 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tagRequired.pngbin0 -> 740 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/unchecked.gifbin0 -> 251 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/StereotypeInterface.gifbin0 -> 211 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualDatatype.gifbin0 -> 199 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualEnum.gifbin0 -> 131 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualLiteral.gifbin0 -> 109 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualMetaclass.gifbin0 -> 206 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualOperation.gifbin0 -> 141 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualParameter.gifbin0 -> 911 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualReference.gifbin0 -> 183 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/plugin.xml18
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/ResourceManager.java407
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/SWTResourceManager.java440
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/Activator.java63
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/FacadeSpecificEditor.java725
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/EditionUtils.java177
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/ExtensionKindColumnEditingSupport.java257
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/IsPossibleColumnEditingSupport.java190
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassAliasColumnEditingSupport.java56
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassIsAbstractColumnEditingSupport.java64
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassToKeepColumnEditingSupport.java67
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesAliasColumnEdintingSupport.java64
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMaxColumnEdintingSupport.java105
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMinColumnEdintingSupport.java100
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesToKeepColumnEditingSupport.java59
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/StereotypeIncompatibilityColumnEditingSupport.java374
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/glue/GlueGenerator.java127
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/CreatePreliminaryMetamodelListener.java332
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/EcoreGenerator.java978
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/MetamodelUtils.java1029
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionContentProvider.java88
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionLabelProvider.java176
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesContentProvider.java40
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesLabelProvider.java168
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelContentProvider.java74
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelLabelProvider.java195
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/PropertiesContentProvider.java39
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/PropertiesLabelProvider.java137
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/utils/CombinationGenerator.java104
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/utils/ProfileUtils.java271
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/utils/PrunerUtils.java77
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/utils/StereotypeUtils.java112
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/utils/UMLModelUtils.java25
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/.classpath7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/.project28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/META-INF/MANIFEST.MF23
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/build.properties10
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateBaseMetaclass_compatibleStereotypes_Combination.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateBaseMetaclass_incompatibleStereotypes_Combination.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateExtensionDefinition_baseMetaclasses_BaseMetaclass.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacadeMappping_mappings_Mapping.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacadeMappping_mappings_StereotypedMapping.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacade_extensionDefinitions_ExtensionDefinition.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacade_virtualMetaclasses_StereotypeInterface.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacade_virtualMetaclasses_VirtualMetaclass.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateFacade_virtualmetamodel_VirtualMetamodel.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualEnum_literals_VirtualLiteral.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetaclass_operations_VirtualOperation.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetaclass_properties_VirtualProperty.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetaclass_virtualProperties_VirtualProperty.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetamodel_virtualClassifiers_StereotypeInterface.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetamodel_virtualClassifiers_VirtualDatatype.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetamodel_virtualClassifiers_VirtualEnum.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualMetamodel_virtualClassifiers_VirtualMetaclass.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/ctool16/CreateVirtualOperation_parameters_VirtualParameter.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/BaseMetaclass.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/Combination.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/ExtensionDefinition.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/Facade.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/FacadeMappping.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/KeepableElement.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/Literal.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/Mapping.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/StereotypeInterface.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/StereotypedMapping.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualDatatype.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualElement.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualEnum.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualLiteral.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualMetaclass.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualMetamodel.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualOperation.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualParameter.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/icons/full/obj16/VirtualProperty.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/plugin.properties91
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/plugin.xml61
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/extensiondefinition/provider/BaseMetaclassItemProvider.java251
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/extensiondefinition/provider/CombinationItemProvider.java147
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/extensiondefinition/provider/ExtensionDefinitionItemProvider.java248
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/extensiondefinition/provider/ExtensiondefinitionItemProviderAdapterFactory.java247
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/provider/FacadeEditPlugin.java95
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/provider/FacadeItemProvider.java177
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/provider/FacadeItemProviderAdapterFactory.java199
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualClassifierItemProvider.java99
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualDatatypeItemProvider.java110
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualElementItemProvider.java195
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualEnumItemProvider.java156
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualLiteralItemProvider.java110
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualMetaclassItemProvider.java261
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualMetamodelItemProvider.java258
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualOperationItemProvider.java156
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualParameterItemProvider.java110
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualPropertyItemProvider.java167
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facade/virtualmetamodel/provider/VirtualmetamodelItemProviderAdapterFactory.java367
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facademapping/provider/FacadeMapppingItemProvider.java172
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facademapping/provider/FacademappingEditPlugin.java89
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facademapping/provider/FacademappingItemProviderAdapterFactory.java247
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facademapping/provider/MappingItemProvider.java168
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.edit/src/org/eclipse/papyrus/facademapping/provider/StereotypedMappingItemProvider.java168
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/.classpath7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/.project28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/META-INF/MANIFEST.MF23
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/build.properties10
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/obj16/ExtensiondefinitionModelFile.gifbin0 -> 346 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/obj16/FacadeModelFile.gifbin0 -> 346 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/obj16/FacademappingModelFile.gifbin0 -> 346 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/obj16/ProfilclarificationModelFile.gifbin0 -> 346 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/obj16/VirtualmetamodelModelFile.gifbin0 -> 346 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/wizban/NewExtensiondefinition.gifbin0 -> 2462 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/wizban/NewFacade.gifbin0 -> 2462 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/wizban/NewFacademapping.gifbin0 -> 2462 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/wizban/NewProfilclarification.gifbin0 -> 2462 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/icons/full/wizban/NewVirtualmetamodel.gifbin0 -> 2462 bytes
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/plugin.properties80
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/plugin.xml119
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/extensiondefinition/presentation/ExtensiondefinitionActionBarContributor.java425
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/extensiondefinition/presentation/ExtensiondefinitionEditor.java1832
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/extensiondefinition/presentation/ExtensiondefinitionModelWizard.java630
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/presentation/FacadeActionBarContributor.java423
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/presentation/FacadeEditor.java1830
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/presentation/FacadeEditorPlugin.java97
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/presentation/FacadeModelWizard.java628
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/virtualmetamodel/presentation/VirtualmetamodelActionBarContributor.java425
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/virtualmetamodel/presentation/VirtualmetamodelEditor.java1832
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facade/virtualmetamodel/presentation/VirtualmetamodelModelWizard.java630
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facademapping/presentation/FacademappingActionBarContributor.java423
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facademapping/presentation/FacademappingEditor.java1818
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facademapping/presentation/FacademappingEditorPlugin.java91
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.editor/src/org/eclipse/papyrus/facademapping/presentation/FacademappingModelWizard.java627
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/.classpath7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/.project28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/META-INF/MANIFEST.MF15
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/build.properties4
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/Activator.java30
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/RepresentingElement.java13
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/WrappingEObjectContainmentEList.java220
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/WrappingEObjectContainmentWithInverseEList.java200
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/WrappingEObjectEList.java211
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/WrappingEObjectWithInverseEList.java225
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/WrappingList.java18
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/subset/WrappingSubsetEObjectContainmentEList.java134
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/subset/WrappingSubsetEObjectContainmentWithInverseEList.java137
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/subset/WrappingSubsetEObjectEList.java142
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.utils/src/org/eclipse/papyrus/facade/utils/wrappinglist/subset/WrappingSubsetEObjectWithInverseEList.java149
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/.classpath7
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/.project28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/META-INF/MANIFEST.MF28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/build.properties15
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/model/facade.ecore103
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/model/facade.genmodel55
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/model/facademapping.ecore26
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/model/facademapping.genmodel28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/model/marte-domain-with Generals.uml2870
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/plugin.properties8
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/plugin.xml68
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/Facade.java77
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/FacadeFactory.java42
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/FacadePackage.java188
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/BaseMetaclass.java142
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/Combination.java42
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/ExtensionDefinition.java162
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/ExtensionDefinitionKind.java262
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/ExtensiondefinitionFactory.java60
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/ExtensiondefinitionPackage.java568
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/impl/BaseMetaclassImpl.java405
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/impl/CombinationImpl.java134
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/impl/ExtensionDefinitionImpl.java437
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/impl/ExtensiondefinitionFactoryImpl.java168
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/impl/ExtensiondefinitionPackageImpl.java380
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/util/ExtensiondefinitionAdapterFactory.java156
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/util/ExtensiondefinitionResourceFactoryImpl.java52
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/util/ExtensiondefinitionResourceImpl.java28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/util/ExtensiondefinitionSwitch.java152
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/extensiondefinition/util/ExtensiondefinitionXMLProcessor.java50
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/impl/FacadeFactoryImpl.java95
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/impl/FacadeImpl.java244
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/impl/FacadePackageImpl.java217
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/util/FacadeAdapterFactory.java120
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/util/FacadeResourceFactoryImpl.java52
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/util/FacadeResourceImpl.java28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/util/FacadeSwitch.java110
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/util/FacadeXMLProcessor.java50
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualClassifier.java51
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualDatatype.java17
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualElement.java104
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualEnum.java40
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualLiteral.java17
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualMetaclass.java149
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualMetamodel.java156
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualOperation.java40
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualParameter.java17
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualProperty.java105
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualmetamodelFactory.java105
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/VirtualmetamodelPackage.java1368
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualClassifierImpl.java195
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualDatatypeImpl.java39
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualElementImpl.java279
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualEnumImpl.java150
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualLiteralImpl.java39
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualMetaclassImpl.java399
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualMetamodelImpl.java421
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualOperationImpl.java150
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualParameterImpl.java39
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualPropertyImpl.java317
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualmetamodelFactoryImpl.java172
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/impl/VirtualmetamodelPackageImpl.java611
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/util/VirtualmetamodelAdapterFactory.java282
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/util/VirtualmetamodelResourceFactoryImpl.java52
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/util/VirtualmetamodelResourceImpl.java28
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/util/VirtualmetamodelSwitch.java310
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facade/virtualmetamodel/util/VirtualmetamodelXMLProcessor.java50
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/ExtensionDefinitionKind.java262
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/FacadeMappping.java42
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/FacademappingFactory.java60
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/FacademappingPackage.java418
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/Mapping.java77
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/StereotypedMapping.java72
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/impl/FacadeMapppingImpl.java152
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/impl/FacademappingFactoryImpl.java168
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/impl/FacademappingPackageImpl.java293
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/impl/MappingImpl.java217
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/impl/StereotypedMappingImpl.java205
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/util/FacademappingAdapterFactory.java156
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade/src/org/eclipse/papyrus/facademapping/util/FacademappingSwitch.java153
282 files changed, 46777 insertions, 0 deletions
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.classpath b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.classpath
new file mode 100644
index 00000000000..0c2c7e3d267
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-custom"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.project b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.project
new file mode 100644
index 00000000000..b44c0bf785d
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.project
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.facade.codegen</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.acceleo.ide.ui.acceleoBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>compliance</key>
+ <value>pragmatic</value>
+ </dictionary>
+ <dictionary>
+ <key>resource.kind</key>
+ <value>binary</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.acceleo.ide.ui.acceleoNature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.settings/org.eclipse.jdt.core.prefs b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..11f6e462df7
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/META-INF/MANIFEST.MF b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..f980a18f0c0
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Codegen
+Bundle-SymbolicName: org.eclipse.papyrus.facade.codegen;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.facade.codegen.FacadeCodeGenPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.eef.codegen.launcher,
+ org.eclipse.core.resources,
+ org.eclipse.emf.common,
+ org.eclipse.emf.codegen.ecore,
+ org.eclipse.acceleo.engine,
+ org.eclipse.emf.eef.codegen.ecore;bundle-version="1.2.0",
+ org.eclipse.papyrus.facade;bundle-version="1.0.0",
+ org.eclipse.uml2.codegen.ecore;bundle-version="1.9.0",
+ org.eclipse.uml2.uml;bundle-version="4.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.facade.codegen.GenFacade,
+ org.eclipse.papyrus.facade.codegen.utils
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.acceleo b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.acceleo
new file mode 100644
index 00000000000..e23ef25281c
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.acceleo
@@ -0,0 +1,26 @@
+<!-- ===================================================================== -->
+<!-- Custom targets. -->
+<!-- Set customBuildCallbacks = build.acceleo in your build.properties. -->
+<!-- ===================================================================== -->
+<project name="Build Acceleo Module" default="noDefault">
+ <!-- ================================================================= -->
+ <!-- Default target -->
+ <!-- ================================================================= -->
+ <target name="noDefault">
+ <echo message="This file must be called with explicit targets" />
+ </target>
+
+ <!-- ================================================================= -->
+ <!-- This will be called automatically after the compilation of each -->
+ <!-- Bundle... in dependency order. -->
+ <!-- ================================================================= -->
+ <target name="post.compile.@dot">
+ <acceleoCompiler
+ sourceFolder="${target.folder}"
+ outputFolder="${target.folder}"
+ dependencies="${target.folder}/../../org.eclipse.papyrus.facade;"
+ binaryResource="false"
+ packagesToRegister="">
+ </acceleoCompiler>
+ </target>
+</project>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.properties b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.properties
new file mode 100644
index 00000000000..75710eb2526
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/build.properties
@@ -0,0 +1,8 @@
+source.. = src/,\
+ src-custom/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ bin/,\
+ src-custom/
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/plugin.xml b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/plugin.xml
new file mode 100644
index 00000000000..518938f551f
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/plugin.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.eclipse.emf.eef.codegen.ecore.ui.launcher"
+ objectClass="org.eclipse.emf.codegen.ecore.genmodel.GenModel">
+ <menu
+ id="org.eclipse.emf.eef.ui.menu"
+ label="EEF"
+ path="edit">
+ <groupMarker
+ name="facade-generation">
+ </groupMarker>
+ </menu>
+ <action
+ class="org.eclipse.papyrus.facade.codegen.ui.launcher.GenerateFacadeAction"
+ enablesFor="*"
+ id="org.eclipse.papyrus.facade.codegen"
+ label="Generate Facade Code"
+ menubarPath="org.eclipse.emf.eef.ui.menu/facade-generation">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/FacadeCodeGenPlugin.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/FacadeCodeGenPlugin.java
new file mode 100644
index 00000000000..bbc9d745b88
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/FacadeCodeGenPlugin.java
@@ -0,0 +1,50 @@
+package org.eclipse.papyrus.facade.codegen;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class FacadeCodeGenPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.facade.codegen"; //$NON-NLS-1$
+
+ // The shared instance
+ private static FacadeCodeGenPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public FacadeCodeGenPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#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 FacadeCodeGenPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateCodeAction.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateCodeAction.java
new file mode 100644
index 00000000000..a2c19cf693c
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateCodeAction.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.eclipse.papyrus.facade.codegen.ui.launcher;
+
+import java.util.ArrayList;
+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.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.eef.codegen.flow.Workflow;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @author <a href="mailto:stephane.bouchet@obeo.fr">Stephane Bouchet</a>
+ */
+public abstract class GenerateCodeAction implements IObjectActionDelegate {
+
+ protected Shell shell;
+
+ protected List<GenModel> emfGenModels;
+
+ protected IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ public GenerateCodeAction() {
+ emfGenModels = new ArrayList<GenModel>();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ shell = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ if(emfGenModels != null) {
+ final Workflow flow = initEMFGenFlow();
+ flow.prepare();
+ Job job = new Job("EEF architecture generation") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ flow.execute(monitor);
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ }
+
+ /**
+ * @return the flow to execute in order to generate EMF code.
+ */
+ protected abstract Workflow initEMFGenFlow();
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ emfGenModels.clear();
+ if(selection instanceof StructuredSelection) {
+ StructuredSelection sSelection = (StructuredSelection)selection;
+ for(Object selectedElement : sSelection.toList()) {
+ if(selectedElement instanceof GenModel) {
+ emfGenModels.add((GenModel)selectedElement);
+ }
+ }
+
+ }
+ }
+
+ protected IProject extractProject(String sPath) {
+ IPath path = new Path(sPath);
+ if(path.isEmpty()) {
+ return null;
+ }
+ return workspace.getRoot().getProject(path.segment(0));
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateFacadeAction.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateFacadeAction.java
new file mode 100644
index 00000000000..ed4cff98f7b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/ui/launcher/GenerateFacadeAction.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.eclipse.papyrus.facade.codegen.ui.launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.emf.codegen.ecore.Generator;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.UniqueEList;
+import org.eclipse.emf.eef.codegen.flow.Step;
+import org.eclipse.emf.eef.codegen.flow.Workflow;
+import org.eclipse.papyrus.facade.codegen.FacadeCodeGenPlugin;
+import org.eclipse.papyrus.facade.codegen.GenFacade.GenFacade;
+import org.eclipse.papyrus.facade.codegen.util.EEFGeneratorAdapter;
+
+/**
+ * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a>
+ */
+public class GenerateFacadeAction extends GenerateCodeAction {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see GenerateCodeAction#initEMFGenFlow()
+ */
+ protected Workflow initEMFGenFlow() {
+ final Workflow flow = new Workflow("Generate Facade code ", shell);
+ for(final org.eclipse.emf.codegen.ecore.genmodel.GenModel emfGenModel : emfGenModels) {
+ String s2 = "Generate Facade code for " + emfGenModel.eResource().getURI().toString();
+ flow.addStep(s2, new Step("FACADE MODEL") {
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor) {
+ // create the model project
+ IProject modelProject = extractProject(emfGenModel.getModelProjectDirectory());
+ if(modelProject == null) {
+ return Status.OK_STATUS;
+ }
+ List<IProject> referencedProjects = new UniqueEList<IProject>();
+ if(!workspace.getRoot().exists(modelProject.getFullPath())) {
+ // TODO Manage the case when the model project has been deleted from the workspace but is still present on disk ?
+ modelProject = Generator.createEMFProject(new Path(emfGenModel.getModelDirectory()), modelProject.getLocation(), referencedProjects, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN), Generator.EMF_MODEL_PROJECT_STYLE | Generator.EMF_PLUGIN_PROJECT_STYLE);
+ } else if(!modelProject.isAccessible()) {
+ try {
+ modelProject.open(monitor);
+ } catch (CoreException e) {
+ return new Status(IStatus.ERROR, FacadeCodeGenPlugin.PLUGIN_ID, e.getMessage(), e);
+ }
+ }
+ // generate using acceleo
+ List<String> args = new ArrayList<String>();
+ File modelDirectory = modelProject.getLocation().toFile();
+ try {
+ GenFacade generator = new GenFacade(emfGenModel, modelDirectory, args);
+ generator.doGenerate(BasicMonitor.toMonitor(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)));
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, FacadeCodeGenPlugin.PLUGIN_ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
+ }
+ });
+
+ if(emfGenModel.isCodeFormatting()) {
+ // TODO Ne rafraichir avant le formatage que si le folder demand� n'est pas accessible
+ // FIXME IMPORTANT !!! Virer le double refresh, fait � l'arrache par LDE qui sait pas comment faire autrement
+ // TODO D�terminer pourquoi il reste des diff�rences de formatage avec EMF
+ // TODO D�terminer pourquoi quand on fait clic-droit -> Source -> format sur le code g�n�r�, le code est modifi�
+ // (cas o� le projet vient d'�tre cr�� par exemple)
+ String s1b = "Refreshing workspace " + emfGenModel.eResource().getURI().toString();
+ flow.addStep(s1b, new Step("REFRESH") {
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor) {
+ // refresh model project
+ IProject modelProject = extractProject(emfGenModel.getModelProjectDirectory());
+ if(modelProject == null) {
+ return Status.OK_STATUS;
+ }
+ try {
+ if(!modelProject.isOpen()) {
+ modelProject.open(monitor);
+ }
+ modelProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException e) {
+ return new Status(IStatus.ERROR, FacadeCodeGenPlugin.PLUGIN_ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
+ }
+ });
+
+ String s2prime = "Formatting generated files";
+ flow.addStep(s2prime, new Step(s2prime) {
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor) {
+ EEFGeneratorAdapter eefGen = new EEFGeneratorAdapter();
+ eefGen.generate(emfGenModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, BasicMonitor.toMonitor(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)));
+ return Status.OK_STATUS;
+ }
+ });
+ }
+
+ String s3 = "Refreshing workspace " + emfGenModel.eResource().getURI().toString();
+ flow.addStep(s3, new Step("REFRESH") {
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor) {
+ // refresh model project
+ IProject modelProject = extractProject(emfGenModel.getModelProjectDirectory());
+ if(modelProject == null) {
+ return Status.OK_STATUS;
+ }
+ try {
+ if(!modelProject.isOpen()) {
+ modelProject.open(monitor);
+ }
+ modelProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException e) {
+ return new Status(IStatus.ERROR, FacadeCodeGenPlugin.PLUGIN_ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
+ }
+ });
+ }
+ return flow;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/util/EEFGeneratorAdapter.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/util/EEFGeneratorAdapter.java
new file mode 100644
index 00000000000..594c46d7f51
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src-custom/org/eclipse/papyrus/facade/codegen/util/EEFGeneratorAdapter.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * 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.eclipse.papyrus.facade.codegen.util;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter;
+import org.eclipse.emf.common.EMFPlugin;
+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.URI;
+
+/**
+ * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a>
+ */
+public class EEFGeneratorAdapter extends AbstractGeneratorAdapter {
+
+ private static final String JAVA_EXT_FILE = "java";
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#canGenerate(java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean canGenerate(Object object, Object projectType) {
+ return EMFPlugin.IS_ECLIPSE_RUNNING && object instanceof GenModel;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#doGenerate(java.lang.Object,
+ * java.lang.Object, org.eclipse.emf.common.util.Monitor)
+ */
+ @Override
+ protected Diagnostic doGenerate(Object object, Object projectType,
+ Monitor monitor) throws Exception {
+ GenModel genmodel = (GenModel) object;
+ IFolder folder = null;
+ final IProgressMonitor progressMonitor = BasicMonitor
+ .toIProgressMonitor(monitor);
+ if (projectType == GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE) {
+ final Object codeFormatter = createCodeFormatter(null,
+ URI.createPlatformResourceURI(genmodel.getModelDirectory(),
+ true));
+ folder = ResourcesPlugin.getWorkspace().getRoot()
+ .getFolder(new Path(genmodel.getModelDirectory())); // path);
+ if (folder != null && folder.isAccessible()) {
+ folder.accept(new ResourceVisitorFormatter(codeFormatter,
+ progressMonitor));
+ }
+ } else if (projectType == GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE) {
+ final Object codeFormatter = createCodeFormatter(null,
+ URI.createPlatformResourceURI(genmodel.getEditDirectory(),
+ true));
+ folder = ResourcesPlugin.getWorkspace().getRoot()
+ .getFolder(new Path(genmodel.getEditDirectory()));
+ if (folder != null && folder.isAccessible()) {
+ folder.accept(new ResourceVisitorFormatter(codeFormatter,
+ progressMonitor));
+ }
+ } else if (projectType == GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE) {
+ final Object codeFormatter = createCodeFormatter(null,
+ URI.createPlatformResourceURI(
+ genmodel.getEditorDirectory(), true));
+ folder = ResourcesPlugin.getWorkspace().getRoot()
+ .getFolder(new Path(genmodel.getEditorDirectory()));
+ if (folder != null && folder.isAccessible()) {
+ folder.accept(new ResourceVisitorFormatter(codeFormatter,
+ progressMonitor));
+ }
+ }
+ return Diagnostic.OK_INSTANCE;
+ }
+
+ /**
+ * @param genmodel
+ * @param genPack
+ * @return
+ */
+ protected IPath buildModelPath(GenModel genmodel, GenPackage genPack) {
+ String pathStr = genmodel.getModelDirectory() + "/"
+ + genPack.getQualifiedPackageName().replaceAll("\\.", "/");
+ IPath path = new Path(pathStr);
+ return path;
+ }
+
+ /**
+ * @param genmodel
+ * @param genPack
+ * @return
+ */
+ protected IPath buildProviderPath(GenModel genmodel, GenPackage genPack) {
+ String pathStr = genmodel.getEditDirectory();
+ if (genPack.getProviderPackageName() != null
+ && !genPack.getProviderPackageName().equals("")) {
+ pathStr += "/"
+ + genPack.getProviderPackageName().replaceAll("\\.", "/");
+ }
+ IPath path = new Path(pathStr);
+ return path;
+ }
+
+ /**
+ * @param genmodel
+ * @param genPack
+ * @return
+ */
+ protected IPath buildPresentationPath(GenModel genmodel, GenPackage genPack) {
+ String pathStr = genmodel.getEditorDirectory();
+ if (genPack.getPresentationPackageName() != null
+ && !genPack.getPresentationPackageName().equals("")) {
+ pathStr += "/"
+ + genPack.getPresentationPackageName().replaceAll("\\.",
+ "/");
+ }
+ IPath path = new Path(pathStr);
+ return path;
+ }
+
+ /**
+ * IResourceVisitor responsible to format all java code in a given folder.
+ *
+ * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a>
+ */
+ private final class ResourceVisitorFormatter implements IResourceVisitor {
+ private final Object codeFormatter;
+
+ private final IProgressMonitor progressMonitor;
+
+ private ResourceVisitorFormatter(Object codeFormatter,
+ IProgressMonitor progressMonitor) {
+ this.codeFormatter = codeFormatter;
+ this.progressMonitor = progressMonitor;
+ }
+
+ public boolean visit(IResource resource) throws CoreException {
+ try {
+ if (resource instanceof IFile
+ && ((IFile) resource).getFileExtension().equals(
+ JAVA_EXT_FILE)) {
+ formatFile((IFile) resource, codeFormatter, progressMonitor);
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * @param file
+ * @param codeFormatter
+ * @param progressMonitor
+ * @throws Exception
+ */
+ private void formatFile(IFile file, Object codeFormatter,
+ IProgressMonitor progressMonitor) throws Exception {
+ URI createPlatformResourceURI = URI.createURI(file.getFullPath()
+ .toString(), true);
+ final String contentsStr = getContents(createPlatformResourceURI,
+ null);
+ String formatedContentsStr = formatCode(contentsStr, codeFormatter);
+ ByteArrayInputStream formatedContents = new ByteArrayInputStream(
+ formatedContentsStr.getBytes());
+ file.setContents(formatedContents, true, true, progressMonitor);
+ formatedContents.close();
+ }
+
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/AbstractRepresentingClass.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/AbstractRepresentingClass.mtl
new file mode 100644
index 00000000000..848dbdac4e4
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/AbstractRepresentingClass.mtl
@@ -0,0 +1,59 @@
+[comment encoding = UTF-8 /]
+[module AbstractRepresentingClass('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+
+
+[template public abstractRepresentingClass(genPackage : GenPackage) { genModel : GenModel = genPackage.genModel; packageName : String = genPackage.getUtilitiesPackageName(); className : String = 'AbstractRepresentingElement'} ]
+[genModel.initializeImportManager(packageName, className)/]
+
+[genModel.getImportedName('org.eclipse.emf.common.util.URI')/]
+
+[file (genPackage.abstractRepresentingClassPath(className), false, 'UTF-8')]
+[genModel.includeHeader()/]
+package [packageName/];
+[let content : String = genPackage. abstractRepresentingFileContent(genModel, className)]
+[genModel.genSortedImports()/]
+[content/]
+[/let]
+[/file]
+[/template]
+
+[template protected abstractRepresentingFileContent(genPackage : GenPackage, genModel : GenModel, className : String)]
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+import org.eclipse.papyrus.facade.utils.RepresentingElement;
+
+
+public abstract class AbstractRepresentingElement extends MinimalEObjectImpl.Container implements RepresentingElement {
+
+
+ protected EObject __representedElement;
+
+ @Override
+ public EObject get__Represented() {
+ return __representedElement;
+ }
+
+ @Override
+ public void set__Represented(EObject represented) {
+ this.__representedElement = represented;
+ }
+
+
+}
+
+[/template]
+
+[query public abstractRepresentingClassPath(genPackage : GenPackage, className : String) : String
+ = genPackage.genModel.extractSourceDirectory(genPackage.genModel.modelDirectory) + '/'+ genPackage.getUtilitiesPackageName().toPath() + '/' +
+ className+ '.java'/]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/Class.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/Class.mtl
new file mode 100644
index 00000000000..e15cc883bc1
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/Class.mtl
@@ -0,0 +1,1020 @@
+[comment encoding = UTF-8 /]
+[module Class('http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenOperation /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenParameter /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::papyrus::facade::codegen::genclass::genDeclaredFields /]
+[import org::eclipse::papyrus::facade::codegen::genclass::genFeature /]
+[import org::eclipse::papyrus::facade::codegen::genclass::genOperation /]
+[import org::eclipse::papyrus::facade::codegen::genclass::eUnset /]
+[import org::eclipse::papyrus::facade::codegen::genclass::eIsSet /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+[import org::eclipse::papyrus::facade::codegen::utils::FacadeCodegenUtils /]
+
+[template public genGenClass(genClass : GenClass, isInterface : Boolean, isImplementation : Boolean)]
+[let genPackage : GenPackage = genClass.genPackage]
+[let genModel : GenModel = genPackage.genModel]
+[let isJDK50 : Boolean = genModel.isJDK50()]
+[comment the two following booleans are passed as arguments to this template/]
+[comment] final boolean isInterface = Boolean.TRUE.equals(((Object['[]'/])argument)[1]); final boolean isImplementation = Boolean.TRUE.equals(((Object['[]'/])argument)[2]);[/comment]
+[let isGWT : Boolean = genModel.runtimePlatform = GenRuntimePlatform::GWT]
+[let publicStaticFinalFlag : String = if isImplementation then 'public static final ' else '' endif]
+[let singleWildcard : String = if isJDK50 then '<?>' else '' endif]
+[let negativeOffsetCorrection : String = if genClass.hasOffsetCorrection() then ' - ' + genClass.getDefaultOffsetCorrectionField(genClass) else '' endif]
+[let positiveOffsetCorrection : String = if genClass.hasOffsetCorrection() then ' + ' + genClass.getDefaultOffsetCorrectionField(genClass) else '' endif]
+[let negativeOperationOffsetCorrection : String = if genClass.hasOffsetCorrection() then ' - EOPERATION_OFFSET_CORRECTION' + genClass.getDefaultOffsetCorrectionField(genClass) else '' endif]
+[let positiveOperationOffsetCorrection : String = if genClass.hasOffsetCorrection() then ' + EOPERATION_OFFSET_CORRECTION' + genClass.getDefaultOffsetCorrectionField(genClass) else '' endif]
+
+[let packageName : String = if (isInterface) then
+ genPackage.getInterfacePackageName()
+ else
+ genPackage.getClassPackageName()
+ endif]
+[let className : String = if (isImplementation) then
+ genClass.getClassName()
+ else
+ genClass.getInterfaceName()
+ endif]
+
+[genModel.initializeImportManager(genPackage, packageName, className)/]
+[if (isImplementation)]
+ [genClass.addClassPseudoImports()/]
+[/if]
+
+
+
+[file (genClass.classFilePath(isInterface, isImplementation), false, 'UTF-8')]
+[genClass.includeHeader()/]
+[if (isInterface) ]
+package [genPackage.getInterfacePackageName()/];
+[else]
+package [genPackage.getClassPackageName()/];
+[/if]
+[let content : String = genClass.classFileContent(isInterface, isImplementation, genPackage, genModel, isJDK50, isGWT, publicStaticFinalFlag, singleWildcard, negativeOffsetCorrection, positiveOffsetCorrection, negativeOperationOffsetCorrection, positiveOperationOffsetCorrection)]
+
+[genClass.genSortedImports(isInterface, isImplementation).trim()/]
+
+[content/]
+[/let]
+[/file]
+
+
+
+[/let]
+[/let]
+
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/template]
+
+[template protected classFileContent(genClass : GenClass, isInterface : Boolean, isImplementation : Boolean, genPackage : GenPackage, genModel : GenModel, isJDK50 : Boolean, isGWT : Boolean, publicStaticFinalFlag : String, singleWildcard : String, negativeOffsetCorrection : String, positiveOffsetCorrection : String, negativeOperationOffsetCorrection : String, positiveOperationOffsetCorrection : String) post(trim())]
+[if (isInterface)]
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>[genClass.getFormattedName()/]</b></em>'.
+ * <!-- end-user-doc -->
+ [if (genClass.hasDocumentation())]
+ *
+ * <!-- begin-model-doc -->
+ * [genClass.getDocumentation(genModel.getIndentation())/]
+ * <!-- end-model-doc -->
+ [/if]
+ *
+ [if (not genClass.genFeatures->isEmpty())]
+ * <p>
+ * The following features are supported:
+ * <ul>
+ [for (genFeature : GenFeature | genClass.genFeatures)]
+ [if (not genFeature.isSuppressedGetVisibility())]
+ * <li>{@link [genClass.getQualifiedInterfaceName()/]#[genFeature.getGetAccessor()/] <em>[genFeature.getFormattedName()/]</em>}</li>
+ [/if]
+ [/for]
+ * </ul>
+ * </p>
+ [/if]
+ *
+ [if (not genModel.suppressEMFMetaData)]
+ * @see [genPackage.getQualifiedPackageInterfaceName()/]#get[genClass.getClassifierAccessorName()/]()
+ [/if]
+ [if (not genModel.suppressEMFModelTags)]
+ [let modelInfoLines : Sequence(String) = genClass.getModelInfo().tokenize(genModel.getLineDelimiter() + '\r')]
+ [if (modelInfoLines->isEmpty())]
+ * @model
+ [else]
+ * @model [modelInfoLines->sep(genModel.getLineDelimiter() + ' * ')/]
+ [/if]
+ [/let]
+ [/if]
+ [if (genClass.needsRootExtendsInterfaceExtendsTag())]
+ * @extends [genModel.getImportedName(genModel.rootExtendsInterface)/]
+ [/if]
+ * @generated
+ */
+[else]
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>[genClass.getFormattedName()/]</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ [if (not genClass.getImplementedGenFeatures()->isEmpty())]
+ * The following features are implemented:
+ * <ul>
+ [for (genFeature : GenFeature | genClass.getImplementedGenFeatures())]
+ * <li>{@link [genClass.getQualifiedClassName()/]#[genFeature.getGetAccessor()/] <em>[genFeature.getFormattedName()/]</em>}</li>
+ [/for]
+ * </ul>
+ [/if]
+ * </p>
+ *
+ * @generated
+ */
+[/if]
+[if (isImplementation) ]
+public[if (genClass.isAbstract()) ] abstract[/if] class [genClass.getClassName()/][genClass.getTypeParameters().trim()/][if (genClass.ecoreClass.eSuperTypes->isEmpty()) ] extends [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.AbstractRepresentingElement')/] [else] [genClass.getClassExtends()/] [/if][genClass.getClassImplements()/] {
+
+
+
+[else]
+public interface [genClass.getInterfaceName()/][genClass.getTypeParameters().trim()/][genClass.getInterfaceExtends()/], [genModel.getImportedName('org.eclipse.papyrus.facade.utils.RepresentingElement')/] {
+
+ [comment]public [genModel.getImportedName('org.eclipse.uml2.uml.Element')/] get__Represented();
+
+ public void set__Represented([genModel.getImportedName('org.eclipse.uml2.uml.Element')/] represented);[/comment]
+
+[/if]
+[if (genModel.hasCopyrightField()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [publicStaticFinalFlag/][genModel.getImportedName('java.lang.String')/] copyright = [genModel.getCopyrightFieldLiteral()/];[genModel.getNonNLS()/]
+
+[/if]
+[if (isImplementation and genModel.getDriverNumber() <> null) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final [genModel.getImportedName('java.lang.String')/] mofDriverNumber = "[genModel.getDriverNumber()/]";[genModel.getNonNLS()/]
+
+[/if]
+[if (isImplementation and genClass.isJavaIOSerializable()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final long serialVersionUID = 1L;
+
+[/if]
+[if (isImplementation and genModel.isVirtualDelegation())]
+ [let eVirtualValuesField : String = genClass.getEVirtualValuesField()]
+ [if (genClass.getEVirtualValuesField() <> null) ]
+ /**
+ * An array of objects representing the values of non-primitive features.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected Object['[]'/] [genClass.getEVirtualValuesField()/];
+
+ [/if]
+ [let eVirtualIndexBitFields : Sequence(String) = genClass.getEVirtualIndexBitFields()]
+ [if (not eVirtualIndexBitFields->isEmpty()) ]
+ [for (eVirtualIndexBitField : String | eVirtualIndexBitFields)]
+ /**
+ * A bit field representing the indices of non-primitive feature values.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected int [eVirtualIndexBitField/];
+
+ [/for]
+ [/if]
+ [/let]
+ [/let]
+[/if]
+[if (isImplementation and genClass.isModelRoot() and genModel.isBooleanFlagsEnabled() and genModel.booleanFlagsReservedBits = -1) ]
+ /**
+ * A set of bit flags representing the values of boolean attributes and whether unsettable features have been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected int [genModel.booleanFlagsField/] = 0;
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation) ]
+ [for (genFeature : GenFeature | genClass.getDeclaredFieldGenFeatures())]
+[genFeature.genDeclaredFields(genClass, genModel, isGWT, isJDK50)/][/for]
+[/if]
+[if (isImplementation and genClass.hasOffsetCorrection() and not genClass.getImplementedGenFeatures()->isEmpty()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final int [genClass.getDefaultOffsetCorrectionField()/] = [genClass.getQualifiedClassifierAccessor()/].getFeatureID([genClass.getImplementedGenFeatures()->at(1).oclAsType(GenFeature).getQualifiedFeatureAccessor()/]) - [genClass.getQualifiedFeatureID(genClass.getImplementedGenFeatures()->at(1).oclAsType(GenFeature))/];
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation) ]
+ [for (genFeature : GenFeature | genClass.getImplementedGenFeatures())]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [if (reverseFeature <> null and reverseFeature.genClass.hasOffsetCorrection()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final int [genClass.getOffsetCorrectionField(genFeature)/] = [reverseFeature.genClass.getQualifiedClassifierAccessor()/].getFeatureID([reverseFeature.getQualifiedFeatureAccessor()/]) - [reverseFeature.genClass.getQualifiedFeatureID(reverseFeature)/];
+
+ [/if]
+ [/let]
+ [/for]
+[/if]
+[if (genModel.operationReflection and isImplementation and genClass.hasOffsetCorrection() and not genClass.getImplementedGenOperations()->isEmpty()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final int "EOPERATION_OFFSET_CORRECTION" = [genClass.getQualifiedClassifierAccessor()/].getOperationID([genClass.getImplementedGenOperations()->at(1).oclAsType(GenOperation).getQualifiedOperationAccessor()/]) - [genClass.getQualifiedOperationID(genClass.getImplementedGenOperations()->at(1).oclAsType(GenOperation))/];
+
+[/if]
+[if (isImplementation) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.publicConstructors) ]public[else]protected[/if] [genClass.getClassName()/]() {
+ super();
+ [if (not genClass.isAbstract()) ]
+ __representedElement = [genClass.ecoreClass.getUMLFactory(genModel)/].eINSTANCE.create[genClass.ecoreClass.getUMLMetaElement(genModel)/]();
+
+ boolean adapterExists = false;
+ for([genModel.getImportedName('org.eclipse.emf.common.notify.Adapter')/] adapter : __representedElement.eAdapters()) {
+ if(adapter instanceof [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/]) {
+ (([genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/])adapter).set__Representing(this);
+ adapterExists = true;
+ }
+ }
+
+ if(!adapterExists) {
+ [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/] adapter = new [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/]();
+ adapter.set__Representing(this);
+ __representedElement.eAdapters().add(adapter);
+ }
+ [/if]
+
+
+
+ [for (genFeature : GenFeature | genClass.getFlagGenFeaturesWithDefault()) ]
+ [genClass.getFlagsField(genFeature)/] |= [genFeature.getUpperName()/]_EFLAG[if (not genFeature.isBooleanType()) ]_DEFAULT[/if];
+ [/for]
+ }
+
+
+ [if ( genClass.ecoreClass.getNonAssociationStereotypeQualifiedNames(genModel) <> '' )]
+
+ @Override
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] eBasicSetContainer([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/] newContainer, int newContainerFeatureID, [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] chain = super.eBasicSetContainer(newContainer, newContainerFeatureID, msgs);
+ if(newContainer != null) {
+ String['[]'/] stereotypesQualifiedNames = { [genClass.ecoreClass.getNonAssociationStereotypeQualifiedNames(genModel)/] };
+
+ for([genModel.getImportedName('java.lang.String')/] stereoQualifiedName : stereotypesQualifiedNames) {
+ if((([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getAppliedStereotype(stereoQualifiedName) == null) {
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getApplicableStereotype(stereoQualifiedName);
+ if(stereotype != null) {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).applyStereotype(stereotype);
+ } else {
+ System.err.println("Problem: cannot apply stereotype " + stereoQualifiedName);
+ }
+ }
+ }
+ }
+
+ return chain;
+ }
+
+ [/if]
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected [genModel.getImportedName('org.eclipse.emf.ecore.EClass')/] eStaticClass() {
+ return [genClass.getQualifiedClassifierAccessor()/];
+ }
+
+[/if]
+
+[for (genFeature : GenFeature | if isImplementation then genClass.getImplementedGenFeatures() else genClass.getDeclaredGenFeatures() endif)]
+[genFeature.genFeature(genClass, genPackage, genModel, isJDK50, isInterface, isImplementation, positiveOffsetCorrection, negativeOffsetCorrection, singleWildcard)/][/for]
+
+[for (genOperation : GenOperation | if isImplementation then genClass.getImplementedGenOperations() else genClass.getDeclaredGenOperations() endif)]
+[genOperation.genOperation(genClass, genPackage, genModel, isJDK50, isInterface, isImplementation, isGWT)/][/for]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEInverseAddGenFeatures()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useGenerics())]
+ [if (genClass.getEInverseAddGenFeatures()->filter(GenFeature)->select(f : GenFeature | f.isUncheckedCast(genClass))->size() > 0)]
+ @SuppressWarnings("unchecked")
+ [/if]
+ [/if]
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] eInverseAdd([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/] otherEnd, int featureID, [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ switch (featureID[negativeOffsetCorrection/]) {
+[for (genFeature : GenFeature | genClass.getEInverseAddGenFeatures())]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.isListType())]
+ [let cast : String = '('
+ + genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')
+ + if (not genModel.useGenerics()) then
+ ')'
+ else
+ '<'
+ + genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')
+ + '>)('
+ + genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')
+ + '<?>)'
+ endif]
+ [if (genFeature.isMapType() and genFeature.isEffectiveSuppressEMFTypes()) ]
+ return (([cast/]([genModel.getImportedName('org.eclipse.emf.common.util.EMap')/].InternalMapView[genFeature.getImportedMapTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]()).eMap()).basicAdd(otherEnd, msgs);
+ [else]
+ return ([cast/][genFeature.getGetAccessor()/]()).basicAdd(otherEnd, msgs);
+ [/if]
+ [/let]
+ [else][if (genFeature.isContainer()) ]
+ if (eInternalContainer() != null)
+ msgs = eBasicRemoveFromContainer(msgs);
+ [if (genFeature.isBasicSet()) ]
+ return basicSet[genFeature.getAccessorName()/](([genFeature.getImportedType(genClass)/])otherEnd, msgs);
+ [else]
+ return eBasicSetContainer(otherEnd, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], msgs);
+ [/if]
+ [else]
+ [if (genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else][if (genFeature.isVolatile() or genClass.getImplementingGenModel(genFeature).isDynamicDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = [if (genFeature.isResolveProxies()) ]basicGet[genFeature.getAccessorName()/][else][genFeature.getGetAccessor()/][/if]();
+ [/if][/if]
+ if ([genFeature.getSafeName()/] != null)
+ [if (genFeature.isEffectiveContains()) ]
+ msgs = (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - [genClass.getQualifiedFeatureID(genFeature)/][negativeOffsetCorrection/], null, msgs);
+ [else]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [let targetClass : GenClass = reverseFeature.genClass]
+ [let reverseOffsetCorrection : String = if (targetClass.hasOffsetCorrection()) then ' + ' + genClass.getOffsetCorrectionField(genFeature) else '' endif]
+ msgs = (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, msgs);
+ [/let]
+ [/let]
+ [/let]
+ [/if]
+ return basicSet[genFeature.getAccessorName()/](([genFeature.getImportedType(genClass)/])otherEnd, msgs);
+ [/if][/if]
+[/for]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eInverseAdd(otherEnd, featureID, msgs);
+[else]
+ return eDynamicInverseAdd(otherEnd, featureID, msgs);
+[/if]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEInverseRemoveGenFeatures()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] eInverseRemove([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/] otherEnd, int featureID, [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ switch (featureID[negativeOffsetCorrection/]) {
+[for (genFeature : GenFeature | genClass.getEInverseRemoveGenFeatures())]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.isListType()) ]
+ [if (genFeature.isMapType() and genFeature.isEffectiveSuppressEMFTypes()) ]
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')/][singleWildcard/])(([genModel.getImportedName('org.eclipse.emf.common.util.EMap')/].InternalMapView[genFeature.getImportedMapTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]()).eMap()).basicRemove(otherEnd, msgs);
+ [else][if (genFeature.isWrappedFeatureMapType()) ]
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')/][singleWildcard/])(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)[genFeature.getGetAccessor()/]()).featureMap()).basicRemove(otherEnd, msgs);
+ [else]
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')/][singleWildcard/])[genFeature.getGetAccessor()/]()).basicRemove(otherEnd, msgs);
+ [/if][/if]
+ [else ][if (genFeature.isContainer() and not genFeature.isBasicSet()) ]
+ return eBasicSetContainer(null, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], msgs);
+ [else][if (genFeature.isUnsettable()) ]
+ return basicUnset[genFeature.getAccessorName()/](msgs);
+ [else]
+ return basicSet[genFeature.getAccessorName()/](null, msgs);
+ [/if][/if][/if]
+[/for]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+[else]
+ return eDynamicInverseRemove(otherEnd, featureID, msgs);
+[/if]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEBasicRemoveFromContainerGenFeatures()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] eBasicRemoveFromContainerFeature([genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ switch (eContainerFeatureID()[negativeOffsetCorrection/]) {
+[for (genFeature : GenFeature | genClass.getEBasicRemoveFromContainerGenFeatures())]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [let targetClass : GenClass = reverseFeature.genClass]
+ [let reverseOffsetCorrection : String = if (targetClass.hasOffsetCorrection()) then ' + ' + genClass.getOffsetCorrectionField(genFeature) else '' endif]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ return eInternalContainer().eInverseRemove(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, msgs);
+ [/let]
+ [/let]
+ [/let]
+[/for]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eBasicRemoveFromContainerFeature(msgs);
+[else]
+ return eDynamicBasicRemoveFromContainer(msgs);
+[/if]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEGetGenFeatures()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID[negativeOffsetCorrection/]) {
+[for (genFeature : GenFeature | genClass.getEGetGenFeatures())]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.isPrimitiveType()) ]
+ [if (isJDK50) ]
+ return [genFeature.getGetAccessor()/]();
+ [else][if (genFeature.isBooleanType()) ]
+ return [genFeature.getGetAccessor()/]() ? Boolean.TRUE : Boolean.FALSE;
+ [else]
+ return new [genFeature.getObjectType(genClass)/]([genFeature.getGetAccessor()/]());
+ [/if][/if]
+ [else][if (genFeature.isResolveProxies() and not genFeature.isListType()) ]
+ if (resolve) return [genFeature.getGetAccessor()/]();
+ return basicGet[genFeature.getAccessorName()/]();
+ [else][if (genFeature.isMapType()) ]
+ [if (genFeature.isEffectiveSuppressEMFTypes()) ]
+ if (coreType) return (([genModel.getImportedName('org.eclipse.emf.common.util.EMap')/].InternalMapView[genFeature.getImportedMapTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]()).eMap();
+ else return [genFeature.getGetAccessor()/]();
+ [else]
+ if (coreType) return [genFeature.getGetAccessor()/]();
+ else return [genFeature.getGetAccessor()/]().map();
+ [/if]
+ [else][if (genFeature.isWrappedFeatureMapType()) ]
+ if (coreType) return (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)[genFeature.getGetAccessor()/]()).featureMap();
+ return [genFeature.getGetAccessor()/]();
+ [else][if (genFeature.isFeatureMapType()) ]
+ if (coreType) return [genFeature.getGetAccessor()/]();
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)[genFeature.getGetAccessor()/]()).getWrapper();
+ [else]
+ return [genFeature.getGetAccessor()/]();
+ [/if][/if][/if][/if][/if]
+[/for]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eGet(featureID, resolve, coreType);
+[else]
+ return eDynamicGet(featureID, resolve, coreType);
+[/if]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyESetGenFeatures()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useGenerics()) ]
+ [if (genClass.getESetGenFeatures()->filter(GenFeature)->select(f : GenFeature| f.isUncheckedCast(genClass) and not f.isFeatureMapType() and not f.isMapType())->notEmpty()) ]
+ @SuppressWarnings("unchecked")
+ [/if]
+ [/if]
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID[negativeOffsetCorrection/]) {
+ [for (genFeature : GenFeature | genClass.getESetGenFeatures())]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.isListType()) ]
+ [if (genFeature.isWrappedFeatureMapType()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)[genFeature.getGetAccessor()/]()).featureMap()).set(newValue);
+ [else][if (genFeature.isFeatureMapType()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)[genFeature.getGetAccessor()/]()).set(newValue);
+ [else][if (genFeature.isMapType()) ]
+ [if (genFeature.isEffectiveSuppressEMFTypes()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/].Setting)(([genModel.getImportedName('org.eclipse.emf.common.util.EMap')/].InternalMapView[genFeature.getImportedMapTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]()).eMap()).set(newValue);
+ [else]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/].Setting)[genFeature.getGetAccessor()/]()).set(newValue);
+ [/if]
+ [else]
+ [genFeature.getGetAccessor()/]().clear();
+ [genFeature.getGetAccessor()/]().addAll(([genModel.getImportedName('java.util.Collection')/][if (isJDK50) ]<? extends [genFeature.getListItemType(genClass)/]>[/if])newValue);
+ [/if][/if][/if]
+ [else][if (not isJDK50 and genFeature.isPrimitiveType()) ]
+ set[genFeature.getAccessorName()/]((([genFeature.getObjectType(genClass)/])newValue).[genFeature.getPrimitiveValueFunction()/]());
+ [else]
+ set[genFeature.getAccessorName()/]([if (genFeature.getTypeGenDataType() = null or not genFeature.getTypeGenDataType().isObjectType() or genFeature.getRawType() <> genFeature.getType(genClass)) ]([genFeature.getObjectType(genClass)/])[/if]newValue);
+ [/if][/if]
+ return;
+ [/for]
+ }
+ [if (genModel.minimalReflectiveMethods) ]
+ super.eSet(featureID, newValue);
+ [else]
+ eDynamicSet(featureID, newValue);
+ [/if]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEUnsetGenFeatures()) ]
+[genClass.eUnset(genModel, negativeOffsetCorrection)/]
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genClass.implementsAnyEIsSetGenFeatures()) ]
+[genClass.eIsSet(genModel, positiveOffsetCorrection, negativeOffsetCorrection)/]
+[/if]
+[if (isImplementation and (not genClass.getMixinGenFeatures()->isEmpty() or genClass.hasOffsetCorrection() and not genClass.genFeatures->isEmpty())) ]
+ [if (not genClass.getMixinGenFeatures()->isEmpty()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public int eBaseStructuralFeatureID(int derivedFeatureID, Class[singleWildcard/] baseClass) {
+ [for (mixinGenClass : GenClass | genClass.getMixinGenClasses())]
+ if (baseClass == [mixinGenClass.getRawImportedInterfaceName()/].class) {
+ switch (derivedFeatureID[negativeOffsetCorrection/]) {
+ [for (genFeature : GenFeature | mixinGenClass.genFeatures)]
+ case [genClass.getQualifiedFeatureID(genFeature)/]: return [mixinGenClass.getQualifiedFeatureID(genFeature)/];
+ [/for]
+ default: return -1;
+ }
+ }
+ [/for]
+ return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
+ }
+ [/if]
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public int eDerivedStructuralFeatureID(int baseFeatureID, Class[singleWildcard/] baseClass) {
+ [for (mixinGenClass : GenClass | genClass.getMixinGenClasses())]
+ if (baseClass == [mixinGenClass.getRawImportedInterfaceName()/].class) {
+ switch (baseFeatureID) {
+ [for (genFeature : GenFeature | mixinGenClass.genFeatures)]
+ case [mixinGenClass.getQualifiedFeatureID(genFeature)/]: return [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/];
+ [/for]
+ default: return -1;
+ }
+ }
+ [/for]
+ [if (genClass.hasOffsetCorrection() and not genClass.genFeatures->isEmpty()) ]
+ if (baseClass == [genClass.getRawImportedInterfaceName()/].class) {
+ switch (baseFeatureID[negativeOffsetCorrection/]) {
+ [for (genFeature : GenFeature | genClass.genFeatures)]
+ case [genClass.getQualifiedFeatureID(genFeature)/]: return [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/];
+ [/for]
+ default: return -1;
+ }
+ }
+ [/if]
+ return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
+ }
+
+[/if]
+[if (genModel.operationReflection
+ and isImplementation
+ and (not genClass.getMixinGenOperations()->isEmpty()
+ or not genClass.overridesGenOperations()
+ or genClass.hasOffsetCorrection() and not genClass.genOperations->isEmpty()))]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public int eDerivedOperationID(int baseOperationID, Class[singleWildcard/] baseClass) {
+ [for (extendedGenClass : GenClass | genClass.getExtendedGenClasses())]
+ [let extendedImplementedGenOperations : Sequence(GenOperation) = extendedGenClass.getImplementedGenOperations()]
+ [let implementedGenOperations : Sequence(GenOperation) = genClass.getImplementedGenOperations()]
+ [if (not genClass.overridesExtendedGenOperations(extendedGenClass)) ]
+ if (baseClass == [extendedGenClass.getRawImportedInterfaceName()/].class) {
+ switch (baseOperationID) {
+ [for (genOperation : GenOperation | extendedImplementedGenOperations)]
+ [let overrideGenOperation : GenOperation = genClass.getOverrideGenOperation(genOperation)]
+ [if (implementedGenOperations->includes(overrideGenOperation)) ]
+ case [extendedGenClass.getQualifiedOperationID(genOperation)/]: return [genClass.getQualifiedOperationID(overrideGenOperation)/][positiveOperationOffsetCorrection/];
+ [/if]
+ [/let]
+ [/for]
+ default: return super.eDerivedOperationID(baseOperationID, baseClass);
+ }
+ }
+ [/if]
+ [/let]
+ [/let]
+ [/for]
+ [for (mixinGenClass : GenClass | genClass.getMixinGenClasses())]
+ if (baseClass == [mixinGenClass.getRawImportedInterfaceName()/].class) {
+ switch (baseOperationID) {
+ [for (genOperation : GenOperation | mixinGenClass.genOperations)]
+ [let overrideGenOperation : GenOperation = genClass.getOverrideGenOperation(genOperation)]
+ case [mixinGenClass.getQualifiedOperationID(genOperation)/]: return [genClass.getQualifiedOperationID(if (overrideGenOperation <> null) then overrideGenOperation else genOperation endif)/][positiveOperationOffsetCorrection/];
+ [/let]
+ [/for]
+ default: return -1;
+ }
+ }
+ [/for]
+ [if (genClass.hasOffsetCorrection() and not genClass.genOperations->isEmpty()) ]
+ if (baseClass == [genClass.getRawImportedInterfaceName()/].class) {
+ switch (baseOperationID[negativeOperationOffsetCorrection/]) {
+ [for (genOperation : GenOperation | genClass.genOperations)]
+ case [genClass.getQualifiedOperationID(genOperation)/]: return [genClass.getQualifiedOperationID(genOperation)/][positiveOperationOffsetCorrection/];
+ [/for]
+ default: return -1;
+ }
+ }
+ [/if]
+ return super.eDerivedOperationID(baseOperationID, baseClass);
+ }
+
+[/if]
+[if (isImplementation and genModel.isVirtualDelegation())]
+ [comment][let eVirtualValuesField : String = genClass.getEVirtualValuesField()][/comment]
+ [if (genClass.getEVirtualValuesField() <> null) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected Object['[]'/] eVirtualValues() {
+ return [genClass.getEVirtualValuesField()/];
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected void eSetVirtualValues(Object['[]'/] newValues) {
+ [genClass.getEVirtualValuesField()/] = newValues;
+ }
+
+ [/if]
+ [let eVirtualIndexBitFields : Sequence(String) = genClass.getEVirtualIndexBitFields()]
+ [if (not eVirtualIndexBitFields->isEmpty())]
+ [let allEVirtualIndexBitFields : Sequence(String) = genClass.getAllEVirtualIndexBitFields()]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected int eVirtualIndexBits(int offset) {
+ switch (offset) {
+ [for (field : String | allEVirtualIndexBitFields)]
+ case [i - 1/] :
+ return [field/];
+ [/for]
+ default :
+ throw new IndexOutOfBoundsException();
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected void eSetVirtualIndexBits(int offset, int newIndexBits) {
+ switch (offset) {
+ [for (field : String | allEVirtualIndexBitFields)]
+ case [i - 1/] :
+ [field/] = newIndexBits;
+ break;
+ [/for]
+ default :
+ throw new IndexOutOfBoundsException();
+ }
+ }
+
+ [/let]
+ [/if]
+ [/let]
+ [comment][/let][/comment]
+[/if]
+[if (genModel.operationReflection and isImplementation and not genClass.getImplementedGenOperations()->isEmpty()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ [let genOpList : Sequence(GenOperation) = if (genModel.minimalReflectiveMethods) then genClass.getImplementedGenOperations() else genClass.getAllGenOperations() endif]
+ [if (genOpList.genParameters
+ ->flatten()
+ ->filter(GenParameter)
+ ->select(genParameter : GenParameter | genParameter.isUncheckedCast())
+ ->notEmpty())]
+ @SuppressWarnings("unchecked")
+ [/if]
+ public Object eInvoke(int operationID, [genModel.getImportedName('org.eclipse.emf.common.util.EList')/][singleWildcard/] arguments) throws [genModel.getImportedName(if (isGWT) then 'org.eclipse.emf.common.util.InvocationTargetException' else 'java.lang.reflect.InvocationTargetException' endif)/] {
+ switch (operationID[negativeOperationOffsetCorrection/]) {
+[for (genOperation : GenOperation | genOpList)]
+ [let genParameters : OrderedSet(GenParameter) = genOperation.genParameters]
+ [let size : Integer = genParameters->size()]
+ case [genClass.getQualifiedOperationID(genOperation)/]:
+ [if (genOperation.isVoid()) ]
+ [genOperation.getName()/]([for (genParameter : GenParameter | genParameters)][if (not isJDK50 and genParameter.isPrimitiveType()) ]([/if][if (genParameter.getTypeGenDataType() = null or not genParameter.getTypeGenDataType().isObjectType() or genParameter.getRawType() <> genParameter.getType(genClass)) ]([genParameter.getObjectType(genClass)/])[/if]arguments.get([i/])[if (not isJDK50 and genParameter.isPrimitiveType()) ]).[genParameter.getPrimitiveValueFunction()/]()[/if][if (i < (size - 1)) ], [/if][/for]);
+ return null;
+ [else]
+ return [if (not isJDK50 and genOperation.isPrimitiveType())]new [genOperation.getObjectType(genClass)/]([/if][genOperation.getName()/]([for (genParameter : GenParameter | genParameters)][if (not isJDK50 and genParameter.isPrimitiveType())]([/if][if (genParameter.getTypeGenDataType() = null or not genParameter.getTypeGenDataType().isObjectType() or genParameter.getRawType() <> genParameter.getType(genClass)) ]([genParameter.getObjectType(genClass)/])[/if]arguments.get([i - 1/])[if (not isJDK50 and genParameter.isPrimitiveType()) ]).[genParameter.getPrimitiveValueFunction()/]()[/if][if (i < size) ], [/if][/for])[if (not isJDK50 and genOperation.isPrimitiveType()) ])[/if];
+ [/if]
+ [/let]
+ [/let]
+[/for]
+ [/let]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eInvoke(operationID, arguments);
+[else]
+ return eDynamicInvoke(operationID, arguments);
+[/if]
+ }
+
+[/if]
+[if (not genClass.hasImplementedToStringGenOperation() and isImplementation and not genModel.reflectiveDelegation and not genModel.isDynamicDelegation() and not genClass.getToStringGenFeatures()->isEmpty()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ [for (genFeature : GenFeature | genClass.getToStringGenFeatures())]
+ [if (i = 1)]
+ result.append(" ([genFeature.getName()/]: ");[genModel.getNonNLS()/]
+ [else]
+ result.append(", [genFeature.getName()/]: ");[genModel.getNonNLS()/]
+ [/if]
+ [if (genFeature.isUnsettable() and not genFeature.isListType()) ]
+ [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]
+ if (eVirtualIsSet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/])) result.append(eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/])); else result.append("<unset>");[genModel.getNonNLS()/]
+ [else]
+ [if (genClass.isFlag(genFeature)) ]
+ [if (genFeature.isBooleanType()) ]
+ if ([if (genClass.isESetFlag(genFeature)) ]([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0[else][genFeature.getUncapName()/]ESet[/if]) result.append(([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) != 0); else result.append("<unset>");[genModel.getNonNLS()/]
+ [else]
+ if ([if (genClass.isESetFlag(genFeature)) ]([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0[else][genFeature.getUncapName()/]ESet[/if]) result.append([genFeature.getUpperName()/]_EFLAG_VALUES['['/]([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) >>> [genFeature.getUpperName()/]_EFLAG_OFFSET]); else result.append("<unset>");[genModel.getNonNLS()/]
+ [/if]
+ [else]
+ if ([if (genClass.isESetFlag(genFeature)) ]([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0[else][genFeature.getUncapName()/]ESet[/if]) result.append([genFeature.getSafeName()/]); else result.append("<unset>");[genModel.getNonNLS()/]
+ [/if]
+ [/if]
+ [else]
+ [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]
+ result.append(eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/][if (not genFeature.isListType() and not genFeature.isReferenceType())], [genFeature.getEDefault()/][/if]));
+ [else]
+ [if (genClass.isFlag(genFeature)) ]
+ [if (genFeature.isBooleanType()) ]
+ result.append(([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) != 0);
+ [else]
+ result.append([genFeature.getUpperName()/]_EFLAG_VALUES['['/]([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) >>> [genFeature.getUpperName()/]_EFLAG_OFFSET]);
+ [/if]
+ [else]
+ result.append([genFeature.getSafeName()/]);
+ [/if]
+ [/if]
+ [/if]
+ [/for]
+ result.append(')');
+ return result.toString();
+ }
+
+[/if]
+[if (isImplementation and genClass.isMapEntry())]
+[let keyFeature : GenFeature = genClass.getMapEntryKeyFeature()]
+[let valueFeature : GenFeature = genClass.getMapEntryValueFeature()]
+[let objectType : String = genModel.getImportedName('java.lang.Object')]
+[let keyType : String = if isJDK50 then keyFeature.getObjectType(genClass) else objectType endif]
+[let valueType : String = if isJDK50 then valueFeature.getObjectType(genClass) else objectType endif]
+[let eMapType : String = genModel.getImportedName('org.eclipse.emf.common.util.EMap') + (if isJDK50 then '<' + keyType + ', ' + valueType + '>' else '' endif)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected int hash = -1;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getHash() {
+ if (hash == -1) {
+ [objectType/] theKey = getKey();
+ hash = (theKey == null ? 0 : theKey.hashCode());
+ }
+ return hash;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setHash(int hash) {
+ this.hash = hash;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [keyType/] getKey() {
+ [if (not isJDK50 and keyFeature.isPrimitiveType()) ]
+ return new [keyFeature.getObjectType(genClass)/](getTypedKey());
+ [else]
+ return getTypedKey();
+ [/if]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setKey([keyType/] key) {
+ [if (keyFeature.isListType()) ]
+ getTypedKey().addAll([if (not genModel.useGenerics()) ]([genModel.getImportedName('java.util.Collection')/])[/if]key);
+ [else][if (isJDK50)]
+ setTypedKey(key);
+ [else][if (keyFeature.isPrimitiveType())]
+ setTypedKey((([keyFeature.getObjectType(genClass)/])key).[keyFeature.getPrimitiveValueFunction()/]());
+ [else]
+ setTypedKey(([keyFeature.getImportedType(genClass)/])key);
+ [/if][/if][/if]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [valueType/] getValue() {
+ [if (not isJDK50 and valueFeature.isPrimitiveType()) ]
+ return new [valueFeature.getObjectType(genClass)/](getTypedValue());
+ [else]
+ return getTypedValue();
+ [/if]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [valueType/] setValue([valueType/] value) {
+ [valueType/] oldValue = getValue();
+ [if (valueFeature.isListType()) ]
+ getTypedValue().clear();
+ getTypedValue().addAll([if (not genModel.useGenerics()) ]([genModel.getImportedName('java.util.Collection')/])[/if]value);
+ [else][if (isJDK50)]
+ setTypedValue(value);
+ [else][if (valueFeature.isPrimitiveType()) ]
+ setTypedValue((([valueFeature.getObjectType(genClass)/])value).[valueFeature.getPrimitiveValueFunction()/]());
+ [else]
+ setTypedValue(([valueFeature.getImportedType(genClass)/])value);
+ [/if][/if][/if]
+ return oldValue;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useGenerics()) ]
+ @SuppressWarnings("unchecked")
+ [/if]
+ public [eMapType/] getEMap() {
+ [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] container = eContainer();
+ return container == null ? null : ([eMapType/])container.eGet(eContainmentFeature());
+ }
+
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/if]
+} //[if (isInterface)] [genClass.getInterfaceName()/][else][genClass.getClassName()/][/if]
+[/template]
+
+[query public classFilePath(genClass : GenClass, isInterface : Boolean, isImplementation : Boolean) : String
+ = genClass.getGenModel().extractSourceDirectory(genClass.getGenModel().modelDirectory) + '/' +
+ if isInterface then
+ genClass.getQualifiedInterfaceName().toPath()
+ else
+ genClass.getQualifiedClassName().toPath()
+ endif +
+ '.java' /]
+
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.java
new file mode 100644
index 00000000000..d4721636a43
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.java
@@ -0,0 +1,419 @@
+/*******************************************************************************
+ * 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.eclipse.papyrus.facade.codegen.GenFacade;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.common.preference.AcceleoPreferences;
+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 'GenFacade' generation module.
+ *
+ * @generated
+ */
+public class GenFacade extends AbstractAcceleoGenerator {
+
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "GenAllGenClass" };
+
+ /**
+ * 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 GenFacade() {
+ // 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 GenFacade(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 GenFacade(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.
+ */
+
+ GenFacade generator = new GenFacade(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 NOT
+ */
+ @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);
+ EObject model = getModel();
+ if(model instanceof org.eclipse.emf.codegen.ecore.genmodel.GenModel) {
+ ((org.eclipse.emf.codegen.ecore.genmodel.GenModel)model).getStaticGenPackages();
+ }
+ boolean formerCacheFlag = AcceleoPreferences.isQueryCacheEnabled();
+ try {
+ AcceleoPreferences.switchQueryCache(false);
+ super.doGenerate(monitor);
+ } finally {
+ AcceleoPreferences.switchQueryCache(formerCacheFlag);
+ }
+ }
+
+ /**
+ * 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.emf.ecore.EcorePackage.class)) {
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ }
+ if (!isInWorkspace(org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.class)) {
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.eINSTANCE.getNsURI(), org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.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/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.mtl
new file mode 100644
index 00000000000..4751c33a8ab
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/GenFacade.mtl
@@ -0,0 +1,159 @@
+[comment encoding = UTF-8
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+/]
+[module GenFacade('http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::model::buildproperties /]
+[import org::eclipse::emf::eef::codegen::ecore::model::AdapterFactoryClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::FactoryClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::PackageClass /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::Class /]
+[import org::eclipse::emf::eef::codegen::ecore::model::EnumClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenEnum /]
+[import org::eclipse::emf::eef::codegen::ecore::model::manifest /]
+[import org::eclipse::emf::eef::codegen::ecore::model::module_gwt_xml /]
+[import org::eclipse::emf::eef::codegen::ecore::model::Plugin /]
+[import org::eclipse::emf::eef::codegen::ecore::model::plugin_properties /]
+[import org::eclipse::emf::eef::codegen::ecore::model::plugin_xml /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::ResourceClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::ResourceFactoryClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::SwitchClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::ValidatorClass /]
+[import org::eclipse::emf::eef::codegen::ecore::model::XmlProcessorClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::fileUtil /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::WrapperClass /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::LoaderClass /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::AbstractRepresentingClass /]
+[import org::eclipse::papyrus::facade::codegen::GenFacade::RepresentingElementAdapter /]
+[import org::eclipse::papyrus::facade::codegen::utils::FacadeCodegenUtils /]
+
+
+[**
+ * Generates all the classes of the Model plug-in from a genModel.
+ *
+ * WARNING: The genModel passed to this template MUST be loaded and reconciled as in
+ * org.eclipse.emf.codegen.ecore.genmodel.presentation.GeneratorUIUtil.loadGenModels()
+ * Otherwise canGenerate() will always return false, and invalid reference in the GenModel will cause problems.
+ * In order to prevent a reference to an Ecore UI plug-in, this is done in the eef ui plug-in.
+ *
+*/]
+[template public GenAllGenClass(genModel : GenModel) ? (genModel.canGenerate())]
+ [comment @main /]
+ [if (not genModel.fileExistsModel(genModel.buildPropertiesFilePath()))]
+ [genModel.buildProperties()/]
+ [/if]
+
+ [comment from EMF codegen : Do allow an existing MANIFEST.MF to be overwritten, since it may have been created as part of an empty EMF project.
+ Use the existence of a plugin.xml as a guard against overwriting in a project that has already been generated. /]
+ [if (not genModel.fileExistsModel(genModel.pluginXmlFilePath()))]
+ [genModel.manifest()/]
+ [/if]
+
+ [comment @TODO See when and where GWT files are generated/]
+ [comment][genModel.moduleGwt()/][/comment]
+
+ [if (genModel.hasModelPluginClass())]
+ [genModel.plugin()/]
+ [/if]
+
+ [if (genModel.hasPluginSupport())]
+ [if (not genModel.sameModelEditProject() and not genModel.sameModelEditorProject())]
+ [if (genModel.bundleManifest and not genModel.fileExistsModel(genModel.manifestFilePath()))]
+ [genModel.manifest()/]
+ [/if]
+
+ [if (not genModel.fileExistsModel(genModel.pluginXmlFilePath()))]
+ [genModel.pluginXml()/]
+ [/if]
+ [/if]
+
+ [if (not genModel.fileExistsModel(genModel.pluginPropertiesFilePath()))]
+ [genModel.pluginProperties()/]
+ [/if]
+
+ [if (not genModel.fileExistsModel(genModel.buildPropertiesFilePath()))]
+ [genModel.buildProperties()/]
+ [/if]
+ [/if]
+
+ [for (p : GenPackage | genModel.eAllContents(GenPackage))]
+ [if (p.canGenerate())]
+ [p.prepareCache()/][comment Create helpers to cache and supply information for unique naming./]
+
+ [copyEcore(p)/]
+
+ [for (genClass : GenClass | p.genClasses)]
+ [if (genClass.canGenerate())]
+ [if (not genClass.isExternalInterface() and (not genModel.suppressInterfaces or genClass.isInterface()))]
+ [genClass.genGenClass(true, false)/]
+ [/if]
+ [if (not genClass.isInterface())]
+ [genClass.genGenClass(if genModel.suppressInterfaces then true else false endif, true)/]
+ [/if]
+ [/if]
+ [/for]
+ [for (genEnum : GenEnum | p.genEnums)]
+ [if (genEnum.canGenerate())]
+ [genEnum.enumClass()/]
+ [/if]
+ [/for]
+
+ [if (p.hasClassifiers())]
+
+ [comment @TODO
+ if genModel.generateSchema -> generateSchema,
+ if p.loadingInitialization -> generateSerialization/]
+
+ [if (not genModel.suppressEMFMetaData and not genModel.suppressInterfaces)]
+ [p.packageClass(true, false)/]
+ [/if]
+
+ [p.packageClass(if genModel.suppressEMFMetaData or genModel.suppressInterfaces then true else false endif, true)/]
+
+ [if (not genModel.suppressInterfaces)]
+ [p.factoryClass(true, false)/]
+ [/if]
+
+ [p.factoryClass(if genModel.suppressInterfaces then true else false endif, true)/]
+
+ [if (p.resource = GenResourceKind::XML)]
+ [p.xmlProcessorClass()/]
+ [/if]
+
+ [if (p.hasConstraints())]
+ [p.validatorClass()/]
+ [/if]
+
+ [if (p.adapterFactory and p.genClasses->notEmpty())]
+ [p.switchClass()/]
+ [p.adapterFactoryClass()/]
+ [/if]
+ [/if]
+
+ [p.wrapperClass()/]
+ [p.loaderClass()/]
+ [p.abstractRepresentingClass()/]
+ [p.representingElementAdapterClass()/]
+
+
+ [if (p.resource <> GenResourceKind::None)]
+ [p.resourceFactoryClass()/]
+ [p.resourceClass()/]
+ [/if]
+
+ [p.clearCache()/]
+ [/if]
+ [/for]
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/LoaderClass.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/LoaderClass.mtl
new file mode 100644
index 00000000000..310a7f19d66
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/LoaderClass.mtl
@@ -0,0 +1,118 @@
+[comment encoding = UTF-8 /]
+[module LoaderClass('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+
+
+[template public loaderClass(genPackage : GenPackage) { genModel : GenModel = genPackage.genModel; packageName : String = genPackage.getUtilitiesPackageName(); className : String = 'Loader'} ]
+[genModel.initializeImportManager(packageName, className)/]
+
+[genModel.getImportedName('org.eclipse.emf.common.util.URI')/]
+
+[file (genPackage.loaderPath(className), false, 'UTF-8')]
+[genModel.includeHeader()/]
+package [packageName/];
+[let content : String = genPackage.loaderFileContent(genModel, className)]
+[genModel.genSortedImports()/]
+[content/]
+[/let]
+[/file]
+[/template]
+
+[template protected loaderFileContent(genPackage : GenPackage, genModel : GenModel, className : String)]
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.InternalEList;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+
+public class Loader {
+
+ public static Resource doLoad(InputStream inputStream, Map<?, ?> options, EFactory inputFactory, Resource res) throws IOException {
+ System.err.println("Load : " + res);
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+
+ // Open XML
+ try {
+ db = dbf.newDocumentBuilder();
+ Document document = db.parse(inputStream);
+ Element root = document.getDocumentElement();
+
+ if(root.getNodeName().equals("source")) {
+ String umlFileURIAtt = root.getAttribute("uri");
+ URI umlFileURI = URI.createURI(umlFileURIAtt);
+
+ ResourceSet resSetUML = new ResourceSetImpl();
+ Resource resUML = resSetUML.getResource(umlFileURI, true);
+ if(resUML != null) {
+
+ Iterator<EObject> content = resUML.getContents().iterator();
+ ArrayList internalEObjectList = new ArrayList<>();
+
+ while(content.hasNext()) {
+ EObject umlModelElement = (EObject)content.next();
+ if(umlModelElement instanceof org.eclipse.uml2.uml.Element) {
+ EObject representing = Wrapper.getInstance().findOrCreateSpecific((org.eclipse.uml2.uml.Element)umlModelElement);
+
+ if(representing != null) {
+ internalEObjectList.add(representing);
+ }
+ }
+ }
+
+ InternalEList<InternalEObject> internalEObjects = (InternalEList<InternalEObject>)(InternalEList<?>)res.getContents();
+ internalEObjects.addAllUnique(internalEObjectList);
+
+ return resUML;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+}
+
+
+[/template]
+
+[query public loaderPath(genPackage : GenPackage, className : String) : String
+ = genPackage.genModel.extractSourceDirectory(genPackage.genModel.modelDirectory) + '/'+ genPackage.getUtilitiesPackageName().toPath() + '/' +
+ className+ '.java'/]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/RepresentingElementAdapter.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/RepresentingElementAdapter.mtl
new file mode 100644
index 00000000000..87fbb44c113
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/RepresentingElementAdapter.mtl
@@ -0,0 +1,96 @@
+[comment encoding = UTF-8 /]
+[module RepresentingElementAdapter('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+
+
+[template public representingElementAdapterClass(genPackage : GenPackage) { genModel : GenModel = genPackage.genModel; packageName : String = genPackage.getUtilitiesPackageName(); className : String = 'RepresentingElementAdapter'} ]
+[genModel.initializeImportManager(packageName, className)/]
+
+[genModel.getImportedName('org.eclipse.emf.common.util.URI')/]
+
+[file (genPackage.representingElementAdapterClassPath(className), false, 'UTF-8')]
+[genModel.includeHeader()/]
+package [packageName/];
+[let content : String = genPackage. representingElementAdapterFileContent(genModel, className)]
+[genModel.genSortedImports()/]
+[content/]
+[/let]
+[/file]
+[/template]
+
+[template protected representingElementAdapterFileContent(genPackage : GenPackage, genModel : GenModel, className : String)]
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.uml2.uml.Element;
+
+public class RepresentingElementAdapter extends AdapterImpl {
+
+ private EObject representingElement;
+
+ /**
+ * Does nothing; clients may override so that it does something.
+ */
+ public void notifyChanged(Notification msg) {
+
+ //Wrap notif
+ Object umlNotifier = msg.getNotifier();
+ EObject specificNotifier = Wrapper.getInstance().findOrCreateSpecific((EObject)umlNotifier);
+
+ Object umlFeature = msg.getFeature();
+ EStructuralFeature specificFeature = Wrapper.getInstance().getFeatureMappingFromUML((EStructuralFeature)umlFeature);
+
+ if(msg.getFeature() instanceof EReference) {
+ Object umlOld = msg.getOldValue();
+ EObject specificOld = null;
+ if(umlOld != null) {
+ specificOld = Wrapper.getInstance().findOrCreateSpecific((Element)umlOld);
+ }
+
+ Object umlNew = msg.getNewValue();
+ EObject specificNew = null;
+ if(umlNew != null) {
+ specificNew = Wrapper.getInstance().findOrCreateSpecific((Element)umlNew);
+ }
+
+ Notification notification = new ENotificationImpl((InternalEObject)specificNotifier, msg.getEventType(), specificFeature, specificOld, specificNew, msg.getPosition(), msg.wasSet());
+
+ specificNotifier.eNotify(notification);
+
+ } else {
+ Notification notification = new ENotificationImpl((InternalEObject)specificNotifier, msg.getEventType(), specificFeature, msg.getOldValue(), msg.getNewValue(), msg.getPosition(), msg.wasSet());
+
+ specificNotifier.eNotify(notification);
+ }
+ System.err.println("UML Notif -> " + msg);
+ }
+
+
+ public EObject get__Representing() {
+ return representingElement;
+ }
+
+ public void set__Representing(EObject representing) {
+ representingElement = representing;
+ }
+}
+
+
+[/template]
+
+[query public representingElementAdapterClassPath(genPackage : GenPackage, className : String) : String
+ = genPackage.genModel.extractSourceDirectory(genPackage.genModel.modelDirectory) + '/'+ genPackage.getUtilitiesPackageName().toPath() + '/' +
+ className+ '.java'/]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/ResourceClass.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/ResourceClass.mtl
new file mode 100644
index 00000000000..8915fbe1934
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/ResourceClass.mtl
@@ -0,0 +1,526 @@
+[comment encoding = UTF-8 /]
+[module ResourceClass('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+
+[comment]
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2006 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ */
+[/comment]
+
+[template public resourceClass(genPackage : GenPackage) { genModel : GenModel = genPackage.genModel; packageName : String = genPackage.getUtilitiesPackageName(); className : String = genPackage.getResourceClassName();} ]
+[genModel.initializeImportManager(packageName, className)/]
+
+[genModel.getImportedName('org.eclipse.emf.common.util.URI')/]
+
+[file (genPackage.resourceClassPath(), false, 'UTF-8')]
+[genModel.includeHeader()/]
+package [packageName/];
+[let content : String = genPackage.resourceFileContent(genModel, className)]
+[genModel.genSortedImports()/]
+[content/]
+[/let]
+[/file]
+[/template]
+
+[template protected resourceFileContent(genPackage : GenPackage, genModel : GenModel, className : String)]
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see [genPackage.getQualifiedResourceFactoryClassName()/]
+ * @generated
+ */
+public class [className/] extends [genPackage.getImportedResourceBaseClassName()/]
+{
+ private [genModel.getImportedName('org.eclipse.emf.ecore.resource.Resource')/] resUML;
+
+ @Override
+ public void doLoad([genModel.getImportedName('java.io.InputStream')/] inputStream, [genModel.getImportedName('java.util.Map')/]<?, ?> options) throws [genModel.getImportedName('java.io.IOException')/] {
+ resUML = [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Loader')/].doLoad(inputStream, options, [genModel.getImportedName(genPackage.getImportedFactoryInterfaceName())/].eINSTANCE, this);
+ }
+
+ @Override
+ public void doSave([genModel.getImportedName('java.io.OutputStream')/] outputStream, [genModel.getImportedName('java.util.Map')/]<?, ?> options) throws [genModel.getImportedName('java.io.IOException')/] {
+ if(resUML != null) {
+ resUML.save(options);
+ }
+ [genModel.getImportedName('java.io.PrintStream')/] stream = new [genModel.getImportedName('java.io.PrintStream')/](outputStream);
+ stream.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ String uri = resUML.getURI().toString();
+ stream.println("<source uri=\"" + uri + "\"/>");
+ }
+
+[if (genModel.hasCopyrightField())]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final [genModel.getImportedName('java.lang.String')/] copyright = [genModel.getCopyrightFieldLiteral()/];[genModel.getNonNLS()/]
+
+[/if]
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public [className/](URI uri)
+ {
+ super(uri);
+[if (genPackage.getResource() = GenResourceKind::XML)][comment Do nothing/]
+[/if]
+ }
+
+[if (genPackage.dataTypeConverters and (genPackage.hasDocumentRoot() or genPackage.isXMLTypePackage()))]
+[let _Map : String = if (genModel.useGenerics()) then 'Map<?, ?>' else 'Map' endif]
+[let _MapStringBoolean : String = if (genModel.useGenerics()) then 'Map<String, Boolean>' else 'Map' endif]
+[let _MapStringWildcard : String = if (genModel.useGenerics()) then 'Map<String, ?>' else 'Map' endif]
+[comment || org.eclipse.emf.ecore.xml.type.XMLTypePackage.eNS_URI.equals(genPackage.getNSURI()))) { boolean isXMLTypePackage = org.eclipse.emf.ecore.xml.type.XMLTypePackage.eNS_URI.equals(genPackage.getNSURI());%>/]
+ [if (not genPackage.isXMLTypePackage())]
+[genModel.getImportedName('org.eclipse.emf.ecore.xmi.XMLResource')/]
+[genModel.getImportedName('org.eclipse.emf.ecore.xmi.XMLParserPool')/]
+[genModel.getImportedName('org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl')/]
+[genModel.getImportedName('java.io.InputStream')/]
+[genModel.getImportedName('java.io.IOException')/]
+[genModel.getImportedName('org.eclipse.emf.ecore.EObject')/]
+[genModel.getImportedName('java.util.Collections')/]
+[genModel.getImportedName('java.util.HashMap')/]
+[genModel.getImportedName('java.util.Map')/]
+[genModel.getImportedName('org.xml.sax.InputSource')/]
+[genModel.getImportedName('javax.xml.parsers.SAXParser')/]
+ [/if]
+[genModel.getImportedName('org.xml.sax.Attributes')/]
+[genModel.getImportedName('org.xml.sax.SAXException')/]
+[let _StackFrame : String = genModel.getImportedName('org.eclipse.emf.ecore.xml.type.util.XMLTypeResourceImpl') + '.StackFrame']
+[let _DataFrame : String = genModel.getImportedName('org.eclipse.emf.ecore.xml.type.util.XMLTypeResourceImpl') + '.DataFrame']
+ [if (not genPackage.isXMLTypePackage())]
+ /**
+ * A load option that turns of the use of the generate data converters.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String OPTION_USE_DATA_CONVERTER = "USE_DATA_CONVERTER";
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public void doLoad(InputStream inputStream, [_Map/] options) throws IOException
+ {
+ if (options != null && Boolean.TRUE.equals(options.get(OPTION_USE_DATA_CONVERTER)))
+ {
+ getContents().add
+ (load
+ (new InputSource(inputStream),
+ ([_MapStringBoolean/])options.get(XMLResource.OPTION_PARSER_FEATURES),
+ ([_MapStringWildcard/])options.get(XMLResource.OPTION_PARSER_PROPERTIES),
+ Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_LEXICAL_HANDLER))).eContainer());
+ }
+ else
+ {
+ super.doLoad(inputStream, options);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public void doLoad(InputSource inputSource, [_Map/] options) throws IOException
+ {
+ if (options != null && Boolean.TRUE.equals(options.get(OPTION_USE_DATA_CONVERTER)))
+ {
+ getContents().add
+ (load
+ (inputSource,
+ ([_MapStringBoolean/])options.get(XMLResource.OPTION_PARSER_FEATURES),
+ ([_MapStringWildcard/])options.get(XMLResource.OPTION_PARSER_PROPERTIES),
+ Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_LEXICAL_HANDLER))).eContainer());
+ }
+ else
+ {
+ super.doLoad(inputSource, options);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static final XMLParserPool parserPool = new XMLParserPoolImpl();
+
+ /**
+ * Loads an instance from the input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param inputSource the input from which to load.
+ * @param features a map of the parser features and their values.
+ * @param properties a map of a parser properties and their values.
+ * @param useLexicalHandler whether a lexical handler should be used during loading.
+ * @return the root object; for the case of a document root, the child of that document root is return.
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @generated
+ */
+ public static EObject load(InputSource inputSource, [_MapStringBoolean/] features, [_MapStringWildcard/] properties, boolean useLexicalHandler) throws IOException
+ {
+ [_MapStringBoolean/] requiredFeatures = new [_MapStringBoolean.replaceAll('Map','HashMap')/]();
+ requiredFeatures.put("http://xml.org/sax/features/namespaces", Boolean.TRUE);
+ if (features != null)
+ {
+ requiredFeatures.putAll(features);
+ }
+
+ if (properties == null)
+ {
+ properties = Collections.[if (genModel.useGenerics())]emptyMap()[else]EMPTY_MAP[/if];
+ }
+
+ SAXParser saxParser = null;
+ try
+ {
+ saxParser = parserPool.get(requiredFeatures, properties, useLexicalHandler);
+ final FrameFactory.DocumentRootStackFrame documentRoot = FrameFactory.INSTANCE.pushDocumentRoot(null, null);
+ XMLTypeResourceImpl.Handler handler = new XMLTypeResourceImpl.Handler(documentRoot);
+ saxParser.parse(inputSource, handler);
+ [if (genModel.suppressEMFTypes)]
+ return (EObject)((EObject)FrameFactory.INSTANCE.popDocumentRoot(documentRoot)).eContents().get(0);
+ [else]
+ return FrameFactory.INSTANCE.popDocumentRoot(documentRoot).eContents().get(0);
+ [/if]
+ }
+ catch (Exception exception)
+ {
+ throw new IOWrappedException(exception);
+ }
+ finally
+ {
+ parserPool.release(saxParser, requiredFeatures, properties, useLexicalHandler);
+ }
+ }
+
+ [/if]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public final static class FrameFactory
+ {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final FrameFactory INSTANCE = new FrameFactory();
+
+ [for (genClass : GenClass | genPackage.genClasses)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [genClass.getName()/]StackFrame [genClass.getSafeUncapName()/];
+
+ [/for]
+ [for (genDataType : GenDataType | genPackage.getAllGenDataTypes())]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [_DataFrame/] [genDataType.getSafeUncapName()/];
+
+ [/for]
+ [for (genClass : GenClass | genPackage.genClasses)]
+ [let attributes : Sequence(EStructuralFeature) = genModel.getAllExtendedMetaDataAttributes(genClass.ecoreClass)]
+ [let elements : Sequence(EStructuralFeature) = genModel.getAllExtendedMetaDataElements(genClass.ecoreClass)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [genClass.getName()/]StackFrame push[genClass.getName()/]([_StackFrame/] previous, Attributes attributes)
+ {
+ [genClass.getName()/]StackFrame result[genClass.getName()/] = [genClass.getSafeUncapName()/] == null ? new [genClass.getName()/]StackFrame() : [genClass.getSafeUncapName()/];
+ [genClass.getSafeUncapName()/] = null;
+ result[genClass.getName()/].pushOnto(previous);
+ result[genClass.getName()/].handleAttributes(attributes);
+ return result[genClass.getName()/];
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [genClass.getImportedInterfaceName()/] pop[genClass.getName()/]([genClass.getName()/]StackFrame [genClass.getSafeUncapName()/])
+ {
+ [genClass.getImportedInterfaceName()/] result[genClass.getName()/]Value = [genClass.getSafeUncapName()/].pop[genClass.getName()/]();
+ this.[genClass.getSafeUncapName()/] = [genClass.getSafeUncapName()/];
+ return result[genClass.getName()/]Value;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class [genClass.getName()/]StackFrame extends [_StackFrame/]
+ {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [genClass.getImportedInterfaceName()/] the[genClass.getName()/];
+
+ [for (genFeature : GenFeature | genClass.getAllGenFeatures())]
+ [let name : String = genModel.getExtendedMetaDataName(genFeature.ecoreFeature)]
+ [if ((elements->includes(genFeature.ecoreFeature) or attributes->includes(genFeature.ecoreFeature)) and name.index(':') < 0)]
+ [if (genFeature.isReferenceType())]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [genFeature.getTypeGenClass().genPackage.getImportedResourceClassName()/].FrameFactory.[genFeature.getTypeGenClass().getName()/]StackFrame [genFeature.getSafeName()/];
+
+ [else]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [_DataFrame/] [genFeature.getSafeName()/];
+
+ [/if]
+ [/if]
+ [/let]
+ [/for]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public void handleAttributes(Attributes attributes)
+ {
+ [comment int count = 0; for (GenFeature genFeature : genClass.getAllGenFeatures()) /]
+ [let featuresToHandle : Sequence(GenFeature) = genClass.getAllGenFeatures()->filter(GenFeature)
+ ->select(f : GenFeature| attributes->includes(f.ecoreFeature)
+ and not f.isDerived()
+ and genModel.getExtendedMetaDataName(f.ecoreFeature).index(':') < 0
+ and not f.isReferenceType())]
+ [for (genFeature : GenFeature | featuresToHandle)]
+ [let name : String = genModel.getExtendedMetaDataName(genFeature.ecoreFeature)]
+ [let namespace : String = genModel.getExtendedMetaDataNamespaceAsLiteral(genFeature.ecoreFeature)]
+ [let genClassifier : GenClassifier = genFeature.getTypeGenClassifier()]
+ [if (i = 0)]
+ String theValue = attributes.getValue([namespace/], "[name/]");
+ [else]
+ theValue = attributes.getValue([namespace/], "[name/]");
+ [/if]
+ if (theValue != null)
+ {
+ [if (genClassifier.genPackage.dataTypeConverters)]
+ the[genClass.getName()/].set[genFeature.getAccessorName()/]([genClassifier.genPackage.getQualifiedFactoryInstanceAccessor()/].create[genClassifier.getName()/](theValue));
+ [else]
+ the[genClass.getName()/].set[genFeature.getAccessorName()/](([genFeature.getImportedType(null)/])[genClassifier.genPackage.getQualifiedEFactoryInstanceAccessor()/].createFromString([genClassifier.getQualifiedClassifierAccessor()/], theValue));
+ [/if]
+ }
+ [/let]
+ [/let]
+ [/let]
+ [/for]
+ [if (featuresToHandle->isEmpty())]
+ // There are attributes to handle.
+ [/if]
+ [/let]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public [_StackFrame/] startElement(String namespace, String localName, String qName, Attributes attributes) throws SAXException
+ {
+ [let featuresToHandle : Sequence(GenFeature) = genClass.getAllGenFeatures()->filter(GenFeature)
+ ->select(f : GenFeature | elements->includes(f.ecoreFeature)
+ and genModel.getExtendedMetaDataName(f.ecoreFeature).index(':') < 0)]
+ [for (genFeature : GenFeature | featuresToHandle)]
+ [let name : String = genModel.getExtendedMetaDataName(genFeature.ecoreFeature)]
+ [let namespace : String = genModel.getExtendedMetaDataNamespaceAsLiteral(genFeature.ecoreFeature)]
+ [if (i > 0)]else [/if]if ("[name/]".equals(localName) && [namespace/].equals(namespace))
+ {
+ return [genFeature.getSafeName()/] = [genFeature.getTypeGenClassifier().genPackage.getImportedResourceClassName()/].FrameFactory.INSTANCE.push[genFeature.getTypeGenClassifier().getName()/](this, attributes);
+ }
+ [/let]
+ [/let]
+ [/for]
+ [if (featuresToHandle->isEmpty())]
+ return super.startElement(namespace, localName, qName, attributes);
+ [else]
+ else
+ {
+ return super.startElement(namespace, localName, qName, attributes);
+ }
+ [/if]
+ [/let]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public void endElement([_StackFrame/] child) throws SAXException
+ {
+ [let featuresToHandle : Sequence(GenFeature) = genClass.getAllGenFeatures()->filter(GenFeature)
+ ->select(f : GenFeature | elements->includes(f.ecoreFeature)
+ and genModel.getExtendedMetaDataName(f.ecoreFeature).index(':') < 0)]
+ [for (genFeature : GenFeature | featuresToHandle)]
+ [let name : String = genModel.getExtendedMetaDataName(genFeature.ecoreFeature)]
+ [if (i > 0)]else [/if]if (child == [genFeature.getSafeName()/])
+ {
+ [if (genFeature.isListType())]
+ the[genClass.getName()/].[genFeature.getGetAccessor()/]().add([genFeature.getTypeGenClassifier().genPackage.getImportedResourceClassName()/].FrameFactory.INSTANCE.pop[genFeature.getTypeGenClassifier().getName()/]([genFeature.getSafeName()/]));
+ [else]
+ the[genClass.getName()/].set[genFeature.getAccessorName()/]([genFeature.getTypeGenClassifier().genPackage.getImportedResourceClassName()/].FrameFactory.INSTANCE.pop[genFeature.getTypeGenClassifier().getName()/]([genFeature.getSafeName()/]));
+ [/if]
+ [genFeature.getSafeName()/] = null;
+ }
+ [/let]
+ [/for]
+ [if (featuresToHandle->isEmpty())]
+ super.endElement(child);
+ [else]
+ else
+ {
+ super.endElement(child);
+ }
+ [/if]
+ [/let]
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation())]
+ @Override
+ [/if]
+ public void create()
+ {
+ the[genClass.getName()/] = [genPackage.getQualifiedFactoryInstanceAccessor()/].create[genClass.getName()/]();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected [genClass.getImportedInterfaceName()/] pop[genClass.getName()/]()
+ {
+ pop();
+ [genClass.getImportedInterfaceName()/] result[genClass.getName()/]Value = the[genClass.getName()/];
+ the[genClass.getName()/] = null;
+ return result[genClass.getName()/]Value;
+ }
+
+ }
+
+ [/let]
+ [/let]
+ [/for]
+ [for (genDataType : GenDataType | genPackage.getAllGenDataTypes())]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [_DataFrame/] push[genDataType.getName()/]([_StackFrame/] previous, Attributes attributes)
+ {
+ [_DataFrame/] result[genDataType.getName()/] = [genDataType.getSafeUncapName()/] == null ? new [_DataFrame/]() : [genDataType.getSafeUncapName()/];
+ [genDataType.getSafeUncapName()/] = null;
+ result[genDataType.getName()/].pushOnto(previous);
+ result[genDataType.getName()/].handleAttributes(attributes);
+ return result[genDataType.getName()/];
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public [genDataType.getImportedParameterizedInstanceClassName()/] pop[genDataType.getName()/]([_DataFrame/] [genDataType.getSafeUncapName()/])
+ {
+ [if (genDataType.genPackage.dataTypeConverters)]
+ [genDataType.getImportedParameterizedInstanceClassName()/] result[genDataType.getName()/]Value = [genDataType.genPackage.getQualifiedFactoryInstanceAccessor()/].create[genDataType.getName()/]([genDataType.getSafeUncapName()/].popValue());
+ [else][if (genDataType.isPrimitiveType() and not genModel.isJDK50())]
+ [genDataType.getImportedInstanceClassName()/] result[genDataType.getName()/]Value = (([genDataType.getObjectInstanceClassName()/])[genDataType.genPackage.getQualifiedEFactoryInstanceAccessor()/].createFromString([genDataType.getQualifiedClassifierAccessor()/], [genDataType.getSafeUncapName()/].popValue())).[genDataType.getPrimitiveValueFunction()/]();
+ [else]
+ [genDataType.getImportedInstanceClassName()/] result[genDataType.getName()/]Value = ([genDataType.getObjectInstanceClassName()/])[genDataType.genPackage.getQualifiedEFactoryInstanceAccessor()/].createFromString([genDataType.getQualifiedClassifierAccessor()/], [genDataType.getSafeUncapName()/].popValue());
+ [/if][/if]
+ this.[genDataType.getSafeUncapName()/] = [genDataType.getSafeUncapName()/];
+ return result[genDataType.getName()/]Value;
+ }
+
+ [/for]
+ }
+
+[/let]
+[/let]
+[/let]
+[/let]
+[/let]
+[/if]
+} //[className/]
+[/template]
+
+[query public resourceClassPath(genPackage : GenPackage) : String
+ = genPackage.genModel.extractSourceDirectory(genPackage.genModel.modelDirectory) + '/'
+ + genPackage.getQualifiedResourceClassName().toPath() + '.java'/]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/WrapperClass.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/WrapperClass.mtl
new file mode 100644
index 00000000000..4b485f67b0e
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/GenFacade/WrapperClass.mtl
@@ -0,0 +1,170 @@
+[comment encoding = UTF-8 /]
+[module WrapperClass('http://www.eclipse.org/emf/2002/GenModel','http://www.eclipse.org/papyrus/facademapping','http://www.eclipse.org/emf/2002/Ecore')]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::common /]
+[import org::eclipse::emf::eef::codegen::ecore::services::header /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::StringUtil /]
+[import org::eclipse::papyrus::facade::codegen::utils::FacadeCodegenUtils /]
+
+
+[template public wrapperClass(genPackage : GenPackage) { genModel : GenModel = genPackage.genModel; packageName : String = genPackage.getUtilitiesPackageName(); className : String = 'Wrapper'}]
+
+[genModel.initializeImportManager(packageName, className)/]
+
+[genModel.getImportedName('org.eclipse.emf.common.util.URI')/]
+
+
+[file (genPackage.wrapperClassPath(className), false, 'UTF-8')]
+[genModel.includeHeader()/]
+package [packageName/];
+[let content : String = genPackage.wrapperFileContent(genModel, className)]
+[genModel.genSortedImports()/]
+[content/]
+[/let]
+[/file]
+
+[/template]
+
+[template protected wrapperFileContent(genPackage : GenPackage, genModel : GenModel, className : String)]
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Wrapper</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see [genPackage.getQualifiedResourceFactoryClassName()/]
+ * @generated
+ */
+public class [className/]
+{
+private static volatile Wrapper instance = null;
+
+ private Wrapper() {
+ super();
+ }
+
+ public final static Wrapper getInstance() {
+ if(instance == null) {
+ synchronized(Wrapper.class) {
+ if(instance == null) {
+ instance = new Wrapper();
+ }
+ }
+ }
+ return instance;
+ }
+
+ public [genModel.getImportedName('org.eclipse.emf.ecore.EClassifier')/] getMappingFromUML([genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] umlElement) {
+
+ [genModel.getAllMetaclassMappings().genMappingfromUML(genModel, genPackage)/]
+
+
+ return null;
+ }
+
+ public <E extends [genModel.getImportedName('org.eclipse.papyrus.facade.utils.RepresentingElement')/]> void updateCache([genModel.getImportedName('org.eclipse.emf.common.util.EList')/]<E> update, [genModel.getImportedName('org.eclipse.emf.common.util.EList')/]<E> cache) {
+ //Empty the cache
+ while(!cache.isEmpty()) {
+ ((org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList<E>)cache).silentRemove(0);
+ }
+
+
+ for(int i = 0; i < update.size(); i++) {
+ E elementInUpdate = update.get(i);
+ ((org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList<E>)cache).silentAdd(i, elementInUpdate);
+ }
+ }
+
+ public [genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/] getFeatureMappingFromUML([genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/] feature) {
+
+ [genModel.getAllFeatureMappings().getFeatureMappingFromUML(genModel, genPackage)/]
+
+
+ return null;
+ }
+
+ public Enum getEnumMappingFromUML(Enum value) {
+
+ [genModel.getAllEnumLiteralMappings().genEnumMappingfromUML(genModel, genPackage)/]
+
+ return null;
+ }
+
+ public Enum getEnumMappingFromSpecific(Enum value) {
+
+ [genModel.getAllEnumLiteralMappings().genEnumMappingfromSpecific(genModel, genPackage)/]
+
+ return null;
+ }
+
+ public [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] findOrCreateSpecific([genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] umlElement) {
+ [genModel.getImportedName('org.eclipse.emf.common.util.EList')/]<[genModel.getImportedName('org.eclipse.emf.common.notify.Adapter')/]> adapters = umlElement.eAdapters();
+ for([genModel.getImportedName('org.eclipse.emf.common.notify.Adapter')/] adapter : adapters) {
+ if(adapter instanceof [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/]) {
+ return (([genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/])adapter).get__Representing();
+ }
+ }
+
+ [genModel.getImportedName('org.eclipse.emf.ecore.EClassifier')/] eClassifier = getMappingFromUML(umlElement);
+ if(eClassifier != null) {
+ if(eClassifier instanceof [genModel.getImportedName('org.eclipse.emf.ecore.EClass')/]) {
+ [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] representingElement = [genPackage.getImportedFactoryInterfaceName()/].eINSTANCE.create(([genModel.getImportedName('org.eclipse.emf.ecore.EClass')/])eClassifier);
+ if(representingElement instanceof [genModel.getImportedName('org.eclipse.papyrus.facade.utils.RepresentingElement')/]) {
+ //Override represented
+
+ (([genModel.getImportedName('org.eclipse.papyrus.facade.utils.RepresentingElement')/])representingElement).set__Represented(umlElement);
+ [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/] adapter = new [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.RepresentingElementAdapter')/]();
+ adapter.set__Representing(representingElement);
+ umlElement.eAdapters().add(adapter);
+ return representingElement;
+ }
+ }
+ }
+
+
+ return null;
+ }
+}
+
+[/template]
+
+[template public genEnumMappingfromUML(mapping : Mapping , genModel:GenModel, genPackage: GenPackage)]
+
+ if(value == [getPackagePathFromMapping(mapping)/].[getUMLEnumElementFromMapping(mapping)/]) {
+ return [genModel.getImportedName(genPackage.getInterfacePackageName())/].[getSpecificEnumElementFromMapping(mapping)/];
+ }
+
+[/template]
+
+[template public genEnumMappingfromSpecific(mapping : Mapping , genModel:GenModel, genPackage: GenPackage)]
+
+ if(value == [genModel.getImportedName(genPackage.getInterfacePackageName())/].[getSpecificEnumElementFromMapping(mapping)/]) {
+ return [getPackagePathFromMapping(mapping)/].[getUMLEnumElementFromMapping(mapping)/];
+ }
+
+[/template]
+
+[template public genMappingfromUML(mapping : Mapping , genModel:GenModel, genPackage: GenPackage)]
+
+ if(umlElement.eClass() == [genModel.getImportedName(getUMLPackageName(mapping))/].eINSTANCE.get[getUMLAccessorName(mapping,genModel)/]()) {
+ [mapping.getCorrespondingStereotypeMapping(genModel,genPackage)/]
+
+ return [genModel.getImportedName(genPackage.getImportedPackageInterfaceName())/].eINSTANCE.get[getClassifierAccessorName(genModel,mapping)/]();
+ }
+
+[/template]
+
+[template public getFeatureMappingFromUML(mapping : Mapping , genModel:GenModel, genPackage: GenPackage)]
+ if(feature == [genModel.getImportedName(getUMLPackageName(mapping))/].eINSTANCE.get[getUMLFeatureFromMapping(mapping,genModel)/]()) {
+ return [genModel.getImportedName(genPackage.getImportedPackageInterfaceName())/].eINSTANCE.get[getFeatureAccessorName(genModel,mapping)/]();
+
+ }
+[/template]
+
+[query public wrapperClassPath(genPackage : GenPackage, className : String) : String
+ = genPackage.genModel.extractSourceDirectory(genPackage.genModel.modelDirectory) + '/'+ genPackage.getUtilitiesPackageName().toPath() + '/' +
+ className+ '.java'/]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eIsSet.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eIsSet.mtl
new file mode 100644
index 00000000000..a438b94e2f4
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eIsSet.mtl
@@ -0,0 +1,120 @@
+[comment encoding = UTF-8 /]
+[module eIsSet('http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenEnum /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenOperation /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenParameter /]
+
+[template public eIsSet(genClass : GenClass, genModel : GenModel, positiveOffsetCorrection : String, negativeOffsetCorrection : String)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useGenerics()) ]
+ [if (genClass.getEIsSetGenFeatures()->filter(GenFeature)->select(genFeature : GenFeature | genFeature.isListType() and not genFeature.isUnsettable() and not genFeature.isWrappedFeatureMapType() and not genClass.isField(genFeature) and genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()))->notEmpty()]
+ @SuppressWarnings("unchecked")
+ [/if]
+ [/if]
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public boolean eIsSet(int featureID) {
+ switch (featureID[negativeOffsetCorrection/]) {
+[for (genFeature : GenFeature | genClass.getEIsSetGenFeatures())]
+ [let safeNameAccessor : String = if (genFeature.getSafeName() = 'featureID') then 'this.' + genFeature.getSafeName() else genFeature.getSafeName() endif]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.hasSettingDelegate()) ]
+ [if (genFeature.isUnsettable()) ]
+ return isSet[genFeature.getAccessorName()/]();
+ [else]
+ return [genFeature.getUpperName()/]__ESETTING_DELEGATE.dynamicIsSet(this, null, 0);
+ [/if]
+ [else][if (genFeature.isListType() and not genFeature.isUnsettable()) ]
+ [if (genFeature.isWrappedFeatureMapType()) ]
+ [if (genFeature.isVolatile()) ]
+ return !(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)[genFeature.getGetAccessor()/]()).featureMap().isEmpty();
+ [else]
+ return [safeNameAccessor/] != null && ![safeNameAccessor/].featureMap().isEmpty();
+ [/if]
+ [else]
+ [if (genClass.isField(genFeature)) ]
+ return [safeNameAccessor/] != null && ![safeNameAccessor/].isEmpty();
+ [else]
+ [if (genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [safeNameAccessor/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ return [safeNameAccessor/] != null && ![safeNameAccessor/].isEmpty();
+ [else]
+ return ![genFeature.getGetAccessor()/]().isEmpty();
+ [/if]
+ [/if]
+ [/if]
+ [else][if (genFeature.isUnsettable()) ]
+ return isSet[genFeature.getAccessorName()/]();
+ [else][if (genFeature.isResolveProxies()) ]
+ [if (genClass.isField(genFeature)) ]
+ return [safeNameAccessor/] != null;
+ [else]
+ [if (genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ return eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]) != null;
+ [else]
+ return basicGet[genFeature.getAccessorName()/]() != null;
+ [/if]
+ [/if]
+ [else][if (not genFeature.hasEDefault()) ]
+ [if (genClass.isField(genFeature)) ]
+ return [safeNameAccessor/] != null;
+ [else]
+ [if (genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ return eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]) != null;
+ [else]
+ return [genFeature.getGetAccessor()/]() != null;
+ [/if]
+ [/if]
+ [else][if (genFeature.isPrimitiveType() or genFeature.isEnumType()) ]
+ [if (genClass.isField(genFeature)) ]
+ [if (genClass.isFlag(genFeature)) ]
+ [if (genFeature.isBooleanType()) ]
+ return (([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) != 0) != [genFeature.getEDefault()/];
+ [else]
+ return ([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) != [genFeature.getUpperName()/]_EFLAG_DEFAULT;
+ [/if]
+ [else]
+ return [safeNameAccessor/] != [genFeature.getEDefault()/];
+ [/if]
+ [else]
+ [if (genFeature.isEnumType() and genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ return eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], [genFeature.getEDefault()/]) != [genFeature.getEDefault()/];
+ [else]
+ return [genFeature.getGetAccessor()/]() != [genFeature.getEDefault()/];
+ [/if]
+ [/if]
+ [else]
+ [if (genClass.isField(genFeature)) ]
+ return [genFeature.getEDefault()/] == null ? [safeNameAccessor/] != null : ![genFeature.getEDefault()/].equals([safeNameAccessor/]);
+ [else]
+ [if (genFeature.isField() and genClass.getImplementingGenModel(genFeature).isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [safeNameAccessor/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], [genFeature.getEDefault()/]);
+ return [genFeature.getEDefault()/] == null ? [safeNameAccessor/] != null : ![genFeature.getEDefault()/].equals([safeNameAccessor/]);
+ [else]
+ return [genFeature.getEDefault()/] == null ? [genFeature.getGetAccessor()/]() != null : ![genFeature.getEDefault()/].equals([genFeature.getGetAccessor()/]());
+ [/if]
+ [/if]
+ [/if][/if][/if][/if][/if][/if]
+ [/let]
+[/for]
+ }
+[if (genModel.minimalReflectiveMethods) ]
+ return super.eIsSet(featureID);
+[else]
+ return eDynamicIsSet(featureID);
+[/if]
+ }
+
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eUnset.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eUnset.mtl
new file mode 100644
index 00000000000..9a573177520
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/eUnset.mtl
@@ -0,0 +1,44 @@
+[comment encoding = UTF-8 /]
+[module eUnset('http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+
+[template public eUnset(genClass : GenClass, genModel : GenModel, negativeOffsetCorrection : String)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ public void eUnset(int featureID) {
+ switch (featureID[negativeOffsetCorrection/]) {
+ [for (genFeature : GenFeature | genClass.getEUnsetGenFeatures())]
+ case [genClass.getQualifiedFeatureID(genFeature)/]:
+ [if (genFeature.isListType() and not genFeature.isUnsettable()) ]
+ [if (genFeature.isWrappedFeatureMapType()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)[genFeature.getGetAccessor()/]()).featureMap().clear();
+ [else]
+ [genFeature.getGetAccessor()/]().clear();
+ [/if]
+ [else][if (genFeature.isUnsettable()) ]
+ unset[genFeature.getAccessorName()/]();
+ [else][if (not genFeature.hasEDefault()) ]
+ set[genFeature.getAccessorName()/](([genFeature.getImportedType(genClass)/])null);
+ [else]
+ set[genFeature.getAccessorName()/]([genFeature.getEDefault()/]);
+ [/if][/if][/if]
+ return;
+ [/for]
+ }
+ [if (genModel.minimalReflectiveMethods) ]
+ super.eUnset(featureID);
+ [else]
+ eDynamicUnset(featureID);
+ [/if]
+ }
+
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genDeclaredFields.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genDeclaredFields.mtl
new file mode 100644
index 00000000000..85e96a8eb49
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genDeclaredFields.mtl
@@ -0,0 +1,196 @@
+[comment encoding = UTF-8 /]
+[module genDeclaredFields('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+
+[template public genDeclaredFields(genFeature : GenFeature, genClass : GenClass, genModel : GenModel, isGWT : Boolean, isJDK50 : Boolean)]
+ [if (genFeature.hasSettingDelegate())]
+ /**
+ * The cached setting delegate for the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected [genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/].Internal.SettingDelegate [genFeature.getUpperName()/]__ESETTING_DELEGATE = (([genModel.getImportedName('org.eclipse.emf.ecore.EStructuralFeature')/].Internal)[genFeature.getQualifiedFeatureAccessor()/]).getSettingDelegate();
+
+ [else][if (genFeature.isListType() or genFeature.isReferenceType())]
+ [if (genClass.isField(genFeature)) ]
+ /**
+ * The cached value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected [genFeature.getImportedInternalType(genClass)/] [genFeature.getSafeName()/];
+
+ [/if]
+ [if (genModel.arrayAccessors and genFeature.isListType() and not genFeature.isFeatureMapType() and not genFeature.isMapType())]
+ [let rawListItemType : String = genFeature.getRawListItemType()]
+ [let index : Integer = rawListItemType.index('[')]
+ [let head : String = if (index <> -1) then rawListItemType.substring(1, index) else rawListItemType endif]
+ [let tail : String = if (index <> -1) then rawListItemType.substring(index + 1) else '' endif]
+ /**
+ * The empty value for the '{@link #[genFeature.getGetArrayAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' array accessor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetArrayAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ [if (genFeature.getQualifiedListItemType(genClass).contains('<')) ]
+ @SuppressWarnings("unchecked")
+ [/if]
+ protected static final [rawListItemType/]['[]'/] [genFeature.getUpperName()/]_EEMPTY_ARRAY = new [head/] ['[0]'/][tail/];
+
+ [/let]
+ [/let]
+ [/let]
+ [/let]
+ [/if]
+ [else]
+ [if (genFeature.hasEDefault() and (not genFeature.isVolatile() or not genModel.reflectiveDelegation and (not genFeature.hasDelegateFeature() or not genFeature.isUnsettable())))]
+ [let staticDefaultValue : String = genFeature.getStaticDefaultValue()]
+ /**
+ * The default value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ [if (genModel.useGenerics() and genFeature.isListDataType() and genFeature.isSetDefaultValue()) ]
+ @SuppressWarnings("unchecked")
+ [/if]
+ protected static final [genFeature.getImportedType(genClass)/] [genFeature.getEDefault()/][if (staticDefaultValue = '') ]; // TODO The default value literal "[genFeature.ecoreFeature.defaultValueLiteral/]" is not valid.[else] = [staticDefaultValue/];[genModel.getNonNLS(staticDefaultValue)/][/if]
+
+ [/let]
+ [/if]
+ [if (genClass.isField(genFeature)) ]
+ [if (genClass.isFlag(genFeature))]
+ [let flagIndex : Integer = genClass.getFlagIndex(genFeature)]
+ [if (flagIndex > 31 and flagIndex.mod(32) = 0)]
+ /**
+ * An additional set of bit flags representing the values of boolean attributes and whether unsettable features have been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ [if (isGWT)]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected int [genClass.getFlagsField(genFeature)/] = 0;
+
+ [/if]
+ [if (genFeature.isEnumType())]
+ /**
+ * The offset of the flags representing the value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected static final int [genFeature.getUpperName()/]_EFLAG_OFFSET = [flagIndex.mod(32)/];
+
+ /**
+ * The flags representing the default value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected static final int [genFeature.getUpperName()/]_EFLAG_DEFAULT = [if (isJDK50) ][genFeature.getEDefault()/].ordinal()[else][genFeature.getImportedType(genClass)/].VALUES.indexOf([genFeature.getEDefault()/])[/if] << [genFeature.getUpperName()/]_EFLAG_OFFSET;
+
+ /**
+ * The array of enumeration values for '{@link [genFeature.getImportedType(genClass)/] [genFeature.getTypeGenClassifier().getFormattedName()/]}'
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ private static final [genFeature.getImportedType(genClass)/]['[]'/] [genFeature.getUpperName()/]_EFLAG_VALUES = [if (isJDK50) ][genFeature.getImportedType(genClass)/].values()[else]([genFeature.getImportedType(genClass)/]['[]'/])[genFeature.getImportedType(genClass)/].VALUES.toArray(new [genFeature.getImportedType(genClass)/]['['/][genFeature.getImportedType(genClass)/].VALUES->size()])[/if];
+
+ [/if]
+ /**
+ * The flag[if genClass.getFlagSize(genFeature) > 1]s[/if] representing the value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ protected static final int [genFeature.getUpperName()/]_EFLAG = [genClass.getFlagMask(genFeature)/] << [if (genFeature.isEnumType()) ][genFeature.getUpperName()/]_EFLAG_OFFSET[else][flagIndex.mod(32)/][/if];
+
+ [/let]
+ [else]
+ /**
+ * The cached value of the '{@link #[genFeature.getGetAccessor()/]() <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/][if (genFeature.hasEDefault()) ] = [genFeature.getEDefault()/][/if];
+
+ [/if]
+ [/if]
+ [/if][/if]
+ [if (genClass.isESetField(genFeature)) ]
+ [if (genClass.isESetFlag(genFeature))]
+ [let flagIndex : Integer = genClass.getESetFlagIndex(genFeature)]
+ [if (flagIndex > 31 and flagIndex.mod(32) = 0) ]
+ /**
+ * An additional set of bit flags representing the values of boolean attributes and whether unsettable features have been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected int [genClass.getESetFlagsField(genFeature)/] = 0;
+
+ [/if]
+ /**
+ * The flag representing whether the [genFeature.getFormattedName()/] [genFeature.getFeatureKind()/] has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected static final int [genFeature.getUpperName()/]_ESETFLAG = 1 << [flagIndex.mod(32) /];
+ [/let]
+ [else]
+ /**
+ * This is true if the [genFeature.getFormattedName()/] [genFeature.getFeatureKind()/] has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ [if (isGWT) ]
+ @[genModel.getImportedName('com.google.gwt.user.client.rpc.GwtTransient')/]
+ [/if]
+ protected boolean [genFeature.getUncapName()/]ESet;
+
+ [/if]
+ [/if]
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genFeature.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genFeature.mtl
new file mode 100644
index 00000000000..b790a7c7aad
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genFeature.mtl
@@ -0,0 +1,892 @@
+[comment encoding = UTF-8 /]
+[module genFeature('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore','http://www.eclipse.org/uml2/4.0.0/UML')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenEnum /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenOperation /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenParameter /]
+[import org::eclipse::papyrus::facade::codegen::utils::FacadeCodegenUtils /]
+[import org::eclipse::papyrus::facade::codegen::utils::WrappingListUtils /]
+[import org::eclipse::emf::eef::codegen::ecore::model::FactoryClass/]
+
+[template public genFeature(genFeature : GenFeature, genClass : GenClass, genPackage : GenPackage, genModel : GenModel, isJDK50 : Boolean, isInterface : Boolean, isImplementation : Boolean, positiveOffsetCorrection : String, negativeOffsetCorrection : String, singleWildcard : String)]
+[if (genModel.arrayAccessors and genFeature.isListType() and not genFeature.isFeatureMapType() and not genFeature.isMapType()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (not isImplementation) ]
+ [genFeature.getListItemType(genClass)/]['[]'/] [genFeature.getGetArrayAccessor()/]();
+
+ [else]
+ public [genFeature.getListItemType(genClass)/]['[]'/] [genFeature.getGetArrayAccessor()/]() {
+ [if (genFeature.isVolatile()) ]
+ [genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/][genFeature.getListTemplateArguments(genClass)/] list = ([genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/][genFeature.getListTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]();
+ if (list.isEmpty()) return [if (genModel.useGenerics() and not genFeature.getListItemType(genClass).contains('<') and genFeature.getListItemType(null) <> genFeature.getListItemType(genClass)) ]([genFeature.getListItemType(genClass)/]['[]'/])[/if][genFeature.getUpperName()/]_EEMPTY_ARRAY;
+ [else]
+ if ([genFeature.getSafeName()/] == null || [genFeature.getSafeName()/].isEmpty()) return [if (genModel.useGenerics() and not genFeature.getListItemType(genClass).contains('<') and genFeature.getListItemType(null) <> genFeature.getListItemType(genClass)) ]([genFeature.getListItemType(genClass)/]['[]'/])[/if][genFeature.getUpperName()/]_EEMPTY_ARRAY;
+ [genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/][genFeature.getListTemplateArguments(genClass)/] list = ([genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/][genFeature.getListTemplateArguments(genClass)/])[genFeature.getSafeName()/];
+ [/if]
+ list.shrink();
+ return ([genFeature.getListItemType(genClass)/]['[]'/])list.data();
+ }
+
+ [/if]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (not isImplementation) ]
+ [genFeature.getListItemType(genClass)/] get[genFeature.getAccessorName()/](int index);
+
+ [else]
+ public [genFeature.getListItemType(genClass)/] get[genFeature.getAccessorName()/](int index) {
+ return [if (not genModel.useGenerics()) ]([genFeature.getListItemType(genClass)/])[/if][genFeature.getGetAccessor()/]().get(index);
+ }
+
+ [/if]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (not isImplementation) ]
+ int get[genFeature.getAccessorName()/]Length();
+
+ [else]
+ public int get[genFeature.getAccessorName()/]Length() {
+ [if (genFeature.isVolatile()) ]
+ return [genFeature.getGetAccessor()/]().size();
+ [else]
+ return [genFeature.getSafeName()/] == null ? 0 : [genFeature.getSafeName()/].size();
+ [/if]
+ }
+
+ [/if]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (not isImplementation) ]
+ void set[genFeature.getAccessorName()/]([genFeature.getListItemType(genClass)/]['[]'/] new[genFeature.getCapName()/]);
+
+ [else]
+ public void set[genFeature.getAccessorName()/]([genFeature.getListItemType(genClass)/]['[]'/] new[genFeature.getCapName()/]) {
+ (([genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/][genFeature.getListTemplateArguments(genClass)/])[genFeature.getGetAccessor()/]()).setData(new[genFeature.getCapName()/].length, new[genFeature.getCapName()/]);
+ }
+
+ [/if]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (not isImplementation) ]
+ void set[genFeature.getAccessorName()/](int index, [genFeature.getListItemType(genClass)/] element);
+
+ [else]
+ public void set[genFeature.getAccessorName()/](int index, [genFeature.getListItemType(genClass)/] element) {
+ [genFeature.getGetAccessor()/]().set(index, element);
+ }
+
+ [/if]
+[/if]
+[if (genFeature.isGet() and (isImplementation or not genFeature.isSuppressedGetVisibility()))]
+ [if (isInterface)]
+ /**
+ * Returns the value of the '<em><b>[genFeature.getFormattedName()/]</b></em>' [genFeature.getFeatureKind()/].
+ [if (genFeature.isListType())]
+ [if (genFeature.isMapType())]
+ [let keyFeature : GenFeature = genFeature.getMapEntryTypeGenClass().getMapEntryKeyFeature()]
+ [let valueFeature : GenFeature = genFeature.getMapEntryTypeGenClass().getMapEntryValueFeature()]
+ * The key is of type [if (keyFeature.isListType()) ]list of {@link [keyFeature.getQualifiedListItemType(genClass)/]}[else]{@link [keyFeature.getType(genClass)/]}[/if],
+ * and the value is of type [if (valueFeature.isListType()) ]list of {@link [valueFeature.getQualifiedListItemType(genClass)/]}[else]{@link [valueFeature.getType(genClass)/]}[/if],
+ [/let]
+ [/let]
+ [else][if (not genFeature.isWrappedFeatureMapType() and not (genModel.suppressEMFMetaData and 'org.eclipse.emf.ecore.EObject' = genFeature.getQualifiedListItemType(genClass)))]
+ [let typeName : String = genFeature.getQualifiedListItemType(genClass)]
+ [let index : Integer = if typeName.index('<') < 0 then typeName.index('[') else typeName.index('<') endif]
+ [let head : String = if index < 0 then typeName else typeName.substring(1, index - 1) endif]
+ [let tail : String = if index < 0 then '' else typeName.substring(index).replaceAll('<', '&lt;') endif]
+ * The list contents are of type {@link [head/]}[tail/].
+ [/let]
+ [/let]
+ [/let]
+ [/let]
+ [/if][/if]
+ [else][if (genFeature.isSetDefaultValue()) ]
+ * The default value is <code>[genFeature.getDefaultValue()/]</code>.
+ [/if][/if]
+ [if (genFeature.getTypeGenEnum() <> null) ]
+ * The literals are from the enumeration {@link [genFeature.getTypeGenEnum().getQualifiedName()/]}.
+ [/if]
+ [if (genFeature.isBidirectional() and not genFeature.getReverse().genClass.isMapEntry())]
+ [let reverseGenFeature : GenFeature = genFeature.getReverse()]
+ [if (not reverseGenFeature.isSuppressedGetVisibility()) ]
+ * It is bidirectional and its opposite is '{@link [reverseGenFeature.genClass.getQualifiedInterfaceName()/]#[reverseGenFeature.getGetAccessor()/] <em>[reverseGenFeature.getFormattedName()/]</em>}'.
+ [/if]
+ [/let]
+ [/if]
+ * <!-- begin-user-doc -->
+ [if (not genFeature.hasDocumentation()) ]
+ * <p>
+ * If the meaning of the '<em>[genFeature.getFormattedName()/]</em>' [genFeature.getFeatureKind()/] isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ [/if]
+ * <!-- end-user-doc -->
+ [if (genFeature.hasDocumentation()) ]
+ * <!-- begin-model-doc -->
+ * [genFeature.getDocumentation(genModel.getIndentation())/]
+ * <!-- end-model-doc -->
+ [/if]
+ * @return the value of the '<em>[genFeature.getFormattedName()/]</em>' [genFeature.getFeatureKind()/].
+ [if (genFeature.getTypeGenEnum() <> null) ]
+ * @see [genFeature.getTypeGenEnum().getQualifiedName()/]
+ [/if]
+ [if (genFeature.isUnsettable()) ]
+ [if (not genFeature.isSuppressedIsSetVisibility()) ]
+ * @see #isSet[genFeature.getAccessorName()/]()
+ [/if]
+ [if (genFeature.isChangeable() and not genFeature.isSuppressedUnsetVisibility()) ]
+ * @see #unset[genFeature.getAccessorName()/]()
+ [/if]
+ [/if]
+ [if (genFeature.isChangeable() and not genFeature.isListType() and not genFeature.isSuppressedSetVisibility()) ]
+ * @see #set[genFeature.getAccessorName()/]([genFeature.getRawImportedBoundType()/])
+ [/if]
+ [if (not genModel.suppressEMFMetaData) ]
+ * @see [genPackage.getQualifiedPackageInterfaceName()/]#get[genFeature.getFeatureAccessorName()/]()
+ [/if]
+ [if (genFeature.isBidirectional() and not genFeature.getReverse().genClass.isMapEntry())]
+ [let reverseGenFeature : GenFeature = genFeature.getReverse()]
+ [if (not reverseGenFeature.isSuppressedGetVisibility()) ]
+ * @see [reverseGenFeature.genClass.getQualifiedInterfaceName()/]#[reverseGenFeature.getGetAccessor()/]
+ [/if]
+ [/let]
+ [/if]
+ [if (not genModel.suppressEMFModelTags)]
+ [let modelInfoLines : Sequence(String) = genFeature.getModelInfo().tokenize(genModel.getLineDelimiter())]
+ [if (modelInfoLines->isEmpty())]
+ * @model
+ [else]
+ * @model [modelInfoLines->sep(genModel.getLineDelimiter() + '\t * ')/]
+ [/if]
+ [/let]
+ [/if]
+ * @generated
+ */
+ [else][comment isInterface/]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/getGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ [/if][comment isInterface/]
+ [if (not isImplementation) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getGetAccessor()/]();
+
+ [else]
+ [if (genModel.useGenerics() and ((genFeature.isContainer() or genFeature.isResolveProxies()) and not genFeature.isListType() and not (genModel.reflectiveDelegation and genModel.isDynamicDelegation()) and genFeature.isUncheckedCast(genClass) or genFeature.isListType() and not genFeature.isFeatureMapType() and (genModel.reflectiveDelegation or genModel.isVirtualDelegation() or genModel.isDynamicDelegation()) or genFeature.isListDataType() and genFeature.hasDelegateFeature() or genFeature.isListType() and genFeature.hasSettingDelegate())) ]
+ @SuppressWarnings("unchecked")
+ [/if]
+ public [genFeature.getImportedType(genClass)/] [genFeature.getGetAccessor()/][if (genClass.hasCollidingGetAccessorOperation(genFeature)) ]_[/if]() {
+ [genGetContent(genFeature,genModel,genPackage,isImplementation)/]
+
+ }
+
+ [/if]
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genFeature.isBasicGet()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/basicGetGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ public [genFeature.getImportedType(genClass)/] basicGet[genFeature.getAccessorName()/]() {
+ [genGetContent(genFeature,genModel,genPackage,isImplementation)/]
+ }
+
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genFeature.isBasicSet()) ]
+
+ [genBasicSetContent(genFeature, genModel, genPackage, isImplementation, isJDK50, negativeOffsetCorrection, positiveOffsetCorrection)/]
+
+[/if]
+[if (genFeature.isSet() and (isImplementation or not genFeature.isSuppressedSetVisibility())) ]
+ [if (isInterface) ]
+ /**
+ * Sets the value of the '{@link [genClass.getQualifiedInterfaceName()/]#[genFeature.getGetAccessor()/] <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>[genFeature.getFormattedName()/]</em>' [genFeature.getFeatureKind()/].
+ [if (genFeature.isEnumType()) ]
+ * @see [genFeature.getTypeGenEnum().getQualifiedName()/]
+ [/if]
+ [if (genFeature.isUnsettable()) ]
+ [if (not genFeature.isSuppressedIsSetVisibility()) ]
+ * @see #isSet[genFeature.getAccessorName()/]()
+ [/if]
+ [if (not genFeature.isSuppressedUnsetVisibility()) ]
+ * @see #unset[genFeature.getAccessorName()/]()
+ [/if]
+ [/if]
+ * @see #[genFeature.getGetAccessor()/]()
+ * @generated
+ */
+ [else][comment isInterface /]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/setGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ [/if][comment isInterface /]
+ [if (not isImplementation)]
+ void set[genFeature.getAccessorName()/]([genFeature.getImportedType(genClass)/] value);
+
+ [else][comment not isImplementation /]
+ [comment Using query instead of variable because let does not support null !!!
+ let setAccessorOperation : GenOperation = genClass.getSetAccessorOperation(genFeature)/]
+
+ [genSetContent(genFeature, genModel, genPackage , isImplementation, isJDK50,negativeOffsetCorrection,positiveOffsetCorrection)/]
+
+ [/if][comment not isImplementation /]
+[/if]
+[if (isImplementation and not genModel.reflectiveDelegation and genFeature.isBasicUnset()) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/basicUnsetGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] basicUnset[genFeature.getAccessorName()/]([genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ [if (genModel.isDynamicDelegation()) ]
+ return eDynamicInverseRemove(([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[if (genFeature.isResolveProxies()) ]basicGet[genFeature.getAccessorName()/][else][genFeature.getGetAccessor()/][/if](), [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], msgs);
+ [else][if (not genFeature.isVolatile()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [if (not genModel.suppressNotification) ]Object old[genFeature.getCapName()/] = [/if]eVirtualUnset([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else]
+ [if (not genModel.suppressNotification) ]
+ [genFeature.getImportedType(genClass)/] old[genFeature.getCapName()/] = [genFeature.getSafeName()/];
+ [/if]
+ [genFeature.getSafeName()/] = null;
+ [/if]
+ [if (genModel.isVirtualDelegation()) ]
+ [if (not genModel.suppressNotification) ]
+ boolean isSetChange = old[genFeature.getCapName()/] != EVIRTUAL_NO_VALUE;
+ [/if]
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [/if]
+ [genClass.getESetFlagsField(genFeature)/] &= ~[genFeature.getUpperName()/]_ESETFLAG;
+ [else]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = [genFeature.getUncapName()/]ESet;
+ [/if]
+ [genFeature.getUncapName()/]ESet = false;
+ [/if][/if]
+ [if (not genModel.suppressNotification) ]
+ if (eNotificationRequired()) {
+ [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/] notification = new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].UNSET, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], [if (genModel.isVirtualDelegation()) ]isSetChange ? old[genFeature.getCapName()/] : null[else]old[genFeature.getCapName()/][/if], null, [if (genModel.isVirtualDelegation()) ]isSetChange[else]old[genFeature.getCapName()/]ESet[/if]);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ [/if]
+ [else]
+ // TODO: implement this method to unset the contained '[genFeature.getFormattedName()/]' [genFeature.getFeatureKind()/]
+ // -> this method is automatically invoked to keep the containment relationship in synch
+ // -> do not modify other features
+ // -> return msgs, after adding any generated Notification to it (if it is null, a NotificationChain object must be created first)
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+ [/if][/if]
+ }
+
+[/if]
+[if (genFeature.isUnset() and (isImplementation or not genFeature.isSuppressedUnsetVisibility())) ]
+ [if (isInterface) ]
+ /**
+ * Unsets the value of the '{@link [genClass.getQualifiedInterfaceName()/]#[genFeature.getGetAccessor()/] <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/].
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ [if (not genFeature.isSuppressedIsSetVisibility()) ]
+ * @see #isSet[genFeature.getAccessorName()/]()
+ [/if]
+ * @see #[genFeature.getGetAccessor()/]()
+ [if (not genFeature.isListType() and not genFeature.isSuppressedSetVisibility()) ]
+ * @see #set[genFeature.getAccessorName()/]([genFeature.getRawImportedBoundType()/])
+ [/if]
+ * @generated
+ */
+ [else][comment isInterface/]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/unsetGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ [/if][comment isInterface/]
+ [if (not isImplementation) ]
+ void unset[genFeature.getAccessorName()/]();
+
+ [else][comment not isImplementation/]
+ [genUnsetContent(genFeature,genModel,genPackage,isJDK50,negativeOffsetCorrection,positiveOffsetCorrection, singleWildcard)/]
+ [/if][comment not isImplementation/]
+[/if]
+[if (genFeature.isIsSet() and (isImplementation or not genFeature.isSuppressedIsSetVisibility())) ]
+ [if (isInterface) ]
+ /**
+ * Returns whether the value of the '{@link [genClass.getQualifiedInterfaceName()/]#[genFeature.getGetAccessor()/] <em>[genFeature.getFormattedName()/]</em>}' [genFeature.getFeatureKind()/] is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>[genFeature.getFormattedName()/]</em>' [genFeature.getFeatureKind()/] is set.
+ [if (genFeature.isChangeable() and not genFeature.isSuppressedUnsetVisibility()) ]
+ * @see #unset[genFeature.getAccessorName()/]()
+ [/if]
+ * @see #[genFeature.getGetAccessor()/]()
+ [if (not genFeature.isListType() and genFeature.isChangeable() and not genFeature.isSuppressedSetVisibility()) ]
+ * @see #set[genFeature.getAccessorName()/]([genFeature.getRawImportedBoundType()/])
+ [/if]
+ * @generated
+ */
+ [else][comment isInterface/]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [comment][if (isJDK50)][comment] { //Class/isSetGenFeature.annotations.insert.javajetinc[/comment]
+ [/if][/comment]
+ [/if][comment isInterface/]
+ [if (not isImplementation) ]
+ boolean isSet[genFeature.getAccessorName()/]();
+
+ [else][comment not isImplementation/]
+ [genIsSetContent(genFeature , genModel, genPackage ,isJDK50,negativeOffsetCorrection,positiveOffsetCorrection, singleWildcard )/]
+
+ [/if][comment not isImplementation/]
+[/if]
+[/template]
+
+[template public genGetContentPrimitiveType(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage)]
+ [if (genFeature.isStereotypeProperty())]
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getAppliedStereotype("[genFeature.getStereotypeQualifiedName()/]");
+
+ if(stereotype != null) {
+ Object umlElement = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getValue(stereotype, "[genFeature.getSafeName()/]");
+
+ [if (genFeature.isDerived())]
+ [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])umlElement;
+ return [genFeature.getSafeName()/];
+ [else]
+ return ([genFeature.getImportedType(genClass)/])umlElement;
+ [/if]
+ }
+
+ throw new UnsupportedOperationException();
+ [else]
+ [if (genFeature.isField())]
+ [genFeature.getSafeName()/] = (([genModel.getImportedName(genFeature.genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).[genFeature.ecoreFeature.findUMLGetAccessor(genModel)/]();
+ return [genFeature.getSafeName()/];
+ [else]
+ return (([genModel.getImportedName(genFeature.genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).[genFeature.ecoreFeature.findUMLGetAccessor(genModel)/]();
+ [/if]
+ [/if]
+[/template]
+
+[template public genGetContent(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage, isImplementation:Boolean)]
+ [if (genFeature.isListType())]
+ [if (genFeature.isPrimtiveList())]
+ [genFeature.genGetContentPrimitiveType(genModel, genPackage)/]
+ [else]
+ [genModel.getImportedName('org.eclipse.emf.common.util.EList')/]<[genModel.getImportedName(genFeature.getTypeGenClass().ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClass().ecoreClass.getUMLMetaElement(genModel))/]> umlList = (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).[genFeature.ecoreFeature.findUMLGetAccessor(genModel)/]();
+ [genFeature.getImportedType(genClass)/] update = new [genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/]<[genFeature.getTypeGenClass().getQualifiedInterfaceName()/]>();
+ [if (genFeature.isField())]
+ if([genFeature.getSafeName()/] == null) {
+ [comment][genFeature.getSafeName()/] = new [genClass.getListConstructor(genFeature)/];[/comment]
+ [genFeature.getSafeName()/] = new [genClass.getWrappingListConstructor(genFeature,genFeature.getTypeGenClass().getQualifiedInterfaceName())/];
+ }
+ [else]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = new [genClass.getWrappingListConstructor(genFeature,genFeature.getTypeGenClass().getQualifiedInterfaceName())/];[comment]org.eclipse.papyrus.facade.utils.wrappinglist.WrappingBasicEList(umlList);[/comment]
+ [/if]
+
+ for([genModel.getImportedName(genFeature.getTypeGenClass().ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClass().ecoreClass.getUMLMetaElement(genModel))/] umlElement : umlList) {
+
+ [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] representingElement = [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Wrapper')/].getInstance().findOrCreateSpecific(([genModel.getImportedName('org.eclipse.emf.ecore.EObject')/])umlElement);
+ if(representingElement != null) {
+ if(representingElement instanceof [genFeature.getTypeGenClass().getQualifiedInterfaceName()/]) {
+ update.add(([genFeature.getTypeGenClass().getQualifiedInterfaceName()/])representingElement);
+ }
+ }
+ }
+
+ [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Wrapper')/].getInstance().updateCache(update, [genFeature.getSafeName()/]);
+ return [genFeature.getSafeName()/];
+ [/if]
+
+ [else]
+ [if (genFeature.isPrimitiveType() or genFeature.isStringType())]
+ [genFeature.genGetContentPrimitiveType(genModel, genPackage)/]
+ [else]
+ [if (genFeature.isStereotypeProperty())]
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getAppliedStereotype("[genFeature.getStereotypeQualifiedName()/]");
+
+ if(stereotype != null) {
+ Object umlElement = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getValue(stereotype, "[genFeature.getSafeName()/]");
+ [else]
+ [if (genFeature.isExtentionStereotypeProperty())]
+ [genModel.getImportedName(genFeature.getTypeGenClassifier().getEcoreClassifier().findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClassifier().getEcoreClassifier().getUMLMetaElement(genModel))/] umlElement = [genModel.getImportedName('org.eclipse.uml2.uml.util.UMLUtil')/].getStereotypeApplication(([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented(), [genModel.getImportedName(genFeature.getTypeGenClassifier().getEcoreClassifier().findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClassifier().getEcoreClassifier().getUMLMetaElement(genModel))/].class);
+ [else]
+ [genModel.getImportedName(genFeature.getTypeGenClassifier().getEcoreClassifier().findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClassifier().getEcoreClassifier().getUMLMetaElement(genModel))/] umlElement = (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).[genFeature.ecoreFeature.findUMLGetAccessor(genModel)/]();
+ [/if]
+
+ [/if]
+
+ if(umlElement [if (genFeature.isEnumType())] !=null [else] instanceof [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] [/if]) {
+
+
+ [if (genFeature.isEnumType())]
+ Enum representingElement = [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Wrapper')/].getInstance().getEnumMappingFromUML((Enum)umlElement);
+ [else]
+ [genModel.getImportedName('org.eclipse.emf.ecore.EObject')/] representingElement = [genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Wrapper')/].getInstance().findOrCreateSpecific(([genModel.getImportedName('org.eclipse.emf.ecore.EObject')/])umlElement);
+ [/if]
+
+ if(representingElement != null) {
+ if(representingElement instanceof [genFeature.getTypeGenClassifier().getAppropriateQualifiedTypeName()/]) {
+ [if (not genClass.isField(genFeature)) ]
+ return ([genFeature.getTypeGenClassifier().getAppropriateQualifiedTypeName()/])representingElement;
+ [else]
+ [genFeature.getSafeName()/] = ([genFeature.getTypeGenClassifier().getAppropriateQualifiedTypeName()/])representingElement;
+
+ return [genFeature.getSafeName()/];
+ [/if]
+ }
+ }
+ }
+ [if (genFeature.isStereotypeProperty())]
+ }
+ [/if]
+
+ return null;
+ [/if]
+ [/if]
+[/template]
+
+[template public genSetContent(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage, isImplementation:Boolean, isJDK50:Boolean,negativeOffsetCorrection:String,positiveOffsetCorrection:String)]
+ public void set[genFeature.getAccessorName()/][if (genClass.hasCollidingSetAccessorOperation(genFeature)) ]_[/if]([genFeature.getImportedType(genClass)/] [if (genClass.getSetAccessorOperation(genFeature) = null)]new[genFeature.getCapName()/][else][genClass.getSetAccessorOperation(genFeature).genParameters->at(1).getName()/][/if]) {
+ [if (not genFeature.isVolatile()) ]
+ [if (genFeature.isContainer())]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [let targetClass : GenClass = reverseFeature.genClass]
+ [let reverseOffsetCorrection : String = if (targetClass.hasOffsetCorrection()) then ' + ' + genClass.getOffsetCorrectionField(genFeature) else '' endif]
+ if (new[genFeature.getCapName()/] != eInternalContainer() || (eContainerFeatureID() != [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/] && new[genFeature.getCapName()/] != null)) {
+ if ([genModel.getImportedName('org.eclipse.emf.ecore.util.EcoreUtil')/].isAncestor(this, [genFeature.getEObjectCast()/]new[genFeature.getCapName()/]))
+ throw new [genModel.getImportedName('java.lang.IllegalArgumentException')/]("Recursive containment not allowed for " + toString());[genModel.getNonNLS()/]
+ if (eInternalContainer() != null)
+ eBasicRemoveFromContainer(null);
+ if (new[genFeature.getCapName()/] != null)
+ (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])new[genFeature.getCapName()/]).eInverseAdd(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, null);
+ basicSet[genFeature.getAccessorName()/]([genFeature.getInternalTypeCast()/]new[genFeature.getCapName()/], null);
+
+ }
+ [/let]
+ [/let]
+ [/let]
+ [else][if (genFeature.isBidirectional() or genFeature.isEffectiveContains()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [/if]
+ if (new[genFeature.getCapName()/] != [genFeature.getSafeName()/]) {
+ if ([genFeature.getSafeName()/] != null)
+ [if (not genFeature.isBidirectional()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - [genClass.getQualifiedFeatureID(genFeature)/][negativeOffsetCorrection/], null, null);
+ if (new[genFeature.getCapName()/] != null)
+ (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])new[genFeature.getCapName()/]).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - [genClass.getQualifiedFeatureID(genFeature)/][negativeOffsetCorrection/], null, null);
+ [else]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [let targetClass : GenClass = reverseFeature.genClass]
+ [let reverseOffsetCorrection : String = if (targetClass.hasOffsetCorrection()) then ' + ' + genClass.getOffsetCorrectionField(genFeature) else '' endif]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, null);
+ if (new[genFeature.getCapName()/] != null)
+ (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])new[genFeature.getCapName()/]).eInverseAdd(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, null);
+ [/let]
+ [/let]
+ [/let]
+ [/if]
+ basicSet[genFeature.getAccessorName()/]([genFeature.getInternalTypeCast()/]new[genFeature.getCapName()/], null);
+ }[if (genFeature.isUnsettable())] else {
+ [if (genModel.isVirtualDelegation()) ]
+ boolean old[genFeature.getCapName()/]ESet = eVirtualIsSet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [/if]
+ [genClass.getESetFlagsField(genFeature)/] |= [genFeature.getUpperName()/]_ESETFLAG;
+ [else]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = [genFeature.getUncapName()/]ESet;
+ [/if]
+ [genFeature.getUncapName()/]ESet = true;
+ [/if][/if]
+ [if (not genModel.suppressNotification) ]
+ if (eNotificationRequired())
+ eNotify(new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].SET, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], new[genFeature.getCapName()/], new[genFeature.getCapName()/], not old[genFeature.getCapName()/]ESet));
+ [/if]
+ }
+
+ [/if]
+ [else]
+
+
+
+ [if (genFeature.isAPrimitiveType() or genFeature.isStringType() ) ]
+ [if (genFeature.isStereotypeProperty())]
+ [stereotypeSetContent(genModel,genFeature)/]
+ [else]
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).set[genFeature.ecoreFeature.findUMLAccessorName(genModel)/](new[genFeature.getCapName()/]);
+ [/if]
+ [else]
+ [if (genFeature.isEnumType())]
+ [if (genFeature.isStereotypeProperty())]
+ [stereotypeSetContent(genModel,genFeature)/]
+ [else]
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).set[genFeature.ecoreFeature.findUMLAccessorName(genModel)/](([genModel.getImportedName(genFeature.getTypeGenClassifier().getEcoreClassifier().findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClassifier().getEcoreClassifier().getUMLMetaElement(genModel))/])[genModel.getImportedName(genPackage.getUtilitiesPackageName()+'.Wrapper')/].getInstance().getEnumMappingFromSpecific(new[genFeature.getCapName()/]));
+ [/if]
+ [else]
+ [if (genFeature.isStereotypeProperty())]
+ [stereotypeSetContent(genModel,genFeature)/]
+ [else]
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).set[genFeature.ecoreFeature.findUMLAccessorName(genModel)/](([genModel.getImportedName(genFeature.getTypeGenClassifier().getEcoreClassifier().findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClassifier().getEcoreClassifier().getUMLMetaElement(genModel))/])new[genFeature.getCapName()/].get__Represented());
+ [/if]
+ [/if]
+ [/if]
+ [/if][/if]
+ [else]
+ throw new UnsupportedOperationException();
+ [/if]
+ }
+[/template]
+
+[template public stereotypeSetContent(genModel:GenModel,genFeature:GenFeature)]
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented()).getAppliedStereotype("[genFeature.getStereotypeQualifiedName()/]");
+
+ if(stereotype != null) {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented()).setValue(stereotype, "[genFeature.ecoreFeature.name/]", new[genFeature.getCapName()/]);
+ }
+[/template]
+
+[template public genBasicSetContent(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage, isImplementation:Boolean, isJDK50:Boolean,negativeOffsetCorrection:String,positiveOffsetCorrection:String)]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment] { //Class/basicSetGenFeature.annotations.insert.javajetinc[/comment]
+ [/if]
+ public [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] basicSet[genFeature.getAccessorName()/]([genFeature.getImportedInternalType(genClass)/] new[genFeature.getCapName()/], [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs) {
+ [if (genFeature.isContainer()) ]
+ msgs = eBasicSetContainer(([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])new[genFeature.getCapName()/], [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], msgs);
+ return msgs;
+ [else][if (genModel.isDynamicDelegation()) ]
+ msgs = eDynamicInverseAdd(([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])new[genFeature.getCapName()/], [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], msgs);
+ return msgs;
+ [else][if (not genFeature.isVolatile()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ Object old[genFeature.getCapName()/] = eVirtualSet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], new[genFeature.getCapName()/]);
+ [else]
+ [genFeature.getImportedType(genClass)/] old[genFeature.getCapName()/] = [genFeature.getSafeName()/];
+ [genFeature.getSafeName()/] = new[genFeature.getCapName()/];
+ [/if]
+ [if (genFeature.isUnsettable()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [if (not genModel.suppressNotification) ]
+ boolean isSetChange = old[genFeature.getCapName()/] == EVIRTUAL_NO_VALUE;
+ [/if]
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ boolean old[genFeature.getCapName()/]ESet = ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [if (not genModel.suppressNotification) ]
+ [genClass.getESetFlagsField(genFeature)/] |= [genFeature.getUpperName()/]_ESETFLAG;
+ [/if]
+ [else]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = [genFeature.getUncapName()/]ESet;
+ [/if]
+ [genFeature.getUncapName()/]ESet = true;
+ [/if][/if]
+ [/if]
+
+ [if (genFeature.isStereotypeProperty())]
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented()).getAppliedStereotype("[genFeature.getStereotypeQualifiedName()/]");
+
+ if(stereotype != null) {
+ if(new[genFeature.getCapName()/] == null) {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented()).setValue(stereotype, "[genFeature.ecoreFeature.name/]", null);
+ } else {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])get__Represented()).setValue(stereotype, "[genFeature.ecoreFeature.name/]", new[genFeature.getCapName()/].get__Represented());
+ }
+ }
+ [else]
+ [if (genFeature.isExtentionStereotypeProperty())]
+ if(new[genFeature.getCapName()/] == null) {
+ String['[]'/] stereotypesQualifiedNames = { [genFeature.getTypeGenClassifier().getEcoreClassifier().getAllStereotypeQualifiedNames(genModel)/] };
+
+ for([genModel.getImportedName('java.lang.String')/] stereoQualifiedName : stereotypesQualifiedNames) {
+ if((([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getAppliedStereotype(stereoQualifiedName) != null) {
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getApplicableStereotype(stereoQualifiedName);
+ if(stereotype != null) {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).unapplyStereotype(stereotype);
+ } else {
+ System.err.println("Problem: cannot unapply stereotype " + stereoQualifiedName);
+ }
+ }
+ }
+ [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/] notification = new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].REMOVE, [genModel.getImportedName(genPackage.getImportedPackageInterfaceName())/].eINSTANCE.get[genFeature.getFeatureAccessorName()/](), old[genFeature.getCapName()/], new[genFeature.getCapName()/], -1, old[genFeature.getCapName()/] != null);
+ this.eNotify(notification);
+ } else {
+ String['[]'/] stereotypesQualifiedNames = { [genFeature.getTypeGenClassifier().getEcoreClassifier().getAllStereotypeQualifiedNames(genModel)/] };
+
+ for([genModel.getImportedName('java.lang.String')/] stereoQualifiedName : stereotypesQualifiedNames) {
+ if((([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getAppliedStereotype(stereoQualifiedName) == null) {
+ [genModel.getImportedName('org.eclipse.uml2.uml.Stereotype')/] stereotype = (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).getApplicableStereotype(stereoQualifiedName);
+ if(stereotype != null) {
+ (([genModel.getImportedName('org.eclipse.uml2.uml.Element')/])__representedElement).applyStereotype(stereotype);
+ } else {
+ System.err.println("Problem: cannot apply stereotype " + stereoQualifiedName);
+ }
+ }
+ }
+ [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/] notification = new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].ADD, [genModel.getImportedName(genPackage.getImportedPackageInterfaceName())/].eINSTANCE.get[genFeature.getFeatureAccessorName()/](), old[genFeature.getCapName()/], new[genFeature.getCapName()/], -1, old[genFeature.getCapName()/] != null);
+ this.eNotify(notification);
+ }
+ [else]
+ if(new[genFeature.getCapName()/] == null) {
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).set[genFeature.ecoreFeature.findUMLAccessorName(genModel)/](null);
+ } else {
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).set[genFeature.ecoreFeature.findUMLAccessorName(genModel)/](([genModel.getImportedName(genFeature.getTypeGenClass().ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genFeature.getTypeGenClass().ecoreClass.getUMLMetaElement(genModel))/])new[genFeature.getCapName()/].get__Represented());
+ }
+ [/if]
+ [/if]
+
+
+
+ return null;
+ [else][if (genFeature.hasDelegateFeature())]
+ [let delegateFeature : GenFeature = genFeature.getDelegateFeature()]
+ [if (delegateFeature.isWrappedFeatureMapType()) ]
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)get[delegateFeature.getAccessorName()/]()).featureMap()).basicAdd([genFeature.getQualifiedFeatureAccessor()/], new[genFeature.getCapName()/], msgs);
+ [else]
+ return (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)get[delegateFeature.getAccessorName()/]()).basicAdd([genFeature.getQualifiedFeatureAccessor()/], new[genFeature.getCapName()/], msgs);
+ [/if]
+ [/let]
+ [else]
+ // TODO: implement this method to set the contained '[genFeature.getFormattedName()/]' [genFeature.getFeatureKind()/]
+ // -> this method is automatically invoked to keep the containment relationship in synch
+ // -> do not modify other features
+ // -> return msgs, after adding any generated Notification to it (if it is null, a NotificationChain object must be created first)
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+ [/if][/if][/if][/if]
+ }
+[/template]
+
+[template public genUnsetContent(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage,isJDK50:Boolean,negativeOffsetCorrection:String,positiveOffsetCorrection:String, singleWildcard : String)]
+ public void unset[genFeature.getAccessorName()/][if (genClass.hasCollidingUnsetAccessorOperation(genFeature)) ]_[/if]() {
+
+ (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).unset[genFeature.ecoreFeature.findUMLAccessorName(genModel)/]();
+
+ [comment][if (genModel.isDynamicDelegation()) ]
+ eDynamicUnset([genClass.getQualifiedFeatureID(genFeature)/], [genFeature.getQualifiedFeatureAccessor()/]);
+ [else][if (genModel.reflectiveDelegation) ]
+ eUnset([genFeature.getQualifiedFeatureAccessor()/]);
+ [else][if (genFeature.hasSettingDelegate()) ]
+ [genFeature.getUpperName()/]__ESETTING_DELEGATE.dynamicUnset(this, null, 0);
+ [else][if (not genFeature.isVolatile()) ]
+ [if (genFeature.isListType()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [/if]
+ if ([genFeature.getSafeName()/] != null) (([genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')/].Unsettable[singleWildcard/])[genFeature.getSafeName()/]).unset();
+ [else][if (genFeature.isBidirectional() or genFeature.isEffectiveContains()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [/if]
+ if ([genFeature.getSafeName()/] != null) {
+ [genModel.getImportedName('org.eclipse.emf.common.notify.NotificationChain')/] msgs = null;
+ [if (not genFeature.isBidirectional()) ]
+ msgs = (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - [genClass.getQualifiedFeatureID(genFeature)/][negativeOffsetCorrection/], null, msgs);
+ [else]
+ [let reverseFeature : GenFeature = genFeature.getReverse()]
+ [let targetClass : GenClass = reverseFeature.genClass]
+ [let reverseOffsetCorrection : String = if (targetClass.hasOffsetCorrection()) then ' + ' + genClass.getOffsetCorrectionField(genFeature) else '' endif]
+ msgs = (([genModel.getImportedName('org.eclipse.emf.ecore.InternalEObject')/])[genFeature.getSafeName()/]).eInverseRemove(this, [targetClass.getQualifiedFeatureID(reverseFeature)/][reverseOffsetCorrection/], [targetClass.getRawImportedInterfaceName()/].class, msgs);
+ [/let]
+ [/let]
+ [/let]
+ [/if]
+ msgs = basicUnset[genFeature.getAccessorName()/](msgs);
+ if (msgs != null) msgs.dispatch();
+ } else {
+ [if (genModel.isVirtualDelegation()) ]
+ boolean old[genFeature.getCapName()/]ESet = eVirtualIsSet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [/if]
+ [genClass.getESetFlagsField(genFeature)/] &= ~[genFeature.getUpperName()/]_ESETFLAG;
+ [else]
+ [if (not genModel.suppressNotification) ]
+ boolean old[genFeature.getCapName()/]ESet = [genFeature.getUncapName()/]ESet;
+ [/if]
+ [genFeature.getUncapName()/]ESet = false;
+ [/if][/if]
+ [if (not genModel.suppressNotification) ]
+ if (eNotificationRequired())
+ eNotify(new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].UNSET, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], null, null, old[genFeature.getCapName()/]ESet));
+ [/if]
+ }
+ [else]
+ [if (genClass.isFlag(genFeature)) ]
+ [if (not genModel.suppressNotification) ]
+ [if (genFeature.isBooleanType()) ]
+ [genFeature.getImportedType(genClass)/] old[genFeature.getCapName()/] = ([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) != 0;
+ [else]
+ [genFeature.getImportedType(genClass)/] old[genFeature.getCapName()/] = [genFeature.getUpperName()/]_EFLAG_VALUES['['/]([genClass.getFlagsField(genFeature)/] & [genFeature.getUpperName()/]_EFLAG) >>> [genFeature.getUpperName()/]_EFLAG_OFFSET];
+ [/if]
+ [/if]
+ [else][if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]
+ Object old[genFeature.getCapName()/] = eVirtualUnset([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else]
+ [if (not genModel.suppressNotification) ]
+ [genFeature.getImportedType(genClass)/] old[genFeature.getCapName()/] = [genFeature.getSafeName()/];
+ [/if]
+ [/if][/if]
+ [if (not genModel.suppressNotification) ]
+ [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]
+ boolean isSetChange = old[genFeature.getCapName()/] != EVIRTUAL_NO_VALUE;
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ boolean old[genFeature.getCapName()/]ESet = ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [else]
+ boolean old[genFeature.getCapName()/]ESet = [genFeature.getUncapName()/]ESet;
+ [/if][/if]
+ [/if]
+ [if (genFeature.isReferenceType()) ]
+ [genFeature.getSafeName()/] = null;
+ [if (not genModel.isVirtualDelegation()) ]
+ [if (genClass.isESetFlag(genFeature)) ]
+ [genClass.getESetFlagsField(genFeature)/] &= ~[genFeature.getUpperName()/]_ESETFLAG;
+ [else]
+ [genFeature.getUncapName()/]ESet = false;
+ [/if]
+ [/if]
+ [if (not genModel.suppressNotification) ]
+ if (eNotificationRequired())
+ eNotify(new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].UNSET, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], [if (genModel.isVirtualDelegation()) ]isSetChange ? old[genFeature.getCapName()/] : null[else]old[genFeature.getCapName()/][/if], null, [if (genModel.isVirtualDelegation()) ]isSetChange[else]old[genFeature.getCapName()/]ESet[/if]));
+ [/if]
+ [else]
+ [if (genClass.isFlag(genFeature)) ]
+ [if (genFeature.isBooleanType()) ]
+ if ([genFeature.getEDefault()/]) [genClass.getFlagsField(genFeature)/] |= [genFeature.getUpperName()/]_EFLAG; else [genClass.getFlagsField(genFeature)/] &= ~[genFeature.getUpperName()/]_EFLAG;
+ [else]
+ [genClass.getFlagsField(genFeature)/] = [genClass.getFlagsField(genFeature)/] & ~[genFeature.getUpperName()/]_EFLAG | [genFeature.getUpperName()/]_EFLAG_DEFAULT;
+ [/if]
+ [else][if (not genModel.isVirtualDelegation() or genFeature.isPrimitiveType()) ]
+ [genFeature.getSafeName()/] = [genFeature.getEDefault()/];
+ [/if][/if]
+ [if (not genModel.isVirtualDelegation() or genFeature.isPrimitiveType()) ]
+ [if (genClass.isESetFlag(genFeature)) ]
+ [genClass.getESetFlagsField(genFeature)/] &= ~[genFeature.getUpperName()/]_ESETFLAG;
+ [else]
+ [genFeature.getUncapName()/]ESet = false;
+ [/if]
+ [/if]
+ [if (not genModel.suppressNotification) ]
+ if (eNotificationRequired())
+ eNotify(new [genModel.getImportedName('org.eclipse.emf.ecore.impl.ENotificationImpl')/](this, [genModel.getImportedName('org.eclipse.emf.common.notify.Notification')/].UNSET, [genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/], [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]isSetChange ? old[genFeature.getCapName()/] : [genFeature.getEDefault()/][else]old[genFeature.getCapName()/][/if], [genFeature.getEDefault()/], [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]isSetChange[else]old[genFeature.getCapName()/]ESet[/if]));
+ [/if]
+ [/if]
+ [/if][/if]
+ [else]][if (genFeature.hasDelegateFeature())]
+ [let delegateFeature : GenFeature = genFeature.getDelegateFeature()]
+ [if (delegateFeature.isWrappedFeatureMapType()) ]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)get[delegateFeature.getAccessorName()/]()).featureMap()).clear([genFeature.getQualifiedFeatureAccessor()/]);
+ [else]
+ (([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)get[delegateFeature.getAccessorName()/]()).clear([genFeature.getQualifiedFeatureAccessor()/]);
+ [/if]
+ [/let]
+ [else][if (genClass.getUnsetAccessorOperation(genFeature) <> null) ]
+ [genClass.getUnsetAccessorOperation(genFeature).getBody(genModel.getIndentation())/]
+ [else]
+ // TODO: implement this method to unset the '[genFeature.getFormattedName()/]' [genFeature.getFeatureKind()/]
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+ [/if][/if][/if][/if][/if][/if][/comment]
+ }
+
+[/template]
+
+[template public genIsSetContent(genFeature : GenFeature, genModel: GenModel, genPackage : GenPackage,isJDK50:Boolean,negativeOffsetCorrection:String,positiveOffsetCorrection:String, singleWildcard : String)]
+ public boolean isSet[genFeature.getAccessorName()/][if (genClass.hasCollidingIsSetAccessorOperation(genFeature)) ]_[/if]() {
+
+ return (([genModel.getImportedName(genClass.ecoreClass.findUMLMetaElement(genModel).getPackagePathFromUML()+'.'+genClass.ecoreClass.getUMLMetaElement(genModel))/])get__Represented()).isSet[genFeature.ecoreFeature.findUMLAccessorName(genModel)/]();
+
+ [comment][if (genModel.isDynamicDelegation()) ]
+ return eDynamicIsSet([genClass.getQualifiedFeatureID(genFeature)/], [genFeature.getQualifiedFeatureAccessor()/]);
+ [else][if (genModel.reflectiveDelegation) ]
+ return eIsSet([genFeature.getQualifiedFeatureAccessor()/]);
+ [else][if (genFeature.hasSettingDelegate()) ]
+ return [genFeature.getUpperName()/]__ESETTING_DELEGATE.dynamicIsSet(this, null, 0);
+ [else][if (not genFeature.isVolatile()) ]
+ [if (genFeature.isListType()) ]
+ [if (genModel.isVirtualDelegation()) ]
+ [genFeature.getImportedType(genClass)/] [genFeature.getSafeName()/] = ([genFeature.getImportedType(genClass)/])eVirtualGet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [/if]
+ return [genFeature.getSafeName()/] != null && (([genModel.getImportedName('org.eclipse.emf.ecore.util.InternalEList')/].Unsettable[singleWildcard/])[genFeature.getSafeName()/]).isSet();
+ [else]
+ [if (genModel.isVirtualDelegation() and not genFeature.isPrimitiveType()) ]
+ return eVirtualIsSet([genClass.getQualifiedFeatureID(genFeature)/][positiveOffsetCorrection/]);
+ [else][if (genClass.isESetFlag(genFeature)) ]
+ return ([genClass.getESetFlagsField(genFeature)/] & [genFeature.getUpperName()/]_ESETFLAG) != 0;
+ [else]
+ return [genFeature.getUncapName()/]ESet;
+ [/if][/if]
+ [/if]
+ [else][if (genFeature.hasDelegateFeature())]
+ [let delegateFeature : GenFeature = genFeature.getDelegateFeature()]
+ [if (delegateFeature.isWrappedFeatureMapType()) ]
+ return !(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal.Wrapper)get[delegateFeature.getAccessorName()/]()).featureMap()).isEmpty([genFeature.getQualifiedFeatureAccessor()/]);
+ [else]
+ return !(([genModel.getImportedName('org.eclipse.emf.ecore.util.FeatureMap')/].Internal)get[delegateFeature.getAccessorName()/]()).isEmpty([genFeature.getQualifiedFeatureAccessor()/]);
+ [/if]
+ [/let]
+ [else][if (genClass.getIsSetAccessorOperation(genFeature) <> null) ]
+ [genClass.getIsSetAccessorOperation(genFeature).getBody(genModel.getIndentation())/]
+ [else]
+ // TODO: implement this method to return whether the '[genFeature.getFormattedName()/]' [genFeature.getFeatureKind()/] is set
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+ [/if][/if][/if][/if][/if][/if][/comment]
+ }
+[/template]
+
+[query public isAPrimitiveType(genFeature : GenFeature) : Boolean=
+ if(genFeature.ecoreFeature.eType.instanceTypeName='java.lang.String' or genFeature.ecoreFeature.eType.instanceTypeName='int' or genFeature.ecoreFeature.eType.instanceTypeName='boolean' or genFeature.ecoreFeature.eType.instanceTypeName='double') then true else false endif/]
+
+[query public toUpperCase( string : String) : String
+ = invoke('java.lang.String', 'toUpperCase()', Sequence{string}) /]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genOperation.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genOperation.mtl
new file mode 100644
index 00000000000..3a558b52ae6
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/genOperation.mtl
@@ -0,0 +1,160 @@
+[comment encoding = UTF-8 /]
+[module genOperation('http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClassifier /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenFeature /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenEnum /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenPackage /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenDataType /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenOperation /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenParameter /]
+
+[template public genOperation(genOperation : GenOperation, genClass : GenClass, genPackage : GenPackage, genModel : GenModel, isJDK50 : Boolean, isInterface : Boolean, isImplementation : Boolean, isGWT : Boolean)]
+[if (isImplementation) ]
+ [if (genOperation.isInvariant() and genOperation.hasInvariantExpression()) ]
+ /**
+ * The cached validation expression for the '{@link #[genOperation.getName()/]([genOperation.getParameterTypes(', ')/]) <em>[genOperation.getFormattedName()/]</em>}' invariant operation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genOperation.getName()/]([genOperation.getParameterTypes(', ')/])
+ * @generated
+ * @ordered
+ */
+ protected static final [genModel.getImportedName('java.lang.String')/] [genClass.getUniqueNameUpperCase(genOperation)/]__EEXPRESSION = "[genOperation.getInvariantExpression('\t\t')/]";[genModel.getNonNLS()/]
+
+ [else][if (genOperation.hasInvocationDelegate()) ]
+ /**
+ * The cached invocation delegate for the '{@link #[genOperation.getName()/]([genOperation.getParameterTypes(', ')/]) <em>[genOperation.getFormattedName()/]</em>}' operation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #[genOperation.getName()/]([genOperation.getParameterTypes(', ')/])
+ * @generated
+ * @ordered
+ */
+ protected static final [genModel.getImportedName('org.eclipse.emf.ecore.EOperation')/].Internal.InvocationDelegate [genClass.getUniqueNameUpperCase(genOperation)/]__EINVOCATION_DELEGATE = (([genModel.getImportedName('org.eclipse.emf.ecore.EOperation')/].Internal)[genOperation.getQualifiedOperationAccessor()/]).getInvocationDelegate();
+
+ [/if][/if]
+[/if]
+[if (isInterface) ]
+[comment]<%@ include file="Class/genOperation.javadoc.override.javajetinc" fail="alternative" %>[/comment]
+[comment]<%@ start %>[/comment]
+ /**
+[comment]<%@ include file="Class/genOperation.javadoc.insert.javajetinc" fail="silent" %>[/comment]
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ [if (genOperation.hasDocumentation() or genOperation.hasParameterDocumentation()) ]
+ * <!-- begin-model-doc -->
+ [if (genOperation.hasDocumentation()) ]
+ * [genOperation.getDocumentation(genModel.getIndentation())/]
+ [/if]
+ [for (genParameter : GenParameter | genOperation.genParameters)]
+ [if (genParameter.hasDocumentation())]
+ [let documentation : String = genParameter.getDocumentation('')]
+ [if (documentation.contains('\n') or documentation.contains('\r')) ]
+ * @param [genParameter.getName()/]
+ * [genParameter.getDocumentation(genModel.getIndentation())/]
+ [else]
+ * @param [genParameter.getName()/] [genParameter.getDocumentation(genModel.getIndentation())/]
+ [/if]
+ [/let]
+ [/if]
+ [/for]
+ * <!-- end-model-doc -->
+ [/if]
+ [if (not genModel.suppressEMFModelTags)]
+ [let modelInfoLines : Sequence(String) = genOperation.getModelInfo().tokenize(genModel.getLineDelimiter())]
+ [if (modelInfoLines->isEmpty())]
+ * @model
+ [else]
+ * @model [modelInfoLines->sep(genModel.getLineDelimiter() + '\t * ')/]
+ [/if]
+ [/let]
+ [/if]
+ * @generated
+ */
+[comment]<%@ end %><%//Class/genOperation.javadoc.override.javajetinc%>[/comment]
+[else]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (isJDK50)][comment]//Class/genOperation.annotations.insert.javajetinc[/comment]
+[comment]<%@ include file="Class/genOperation.annotations.insert.javajetinc" fail="silent" %>[/comment]
+ [/if]
+[/if]
+[if (not isImplementation) ]
+ [genOperation.getTypeParameters(genClass)/][genOperation.getImportedType(genClass)/] [genOperation.getName()/]([genOperation.getParameters(genClass)/])[genOperation.getThrows(genClass)/];
+
+[else]
+ public [genOperation.getTypeParameters(genClass)/][genOperation.getImportedType(genClass)/] [genOperation.getName()/]([genOperation.getParameters(genClass)/])[genOperation.getThrows(genClass)/] {
+ [if (genOperation.hasBody()) ]
+ [genOperation.getBody(genModel.getIndentation())/]
+ [else][if (genOperation.isInvariant())]
+ [let opClass : GenClass = genOperation.genClass]
+ [let diagnostics : String = genOperation.genParameters->at(1).oclAsType(GenParameter).getName()]
+ [let ctx : String = genOperation.genParameters->at(2).oclAsType(GenParameter).getName()]
+ [if (genOperation.hasInvariantExpression()) ]
+ return
+ [opClass.genPackage.getImportedValidatorClassName()/].validate
+ ([genClass.getQualifiedClassifierAccessor()/],
+ this,
+ [diagnostics/],
+ [ctx/],
+ "[genOperation.getValidationDelegate()/]",[genModel.getNonNLS()/]
+ [genOperation.getQualifiedOperationAccessor()/],
+ [genClass.getUniqueNameUpperCase(genOperation)/]__EEXPRESSION,
+ [genModel.getImportedName('org.eclipse.emf.common.util.Diagnostic')/].ERROR,
+ [opClass.genPackage.getImportedValidatorClassName()/].DIAGNOSTIC_SOURCE,
+ [opClass.genPackage.getImportedValidatorClassName()/].[opClass.getOperationID(genOperation)/]);
+ [else]
+ // TODO: implement this method
+ // -> specify the condition that violates the invariant
+ // -> verify the details of the diagnostic, including severity and message
+ // Ensure that you remove @generated or mark it @generated NOT
+ if (false) {
+ if ([diagnostics/] != null) {
+ [diagnostics/].add
+ (new [genModel.getImportedName('org.eclipse.emf.common.util.BasicDiagnostic')/]
+ ([genModel.getImportedName('org.eclipse.emf.common.util.Diagnostic')/].ERROR,
+ [opClass.genPackage.getImportedValidatorClassName()/].DIAGNOSTIC_SOURCE,
+ [opClass.genPackage.getImportedValidatorClassName()/].[opClass.getOperationID(genOperation)/],
+ [genModel.getImportedName('org.eclipse.emf.ecore.plugin.EcorePlugin')/].INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object['[]'/] { "[genOperation.getName()/]", [genModel.getImportedName('org.eclipse.emf.ecore.util.EObjectValidator')/].getObjectLabel(this, [ctx/]) }),[genModel.getNonNLS()/][genModel.getNonNLS(2)/]
+ new Object ['[]'/] { this }));
+ }
+ return false;
+ }
+ return true;
+ [/if]
+ [/let]
+ [/let]
+ [/let]
+ [else][if (genOperation.hasInvocationDelegate())]
+ [let size : Integer = genOperation.genParameters->size()]
+ try {
+ [if (genOperation.isVoid()) ]
+ [genClass.getUniqueNameUpperCase(genOperation)/]__EINVOCATION_DELEGATE.dynamicInvoke(this, [if (size > 0) ]new [genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/].UnmodifiableEList<Object>([size/], [genOperation.getParametersArray(genClass)/])[else]null[/if]);
+ [else]
+ return [if (not isJDK50 and genOperation.isPrimitiveType()) ]([/if]([genOperation.getObjectType(genClass)/])[genClass.getUniqueNameUpperCase(genOperation)/]__EINVOCATION_DELEGATE.dynamicInvoke(this, [if (size > 0) ]new [genModel.getImportedName('org.eclipse.emf.common.util.BasicEList')/].UnmodifiableEList<Object>([size/], [genOperation.getParametersArray(genClass)/])[else]null[/if])[if (not isJDK50 and genOperation.isPrimitiveType()) ]).[genOperation.getPrimitiveValueFunction()/]()[/if];
+ [/if]
+ }
+ catch ([genModel.getImportedName(if (isGWT) then 'org.eclipse.emf.common.util.InvocationTargetException' else 'java.lang.reflect.InvocationTargetException' endif)/] ite) {
+ throw new [genModel.getImportedName('org.eclipse.emf.common.util.WrappedException')/](ite);
+ }
+ [/let]
+ [else]
+[comment]<%@ include file="Class/implementedGenOperation.TODO.override.javajetinc" fail="alternative" %>[/comment]
+[comment]<%@ start %>[/comment]
+ // TODO: implement this method
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+[comment]<%@ end %><%//Class/implementedGenOperation.todo.override.javajetinc%>[/comment]
+ [/if][/if][/if]
+ }
+
+[/if]
+[comment]<%@ include file="Class/genOperation.insert.javajetinc" fail="silent" %>[/comment]
+[comment]<%@ end %><%//Class/implementedGenOperation.override.javajetinc%>[/comment]
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/reflectiveDelegationAlternative.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/reflectiveDelegationAlternative.mtl
new file mode 100644
index 00000000000..74b614a1e5e
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/genclass/reflectiveDelegationAlternative.mtl
@@ -0,0 +1,29 @@
+[comment encoding = UTF-8 /]
+[module reflectiveDelegationAlternative('http://www.eclipse.org/emf/2002/GenModel')/]
+
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenModel /]
+[import org::eclipse::emf::eef::codegen::ecore::services::wrappers::GenClass /]
+
+
+[template public reflectiveDelegationAlternative(genClass : GenClass, isImplementation : Boolean, genModel : GenModel)]
+[if (isImplementation
+ and (genModel.featureDelegation = GenDelegationKind::Reflective
+ or genModel.isDynamicDelegation())
+ and (genClass.getClassExtendsGenClass() = null
+ or (genClass.getClassExtendsGenClass().getGenModel().featureDelegation <> GenDelegationKind::Reflective
+ and not genClass.getClassExtendsGenClass().getGenModel().isDynamicDelegation()))) ]
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ [if (genModel.useClassOverrideAnnotation()) ]
+ @Override
+ [/if]
+ protected int eStaticFeatureCount()
+ {
+ return [if genClass.getClassExtendsGenClass() = null]0[else][genClass.getClassExtendsGenClass().getAllGenFeatures()->size()/][/if];
+ }
+
+[/if]
+[/template]
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.java
new file mode 100644
index 00000000000..c83417a2006
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.java
@@ -0,0 +1,935 @@
+package org.eclipse.papyrus.facade.codegen.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.facademapping.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facademapping.FacadeMappping;
+import org.eclipse.papyrus.facademapping.Mapping;
+import org.eclipse.papyrus.facademapping.StereotypedMapping;
+import org.eclipse.uml2.types.TypesPackage;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+public class FacadeCodegenUtils {
+
+ protected static String UML_GEN_MODEL = "platform:/plugin/org.eclipse.uml2.uml/model/UML.genmodel";
+
+ static List<Mapping> allMappings = null;
+
+
+ public static String findMappingModel(GenModel genModel) {
+
+ if(!genModel.getForeignModel().isEmpty()) {
+ String metamodel = genModel.getForeignModel().get(0);
+ metamodel = metamodel.replaceAll(".ecore", ".facademapping");
+
+ URI ecoreURI = genModel.eResource().getURI();
+ ecoreURI = ecoreURI.trimSegments(1);
+ ecoreURI = ecoreURI.appendSegment(metamodel);
+
+ return ecoreURI.toString();
+ }
+ return null;
+
+ }
+
+ protected static EObject getUMLElement(Mapping mapping) {
+
+ if(mapping instanceof StereotypedMapping) {
+ if(((StereotypedMapping)mapping).getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ EList<EObject> appliedStereotypes = ((StereotypedMapping)mapping).getAppliedStereotypes();
+ if(appliedStereotypes.size() != 1) {
+ return null;
+ } else {
+ return appliedStereotypes.get(0);
+ }
+ } else {
+ return mapping.getUmlElement();
+ }
+ } else {
+ return mapping.getUmlElement();
+ }
+
+ }
+
+ protected static List<Mapping> getAllMappings(GenModel specificGenModel) {
+
+ if(allMappings == null) {
+ allMappings = new ArrayList<Mapping>();
+
+ String mappingModel = findMappingModel(specificGenModel);
+ if(mappingModel != null) {
+ if(specificGenModel.eResource() != null) {
+ if(specificGenModel.eResource().getResourceSet() != null) {
+ ResourceSet resourceSet = specificGenModel.eResource().getResourceSet();
+ Resource res = resourceSet.getResource(URI.createURI(mappingModel, true), true);
+ if(res != null) {
+ if(!res.getContents().isEmpty()) {
+ EObject root = res.getContents().get(0);
+
+ if(root instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)root;
+
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ allMappings.add(mapping);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return allMappings;
+ }
+
+ public static String getAllStereotypeQualifiedNames(EObject specificMetaElement, GenModel specificGenModel) {
+
+ Set<String> result = new HashSet<String>();
+
+
+ for(Mapping mapping : getAllMappings(specificGenModel)) {
+ if(EcoreUtil.equals(mapping.getSpecificDomainElement(), specificMetaElement)) {
+ if(mapping instanceof StereotypedMapping) {
+
+ for(EObject stereotype : ((StereotypedMapping)mapping).getAppliedStereotypes()) {
+ if(stereotype instanceof Stereotype) {
+ result.add("\"" + ((Stereotype)stereotype).getQualifiedName() + "\"");
+ }
+ }
+ }
+ }
+ }
+
+ if(!result.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+
+ for(String s : result) {
+ sb.append(s).append(',');
+ }
+
+ sb.deleteCharAt(sb.length() - 1); //delete last comma
+
+ return sb.toString();
+ }
+
+ return "";
+ }
+
+ public static String getNonAssociationStereotypeQualifiedNames(EObject specificMetaElement, GenModel specificGenModel) {
+
+ Set<String> result = new HashSet<String>();
+
+
+ for(Mapping mapping : getAllMappings(specificGenModel)) {
+ if(EcoreUtil.equals(mapping.getSpecificDomainElement(), specificMetaElement)) {
+ if(mapping instanceof StereotypedMapping) {
+
+ if(((StereotypedMapping)mapping).getKind() != ExtensionDefinitionKind.ASSOCIATION) {
+ for(EObject stereotype : ((StereotypedMapping)mapping).getAppliedStereotypes()) {
+ if(stereotype instanceof Stereotype) {
+ result.add("\"" + ((Stereotype)stereotype).getQualifiedName() + "\"");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(!result.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+
+ for(String s : result) {
+ sb.append(s).append(',');
+ }
+
+ sb.deleteCharAt(sb.length() - 1); //delete last comma
+
+ return sb.toString();
+ }
+
+ return "";
+ }
+
+ public static String findUMLGetAccessor(EObject specificMetaFeature, GenModel specificGenModel) {
+
+ EObject umlMetaFeature = findUMLMetaElement(specificMetaFeature, specificGenModel);
+
+ if(umlMetaFeature != null) {
+ if(umlMetaFeature instanceof EStructuralFeature) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ EObject umlGenModel = resourceSet.getResource(URI.createURI(UML_GEN_MODEL, true), true).getContents().get(0);
+
+ if(umlGenModel != null) {
+ if(umlGenModel instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenModel) {
+
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)umlGenModel).findGenFeature((EStructuralFeature)umlMetaFeature).getGetAccessor();
+ }
+ }
+ } else if(umlMetaFeature instanceof Property) {
+
+ if(umlMetaFeature.eResource() != null) {
+ if(!umlMetaFeature.eResource().getContents().isEmpty()) {
+ EObject root = umlMetaFeature.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+
+ GenModel profileGen = getGenModel(umlMetaFeature);
+ EObject umlMetaFeatureDefinition = ((Profile)root).getDefinition((NamedElement)umlMetaFeature);
+ if(umlMetaFeatureDefinition instanceof EStructuralFeature) {
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)profileGen).findGenFeature((EStructuralFeature)umlMetaFeatureDefinition).getGetAccessor();
+ }
+
+ }
+ }
+ }
+
+
+
+
+ }
+ }
+
+ return "FAILED_TO_FIND_MAPPED_GET_ACCESSOR";
+ }
+
+ protected static GenModel getGenModel(EObject element) {
+ Map<String, URI> map = EcorePlugin.getEPackageNsURIToGenModelLocationMap(true);
+
+
+
+ if(element.eResource() != null) {
+ if(!element.eResource().getContents().isEmpty()) {
+ EObject root = element.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+ Stereotype ePackageStereotype = ((Profile)root).getAppliedStereotype("Ecore::EPackage");
+ if(ePackageStereotype != null) {
+ Object nsURI = ((Profile)root).getValue(ePackageStereotype, "nsURI");
+ if(nsURI instanceof String) {
+ URI genModelURI = map.get(nsURI);
+ String paltformstring = genModelURI.toPlatformString(true);
+ URI pluginURI = URI.createPlatformPluginURI(paltformstring, true);
+ if(pluginURI != null) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ EObject genModel = resourceSet.getResource(pluginURI, true).getContents().get(0);
+ if(genModel instanceof GenModel) {
+ return (GenModel)genModel;
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static String findUMLAccessorName(EObject specificMetaFeature, GenModel specificGenModel) {
+ EObject umlMetaFeature = findUMLMetaElement(specificMetaFeature, specificGenModel);
+
+ if(umlMetaFeature instanceof NamedElement) {
+
+ if(umlMetaFeature.eResource() != null) {
+ if(!umlMetaFeature.eResource().getContents().isEmpty()) {
+ EObject root = umlMetaFeature.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+
+ GenModel profileGen = getGenModel(umlMetaFeature);
+ EObject umlMetaFeatureDefinition = ((Profile)root).getDefinition((NamedElement)umlMetaFeature);
+ if(umlMetaFeatureDefinition instanceof EStructuralFeature) {
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)profileGen).findGenFeature((EStructuralFeature)umlMetaFeatureDefinition).getAccessorName();
+ }
+
+ }
+ }
+ }
+ } else {
+
+ if(umlMetaFeature != null) {
+ if(umlMetaFeature instanceof EStructuralFeature) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ EObject umlGenModel = resourceSet.getResource(URI.createURI(UML_GEN_MODEL, true), true).getContents().get(0);
+
+ if(umlGenModel != null) {
+ if(umlGenModel instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenModel) {
+
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)umlGenModel).findGenFeature((EStructuralFeature)umlMetaFeature).getAccessorName();
+ }
+ }
+ }
+ }
+ }
+
+ return "FAILED_TO_FIND_MAPPED_GET_ACCESSOR_NAME";
+ }
+
+ public static List<? extends Mapping> getAllMetaclassMappings(GenModel specificGenModel) {
+
+ ArrayList<Mapping> result = new ArrayList<Mapping>();
+
+ String mappingModel = findMappingModel(specificGenModel);
+ if(mappingModel != null) {
+
+ if(specificGenModel.eResource() != null) {
+ if(specificGenModel.eResource().getResourceSet() != null) {
+ ResourceSet resourceSet = specificGenModel.eResource().getResourceSet();
+ EObject root = resourceSet.getResource(URI.createURI(mappingModel, true), true).getContents().get(0);
+
+ if(root != null) {
+ if(root instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)root;
+
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(!(mapping instanceof StereotypedMapping)) {
+ if(mapping.getSpecificDomainElement() instanceof EClassifier) {
+ if(mapping.getUmlElement() != TypesPackage.eINSTANCE.getBoolean() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getString() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getReal() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getInteger() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getUnlimitedNatural()) {
+ if(!(mapping.getUmlElement() instanceof Stereotype)) {
+ if(mapping.getSpecificDomainElement() instanceof EClass) {
+ if(!((EClass)mapping.getSpecificDomainElement()).isAbstract()) {
+ result.add(mapping);
+ }
+ } else {
+ result.add(mapping);
+ }
+ }
+ }
+ }
+ } else {
+ if(((StereotypedMapping)mapping).getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ result.add(mapping);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ return result;
+ }
+
+ public static List<? extends Mapping> getAllEnumLiteralMappings(GenModel specificGenModel) {
+
+ ArrayList<Mapping> result = new ArrayList<Mapping>();
+
+ String mappingModel = findMappingModel(specificGenModel);
+ if(mappingModel != null) {
+
+ if(specificGenModel.eResource() != null) {
+ if(specificGenModel.eResource().getResourceSet() != null) {
+ ResourceSet resourceSet = specificGenModel.eResource().getResourceSet();
+ EObject root = resourceSet.getResource(URI.createURI(mappingModel, true), true).getContents().get(0);
+
+ if(root != null) {
+ if(root instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)root;
+
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(mapping.getSpecificDomainElement() instanceof EEnumLiteral) {
+ if(mapping.getUmlElement() != TypesPackage.eINSTANCE.getBoolean() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getString() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getReal() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getInteger() && mapping.getUmlElement() != TypesPackage.eINSTANCE.getUnlimitedNatural()) {
+ result.add(mapping);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ return result;
+ }
+
+ public static List<? extends Mapping> getAllFeatureMappings(GenModel specificGenModel) {
+
+ ArrayList<Mapping> result = new ArrayList<Mapping>();
+
+ String mappingModel = findMappingModel(specificGenModel);
+ if(mappingModel != null) {
+
+ if(specificGenModel.eResource() != null) {
+ if(specificGenModel.eResource().getResourceSet() != null) {
+ ResourceSet resourceSet = specificGenModel.eResource().getResourceSet();
+ EObject root = resourceSet.getResource(URI.createURI(mappingModel, true), true).getContents().get(0);
+
+ if(root != null) {
+ if(root instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)root;
+
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(!isExtensionStereotypePropertyFromSpecific(mapping.getSpecificDomainElement(), specificGenModel)) {
+ if(mapping.getSpecificDomainElement() instanceof EStructuralFeature) {
+
+ result.add(mapping);
+ }
+ if(mapping.getSpecificDomainElement() instanceof Property) {
+
+ if(((Property)mapping.getSpecificDomainElement()).getClass_() instanceof Stereotype) {
+ result.add(mapping);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ return result;
+ }
+
+ public static EObject findUMLMetaElement(EObject specificMetaElement, GenModel genModel) {
+ String mappingModel = findMappingModel(genModel);
+ if(mappingModel != null) {
+
+ if(genModel.eResource() != null) {
+ if(genModel.eResource().getResourceSet() != null) {
+ ResourceSet resourceSet = genModel.eResource().getResourceSet();
+ EObject root = resourceSet.getResource(URI.createURI(mappingModel, true), true).getContents().get(0);
+
+ if(root != null) {
+ if(root instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)root;
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(EcoreUtil.equals(mapping.getSpecificDomainElement(), specificMetaElement)) {
+
+ return getUMLElement(mapping);
+
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+
+ }
+
+ return null;
+ }
+
+ public static String getUMLFeatureFromMapping(Mapping mapping, GenModel genModel) {
+ EObject UMLMetaElement = mapping.getUmlElement();
+
+ if(UMLMetaElement instanceof NamedElement) {
+
+ if(UMLMetaElement.eResource() != null) {
+ if(!UMLMetaElement.eResource().getContents().isEmpty()) {
+ EObject root = UMLMetaElement.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+
+ GenModel profileGen = getGenModel(UMLMetaElement);
+ EObject umlMetaFeatureDefinition = ((Profile)root).getDefinition((NamedElement)UMLMetaElement);
+ if(umlMetaFeatureDefinition instanceof EStructuralFeature) {
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)profileGen).findGenFeature((EStructuralFeature)umlMetaFeatureDefinition).getFeatureAccessorName();
+ }
+
+ }
+ }
+ }
+
+
+ } else {
+
+ if(UMLMetaElement instanceof EStructuralFeature) {
+ if(UMLMetaElement != null) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ EObject umlGenModel = resourceSet.getResource(URI.createURI(UML_GEN_MODEL, true), true).getContents().get(0);
+
+ if(umlGenModel != null) {
+ if(umlGenModel instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenModel) {
+
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)umlGenModel).findGenFeature((EStructuralFeature)UMLMetaElement).getFeatureAccessorName();
+ }
+ }
+ }
+ }
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_FEATURE";
+ }
+
+
+ public static String getPackagePathFromMapping(Mapping mapping) {
+ EObject UMLMetaElement = getUMLElement(mapping);
+
+ return getPackagePathFromUML(UMLMetaElement);
+ }
+
+ public static String getPackagePathFromUML(EObject UMLMetaElement) {
+
+ EObject root = UMLMetaElement.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+ Stereotype ePackageStereotype = ((Profile)root).getAppliedStereotype("Ecore::EPackage");
+ if(ePackageStereotype != null) {
+ Object packageName = ((Profile)root).getValue(ePackageStereotype, "packageName");
+ Object basePackage = ((Profile)root).getValue(ePackageStereotype, "basePackage");
+ if(packageName instanceof String && basePackage instanceof String) {
+ if(UMLMetaElement instanceof NamedElement) {
+ return basePackage + "." + packageName;
+ }
+ }
+ }
+
+ } else {
+
+ return "org.eclipse.uml2.uml";
+
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_PACKAGE_PATH";
+ }
+
+ public static String getUMLPackageName(Mapping mapping) {
+
+ EObject UMLMetaElement = getUMLElement(mapping);
+
+ EObject root = UMLMetaElement.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+ Stereotype ePackageStereotype = ((Profile)root).getAppliedStereotype("Ecore::EPackage");
+ if(ePackageStereotype != null) {
+ Object packageName = ((Profile)root).getValue(ePackageStereotype, "packageName");
+ if(packageName instanceof String) {
+ if(UMLMetaElement instanceof NamedElement) {
+ return getPackagePathFromMapping(mapping) + "." + packageName + "Package";
+ }
+ }
+ }
+
+ } else {
+
+ return getPackagePathFromMapping(mapping) + ".UMLPackage";
+
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_PACKAGE_NAME";
+ }
+
+
+ public static String getUMLAccessorName(Mapping mapping, GenModel genModel) {
+
+ EObject UMLMetaElement = getUMLElement(mapping);
+
+ EObject root = UMLMetaElement.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+
+ if(UMLMetaElement instanceof NamedElement) {
+ return ((NamedElement)UMLMetaElement).getName();
+ }
+
+ } else {
+
+ if(UMLMetaElement instanceof EClassifier) {
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ EObject umlGenModel = resourceSet.getResource(URI.createURI(UML_GEN_MODEL, true), true).getContents().get(0);
+
+ if(umlGenModel != null) {
+ if(umlGenModel instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenModel) {
+
+ return ((org.eclipse.uml2.codegen.ecore.genmodel.GenModel)umlGenModel).findGenClassifier((EClassifier)UMLMetaElement).getClassifierAccessorName();
+ }
+ }
+
+ }
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_ACCESSOR_NAME";
+ }
+
+ public static String getClassifierAccessorName(GenModel genModel, Mapping mapping) {
+ return genModel.findGenClassifier((EClassifier)mapping.getSpecificDomainElement()).getClassifierAccessorName();
+ }
+
+ public static String getFeatureAccessorName(GenModel genModel, Mapping mapping) {
+ return genModel.findGenFeature((EStructuralFeature)mapping.getSpecificDomainElement()).getFeatureAccessorName();
+ }
+
+ public static String getUMLMetaElement(EObject specificMetaElement, GenModel genModel) {
+
+ for(Mapping mapping : getAllMappings(genModel)) {
+ if(EcoreUtil.equals(mapping.getSpecificDomainElement(), specificMetaElement)) {
+ EObject UMLMetaElement = getUMLElement(mapping);
+
+ if(UMLMetaElement instanceof ENamedElement) {
+ return ((ENamedElement)UMLMetaElement).getName();
+ } else if(UMLMetaElement instanceof NamedElement) {
+ return ((NamedElement)UMLMetaElement).getName();
+ }
+
+ }
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_METACLASS";
+ }
+
+ public static String getUMLFactory(EObject specificMetaElement, GenModel genModel) {
+
+ for(Mapping mapping : getAllMappings(genModel)) {
+ if(EcoreUtil.equals(mapping.getSpecificDomainElement(), specificMetaElement)) {
+
+ EObject UMLMetaElement = getUMLElement(mapping);
+
+ if(UMLMetaElement != null) {
+ EObject root = UMLMetaElement.eResource().getContents().get(0);
+ if(root instanceof Profile) {
+ Stereotype ePackageStereotype = ((Profile)root).getAppliedStereotype("Ecore::EPackage");
+ if(ePackageStereotype != null) {
+ Object packageName = ((Profile)root).getValue(ePackageStereotype, "packageName");
+ if(packageName instanceof String) {
+ if(UMLMetaElement instanceof NamedElement) {
+ return getPackagePathFromUML(UMLMetaElement) + "." + packageName + "Factory";
+ }
+ }
+ }
+ } else {
+ return getPackagePathFromUML(UMLMetaElement) + ".UMLFactory";
+ }
+ }
+
+ }
+ }
+
+
+
+
+ return "FAILED_TO_FIND_MAPPED_UML_FACTORY";
+ }
+
+ public static String getAppropriateQualifiedTypeName(GenClassifier genClassifier) {
+ if(genClassifier instanceof GenClass) {
+
+ return ((GenClass)genClassifier).getQualifiedInterfaceName();
+
+ } else if(genClassifier instanceof GenDataType) {
+
+ return ((GenDataType)genClassifier).getQualifiedInstanceClassName();
+
+ } else {
+
+ return "FAILED_TO_FIND_QUALIFIED_TYPE_NAME";
+ }
+ }
+
+ public static String getUMLEnumElementFromMapping(Mapping mapping) {
+ if(mapping.getUmlElement() instanceof EEnumLiteral) {
+ return ((EEnumLiteral)mapping.getUmlElement()).getEEnum().getName() + ".get(" + ((EEnumLiteral)mapping.getUmlElement()).getValue() + ")";
+ } else if(mapping.getUmlElement() instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral)mapping.getUmlElement()).getEnumeration().getName() + ".get(\"" + ((EnumerationLiteral)mapping.getUmlElement()).getName() + "\")";
+ }
+
+ return "FAILED_TO_FIND_MAPPED_UML_ENUM_ELEMENT";
+ }
+
+ public static String getSpecificEnumElementFromMapping(Mapping mapping) {
+ if(mapping.getUmlElement() instanceof EEnumLiteral) {
+ return ((EEnumLiteral)mapping.getUmlElement()).getEEnum().getName() + ".get(" + ((EEnumLiteral)mapping.getUmlElement()).getValue() + ")";
+ } else if(mapping.getUmlElement() instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral)mapping.getUmlElement()).getEnumeration().getName() + ".get(\"" + ((EnumerationLiteral)mapping.getUmlElement()).getName() + "\")";
+ }
+
+ return "FAILED_TO_FIND_MAPPED_SPECIFIC_ENUM_ELEMENT";
+ }
+
+ protected static boolean isExtensionStereotypePropertyFromSpecific(EObject specificElement, GenModel genModel) {
+ EObject umlElement = findUMLMetaElement(specificElement, genModel);
+
+ if(umlElement instanceof Property) {
+ if(((Property)umlElement).getAssociation() instanceof Extension) {
+ if(((Property)umlElement).getName().startsWith(Extension.STEREOTYPE_ROLE_PREFIX)) {
+ return Boolean.TRUE;
+ }
+
+ }
+ }
+ return Boolean.FALSE;
+ }
+
+ public static boolean isExtentionStereotypeProperty(GenFeature genFeature) {
+
+
+ EObject umlElement = findUMLMetaElement(genFeature.getEcoreFeature(), genFeature.getGenModel());
+
+ if(umlElement instanceof Property) {
+ if(((Property)umlElement).getAssociation() instanceof Extension) {
+ if(((Property)umlElement).getName().startsWith(Extension.STEREOTYPE_ROLE_PREFIX)) {
+ return Boolean.TRUE;
+ }
+
+ }
+ }
+ return Boolean.FALSE;
+ }
+
+ public static boolean isExtensionProperty(GenFeature genFeature) {
+ EObject umlElement = findUMLMetaElement(genFeature.getEcoreFeature(), genFeature.getGenModel());
+
+ if(umlElement instanceof Property) {
+ if(((Property)umlElement).getAssociation() instanceof Extension) {
+
+ return Boolean.TRUE;
+ }
+ }
+ return Boolean.FALSE;
+ }
+
+ public static boolean isStereotypeProperty(GenFeature genFeature) {
+ EClass ecoreClass = genFeature.getGenClass().getEcoreClass();
+
+ boolean isAppropriateMapping = false;
+ for(Mapping mapping : getAllMappings(genFeature.getGenModel())) {
+ if(EcoreUtil.equals(ecoreClass, mapping.getSpecificDomainElement())) {
+ if(mapping instanceof StereotypedMapping) {
+ if(((StereotypedMapping)mapping).getKind() != ExtensionDefinitionKind.ASSOCIATION) {
+ isAppropriateMapping = true;
+ }
+ }
+ }
+ }
+
+ if(isAppropriateMapping) {
+ EObject umlElement = findUMLMetaElement(genFeature.getEcoreFeature(), genFeature.getGenModel());
+
+ if(umlElement instanceof Property) {
+ if(((Property)umlElement).getClass_() instanceof Stereotype) {
+ if(!isExtensionProperty(genFeature)) {
+ return Boolean.TRUE;
+ }
+ }
+ }
+ }
+ return Boolean.FALSE;
+ }
+
+ public static String getStereotypeQualifiedName(GenFeature genFeature) {
+ EObject umlElement = findUMLMetaElement(genFeature.getEcoreFeature(), genFeature.getGenModel());
+
+ if(umlElement instanceof Property) {
+ if(((Property)umlElement).getClass_() instanceof Stereotype) {
+ return ((Property)umlElement).getClass_().getQualifiedName();
+ }
+ }
+ return "FAILED_TO_FIND_STEREOTYPE_QUALIFIEDNAME";
+ }
+
+ public static String getCorrespondingStereotypeMapping(org.eclipse.papyrus.facademapping.Mapping mapping, GenModel genModel, GenPackage genPackage) {
+ String result = "";
+
+ if(!(mapping instanceof StereotypedMapping)) {
+ List<Mapping> allMappings = getAllMappings(genModel);
+
+ List<StereotypedMapping> correspondingStereotypeMappings = new ArrayList<StereotypedMapping>();
+ List<StereotypedMapping> correspondingAssocationStereotypeMappings = new ArrayList<StereotypedMapping>();
+
+ for(Mapping toProcessMapping : allMappings) {
+ if(mapping != toProcessMapping) {
+ if(toProcessMapping instanceof StereotypedMapping) {
+
+
+ boolean isAbstract = false;
+ EList<EObject> stereos = ((StereotypedMapping)toProcessMapping).getAppliedStereotypes();
+ for(EObject stereo : stereos) {
+ if(stereo instanceof Stereotype) {
+ if(((Stereotype)stereo).isAbstract()) {
+ isAbstract = true;
+ }
+ }
+ }
+ if(!isAbstract) {
+
+ if(((StereotypedMapping)toProcessMapping).getKind() == ExtensionDefinitionKind.GENERALIZATION || ((StereotypedMapping)toProcessMapping).getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(toProcessMapping.getUmlElement() == mapping.getUmlElement()) {
+ correspondingStereotypeMappings.add((StereotypedMapping)toProcessMapping);
+ }
+ } else {
+ if(toProcessMapping.getUmlElement() instanceof EClass) {
+ List candidates = new ArrayList<>();
+ candidates.add((EClass)toProcessMapping.getUmlElement());
+ candidates.addAll(((EClass)toProcessMapping.getUmlElement()).getEAllSuperTypes());
+
+ if(candidates.contains(toProcessMapping.getUmlElement()))
+ correspondingAssocationStereotypeMappings.add((StereotypedMapping)toProcessMapping);
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+
+
+ for(StereotypedMapping correspondingStereotypeMapping : correspondingStereotypeMappings) {
+ if(correspondingStereotypeMapping.getSpecificDomainElement() instanceof ENamedElement) {
+
+ String name = ((ENamedElement)correspondingStereotypeMapping.getSpecificDomainElement()).getName().toLowerCase();
+
+ //Single stereotype
+ List<Stereotype> combination = new ArrayList<Stereotype>();
+ combination.addAll((Collection<? extends Stereotype>)correspondingStereotypeMapping.getAppliedStereotypes());
+ result += addWrappingStereotypeMapping(combination, name, genPackage, genModel, correspondingStereotypeMapping);
+
+ //Create combination with association stereo
+ if(!correspondingAssocationStereotypeMappings.isEmpty()) {
+ for(StereotypedMapping stereotypedAssocationMapping : correspondingAssocationStereotypeMappings) {
+ combination.addAll((Collection<? extends Stereotype>)stereotypedAssocationMapping.getAppliedStereotypes());
+ if(stereotypedAssocationMapping.getSpecificDomainElement() instanceof ENamedElement) {
+ name += "_" + ((ENamedElement)stereotypedAssocationMapping.getSpecificDomainElement()).getName().toLowerCase();
+ } else {
+ System.err.println("Problem with : " + stereotypedAssocationMapping.getSpecificDomainElement());
+ }
+ }
+ result += addWrappingStereotypeMapping(combination, name, genPackage, genModel, correspondingStereotypeMapping);
+ }
+
+ } else {
+ System.err.println("Problem with : " + correspondingStereotypeMapping.getSpecificDomainElement());
+ }
+
+ }
+
+ }
+
+ return result;
+
+ }
+
+ protected static String addWrappingStereotypeMapping(List<Stereotype> combination, String name, GenPackage genPackage, GenModel genModel, StereotypedMapping correspondingStereotypeMapping) {
+
+ String result = "";
+
+ result += "java.util.List<org.eclipse.uml2.uml.Stereotype> " + name + "_Stereotypes = new java.util.ArrayList<org.eclipse.uml2.uml.Stereotype>();\n";
+
+ result += addStereotypes(combination, name);
+ result += "if(((org.eclipse.uml2.uml.Element)umlElement).getAppliedStereotypes().size() == " + name + "_Stereotypes.size()) {\n";
+ result += "if(((org.eclipse.uml2.uml.Element)umlElement).getAppliedStereotypes().containsAll(" + name + "_Stereotypes)) {\n";
+ result += "return " + genPackage.getImportedPackageInterfaceName() + ".eINSTANCE.get" + getClassifierAccessorName(genModel, correspondingStereotypeMapping) + "();\n";
+ result += "}\n";
+ result += "}\n";
+
+ return result;
+
+ }
+
+ protected static String addStereotypes(List<Stereotype> combination, String name) {
+ String result = "";
+
+ for(EObject stereotype : combination) {
+ if(stereotype instanceof Stereotype) {
+ result += "if(((org.eclipse.uml2.uml.Element)umlElement).getApplicableStereotype(\"" + ((Stereotype)stereotype).getQualifiedName() + "\") != null) {\n";
+ result += name + "_Stereotypes.add(((org.eclipse.uml2.uml.Element)umlElement).getApplicableStereotype(\"" + ((Stereotype)stereotype).getQualifiedName() + "\"));\n";
+ result += "}\n";
+ }
+ }
+
+ return result;
+ }
+
+ public static boolean isPrimtiveList(GenFeature genFeature) {
+ if(CodeGenUtil.isJavaDefaultType(genFeature.getListItemType())) {
+ return Boolean.TRUE;
+ }
+
+ return Boolean.FALSE;
+ }
+
+ public static void copyEcore(GenPackage genPackage) {
+
+
+ GenModel genModel = genPackage.getGenModel();
+ EModelElement ecoreModelElement = genPackage.getEcoreModelElement();
+ if(ecoreModelElement != null) {
+
+ URI originalURI = ecoreModelElement.eResource().getURI();
+ String modelDirectory = genModel.getModelDirectory();
+ String implPackage = genPackage.getClassPackageName().replaceAll("\\.", "/");
+ if(!implPackage.startsWith("/") && !modelDirectory.endsWith("/")) {
+ implPackage = "/" + implPackage;
+ }
+ String filePath = modelDirectory + implPackage;
+ if(!filePath.endsWith("/")) {
+ filePath += "/";
+ }
+ filePath += originalURI.lastSegment();
+ URI destURI = URI.createURI("platform:/resource" + filePath, true);
+ String dest = destURI.toPlatformString(true);
+
+ try {
+
+ if(originalURI.isPlatformResource()) {
+ String platformString = originalURI.toPlatformString(true);
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(platformString);
+ if(resource instanceof IFile) {
+
+ IPath destPath = new Path(dest);
+ if(destPath.segmentCount() >= 2) {
+ IFile destFolder = resource.getProject().getFile(destPath.removeLastSegments(1).removeFirstSegments(1));
+ IFile destFile = resource.getProject().getFile(destPath.removeFirstSegments(1));
+
+ File destFolderFile = destFolder.getLocation().toFile();
+ File destFileFile = destFile.getLocation().toFile();
+ destFolderFile.mkdirs();
+ destFileFile.createNewFile();
+ Files.copy(resource.getLocation().toFile().toPath(), destFileFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+
+ }
+
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+
+ }
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.mtl
new file mode 100644
index 00000000000..269b8f79569
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/FacadeCodegenUtils.mtl
@@ -0,0 +1,110 @@
+[comment encoding = UTF-8 /]
+[module FacadeCodegenUtils('http://www.eclipse.org/emf/2002/Ecore','http://www.eclipse.org/papyrus/facademapping', 'http://www.eclipse.org/emf/2002/GenModel','http://www.eclipse.org/uml2/4.0.0/UML')/]
+
+[query public getUMLMetaElement( specificMetaElement : EObject, genModel :GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLMetaElement( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaElement,genModel})
+/]
+
+[query public findUMLMetaElement( specificMetaElement : EObject, genModel :GenModel) : EObject
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'findUMLMetaElement( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaElement,genModel})
+/]
+
+[query public findUMLGetAccessor( specificMetaFeature : EObject, specificGenModel :GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'findUMLGetAccessor( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaFeature,specificGenModel})
+/]
+
+[query public findUMLAccessorName( specificMetaFeature : EObject, specificGenModel :GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'findUMLAccessorName( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaFeature,specificGenModel})
+/]
+
+[query public getClassifierAccessorName( genModel:GenModel, mapping:Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getClassifierAccessorName( org.eclipse.emf.codegen.ecore.genmodel.GenModel,org.eclipse.papyrus.facademapping.Mapping)', Sequence{genModel,mapping})
+/]
+
+[query public getFeatureAccessorName( genModel:GenModel, mapping:Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getFeatureAccessorName( org.eclipse.emf.codegen.ecore.genmodel.GenModel,org.eclipse.papyrus.facademapping.Mapping)', Sequence{genModel,mapping})
+/]
+
+[query public getUMLPackageName( mapping : Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLPackageName( org.eclipse.papyrus.facademapping.Mapping)', Sequence{mapping})
+/]
+
+[query public getPackagePathFromUML( specificMetaElement:EObject) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getPackagePathFromUML(org.eclipse.emf.ecore.EObject)', Sequence{specificMetaElement})
+/]
+
+[query public getPackagePathFromMapping( mapping : Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getPackagePathFromMapping(org.eclipse.papyrus.facademapping.Mapping)', Sequence{mapping})
+/]
+
+[query public getUMLFactory( specificMetaElement:EObject, genModel:GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLFactory( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaElement,genModel})
+/]
+
+[query public getUMLAccessorName( mapping : Mapping, genModel :GenModel) : EObject
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLAccessorName( org.eclipse.papyrus.facademapping.Mapping ,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{mapping,genModel})
+/]
+
+[query public getAllMetaclassMappings( specificGenModel :GenModel) : Sequence(Mapping)
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getAllMetaclassMappings(org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificGenModel})
+/]
+
+[query public getUMLFeatureFromMapping( mapping : Mapping, genModel :GenModel) : EObject
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLFeatureFromMapping( org.eclipse.papyrus.facademapping.Mapping ,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{mapping,genModel})
+/]
+
+[query public getAllFeatureMappings( specificGenModel :GenModel) : Sequence(Mapping)
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getAllFeatureMappings(org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificGenModel})
+/]
+
+[query public getAppropriateQualifiedTypeName( genClassifier :GenClassifier) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getAppropriateQualifiedTypeName(org.eclipse.emf.codegen.ecore.genmodel.GenClassifier)', Sequence{genClassifier})
+/]
+
+[query public getAllStereotypeQualifiedNames( specificMetaElement:EObject, specificGenModel:GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getAllStereotypeQualifiedNames( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaElement,specificGenModel})
+/]
+
+[query public getNonAssociationStereotypeQualifiedNames( specificMetaElement:EObject, specificGenModel:GenModel) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getNonAssociationStereotypeQualifiedNames( org.eclipse.emf.ecore.EObject,org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificMetaElement,specificGenModel})
+/]
+
+[query public getUMLEnumElementFromMapping( mapping : Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getUMLEnumElementFromMapping( org.eclipse.papyrus.facademapping.Mapping )', Sequence{mapping})
+/]
+
+[query public getSpecificEnumElementFromMapping( mapping : Mapping) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getSpecificEnumElementFromMapping( org.eclipse.papyrus.facademapping.Mapping )', Sequence{mapping})
+/]
+
+[query public getAllEnumLiteralMappings( specificGenModel :GenModel) : Sequence(Mapping)
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getAllEnumLiteralMappings(org.eclipse.emf.codegen.ecore.genmodel.GenModel)', Sequence{specificGenModel})
+/]
+
+[query public isStereotypeProperty(genFeature:GenFeature) : Boolean
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'isStereotypeProperty(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)', Sequence{genFeature})
+/]
+
+[query public isExtensionProperty(genFeature:GenFeature) : Boolean
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'isExtensionProperty(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)', Sequence{genFeature})
+/]
+
+[query public isExtentionStereotypeProperty(genFeature:GenFeature) : Boolean
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'isExtentionStereotypeProperty(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)', Sequence{genFeature})
+/]
+
+[query public isPrimtiveList(genFeature:GenFeature) : Boolean
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'isPrimtiveList(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)', Sequence{genFeature})
+/]
+
+[query public getCorrespondingStereotypeMapping(mapping : Mapping, genModel:GenModel,genPackage:GenPackage) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getCorrespondingStereotypeMapping(org.eclipse.papyrus.facademapping.Mapping,org.eclipse.emf.codegen.ecore.genmodel.GenModel,org.eclipse.emf.codegen.ecore.genmodel.GenPackage)', Sequence{mapping,genModel,genPackage})
+/]
+
+[query public getStereotypeQualifiedName(genFeature:GenFeature) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'getStereotypeQualifiedName(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)', Sequence{genFeature})
+/]
+
+[query public copyEcore(genPackage:GenPackage) : OclVoid
+= invoke('org.eclipse.papyrus.facade.codegen.utils.FacadeCodegenUtils', 'copyEcore(org.eclipse.emf.codegen.ecore.genmodel.GenPackage)', Sequence{genPackage})
+/] \ No newline at end of file
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/MappingMissing.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/MappingMissing.java
new file mode 100644
index 00000000000..026ab0512d7
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/MappingMissing.java
@@ -0,0 +1,6 @@
+package org.eclipse.papyrus.facade.codegen.utils;
+
+
+public class MappingMissing extends Exception {
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java
new file mode 100644
index 00000000000..fcec17be87a
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java
@@ -0,0 +1,298 @@
+package org.eclipse.papyrus.facade.codegen.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.impl.GenClassImpl;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public class WrappingListUtils {
+
+ private static final String UNSUPPORTED_LIST_CONSTRUCTOR = "UNSUPPORTED_LIST_CONSTRUCTOR";
+
+ protected static List<GenFeature> getSubsetReferenceGenFeature(GenFeature genFeature) {
+ List<GenFeature> result = new ArrayList<GenFeature>();
+ EStructuralFeature ecoreFeature = genFeature.getEcoreFeature();
+ if(ecoreFeature != null) {
+ EAnnotation annotation = ecoreFeature.getEAnnotation("subsets");
+ if(annotation != null) {
+ EList<EObject> references = annotation.getReferences();
+ for(EObject ref : references) {
+
+ if(ref instanceof EReference) {
+ GenFeature refGenFeature = genFeature.getGenModel().findGenFeature((EStructuralFeature)ref);
+ result.add(refGenFeature);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static String getWrappingListConstructor(GenClass genClass, GenFeature genFeature, String typeArgument) {
+
+ boolean isJava5 = isJDK50(genClass.getGenModel());
+ if(genClass instanceof GenClassImpl) {
+
+ GenClassImpl genClassImpl = (GenClassImpl)genClass;
+ StringBuffer sb = new StringBuffer();
+
+ String unsettable = genFeature.isUnsettable() ? ".Unsettable" : "";
+ String offsetCorrectionField = genClassImpl.hasOffsetCorrection() ? " + " + genClassImpl.getOffsetCorrectionField(null) : "";
+
+
+ if(genFeature.isMapType()) {
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_MapType");
+ // GenClass mapGenClass = genFeature.getMapEntryTypeGenClass();
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EcoreEMap"));
+ // sb.append(unsettable);
+ // if(isJava5) {
+ // sb.append('<');
+ // sb.append(genFeature.getImportedMapKeyType(genClassImpl));
+ // sb.append(',');
+ // sb.append(genFeature.getImportedMapValueType(genClassImpl));
+ // sb.append('>');
+ // }
+ // sb.append("(");
+ // sb.append(mapGenClass.getQualifiedClassifierAccessor());
+ // sb.append(", ");
+ // sb.append(genFeature.getImportedMapEntryType());
+ // sb.append(".class, this, ");
+ // sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ // sb.append(offsetCorrectionField);
+ // if(genFeature.isBidirectional() && genClassImpl.getGenModel().getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF27_VALUE) {
+ // sb.append(", ");
+ // sb.append(genFeature.getReverse().getGenClass().getQualifiedFeatureID(genFeature.getReverse()));
+ // }
+ // sb.append(")");
+ } else if(genFeature.isFeatureMapType()) {
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_FeatureMapType");
+ // if(genFeature.isWrappedFeatureMapType()) {
+ // sb.append(genFeature.getImportedEffectiveFeatureMapWrapperClass());
+ // sb.append("(new ");
+ // }
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.BasicFeatureMap"));
+ // sb.append("(this, ");
+ // sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ // sb.append(offsetCorrectionField);
+ // sb.append(")");
+ // if(genFeature.isWrappedFeatureMapType()) {
+ // sb.append(")");
+ // }
+ } else {
+ EGenericType eGenericType = genFeature.getEcoreFeature().getEGenericType();
+ if(genClassImpl.getGenModel().isSuppressNotification()) {
+
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Generic");
+
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.BasicInternalEList"));
+ // if(genClassImpl.getGenModel().getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF28_VALUE) {
+ // sb.append(unsettable);
+ // }
+ // if(isJava5) {
+ // sb.append('<');
+ // sb.append(genFeature.getListItemType(genClassImpl));
+ // sb.append('>');
+ // }
+ // sb.append("(");
+ // sb.append(typeArgument);
+ // sb.append(".class)");
+ } else if(genFeature.isEffectiveContains()) {
+ if(genFeature.isBidirectional()) {
+ GenFeature reverseFeature = genFeature.getReverse();
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentWithInverseEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentWithInverseEList"));
+ }
+ sb.append(unsettable);
+ if(genFeature.isResolveProxies()) {
+ // sb.append(".Resolving");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving");
+ }
+ if(isJava5) {
+ sb.append('<');
+ sb.append(genFeature.getListItemType(genClassImpl));
+ sb.append('>');
+ }
+ sb.append("(");
+ sb.append(typeArgument);
+ sb.append(".class, this, ");
+ sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ sb.append(offsetCorrectionField);
+ sb.append(", ");
+ sb.append(reverseFeature.getGenClass().getQualifiedFeatureID(reverseFeature));
+ if(reverseFeature.getGenClass().hasOffsetCorrection()) {
+ sb.append(" + ");
+ sb.append(genClassImpl.getOffsetCorrectionField(genFeature));
+ }
+ sb.append(",(java.util.Collection)umlList");
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ }
+ }
+ sb.append(")");
+ } else {
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentEList"));
+ }
+ sb.append(unsettable);
+ if(genFeature.isResolveProxies()) {
+ // sb.append(".Resolving");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving");
+ }
+ if(isJava5) {
+ sb.append('<');
+ sb.append(genFeature.getListItemType(genClassImpl));
+ sb.append('>');
+ }
+ sb.append("(");
+ sb.append(typeArgument);
+ sb.append(".class, this, ");
+ sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ sb.append(offsetCorrectionField);
+ sb.append(",(java.util.Collection)umlList");
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ }
+ }
+ sb.append(")");
+ }
+ } else if(genFeature.isReferenceType()) {
+ if(genFeature.isBidirectional()) {
+ GenFeature reverseFeature = genFeature.getReverse();
+ if(genFeature.isResolveProxies()) {
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList"));
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList"));
+ }
+ } else {
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList"));
+ }
+ }
+ sb.append(unsettable);
+ if(reverseFeature.isListType()) {
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(".WrappingSubsetManyInverse");
+ } else {
+ sb.append(".WrappingManyInverse");
+ }
+ }
+ if(isJava5) {
+ sb.append('<');
+ sb.append(genFeature.getListItemType(genClassImpl));
+ sb.append('>');
+ }
+ sb.append("(");
+ sb.append(typeArgument);
+ sb.append(".class, this, ");
+ sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ sb.append(offsetCorrectionField);
+ sb.append(", ");
+ sb.append(reverseFeature.getGenClass().getQualifiedFeatureID(reverseFeature));
+ if(reverseFeature.getGenClass().hasOffsetCorrection()) {
+ sb.append(" + ");
+ sb.append(genClassImpl.getOffsetCorrectionField(genFeature));
+ }
+ sb.append(",(java.util.Collection)umlList");
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ }
+ }
+ sb.append(")");
+ } else {
+ if(genFeature.isResolveProxies()) {
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EObjectResolvingEList"));
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList"));
+ }
+ } else {
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList"));
+ } else {
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList"));
+ }
+ }
+ sb.append(unsettable);
+ if(isJava5) {
+ sb.append('<');
+ sb.append(genFeature.getListItemType(genClassImpl));
+ sb.append('>');
+ }
+ sb.append("(");
+ sb.append(typeArgument);
+ sb.append(".class, this, ");
+ sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ sb.append(offsetCorrectionField);
+ sb.append(",(java.util.Collection)umlList");
+ if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
+ for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ }
+ }
+ sb.append(")");
+ }
+ } else { //data type
+ if(genFeature.isUnique()) {
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EDataTypeUniqueEList"));
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_UniqueDatatype");
+ } else {
+ // sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EDataTypeEList"));
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_NotUniqueDatatype");
+ }
+ sb.append(unsettable);
+ if(isJava5) {
+ sb.append('<');
+ sb.append(genFeature.getListItemType(genClassImpl));
+ sb.append('>');
+ }
+ sb.append("(");
+ sb.append(isPrimitiveType(eGenericType.getERawType()) ? genFeature.getRawListItemType() : typeArgument);
+ sb.append(".class, this, ");
+ sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
+ sb.append(offsetCorrectionField);
+ sb.append(")");
+ }
+ }
+ return sb.toString();
+ }
+ return "";
+ }
+
+ public static boolean isJDK50(GenModel genModel) {
+ if(genModel != null && genModel.getComplianceLevel() != null)
+ return genModel.getComplianceLevel().getValue() >= GenJDKLevel.JDK50;
+ return false;
+ }
+
+ static public boolean isPrimitiveType(EClassifier eType) {
+ return eType != null && CodeGenUtil.isJavaPrimitiveType(eType.getInstanceClassName());
+ }
+
+
+
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.mtl b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.mtl
new file mode 100644
index 00000000000..76c3a5be69e
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.mtl
@@ -0,0 +1,6 @@
+[comment encoding = UTF-8 /]
+[module WrappingListUtils('http://www.eclipse.org/emf/2002/Ecore','http://www.eclipse.org/papyrus/facademapping', 'http://www.eclipse.org/emf/2002/GenModel','http://www.eclipse.org/uml2/2.2.0/GenModel')/]
+
+[query public getWrappingListConstructor(genClass:GenClass, genFeature:GenFeature, typeArgument:String) : String
+= invoke('org.eclipse.papyrus.facade.codegen.utils.WrappingListUtils', 'getWrappingListConstructor(org.eclipse.emf.codegen.ecore.genmodel.GenClass, org.eclipse.emf.codegen.ecore.genmodel.GenFeature, java.lang.String)', Sequence{ genClass, genFeature, typeArgument})
+/] \ No newline at end of file
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.classpath b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.project b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.project
new file mode 100644
index 00000000000..36c4dfa1de0
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.facade.definition.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.settings/org.eclipse.jdt.core.prefs b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..060c5ee3d2e
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/META-INF/MANIFEST.MF b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..736e0407fd9
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: FacadeSepcificEditor
+Bundle-SymbolicName: org.eclipse.papyrus.facade.definition.editor;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.facadeSpecificEditor.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.uml2;bundle-version="3.2.0",
+ org.eclipse.uml2.uml;bundle-version="4.1.0",
+ org.eclipse.papyrus.facade.editor;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.extensionpoints
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/build.properties b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/build.properties
new file mode 100644
index 00000000000..4b8162ab8b2
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/association.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/association.png
new file mode 100644
index 00000000000..0ed33de4bbd
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/association.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/associationRequired.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/associationRequired.png
new file mode 100644
index 00000000000..2e8f27c7c84
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/associationRequired.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/checked.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/checked.gif
new file mode 100644
index 00000000000..9cacb96dca9
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/checked.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/combinaison.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/combinaison.png
new file mode 100644
index 00000000000..fd48fba83ae
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/combinaison.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/facade.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/facade.png
new file mode 100644
index 00000000000..779a7b8b123
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/facade.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusion.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusion.png
new file mode 100644
index 00000000000..48b3d9712e4
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusion.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusionRequired.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusionRequired.png
new file mode 100644
index 00000000000..792ab41bdfd
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/fusionRequired.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalization.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalization.png
new file mode 100644
index 00000000000..2bc0fe5703e
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalization.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalizationRequired.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalizationRequired.png
new file mode 100644
index 00000000000..0d00d0dcbf0
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/generalizationRequired.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralization.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralization.png
new file mode 100644
index 00000000000..d68ef99ac8d
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralization.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralizationRequired.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralizationRequired.png
new file mode 100644
index 00000000000..1690a3eab3b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/multigeneralizationRequired.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tag.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tag.png
new file mode 100644
index 00000000000..228231008ee
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tag.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tagRequired.png b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tagRequired.png
new file mode 100644
index 00000000000..007e8a4dadc
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/tagRequired.png
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/unchecked.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/unchecked.gif
new file mode 100644
index 00000000000..5f17b937e9f
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/unchecked.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/StereotypeInterface.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/StereotypeInterface.gif
new file mode 100644
index 00000000000..4da4be6653b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/StereotypeInterface.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualDatatype.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualDatatype.gif
new file mode 100644
index 00000000000..5d31048451a
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualDatatype.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualEnum.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualEnum.gif
new file mode 100644
index 00000000000..343d086340b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualEnum.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualLiteral.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualLiteral.gif
new file mode 100644
index 00000000000..7bb44f59cc8
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualLiteral.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualMetaclass.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualMetaclass.gif
new file mode 100644
index 00000000000..2b8da630d85
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualMetaclass.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualOperation.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualOperation.gif
new file mode 100644
index 00000000000..60824bba116
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualOperation.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualParameter.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualParameter.gif
new file mode 100644
index 00000000000..bef08f3cc15
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualParameter.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualReference.gif b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualReference.gif
new file mode 100644
index 00000000000..88cdf2ad850
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/icons/virtualmetamodel/VirtualReference.gif
Binary files differ
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/plugin.xml b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/plugin.xml
new file mode 100644
index 00000000000..d0db3b48518
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ name="Facade Definition Editor"
+ extensions="facade"
+ icon="icons/facade.png"
+ contributorClass="org.eclipse.papyrus.facade.presentation.FacadeActionBarContributor"
+ class="org.eclipse.papyrus.facadeSpecificEditor.FacadeSpecificEditor"
+ id="FacadeDefinitionEditor">
+ </editor>
+ </extension>
+
+
+</plugin>
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/ResourceManager.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/ResourceManager.java
new file mode 100644
index 00000000000..1f509369c90
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/ResourceManager.java
@@ -0,0 +1,407 @@
+package com.swtdesigner;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.osgi.framework.Bundle;
+
+/**
+ * Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images,
+ * etc.
+ *
+ * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ *
+ * This class may be freely distributed as part of any application or plugin.
+ * <p>
+ * Copyright (c) 2003 - 2007, Instantiations, Inc. <br>
+ * All Rights Reserved
+ *
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class ResourceManager extends SWTResourceManager {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Image
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
+ /**
+ * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified
+ * class.
+ *
+ * @param clazz
+ * the {@link Class} relative to which to find the image descriptor.
+ * @param path
+ * the path to the image file.
+ * @return the {@link ImageDescriptor} stored in the file at the specified path.
+ */
+ public static ImageDescriptor getImageDescriptor(Class<?> clazz, String path) {
+ return ImageDescriptor.createFromFile(clazz, path);
+ }
+ /**
+ * Returns an {@link ImageDescriptor} stored in the file at the specified path.
+ *
+ * @param path
+ * the path to the image file.
+ * @return the {@link ImageDescriptor} stored in the file at the specified path.
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ try {
+ return ImageDescriptor.createFromURL(new File(path).toURI().toURL());
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+ /**
+ * Returns an {@link Image} based on the specified {@link ImageDescriptor}.
+ *
+ * @param descriptor
+ * the {@link ImageDescriptor} for the {@link Image}.
+ * @return the {@link Image} based on the specified {@link ImageDescriptor}.
+ */
+ public static Image getImage(ImageDescriptor descriptor) {
+ if (descriptor == null) {
+ return null;
+ }
+ Image image = m_descriptorImageMap.get(descriptor);
+ if (image == null) {
+ image = descriptor.createImage();
+ m_descriptorImageMap.put(descriptor, image);
+ }
+ return image;
+ }
+ /**
+ * Maps images to decorated images.
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated.
+ * @param decorator
+ * the {@link Image} to decorate the base image.
+ * @return {@link Image} The resulting decorated image.
+ */
+ public static Image decorateImage(Image baseImage, Image decorator) {
+ return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+ }
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated.
+ * @param decorator
+ * the {@link Image} to decorate the base image.
+ * @param corner
+ * the corner to place decorator image.
+ * @return the resulting decorated {@link Image}.
+ */
+ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+ if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+ throw new IllegalArgumentException("Wrong decorate corner");
+ }
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+ if (cornerDecoratedImageMap == null) {
+ cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ }
+ Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
+ if (decoratedMap == null) {
+ decoratedMap = new HashMap<Image, Image>();
+ cornerDecoratedImageMap.put(baseImage, decoratedMap);
+ }
+ //
+ Image result = decoratedMap.get(decorator);
+ if (result == null) {
+ final Rectangle bib = baseImage.getBounds();
+ final Rectangle dib = decorator.getBounds();
+ final Point baseImageSize = new Point(bib.width, bib.height);
+ CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
+ @Override
+ protected void drawCompositeImage(int width, int height) {
+ drawImage(baseImage.getImageData(), 0, 0);
+ if (corner == TOP_LEFT) {
+ drawImage(decorator.getImageData(), 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ drawImage(decorator.getImageData(), bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ drawImage(decorator.getImageData(), 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height);
+ }
+ }
+ @Override
+ protected Point getSize() {
+ return baseImageSize;
+ }
+ };
+ //
+ result = compositImageDesc.createImage();
+ decoratedMap.put(decorator, result);
+ }
+ return result;
+ }
+ /**
+ * Dispose all of the cached images.
+ */
+ public static void disposeImages() {
+ SWTResourceManager.disposeImages();
+ // dispose ImageDescriptor images
+ {
+ for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) {
+ I.next().dispose();
+ }
+ m_descriptorImageMap.clear();
+ }
+ // dispose decorated images
+ for (int i = 0; i < m_decoratedImageMap.length; i++) {
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ if (cornerDecoratedImageMap != null) {
+ for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
+ for (Image image : decoratedMap.values()) {
+ image.dispose();
+ }
+ decoratedMap.clear();
+ }
+ cornerDecoratedImageMap.clear();
+ }
+ }
+ // dispose plugin images
+ {
+ for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) {
+ I.next().dispose();
+ }
+ m_URLImageMap.clear();
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Plugin images support
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps URL to images.
+ */
+ private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>();
+ /**
+ * Provider for plugin resources, used by WindowBuilder at design time.
+ */
+ public interface PluginResourceProvider {
+ URL getEntry(String symbolicName, String path);
+ }
+ /**
+ * Instance of {@link PluginResourceProvider}, used by WindowBuilder at design time.
+ */
+ private static PluginResourceProvider m_designTimePluginResourceProvider = null;
+ /**
+ * Returns an {@link Image} based on a plugin and file path.
+ *
+ * @param plugin
+ * the plugin {@link Object} containing the image
+ * @param name
+ * the path to the image within the plugin
+ * @return the {@link Image} stored in the file at the specified path
+ *
+ * @deprecated Use {@link #getPluginImage(String, String)} instead.
+ */
+ @Deprecated
+ public static Image getPluginImage(Object plugin, String name) {
+ try {
+ URL url = getPluginImageURL(plugin, name);
+ if (url != null) {
+ return getPluginImageFromUrl(url);
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ return null;
+ }
+ /**
+ * Returns an {@link Image} based on a {@link Bundle} and resource entry path.
+ *
+ * @param symbolicName
+ * the symbolic name of the {@link Bundle}.
+ * @param path
+ * the path of the resource entry.
+ * @return the {@link Image} stored in the file at the specified path.
+ */
+ public static Image getPluginImage(String symbolicName, String path) {
+ try {
+ URL url = getPluginImageURL(symbolicName, path);
+ if (url != null) {
+ return getPluginImageFromUrl(url);
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ return null;
+ }
+ /**
+ * Returns an {@link Image} based on given {@link URL}.
+ */
+ private static Image getPluginImageFromUrl(URL url) {
+ try {
+ try {
+ String key = url.toExternalForm();
+ Image image = m_URLImageMap.get(key);
+ if (image == null) {
+ InputStream stream = url.openStream();
+ try {
+ image = getImage(stream);
+ m_URLImageMap.put(key, image);
+ } finally {
+ stream.close();
+ }
+ }
+ return image;
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ return null;
+ }
+ /**
+ * Returns an {@link ImageDescriptor} based on a plugin and file path.
+ *
+ * @param plugin
+ * the plugin {@link Object} containing the image.
+ * @param name
+ * the path to th eimage within the plugin.
+ * @return the {@link ImageDescriptor} stored in the file at the specified path.
+ *
+ * @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead.
+ */
+ @Deprecated
+ public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) {
+ try {
+ try {
+ URL url = getPluginImageURL(plugin, name);
+ return ImageDescriptor.createFromURL(url);
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ return null;
+ }
+ /**
+ * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
+ *
+ * @param symbolicName
+ * the symbolic name of the {@link Bundle}.
+ * @param path
+ * the path of the resource entry.
+ * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
+ */
+ public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) {
+ try {
+ URL url = getPluginImageURL(symbolicName, path);
+ if (url != null) {
+ return ImageDescriptor.createFromURL(url);
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ return null;
+ }
+ /**
+ * Returns an {@link URL} based on a {@link Bundle} and resource entry path.
+ */
+ private static URL getPluginImageURL(String symbolicName, String path) {
+ // try runtime plugins
+ {
+ Bundle bundle = Platform.getBundle(symbolicName);
+ if (bundle != null) {
+ return bundle.getEntry(path);
+ }
+ }
+ // try design time provider
+ if (m_designTimePluginResourceProvider != null) {
+ return m_designTimePluginResourceProvider.getEntry(symbolicName, path);
+ }
+ // no such resource
+ return null;
+ }
+ /**
+ * Returns an {@link URL} based on a plugin and file path.
+ *
+ * @param plugin
+ * the plugin {@link Object} containing the file path.
+ * @param name
+ * the file path.
+ * @return the {@link URL} representing the file at the specified path.
+ * @throws Exception
+ */
+ private static URL getPluginImageURL(Object plugin, String name) throws Exception {
+ // try to work with 'plugin' as with OSGI BundleContext
+ try {
+ Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$
+ Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$
+ if (BundleContextClass.isAssignableFrom(plugin.getClass())) {
+ Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$
+ Object bundle = getBundleMethod.invoke(plugin, new Object[0]);
+ //
+ Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
+ Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
+ Object path = pathConstructor.newInstance(new Object[]{name});
+ //
+ Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
+ Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$
+ Method findMethod = PlatformClass.getMethod("find", new Class[]{BundleClass, IPathClass}); //$NON-NLS-1$
+ return (URL) findMethod.invoke(null, new Object[]{bundle, path});
+ }
+ } catch (Throwable e) {
+ // Ignore any exceptions
+ }
+ // else work with 'plugin' as with usual Eclipse plugin
+ {
+ Class<?> PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$
+ if (PluginClass.isAssignableFrom(plugin.getClass())) {
+ //
+ Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
+ Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
+ Object path = pathConstructor.newInstance(new Object[]{name});
+ //
+ Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
+ Method findMethod = PluginClass.getMethod("find", new Class[]{IPathClass}); //$NON-NLS-1$
+ return (URL) findMethod.invoke(plugin, new Object[]{path});
+ }
+ }
+ return null;
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // General
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+ * objects are no longer needed (e.g. on application shutdown).
+ */
+ public static void dispose() {
+ disposeColors();
+ disposeFonts();
+ disposeImages();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/SWTResourceManager.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/SWTResourceManager.java
new file mode 100644
index 00000000000..0cf20cb0699
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/com/swtdesigner/SWTResourceManager.java
@@ -0,0 +1,440 @@
+package com.swtdesigner;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc.
+ * <p>
+ * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ * <p>
+ * This class may be freely distributed as part of any application or plugin.
+ * <p>
+ * Copyright (c) 2003 - 2007, Instantiations, Inc. <br>
+ * All Rights Reserved
+ *
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class SWTResourceManager {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Color
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
+ /**
+ * Returns the system {@link Color} matching the specific ID.
+ *
+ * @param systemColorID
+ * the ID value for the color
+ * @return the system {@link Color} matching the specific ID
+ */
+ public static Color getColor(int systemColorID) {
+ Display display = Display.getCurrent();
+ return display.getSystemColor(systemColorID);
+ }
+ /**
+ * Returns a {@link Color} given its red, green and blue component values.
+ *
+ * @param r
+ * the red component of the color
+ * @param g
+ * the green component of the color
+ * @param b
+ * the blue component of the color
+ * @return the {@link Color} matching the given red, green and blue component values
+ */
+ public static Color getColor(int r, int g, int b) {
+ return getColor(new RGB(r, g, b));
+ }
+ /**
+ * Returns a {@link Color} given its RGB value.
+ *
+ * @param rgb
+ * the {@link RGB} value of the color
+ * @return the {@link Color} matching the RGB value
+ */
+ public static Color getColor(RGB rgb) {
+ Color color = m_colorMap.get(rgb);
+ if (color == null) {
+ Display display = Display.getCurrent();
+ color = new Color(display, rgb);
+ m_colorMap.put(rgb, color);
+ }
+ return color;
+ }
+ /**
+ * Dispose of all the cached {@link Color}'s.
+ */
+ public static void disposeColors() {
+ for (Color color : m_colorMap.values()) {
+ color.dispose();
+ }
+ m_colorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Image
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps image paths to images.
+ */
+ private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
+ /**
+ * Returns an {@link Image} encoded by the specified {@link InputStream}.
+ *
+ * @param stream
+ * the {@link InputStream} encoding the image data
+ * @return the {@link Image} encoded by the specified input stream
+ */
+ protected static Image getImage(InputStream stream) throws IOException {
+ try {
+ Display display = Display.getCurrent();
+ ImageData data = new ImageData(stream);
+ if (data.transparentPixel > 0) {
+ return new Image(display, data, data.getTransparencyMask());
+ }
+ return new Image(display, data);
+ } finally {
+ stream.close();
+ }
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path.
+ *
+ * @param path
+ * the path to the image file
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(String path) {
+ Image image = m_imageMap.get(path);
+ if (image == null) {
+ try {
+ image = getImage(new FileInputStream(path));
+ m_imageMap.put(path, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(path, image);
+ }
+ }
+ return image;
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
+ *
+ * @param clazz
+ * the {@link Class} relative to which to find the image
+ * @param path
+ * the path to the image file, if starts with <code>'/'</code>
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(Class<?> clazz, String path) {
+ String key = clazz.getName() + '|' + path;
+ Image image = m_imageMap.get(key);
+ if (image == null) {
+ try {
+ image = getImage(clazz.getResourceAsStream(path));
+ m_imageMap.put(key, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(key, image);
+ }
+ }
+ return image;
+ }
+ private static final int MISSING_IMAGE_SIZE = 10;
+ /**
+ * @return the small {@link Image} that can be used as placeholder for missing image.
+ */
+ private static Image getMissingImage() {
+ Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ //
+ GC gc = new GC(image);
+ gc.setBackground(getColor(SWT.COLOR_RED));
+ gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ gc.dispose();
+ //
+ return image;
+ }
+ /**
+ * Style constant for placing decorator image in top left corner of base image.
+ */
+ public static final int TOP_LEFT = 1;
+ /**
+ * Style constant for placing decorator image in top right corner of base image.
+ */
+ public static final int TOP_RIGHT = 2;
+ /**
+ * Style constant for placing decorator image in bottom left corner of base image.
+ */
+ public static final int BOTTOM_LEFT = 3;
+ /**
+ * Style constant for placing decorator image in bottom right corner of base image.
+ */
+ public static final int BOTTOM_RIGHT = 4;
+ /**
+ * Internal value.
+ */
+ protected static final int LAST_CORNER_KEY = 5;
+ /**
+ * Maps images to decorated images.
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @return {@link Image} The resulting decorated image
+ */
+ public static Image decorateImage(Image baseImage, Image decorator) {
+ return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+ }
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @param corner
+ * the corner to place decorator image
+ * @return the resulting decorated {@link Image}
+ */
+ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+ if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+ throw new IllegalArgumentException("Wrong decorate corner");
+ }
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+ if (cornerDecoratedImageMap == null) {
+ cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ }
+ Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
+ if (decoratedMap == null) {
+ decoratedMap = new HashMap<Image, Image>();
+ cornerDecoratedImageMap.put(baseImage, decoratedMap);
+ }
+ //
+ Image result = decoratedMap.get(decorator);
+ if (result == null) {
+ Rectangle bib = baseImage.getBounds();
+ Rectangle dib = decorator.getBounds();
+ //
+ result = new Image(Display.getCurrent(), bib.width, bib.height);
+ //
+ GC gc = new GC(result);
+ gc.drawImage(baseImage, 0, 0);
+ if (corner == TOP_LEFT) {
+ gc.drawImage(decorator, 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ gc.drawImage(decorator, 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
+ }
+ gc.dispose();
+ //
+ decoratedMap.put(decorator, result);
+ }
+ return result;
+ }
+ /**
+ * Dispose all of the cached {@link Image}'s.
+ */
+ public static void disposeImages() {
+ // dispose loaded images
+ {
+ for (Image image : m_imageMap.values()) {
+ image.dispose();
+ }
+ m_imageMap.clear();
+ }
+ // dispose decorated images
+ for (int i = 0; i < m_decoratedImageMap.length; i++) {
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ if (cornerDecoratedImageMap != null) {
+ for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
+ for (Image image : decoratedMap.values()) {
+ image.dispose();
+ }
+ decoratedMap.clear();
+ }
+ cornerDecoratedImageMap.clear();
+ }
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Font
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps font names to fonts.
+ */
+ private static Map<String, Font> m_fontMap = new HashMap<String, Font>();
+ /**
+ * Maps fonts to their bold versions.
+ */
+ private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>();
+ /**
+ * Returns a {@link Font} based on its name, height and style.
+ *
+ * @param name
+ * the name of the font
+ * @param height
+ * the height of the font
+ * @param style
+ * the style of the font
+ * @return {@link Font} The font matching the name, height and style
+ */
+ public static Font getFont(String name, int height, int style) {
+ return getFont(name, height, style, false, false);
+ }
+ /**
+ * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
+ * flags are also supported.
+ *
+ * @param name
+ * the name of the font
+ * @param size
+ * the size of the font
+ * @param style
+ * the style of the font
+ * @param strikeout
+ * the strikeout flag (warning: Windows only)
+ * @param underline
+ * the underline flag (warning: Windows only)
+ * @return {@link Font} The font matching the name, height, style, strikeout and underline
+ */
+ public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
+ String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
+ Font font = m_fontMap.get(fontName);
+ if (font == null) {
+ FontData fontData = new FontData(name, size, style);
+ if (strikeout || underline) {
+ try {
+ Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$
+ Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$
+ if (logFont != null && logFontClass != null) {
+ if (strikeout) {
+ logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ if (underline) {
+ logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ }
+ } catch (Throwable e) {
+ System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ font = new Font(Display.getCurrent(), fontData);
+ m_fontMap.put(fontName, font);
+ }
+ return font;
+ }
+ /**
+ * Returns a bold version of the given {@link Font}.
+ *
+ * @param baseFont
+ * the {@link Font} for which a bold version is desired
+ * @return the bold version of the given {@link Font}
+ */
+ public static Font getBoldFont(Font baseFont) {
+ Font font = m_fontToBoldFontMap.get(baseFont);
+ if (font == null) {
+ FontData fontDatas[] = baseFont.getFontData();
+ FontData data = fontDatas[0];
+ font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
+ m_fontToBoldFontMap.put(baseFont, font);
+ }
+ return font;
+ }
+ /**
+ * Dispose all of the cached {@link Font}'s.
+ */
+ public static void disposeFonts() {
+ // clear fonts
+ for (Font font : m_fontMap.values()) {
+ font.dispose();
+ }
+ m_fontMap.clear();
+ // clear bold fonts
+ for (Font font : m_fontToBoldFontMap.values()) {
+ font.dispose();
+ }
+ m_fontToBoldFontMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Cursor
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps IDs to cursors.
+ */
+ private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>();
+ /**
+ * Returns the system cursor matching the specific ID.
+ *
+ * @param id
+ * int The ID value for the cursor
+ * @return Cursor The system cursor matching the specific ID
+ */
+ public static Cursor getCursor(int id) {
+ Integer key = Integer.valueOf(id);
+ Cursor cursor = m_idToCursorMap.get(key);
+ if (cursor == null) {
+ cursor = new Cursor(Display.getDefault(), id);
+ m_idToCursorMap.put(key, cursor);
+ }
+ return cursor;
+ }
+ /**
+ * Dispose all of the cached cursors.
+ */
+ public static void disposeCursors() {
+ for (Cursor cursor : m_idToCursorMap.values()) {
+ cursor.dispose();
+ }
+ m_idToCursorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // General
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+ * objects are no longer needed (e.g. on application shutdown).
+ */
+ public static void dispose() {
+ disposeColors();
+ disposeImages();
+ disposeFonts();
+ disposeCursors();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/Activator.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/Activator.java
new file mode 100644
index 00000000000..c0efec8a88f
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/Activator.java
@@ -0,0 +1,63 @@
+package org.eclipse.papyrus.facadeSpecificEditor;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.FacadeSpecificEditor"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#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;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given plug-in relative path
+ *
+ * @param path
+ * the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/FacadeSpecificEditor.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/FacadeSpecificEditor.java
new file mode 100644
index 00000000000..f7a2a84bd95
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/FacadeSpecificEditor.java
@@ -0,0 +1,725 @@
+package org.eclipse.papyrus.facadeSpecificEditor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.FacadePackage;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionFactory;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionPackage;
+import org.eclipse.papyrus.facade.presentation.FacadeEditor;
+import org.eclipse.papyrus.facade.presentation.FacadeEditorPlugin;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetamodel;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelFactory;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.EditionUtils;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.ExtensionKindColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.IsPossibleColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.MetaclassAliasColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.MetaclassIsAbstractColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.MetaclassToKeepColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.PropertiesAliasColumnEdintingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.PropertiesMaxColumnEdintingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.PropertiesMinColumnEdintingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.PropertiesToKeepColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.StereotypeIncompatibilityColumnEditingSupport;
+import org.eclipse.papyrus.facadeSpecificEditor.metamodel.CreatePreliminaryMetamodelListener;
+import org.eclipse.papyrus.facadeSpecificEditor.metamodel.EcoreGenerator;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.ExtensionDefintionContentProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.ExtensionDefintionLabelProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.IncompatibilitiesContentProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.IncompatibilitiesLabelProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.MetamodelContentProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.MetamodelLabelProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.PropertiesContentProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.providers.PropertiesLabelProvider;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.StereotypeUtils;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.UMLModelUtils;
+import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
+import org.eclipse.papyrus.uml.extensionpoints.standard.ExtensionLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class FacadeSpecificEditor extends FacadeEditor {
+
+ protected Facade facade;
+
+ protected String[] filterExtInput = { "*.uml" };
+
+ protected Resource facadeModelResource;
+
+ protected Button initializeButton;
+
+ protected List<Profile> profileModels = new ArrayList<Profile>();
+
+ protected ResourceSet profileResourceSet = new ResourceSetImpl();
+
+ protected Tree metamodelTree;
+
+ protected Tree extensionDefinitionTable;
+
+ protected FilteredTree extensionDefintionFilteredTreeViewer;
+
+ protected static TreeViewer extensionDefintionTreeViewer;
+
+ protected FilteredTree metamodelFilteredTreeViewer;
+
+ protected static TreeViewer metamodelTreeViewer;
+
+ protected TableViewer propertiesTableViewer;
+
+ protected Table propertiesTable;
+
+ protected TableViewer incompatibilitiesTableViewer;
+
+ protected Table incompatibilitiesTable;
+
+ protected TabFolder tabFolder;
+
+ protected Button createMetamodelButton;
+
+ protected Button createEcoreButton;
+
+ protected Button createGlueButton;
+
+ protected Text metamodelName;
+
+ protected Text nsPrefix;
+
+ protected Text nsURI;
+
+ protected String getString(String key) {
+ return FacadeEditorPlugin.INSTANCE.getString(key);
+ }
+
+ public static TreeViewer getExtensionDefintionTreeViewer() {
+ return extensionDefintionTreeViewer;
+ }
+
+ public static TreeViewer getMetamodelTreeViewer() {
+ return metamodelTreeViewer;
+ }
+
+ public void createModel() {
+ // super.createModel();
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Exception exception = null;
+ facadeModelResource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ facadeModelResource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ } catch (Exception e) {
+ exception = e;
+ facadeModelResource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+
+ Diagnostic diagnostic = analyzeResourceProblems(facadeModelResource, exception);
+ if(diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(facadeModelResource, analyzeResourceProblems(facadeModelResource, exception));
+ }
+ editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
+
+ if(facadeModelResource.getContents().size() > 0) {
+ // Get the root
+ facade = (Facade)facadeModelResource.getContents().get(0);
+
+ if(!facade.getExtensionDefinitions().isEmpty()) {
+ // Shouldn't be required but just in case
+ ProfileUtils.clearSiblings();
+
+ for(ExtensionDefinition stereotypeDefinition : facade.getExtensionDefinitions()) {
+ ProfileUtils.initSiblings(stereotypeDefinition.getStereotype());
+ }
+ }
+ }
+ }
+
+ /**
+ * Helper method to clear the template of specific information
+ */
+ protected void clearModel() {
+ RemoveCommand commandMetaclasses = new RemoveCommand(editingDomain, facade, FacadePackage.eINSTANCE.getFacade_Virtualmetamodel(), facade.getVirtualmetamodel());
+ editingDomain.getCommandStack().execute(commandMetaclasses);
+
+ RemoveCommand commandStereotype = new RemoveCommand(editingDomain, facade, FacadePackage.eINSTANCE.getFacade_ExtensionDefinitions(), facade.getExtensionDefinitions());
+ editingDomain.getCommandStack().execute(commandStereotype);
+ }
+
+ protected class FacadeMetamodelInitializer extends MouseAdapter {
+
+ protected void openProfile() {
+ RegisteredProfile[] regProfiles = RegisteredProfile.getRegisteredProfiles();
+ ListSelectionDialog dlg = new ListSelectionDialog(Display.getCurrent().getActiveShell(), Arrays.asList(regProfiles), new IStructuredContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof List) {
+ return ((List)inputElement).toArray();
+ }
+ return Collections.emptyList().toArray();
+ }
+ }, new ExtensionLabelProvider(), "Select the Profiles:");
+ dlg.setTitle("Profile selection");
+ dlg.open();
+
+ for(Object selectedElement : dlg.getResult()) {
+ if(selectedElement instanceof RegisteredProfile) {
+ EObject model = UMLModelUtils.loadModel(((RegisteredProfile)selectedElement).uri, profileResourceSet);
+ if(model instanceof Profile) {
+ TreeIterator<EObject> it = model.eAllContents();
+ boolean failed = false;
+ while(it.hasNext() && !failed) {
+ EObject eObject = (EObject)it.next();
+ if(eObject instanceof PrimitiveType) {
+ Stereotype stereotype = ((PrimitiveType)eObject).getAppliedStereotype("Ecore::EDataType");
+ if(stereotype != null) {
+ Object value = ((PrimitiveType)eObject).getValue(stereotype, "instanceClassName");
+ if(!(value instanceof String)) {
+ failed = true;
+ MessageDialog.openError(getContainer().getShell(), "PrimitiveType issue", "PrimitiveType " + ((PrimitiveType)eObject).getName() + " must be stereotype with Ecore::EDataType and instanceTypeName must be specified");
+ }
+ }
+ }
+ if(eObject instanceof Extension) {
+ if(((Extension)eObject).isRequired()) {
+ failed = true;
+ MessageDialog.openError(getContainer().getShell(), "Required extension issue", "Required extension are not suppported yet.");
+ }
+ }
+ }
+ if(!failed) {
+ profileModels.add((Profile)model);
+ }
+ } else {
+ MessageDialog.openError(getContainer().getShell(), "Open a real Profile", "The model you open is not a profile");
+ }
+ }
+
+ }
+ }
+
+ public void mouseUp(MouseEvent e) {
+
+ profileModels.clear();
+
+ openProfile();
+
+ if(!profileModels.isEmpty()) {
+ // while(MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Open another one", "Should we open another profile")) {
+ // openProfile();
+ // }
+
+ clearModel();
+ ProfileUtils.clearSiblings();
+
+ VirtualMetamodel virtualMetamodel = VirtualmetamodelFactory.eINSTANCE.createVirtualMetamodel();
+ virtualMetamodel.setName("");
+ virtualMetamodel.setNsPrefix("");
+ virtualMetamodel.setNsURI("");
+
+ // facade.setVirtualmetamodel(virtualMetamodel);
+
+ SetCommand command = new SetCommand(editingDomain, facade, FacadePackage.eINSTANCE.getFacade_Virtualmetamodel(), virtualMetamodel);
+ editingDomain.getCommandStack().execute(command);
+
+ createExtensionDefinitions();
+
+ extensionDefintionTreeViewer.refresh();
+
+ metamodelTreeViewer.refresh();
+ }
+ }
+ }
+
+ protected void createExtensionDefinitions() {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ dialog.run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Load profile", IProgressMonitor.UNKNOWN);
+
+ // Find all extensions be it in the profile or in another profile
+ Set<Extension> extensions = new HashSet<Extension>();
+
+ for(Profile profile : profileModels) {
+
+ TreeIterator<EObject> iterator = profile.eAllContents();
+ while(iterator.hasNext()) {
+ EObject eObject = (EObject)iterator.next();
+ if(eObject instanceof Stereotype) {
+
+ extensions.addAll(ProfileUtils.findExtensions((Stereotype)eObject));
+
+ }
+ }
+ }
+
+ for(Extension extension : extensions) {
+
+ List<Stereotype> stereotypes = ProfileUtils.findAllSubsInProfile(extension.getStereotype());
+
+ stereotypes.add(extension.getStereotype());
+
+ for(Stereotype stereotype : stereotypes) {
+ ExtensionDefinition extensionDefinition = ExtensiondefinitionFactory.eINSTANCE.createExtensionDefinition();
+ extensionDefinition.setExtension(extension);
+ extensionDefinition.setKind(ExtensionDefinitionKind.ASSOCIATION);
+ extensionDefinition.setStereotype(stereotype);
+
+ AddCommand command = new AddCommand(editingDomain, facade, FacadePackage.eINSTANCE.getFacade_ExtensionDefinitions(), extensionDefinition);
+ editingDomain.getCommandStack().execute(command);
+
+ ProfileUtils.initSiblings(stereotype);
+
+ // if (!stereotype.isAbstract()) {
+
+ // EList<Classifier> generalsAndI = stereotype.getGenerals();
+ // // generalsAndI.add(stereotype);
+ // boolean oneParentIsAbstract = false;
+ // for (int i = 0; i < generalsAndI.size() && !oneParentIsAbstract; i++) {
+ // Classifier general = generalsAndI.get(i);
+ // if (general.isAbstract()) {
+ // oneParentIsAbstract = true;
+ // }
+ // }
+ //
+ // if (!oneParentIsAbstract) {
+
+ // if (!extension.isRequired()) {
+
+ List<EClass> baseMetaclasses = StereotypeUtils.getAllExtendableMetaclasses(extension, false);
+ for(EClass eClass : baseMetaclasses) {
+
+ BaseMetaclass baseMetaclass = ExtensiondefinitionFactory.eINSTANCE.createBaseMetaclass();
+ baseMetaclass.setBase(eClass);
+ baseMetaclass.setPossible(true);
+
+ AddCommand command2 = new AddCommand(editingDomain, extensionDefinition, ExtensiondefinitionPackage.eINSTANCE.getExtensionDefinition_BaseMetaclasses(), baseMetaclass);
+ editingDomain.getCommandStack().execute(command2);
+ }
+ // }
+ // }
+
+ // }
+ }
+ }
+
+ EditionUtils.initAllStereotypeCombinations(facade, editingDomain);
+
+ EditionUtils.initIsPossible(facade, editingDomain);
+
+ monitor.done();
+
+ }
+
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if(!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ Composite composite = new Composite(getContainer(), SWT.NONE);
+ composite.setLayout(new GridLayout(1, true));
+
+ initializeButton = new Button(composite, SWT.PUSH);
+ initializeButton.setText("Open Profile");
+ initializeButton.addMouseListener(new FacadeMetamodelInitializer());
+
+ tabFolder = new TabFolder(composite, SWT.BORDER);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ tabFolder.setLayoutData(layoutData);
+ tabFolder.setLayout(new GridLayout(1, true));
+
+ TabItem clarifyExtensionsTabItem = new TabItem(tabFolder, SWT.NONE);
+ clarifyExtensionsTabItem.setText("Clarify extensions");
+
+ createClarifyExtension(tabFolder, clarifyExtensionsTabItem);
+
+ TabItem designMetamodelTabItem = new TabItem(tabFolder, SWT.NONE);
+ designMetamodelTabItem.setText("Define metamodel");
+
+ createDesignMetamodel(tabFolder, designMetamodelTabItem);
+
+ TabItem generateMetamodelTabItem = new TabItem(tabFolder, SWT.NONE);
+ generateMetamodelTabItem.setText("Create actual metamodel");
+
+ createGenerateEcore(tabFolder, generateMetamodelTabItem);
+
+ tabFolder.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
+ if(tabFolder.getSelectionIndex() <= 1) {
+ extensionDefintionTreeViewer.refresh();
+ metamodelTreeViewer.refresh();
+ }
+ }
+ });
+
+ int pageIndex = addPage(composite);
+ setPageText(pageIndex, getString("_UI_SelectionPage_label"));
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ setActivePage(0);
+ }
+ });
+
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter() {
+
+ boolean guard = false;
+
+
+ public void controlResized(ControlEvent event) {
+ if(!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+
+ protected void createGenerateEcore(Composite tabFolder, TabItem generateMetamodelTabItem) {
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayoutData(layoutData);
+ composite.setLayout(new GridLayout(1, true));
+
+ Label metamodelNameLabel = new Label(composite, SWT.NONE);
+ metamodelNameLabel.setText("Name: ");
+ metamodelName = new Text(composite, SWT.BORDER);
+ metamodelName.setLayoutData(layoutData);
+ if(facade.getVirtualmetamodel() != null) {
+ if(facade.getVirtualmetamodel().getName() != null) {
+ metamodelName.setText(facade.getVirtualmetamodel().getName());
+ } else {
+ metamodelName.setText("");
+ }
+ }
+ metamodelName.addModifyListener(new ModifyListener() {
+
+
+ public void modifyText(ModifyEvent e) {
+ SetCommand commandName = new SetCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_Name(), metamodelName.getText());
+ editingDomain.getCommandStack().execute(commandName);
+ }
+ });
+
+ Label nsPrefixLabel = new Label(composite, SWT.NONE);
+ nsPrefixLabel.setText("NSPrefix: ");
+ nsPrefix = new Text(composite, SWT.BORDER);
+ nsPrefix.setLayoutData(layoutData);
+ if(facade.getVirtualmetamodel() != null) {
+ if(facade.getVirtualmetamodel().getNsPrefix() != null) {
+ nsPrefix.setText(facade.getVirtualmetamodel().getNsPrefix());
+ } else {
+ nsPrefix.setText("");
+ }
+ }
+ nsPrefix.addModifyListener(new ModifyListener() {
+
+
+ public void modifyText(ModifyEvent e) {
+ SetCommand commandName = new SetCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_NsPrefix(), nsPrefix.getText());
+ editingDomain.getCommandStack().execute(commandName);
+
+ }
+ });
+
+ Label nsURILabel = new Label(composite, SWT.NONE);
+ nsURILabel.setText("NSURI: ");
+ nsURI = new Text(composite, SWT.BORDER);
+ nsURI.setLayoutData(layoutData);
+ if(facade.getVirtualmetamodel() != null) {
+ if(facade.getVirtualmetamodel().getNsURI() != null) {
+ nsURI.setText(facade.getVirtualmetamodel().getNsURI());
+ } else {
+ nsURI.setText("");
+ }
+ }
+ nsURI.addModifyListener(new ModifyListener() {
+
+
+ public void modifyText(ModifyEvent e) {
+ SetCommand commandName = new SetCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_NsURI(), nsURI.getText());
+ editingDomain.getCommandStack().execute(commandName);
+
+ }
+ });
+
+ createEcoreButton = new Button(composite, SWT.NONE);
+ createEcoreButton.setText("Generate Ecore metamodel and mapping");
+ createEcoreButton.addMouseListener(new EcoreGenerator(facade, editingDomain));
+
+
+ // createGlueButton.addMouseListener(new GlueGenerator(facade));
+
+ generateMetamodelTabItem.setControl(composite);
+ }
+
+ protected void createDesignMetamodel(Composite tabFolder, TabItem designMetamodelTabItem) {
+
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayoutData(layoutData);
+ composite.setLayout(new GridLayout(1, true));
+
+ createMetamodelButton = new Button(composite, SWT.NONE);
+ createMetamodelButton.setText("Create preliminary metamodel");
+ createMetamodelButton.addMouseListener(new CreatePreliminaryMetamodelListener(facade, editingDomain));
+
+ SashForm sashFormMetamodel = new SashForm(composite, SWT.VERTICAL);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ sashFormMetamodel.setLayoutData(layoutData);
+ sashFormMetamodel.setLayout(new GridLayout(1, true));
+
+ metamodelFilteredTreeViewer = new FilteredTree(sashFormMetamodel, SWT.BORDER | SWT.FULL_SELECTION, new PatternFilter(), true);
+ metamodelTreeViewer = metamodelFilteredTreeViewer.getViewer();
+ metamodelTreeViewer.getControl().setLayoutData(layoutData);
+ metamodelTree = metamodelTreeViewer.getTree();
+ metamodelTree.setHeaderVisible(true);
+
+ TreeViewerColumn metaclassTreeViewerColumn = new TreeViewerColumn(metamodelTreeViewer, SWT.NONE);
+ TreeColumn metaclassTreeColumn = metaclassTreeViewerColumn.getColumn();
+ metaclassTreeColumn.setWidth(300);
+ metaclassTreeColumn.setText("Metaclass name");
+
+ TreeViewerColumn metaclassToKeepTreeViewerColumn = new TreeViewerColumn(metamodelTreeViewer, SWT.NONE);
+ TreeColumn metaclassToKeepTreeColumn = metaclassToKeepTreeViewerColumn.getColumn();
+ metaclassToKeepTreeColumn.setWidth(60);
+ metaclassToKeepTreeColumn.setText("To keep");
+ metaclassToKeepTreeViewerColumn.setEditingSupport(new MetaclassToKeepColumnEditingSupport(metamodelTreeViewer, editingDomain, metamodelTree, facade));
+
+ TreeViewerColumn metaclassAliasTreeViewerColumn = new TreeViewerColumn(metamodelTreeViewer, SWT.NONE);
+ TreeColumn metaclassAliasTreeColumn = metaclassAliasTreeViewerColumn.getColumn();
+ metaclassAliasTreeColumn.setWidth(300);
+ metaclassAliasTreeColumn.setText("Alias");
+ metaclassAliasTreeViewerColumn.setEditingSupport(new MetaclassAliasColumnEditingSupport(metamodelTreeViewer, editingDomain, metamodelTree));
+
+ TreeViewerColumn metaclassIsAbstractTreeViewerColumn = new TreeViewerColumn(metamodelTreeViewer, SWT.NONE);
+ TreeColumn metaclassIsAbstractTreeColumn = metaclassIsAbstractTreeViewerColumn.getColumn();
+ metaclassIsAbstractTreeColumn.setWidth(100);
+ metaclassIsAbstractTreeColumn.setText("Make it abstract");
+ metaclassIsAbstractTreeViewerColumn.setEditingSupport(new MetaclassIsAbstractColumnEditingSupport(metamodelTreeViewer, editingDomain, metamodelTree));
+
+ metamodelTreeViewer.setContentProvider(new MetamodelContentProvider());
+ metamodelTreeViewer.setLabelProvider(new MetamodelLabelProvider());
+ metamodelTreeViewer.setInput(facade);
+
+ metamodelTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if(event.getSelection() instanceof IStructuredSelection) {
+ Object first = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ propertiesTableViewer.setInput(first);
+ propertiesTableViewer.refresh();
+ }
+
+ }
+ });
+
+ propertiesTableViewer = new TableViewer(sashFormMetamodel, SWT.BORDER | SWT.FULL_SELECTION);
+ propertiesTableViewer.getControl().setLayoutData(layoutData);
+ propertiesTable = propertiesTableViewer.getTable();
+ propertiesTable.setHeaderVisible(true);
+
+ TableViewerColumn propertiesTableViewerColumn = new TableViewerColumn(propertiesTableViewer, SWT.NONE);
+ TableColumn propertiesTableColumn = propertiesTableViewerColumn.getColumn();
+ propertiesTableColumn.setWidth(200);
+ propertiesTableColumn.setText("Feature name");
+
+ TableViewerColumn propertiesToKeepTableViewerColumn = new TableViewerColumn(propertiesTableViewer, SWT.NONE);
+ TableColumn propertiesToKeepTableColumn = propertiesToKeepTableViewerColumn.getColumn();
+ propertiesToKeepTableColumn.setWidth(60);
+ propertiesToKeepTableColumn.setText("To keep");
+ propertiesToKeepTableViewerColumn.setEditingSupport(new PropertiesToKeepColumnEditingSupport(propertiesTableViewer, editingDomain, propertiesTable));
+
+ TableViewerColumn propertiesAliasTableViewerColumn = new TableViewerColumn(propertiesTableViewer, SWT.NONE);
+ TableColumn propertiesAliasTreeColumn = propertiesAliasTableViewerColumn.getColumn();
+ propertiesAliasTreeColumn.setWidth(200);
+ propertiesAliasTreeColumn.setText("Alias");
+ propertiesAliasTableViewerColumn.setEditingSupport(new PropertiesAliasColumnEdintingSupport(propertiesTableViewer, editingDomain, propertiesTable));
+
+ TableViewerColumn propertiesMinTableViewerColumn = new TableViewerColumn(propertiesTableViewer, SWT.NONE);
+ TableColumn propertiesMinTreeColumn = propertiesMinTableViewerColumn.getColumn();
+ propertiesMinTreeColumn.setWidth(50);
+ propertiesMinTreeColumn.setText("Min");
+ propertiesMinTableViewerColumn.setEditingSupport(new PropertiesMinColumnEdintingSupport(propertiesTableViewer, editingDomain, propertiesTable));
+
+ TableViewerColumn propertiesMaxTableViewerColumn = new TableViewerColumn(propertiesTableViewer, SWT.NONE);
+ TableColumn propertiesMaxTreeColumn = propertiesMaxTableViewerColumn.getColumn();
+ propertiesMaxTreeColumn.setWidth(50);
+ propertiesMaxTreeColumn.setText("Max");
+ propertiesMaxTableViewerColumn.setEditingSupport(new PropertiesMaxColumnEdintingSupport(propertiesTableViewer, editingDomain, propertiesTable));
+
+ propertiesTableViewer.setContentProvider(new PropertiesContentProvider());
+ propertiesTableViewer.setLabelProvider(new PropertiesLabelProvider());
+
+ designMetamodelTabItem.setControl(composite);
+
+ }
+
+ protected void createClarifyExtension(Composite tabFolder, TabItem clarifyExtensionsTabItem) {
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ final SashForm sashForm = new SashForm(tabFolder, SWT.HORIZONTAL);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ sashForm.setLayoutData(layoutData);
+ sashForm.setLayout(new GridLayout(1, true));
+
+ extensionDefintionFilteredTreeViewer = new FilteredTree(sashForm, SWT.BORDER | SWT.FULL_SELECTION, new PatternFilter(), true);
+ extensionDefintionTreeViewer = extensionDefintionFilteredTreeViewer.getViewer();
+ extensionDefintionTreeViewer.getControl().setLayoutData(layoutData);
+ extensionDefinitionTable = extensionDefintionTreeViewer.getTree();
+ extensionDefinitionTable.setHeaderVisible(true);
+
+ TreeViewerColumn extensionDefinitionTableViewerColumn = new TreeViewerColumn(extensionDefintionTreeViewer, SWT.NONE);
+ TreeColumn extensionDefinitionTableColumn = extensionDefinitionTableViewerColumn.getColumn();
+ extensionDefinitionTableColumn.setWidth(300);
+ extensionDefinitionTableColumn.setText("Stereotype name");
+
+ TreeViewerColumn extensionKindTableViewerColumn = new TreeViewerColumn(extensionDefintionTreeViewer, SWT.NONE);
+ TreeColumn extensionKindTableColumn = extensionKindTableViewerColumn.getColumn();
+ extensionKindTableColumn.setWidth(150);
+ extensionKindTableColumn.setText("Kind");
+ extensionKindTableViewerColumn.setEditingSupport(new ExtensionKindColumnEditingSupport(extensionDefintionTreeViewer, editingDomain, extensionDefinitionTable));
+
+ TreeViewerColumn isPossibleTableViewerColumn = new TreeViewerColumn(extensionDefintionTreeViewer, SWT.NONE);
+ TreeColumn isPossibleTableColumn = isPossibleTableViewerColumn.getColumn();
+ isPossibleTableColumn.setWidth(200);
+ isPossibleTableColumn.setText("Applicable on this metaclass");
+ isPossibleTableViewerColumn.setEditingSupport(new IsPossibleColumnEditingSupport(extensionDefintionTreeViewer, editingDomain, extensionDefinitionTable));
+
+ extensionDefintionTreeViewer.setContentProvider(new ExtensionDefintionContentProvider());
+ extensionDefintionTreeViewer.setLabelProvider(new ExtensionDefintionLabelProvider());
+ extensionDefintionTreeViewer.setInput(facade);
+
+ extensionDefintionTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if(event.getSelection() instanceof IStructuredSelection) {
+ Object first = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ incompatibilitiesTableViewer.setInput(first);
+ incompatibilitiesTableViewer.refresh();
+ }
+
+ }
+ });
+
+ incompatibilitiesTableViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
+ incompatibilitiesTableViewer.getControl().setLayoutData(layoutData);
+ incompatibilitiesTable = incompatibilitiesTableViewer.getTable();
+ incompatibilitiesTable.setHeaderVisible(true);
+
+ TableViewerColumn stereoTableViewerColumn = new TableViewerColumn(incompatibilitiesTableViewer, SWT.NONE);
+ TableColumn stereoTableColumn = stereoTableViewerColumn.getColumn();
+ stereoTableColumn.setWidth(300);
+ stereoTableColumn.setText("Stereotype");
+
+ TableViewerColumn stereoIncompatibilityTableViewerColumn = new TableViewerColumn(incompatibilitiesTableViewer, SWT.NONE);
+ TableColumn stereoIncompatibilityTableColumn = stereoIncompatibilityTableViewerColumn.getColumn();
+ stereoIncompatibilityTableColumn.setWidth(150);
+ stereoIncompatibilityTableColumn.setText("Is compatible combination");
+ stereoIncompatibilityTableViewerColumn.setEditingSupport(new StereotypeIncompatibilityColumnEditingSupport(incompatibilitiesTableViewer, editingDomain, incompatibilitiesTable));
+
+ incompatibilitiesTableViewer.setContentProvider(new IncompatibilitiesContentProvider());
+ incompatibilitiesTableViewer.setLabelProvider(new IncompatibilitiesLabelProvider());
+
+ clarifyExtensionsTabItem.setControl(sashForm);
+
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/EditionUtils.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/EditionUtils.java
new file mode 100644
index 00000000000..82d88231155
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/EditionUtils.java
@@ -0,0 +1,177 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.Combination;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+
+
+public class EditionUtils {
+
+ public static boolean containsCombination(List<Combination> list, Combination combinaison) {
+ for(Combination item : list) {
+ if(item.getMembers().size() == combinaison.getMembers().size()) {
+ if(item.getMembers().containsAll(combinaison.getMembers())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+
+ }
+
+ public static Combination getCombinationThatMatch(List<Combination> list, Combination combinaison) {
+ for(Combination item : list) {
+ if(item.getMembers().size() == combinaison.getMembers().size()) {
+ if(item.getMembers().containsAll(combinaison.getMembers())) {
+ return item;
+ }
+ }
+ }
+
+ return null;
+
+ }
+
+ public static void initAllStereotypeCombinations(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ for(BaseMetaclass baseMeta : extensionDefinition.getBaseMetaclasses()) {
+
+ List<Combination> possibleCombinations = ProfileUtils.getPossibleCombinations(baseMeta);
+
+ List<Combination> toAdd = new ArrayList<Combination>();
+
+ for(Combination combinaison : possibleCombinations) {
+
+ if(!containsCombination(baseMeta.getIncompatibleStereotypes(), combinaison)) {
+ if(!containsCombination(baseMeta.getCompatibleStereotypes(), combinaison)) {
+ toAdd.add(combinaison);
+ }
+ }
+ }
+
+ for(Combination combination : toAdd) {
+ // if (baseMeta.getExtensionDefinition().getExtension().isRequired()) {
+ // if (combination.getMetaClasses().size() == 1) {
+ // if (combination.getMetaClasses().get(0).isPossible()) {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), combination);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // } else {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), combination);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // }
+ // } else {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), combination);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // }
+ // } else {
+ // if (containsOnlyRequired(combination)) {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), combination);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // } else {
+ AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), combination);
+ editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // }
+ // }
+ }
+
+ // if (baseMeta.isPossible()) {
+ // // if (baseMeta.getExtensionDefinition().getExtension().isRequired()) {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), toAdd);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // // }
+ // } else {
+ // AddCommand addIncompatibilitiesCommand = new AddCommand(editingDomain, baseMeta, FacadeMetamodelPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), toAdd);
+ // editingDomain.getCommandStack().execute(addIncompatibilitiesCommand);
+ // }
+
+ }
+ }
+ }
+
+ public static void clearAllStereotypeCombinations(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ for(BaseMetaclass baseMeta : extensionDefinition.getBaseMetaclasses()) {
+
+ List<Combination> possibleCombinations = ProfileUtils.getPossibleCombinations(baseMeta);
+
+ // System.err.println("For : " + baseMeta.getExtensionDefinition().getStereotype().getName());
+ // for (Combination combination : possibleCombinations) {
+ // System.err.print("\t");
+ // for (BaseMetaclass metaclass : combination.getMetaClasses()) {
+ // System.err.print(metaclass.getExtensionDefinition().getStereotype().getName() + ", ");
+ // }
+ // System.err.println();
+ //
+ // }
+
+ List<Combination> incompatibilitiesToRemove = new ArrayList<Combination>();
+
+ for(Combination incompatibleBase : baseMeta.getIncompatibleStereotypes()) {
+ if(!containsCombination(possibleCombinations, incompatibleBase)) {
+ incompatibilitiesToRemove.add(incompatibleBase);
+ }
+
+ }
+ RemoveCommand removeIncompatibilityCommand = new RemoveCommand(editingDomain, baseMeta, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), incompatibilitiesToRemove); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(removeIncompatibilityCommand);
+
+ List<Combination> compatibilitiesToRemove = new ArrayList<Combination>();
+
+ for(Combination compatibleBase : baseMeta.getCompatibleStereotypes()) {
+ if(!containsCombination(possibleCombinations, compatibleBase)) {
+ compatibilitiesToRemove.add(compatibleBase);
+ }
+ }
+ RemoveCommand removeCompatibilityCommand = new RemoveCommand(editingDomain, baseMeta, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), compatibilitiesToRemove); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(removeCompatibilityCommand);
+
+ }
+ }
+ }
+
+ public static boolean hasARequiredCombination(BaseMetaclass baseMeta) {
+
+ List<Combination> combinaisonsToCheck = new ArrayList<Combination>();
+
+ combinaisonsToCheck.addAll(baseMeta.getCompatibleStereotypes());
+ combinaisonsToCheck.addAll(baseMeta.getIncompatibleStereotypes());
+
+ for(Combination combination : combinaisonsToCheck) {
+ for(BaseMetaclass metaclass : combination.getMembers()) {
+ if(metaclass.getExtensionDefinition().getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(metaclass.getExtensionDefinition().getExtension().isRequired()) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+
+ }
+
+ public static void initIsPossible(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ for(BaseMetaclass baseMeta : extensionDefinition.getBaseMetaclasses()) {
+ // If it has a combination that contains a required
+ if(hasARequiredCombination(baseMeta)) {
+ baseMeta.setPossible(false);
+ } else {
+ baseMeta.setPossible(true);
+ }
+ }
+ }
+
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/ExtensionKindColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/ExtensionKindColumnEditingSupport.java
new file mode 100644
index 00000000000..c6137f888ac
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/ExtensionKindColumnEditingSupport.java
@@ -0,0 +1,257 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class ExtensionKindColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public ExtensionKindColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ protected void transformIntoAssociation(ExtensionDefinition element) {
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getExtensionDefinition_Kind(), ExtensionDefinitionKind.ASSOCIATION); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected void transformIntoGeneralization(ExtensionDefinition element) {
+
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getExtensionDefinition_Kind(), ExtensionDefinitionKind.GENERALIZATION); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected void transformIntoMultiGeneralization(ExtensionDefinition element) {
+
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getExtensionDefinition_Kind(), ExtensionDefinitionKind.MULTI_GENERALIZATION); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected void transformIntoFusion(ExtensionDefinition element) {
+
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getExtensionDefinition_Kind(), ExtensionDefinitionKind.FUSION); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected boolean stereotypeUsedElsewhere(ExtensionDefinition extensionDefinition) {
+ EList<ExtensionDefinition> allExtensionDefintion = extensionDefinition.getFacade().getExtensionDefinitions();
+
+ for(ExtensionDefinition otherExtensionDefinition : allExtensionDefintion) {
+ if(otherExtensionDefinition != extensionDefinition) {
+ for(Property property : otherExtensionDefinition.getStereotype().getAttributes()) {
+ if(property.getType() == extensionDefinition.getStereotype()) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ protected boolean hasOtherExtension(ExtensionDefinition extensionDefinition) {
+ EList<ExtensionDefinition> allExtensionDefintion = extensionDefinition.getFacade().getExtensionDefinitions();
+
+ for(ExtensionDefinition otherExtensionDefinition : allExtensionDefintion) {
+ if(otherExtensionDefinition != extensionDefinition) {
+ if(extensionDefinition.getStereotype() == otherExtensionDefinition.getStereotype()) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void setValue(final Object element, final Object value) {
+ final ExtensionDefinitionKind newValue = ExtensionDefinitionKind.get((Integer)value);
+
+
+ if(element instanceof ExtensionDefinition) {
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ dialog.run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Updating stereotypes definitions", IProgressMonitor.UNKNOWN);
+
+ Facade facade = ((ExtensionDefinition)element).getFacade();
+
+ if(newValue == ExtensionDefinitionKind.ASSOCIATION) {
+
+ transformIntoAssociation((ExtensionDefinition)element);
+
+ // All children and generals must be set to Association as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((ExtensionDefinition)element).getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+
+ if(extensionDefinition.getExtension() == ((ExtensionDefinition)element).getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+
+ transformIntoAssociation(extensionDefinition);
+ }
+ }
+ }
+
+ // // Clear incompatibilities
+ // EditionUtils.clearStereotypeCombinations(facade, editingDomain);
+
+ } else if(newValue == ExtensionDefinitionKind.GENERALIZATION) {
+
+ if(((ExtensionDefinition)element).getExtension().getMetaclass().isAbstract()) {
+
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Warning", "The extension extends an abstract class. The extension cannot be a generalization.");
+
+ } else {
+ if(((ExtensionDefinition)element).getExtension().isRequired()) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Warning", "The extension is required. The extension cannot be a generalization.");
+ } else {
+
+ transformIntoGeneralization((ExtensionDefinition)element);
+ // All children and generals must be set to generalization as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((ExtensionDefinition)element).getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == ((ExtensionDefinition)element).getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+ transformIntoGeneralization(extensionDefinition);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ // // Init incompatibilities
+ // EditionUtils.initStereotypeCombinations(facade, editingDomain);
+
+ } else if(newValue == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+
+ if(hasOtherExtension((ExtensionDefinition)element) && stereotypeUsedElsewhere((ExtensionDefinition)element)) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Warning", "Cannot change the extension kind to MultiGeneralization because stereotype is used to type a property elsewhere. ");
+ } else {
+ transformIntoMultiGeneralization((ExtensionDefinition)element);
+ // All children and generals must be set to generalization as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((ExtensionDefinition)element).getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == ((ExtensionDefinition)element).getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+ transformIntoMultiGeneralization(extensionDefinition);
+ }
+ }
+ }
+ }
+
+ } else if(newValue == ExtensionDefinitionKind.FUSION) {
+ if(hasOtherExtension((ExtensionDefinition)element) && stereotypeUsedElsewhere((ExtensionDefinition)element)) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Warning", "Cannot change the extension kind to Fusion because stereotype is used to type a property elsewhere. ");
+ } else {
+ transformIntoFusion((ExtensionDefinition)element);
+
+ // All children and generals must be set to generalization as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((ExtensionDefinition)element).getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == ((ExtensionDefinition)element).getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+ transformIntoFusion(extensionDefinition);
+ }
+ }
+ }
+ }
+ }
+
+ // Clear incompatibilities that don't exist anymore
+ EditionUtils.clearAllStereotypeCombinations(facade, editingDomain);
+ // Init new incompatibilities
+ EditionUtils.initAllStereotypeCombinations(facade, editingDomain);
+ // Update isPossible
+ EditionUtils.initIsPossible(facade, editingDomain);
+
+ monitor.done();
+
+ }
+
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ getViewer().refresh();
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ // System.err.println("LA : " + element);
+ if(element instanceof ExtensionDefinition) {
+ int value = ((ExtensionDefinition)element).getKind().getValue();
+ return value;
+
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+
+ if(element instanceof ExtensionDefinition) {
+
+
+ // String[] itemsArray = { ExtensionDefinitionKind.ASSOCIATION.getName(), ExtensionDefinitionKind.GENERALIZATION.getName(), ExtensionDefinitionKind.MULTI_GENERALIZATION.getName(), ExtensionDefinitionKind.FUSION.getName() };
+ String[] itemsArray = { ExtensionDefinitionKind.ASSOCIATION.getName(), ExtensionDefinitionKind.GENERALIZATION.getName(), ExtensionDefinitionKind.MULTI_GENERALIZATION.getName() };
+
+
+ ComboBoxCellEditor combo = new ComboBoxCellEditor(parent, itemsArray, SWT.READ_ONLY);
+
+
+ return combo;
+ }
+
+ return null;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/IsPossibleColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/IsPossibleColumnEditingSupport.java
new file mode 100644
index 00000000000..46a8dd39c3b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/IsPossibleColumnEditingSupport.java
@@ -0,0 +1,190 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class IsPossibleColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public IsPossibleColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ protected void transformPossibleIntoImpossible(BaseMetaclass element) {
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_Possible(), false);
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected void transformImpossibleIntoPossible(BaseMetaclass element) {
+
+ SetCommand command = new SetCommand(editingDomain, element, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_Possible(), true);
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ protected void transformAllPossibleIntoImpossible(BaseMetaclass element) {
+ Facade facade = ((BaseMetaclass)element).getExtensionDefinition().getFacade();
+ transformPossibleIntoImpossible((BaseMetaclass)element);
+
+ // All children and generals must be set to Impossible as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((BaseMetaclass)element).getExtensionDefinition().getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == ((BaseMetaclass)element).getExtensionDefinition().getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses())
+ if(baseMetaclass.getBase() == ((BaseMetaclass)element).getBase()) {
+ transformPossibleIntoImpossible(baseMetaclass);
+ }
+ }
+ }
+ }
+
+ // Stereotype incompatibility of required extension must be updated too
+ // for (ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if (extensionDefinition.getExtension().isRequired()) {
+ // for (BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ // Combination fakeCombinaison = VirtualProfileFactory.eINSTANCE.createCombination();
+ // fakeCombinaison.getMetaClasses().add(element);
+ //
+ // Combination combination = EditionUtils.getCombinationThatMatch(baseMetaclass.getCompatibleStereotypes(), fakeCombinaison);
+ // if (combination != null) {
+ // StereotypeIncompatibilityColumnEditingSupport.makeItImcompatible(baseMetaclass, combination, false);
+ // }
+ // }
+ // }
+ // }
+
+ // EditionUtils.clearStereotypeCombinations(facade, editingDomain);
+ }
+
+ protected void transformAllImpossibleIntoPossible(BaseMetaclass element) {
+ Facade facade = ((BaseMetaclass)element).getExtensionDefinition().getFacade();
+ transformImpossibleIntoPossible((BaseMetaclass)element);
+
+ // All children and generals must be set to Possible as well
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(((BaseMetaclass)element).getExtensionDefinition().getStereotype());
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == ((BaseMetaclass)element).getExtensionDefinition().getExtension()) {
+ if(siblings.contains(extensionDefinition.getStereotype())) {
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses())
+ if(baseMetaclass.getBase() == ((BaseMetaclass)element).getBase()) {
+ transformImpossibleIntoPossible(baseMetaclass);
+ }
+ }
+ }
+ }
+
+ // Stereotype incompatibility of required extension must be updated too
+ // for (ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if (extensionDefinition.getExtension().isRequired()) {
+ // for (BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ // Combination fakeCombinaison = VirtualProfileFactory.eINSTANCE.createCombination();
+ // fakeCombinaison.getMetaClasses().add(element);
+ //
+ // Combination combination = EditionUtils.getCombinationThatMatch(baseMetaclass.getIncompatibleStereotypes(), fakeCombinaison);
+ // if (combination != null) {
+ // StereotypeIncompatibilityColumnEditingSupport.makeItCompatible(baseMetaclass, combination, false);
+ // }
+ // }
+ // }
+ // }
+
+ // EditionUtils.initStereotypeCombinations(facade, editingDomain);
+ }
+
+ @Override
+ protected void setValue(final Object element, final Object value) {
+ if(element instanceof BaseMetaclass) {
+
+ if(EditionUtils.hasARequiredCombination((BaseMetaclass)element)) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cannot change possibility", "Cannot change because it contains a required metaclass in the combinations");
+
+ } else {
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ dialog.run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Updating stereotypes definitions", IProgressMonitor.UNKNOWN);
+
+ if((Boolean)value == true) {
+ transformAllImpossibleIntoPossible((BaseMetaclass)element);
+ } else {
+ transformAllPossibleIntoImpossible((BaseMetaclass)element);
+
+ }
+
+ Facade facade = ((BaseMetaclass)element).getExtensionDefinition().getFacade();
+
+ // Clear incompatibilities that don't exist anymore
+ EditionUtils.clearAllStereotypeCombinations(facade, editingDomain);
+ // Init new incompatibilities
+ EditionUtils.initAllStereotypeCombinations(facade, editingDomain);
+
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ getViewer().refresh();
+ }
+ }
+
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ if(element instanceof BaseMetaclass) {
+ if(!((BaseMetaclass)element).getExtensionDefinition().getExtension().isRequired()) {
+ return new CheckboxCellEditor(parent);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof BaseMetaclass) {
+ return Boolean.valueOf(((BaseMetaclass)element).isPossible());
+ }
+ return null;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassAliasColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassAliasColumnEditingSupport.java
new file mode 100644
index 00000000000..ff61b1514bf
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassAliasColumnEditingSupport.java
@@ -0,0 +1,56 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.swt.widgets.Composite;
+
+public class MetaclassAliasColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public MetaclassAliasColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualMetaclass) {
+ SetCommand command = new SetCommand(editingDomain, (VirtualMetaclass)element, VirtualmetamodelPackage.eINSTANCE.getVirtualElement_AliasName(), (String)value); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualMetaclass) {
+ if(((VirtualMetaclass)element).getAliasName() == null) {
+ return "";
+ } else {
+ return ((VirtualMetaclass)element).getAliasName();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return new TextCellEditor(parent);
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassIsAbstractColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassIsAbstractColumnEditingSupport.java
new file mode 100644
index 00000000000..e9489f3d8ad
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassIsAbstractColumnEditingSupport.java
@@ -0,0 +1,64 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.metamodel.MetamodelUtils;
+import org.eclipse.swt.widgets.Composite;
+
+public class MetaclassIsAbstractColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public MetaclassIsAbstractColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ if(element instanceof VirtualMetaclass) {
+
+ if(MetamodelUtils.canBeAbstract((VirtualMetaclass)element)) {
+ return new CheckboxCellEditor(parent);
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualMetaclass) {
+ return Boolean.valueOf(((VirtualMetaclass)element).isAbstract());
+ }
+ return null;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualMetaclass) {
+
+ SetCommand command = new SetCommand(editingDomain, (VirtualMetaclass)element, VirtualmetamodelPackage.eINSTANCE.getVirtualMetaclass_Abstract(), (Boolean)value); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+
+ }
+
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassToKeepColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassToKeepColumnEditingSupport.java
new file mode 100644
index 00000000000..e6527923f8f
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/MetaclassToKeepColumnEditingSupport.java
@@ -0,0 +1,67 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualElement;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetamodel;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.PrunerUtils;
+import org.eclipse.swt.widgets.Composite;
+
+public class MetaclassToKeepColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ protected Facade facade;
+
+ public MetaclassToKeepColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent, Facade facade) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ this.facade = facade;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualElement) {
+
+ VirtualMetamodel metamodel = facade.getVirtualmetamodel();
+
+ if(PrunerUtils.canBeUnkept((VirtualElement)element, metamodel)) {
+ SetCommand command = new SetCommand(editingDomain, (VirtualElement)element, VirtualmetamodelPackage.eINSTANCE.getVirtualElement_Kept(), (Boolean)value); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+ }
+
+
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualElement) {
+ return Boolean.valueOf(((VirtualElement)element).isKept());
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+
+ return new CheckboxCellEditor(parent);
+
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesAliasColumnEdintingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesAliasColumnEdintingSupport.java
new file mode 100644
index 00000000000..c887f4ac83b
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesAliasColumnEdintingSupport.java
@@ -0,0 +1,64 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualProperty;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.swt.widgets.Composite;
+
+public class PropertiesAliasColumnEdintingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public PropertiesAliasColumnEdintingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualProperty) {
+ // if(!(((VirtualProperty)element).getRepresentedElement() instanceof Property)) {
+ SetCommand command = new SetCommand(editingDomain, (VirtualProperty)element, VirtualmetamodelPackage.eINSTANCE.getVirtualElement_AliasName(), (String)value); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+ // }
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualProperty) {
+ // if(!(((VirtualProperty)element).getRepresentedElement() instanceof Property)) {
+ if(((VirtualProperty)element).getAliasName() == null) {
+ return "";
+ } else {
+ return ((VirtualProperty)element).getAliasName();
+ }
+ // }
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ // if(!(((VirtualProperty)element).getRepresentedElement() instanceof Property)) {
+ return new TextCellEditor(parent);
+ // } else {
+ // return null;
+ // }
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMaxColumnEdintingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMaxColumnEdintingSupport.java
new file mode 100644
index 00000000000..67cdca9d995
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMaxColumnEdintingSupport.java
@@ -0,0 +1,105 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualProperty;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Property;
+
+public class PropertiesMaxColumnEdintingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public PropertiesMaxColumnEdintingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualProperty) {
+
+ try {
+
+ if(((VirtualProperty)element).getRepresentedElement() instanceof Property || ((VirtualProperty)element).getRepresentedElement() instanceof EStructuralFeature) {
+ boolean isOk = false;
+ int intValue = Integer.valueOf((String)value);
+
+
+ if(intValue >= -1) {
+ int upperReference = 0;
+
+ if(((VirtualProperty)element).getRepresentedElement() instanceof Property) {
+ upperReference = ((Property)((VirtualProperty)element).getRepresentedElement()).getUpper();
+
+ } else if(((VirtualProperty)element).getRepresentedElement() instanceof EStructuralFeature) {
+ upperReference = ((EStructuralFeature)((VirtualProperty)element).getRepresentedElement()).getUpperBound();
+ }
+
+ if(upperReference != -1) {
+ if(intValue != -1) {
+ if(intValue <= upperReference) {
+ isOk = true;
+ }
+ }
+
+ } else {
+ isOk = true;
+ }
+
+ if(isOk) {
+ SetCommand command = new SetCommand(editingDomain, (VirtualProperty)element, VirtualmetamodelPackage.eINSTANCE.getVirtualProperty_Upper(), intValue); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+ } else {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with upper bound", "Custom upper bound must be <= " + upperReference);
+ }
+ } else {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with upper bound", "Upper bound must be an between [-1 and +inf[");
+ }
+ }
+
+ } catch (NumberFormatException ex) {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with upper bound", "Lower bound must be an integer.");
+ }
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualProperty) {
+
+ return ((VirtualProperty)element).getUpper() + "";
+
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ if(element instanceof VirtualProperty) {
+ return new TextCellEditor(parent);
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ if(element instanceof VirtualProperty) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMinColumnEdintingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMinColumnEdintingSupport.java
new file mode 100644
index 00000000000..51e905e2729
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesMinColumnEdintingSupport.java
@@ -0,0 +1,100 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualProperty;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Property;
+
+public class PropertiesMinColumnEdintingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public PropertiesMinColumnEdintingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualProperty) {
+
+ try {
+
+ if(((VirtualProperty)element).getRepresentedElement() instanceof Property || ((VirtualProperty)element).getRepresentedElement() instanceof EStructuralFeature) {
+ boolean isOk = false;
+ int intValue = Integer.valueOf((String)value);
+
+
+ if(intValue >= -1) {
+ int lowerReference = 0;
+
+ if(((VirtualProperty)element).getRepresentedElement() instanceof Property) {
+ lowerReference = ((Property)((VirtualProperty)element).getRepresentedElement()).getLower();
+
+ } else if(((VirtualProperty)element).getRepresentedElement() instanceof EStructuralFeature) {
+ lowerReference = ((EStructuralFeature)((VirtualProperty)element).getRepresentedElement()).getLowerBound();
+ }
+
+ if(lowerReference != -1) {
+ if(intValue >= lowerReference) {
+ isOk = true;
+ }
+ }
+
+ if(isOk) {
+ SetCommand command = new SetCommand(editingDomain, (VirtualProperty)element, VirtualmetamodelPackage.eINSTANCE.getVirtualProperty_Lower(), intValue); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+ } else {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with lower bound", "Custom lower bound must be >= " + lowerReference);
+ }
+ } else {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with upper bound", "Lower bound must be an between [-1 and +inf[");
+ }
+ }
+
+ } catch (NumberFormatException ex) {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Problem with lower bound", "Lower bound must be an integer.");
+ }
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualProperty) {
+
+ return ((VirtualProperty)element).getLower() + "";
+
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ if(element instanceof VirtualProperty) {
+ return new TextCellEditor(parent);
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ if(element instanceof VirtualProperty) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesToKeepColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesToKeepColumnEditingSupport.java
new file mode 100644
index 00000000000..43232326eff
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/PropertiesToKeepColumnEditingSupport.java
@@ -0,0 +1,59 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualElement;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.swt.widgets.Composite;
+
+public class PropertiesToKeepColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public PropertiesToKeepColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if(element instanceof VirtualElement) {
+
+ SetCommand command = new SetCommand(editingDomain, (VirtualElement)element, VirtualmetamodelPackage.eINSTANCE.getVirtualElement_Kept(), (Boolean)value); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ getViewer().refresh();
+
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof VirtualElement) {
+
+ return Boolean.valueOf(((VirtualElement)element).isKept());
+
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+
+ return new CheckboxCellEditor(parent);
+
+
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/StereotypeIncompatibilityColumnEditingSupport.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/StereotypeIncompatibilityColumnEditingSupport.java
new file mode 100644
index 00000000000..cc241f8d053
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/editingSupport/StereotypeIncompatibilityColumnEditingSupport.java
@@ -0,0 +1,374 @@
+package org.eclipse.papyrus.facadeSpecificEditor.editingSupport;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.Combination;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionFactory;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.FacadeSpecificEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class StereotypeIncompatibilityColumnEditingSupport extends EditingSupport {
+
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ protected Composite parent;
+
+ public StereotypeIncompatibilityColumnEditingSupport(ColumnViewer viewer, AdapterFactoryEditingDomain editingDomain, Composite parent) {
+ super(viewer);
+ this.editingDomain = editingDomain;
+ this.parent = parent;
+ }
+
+ protected void transformCompatibleIntoIncompatible(BaseMetaclass baseMetaclass, Combination combinaison) {
+ AddCommand command = new AddCommand(editingDomain, baseMetaclass, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), combinaison); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(command);
+ RemoveCommand removeCommand = new RemoveCommand(editingDomain, baseMetaclass, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), combinaison); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(removeCommand);
+ }
+
+ protected void transformAllCompatibleIntoIncompatible(BaseMetaclass baseMetaclass, Combination combinaison) {
+ Facade facade = baseMetaclass.getExtensionDefinition().getFacade();
+
+ transformCompatibleIntoIncompatible(baseMetaclass, combinaison);
+
+ // baseMetaclass, all children and generals must be set to Compatible
+ // HashSet<Stereotype> siblings = ProfileUtils.getSiblings(baseMetaclass.getExtensionDefinition().getStereotype());
+ // for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if(extensionDefinition.getExtension() == baseMetaclass.getExtensionDefinition().getExtension()) {
+ // if(siblings.contains(extensionDefinition.getStereotype())) {
+ // for(BaseMetaclass baseMetaclass1 : extensionDefinition.getBaseMetaclasses())
+ //
+ // if(baseMetaclass1.getBase() == baseMetaclass.getBase()) {
+ // Combination combi = EditionUtils.getCombinationThatMatch(baseMetaclass1.getCompatibleStereotypes(), combinaison);
+ // if(combi != null) {
+ // transformCompatibleIntoIncompatible(baseMetaclass1, combi);
+ // } else {
+ // System.err.println("Problem to find combinaison in sibling");
+ // }
+ // }
+ // }
+ // }
+ // }
+ }
+
+ protected void transformImcompatibleIntoCompatible(BaseMetaclass baseMetaclass, Combination combinaison) {
+ RemoveCommand removeCommand = new RemoveCommand(editingDomain, baseMetaclass, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_IncompatibleStereotypes(), combinaison); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(removeCommand);
+ AddCommand addCommand = new AddCommand(editingDomain, baseMetaclass, ExtensiondefinitionPackage.eINSTANCE.getBaseMetaclass_CompatibleStereotypes(), combinaison); //$NON-NLS-1$
+ editingDomain.getCommandStack().execute(addCommand);
+ }
+
+ protected void transformAllImcompatibleIntoCompatible(BaseMetaclass baseMetaclass, Combination combinaison) {
+ Facade facade = baseMetaclass.getExtensionDefinition().getFacade();
+
+ transformImcompatibleIntoCompatible(baseMetaclass, combinaison);
+
+ // baseMetaclass, all children and generals must be set to Incompatible
+ // HashSet<Stereotype> siblings = ProfileUtils.getSiblings(baseMetaclass.getExtensionDefinition().getStereotype());
+ // for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if(extensionDefinition.getExtension() == baseMetaclass.getExtensionDefinition().getExtension()) {
+ // if(siblings.contains(extensionDefinition.getStereotype())) {
+ // for(BaseMetaclass baseMetaclass1 : extensionDefinition.getBaseMetaclasses())
+ // if(baseMetaclass1.getBase() == baseMetaclass.getBase()) {
+ // Combination combi = EditionUtils.getCombinationThatMatch(baseMetaclass1.getIncompatibleStereotypes(), combinaison);
+ // if(combi != null) {
+ // transformImcompatibleIntoCompatible(baseMetaclass1, combi);
+ // } else {
+ // System.err.println("Problem to find combinaison in sibling");
+ // }
+ // }
+ // }
+ // }
+ // }
+ }
+
+ protected BaseMetaclass findCorrespondingGeneral(BaseMetaclass containerBaseMetaClass) {
+
+ Stereotype containerGeneral = containerBaseMetaClass.getExtensionDefinition().getExtension().getStereotype();
+
+ Facade facade = containerBaseMetaClass.getExtensionDefinition().getFacade();
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getExtension() == containerBaseMetaClass.getExtensionDefinition().getExtension()) {
+ if(extensionDefinition.getStereotype() == containerGeneral) {
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ if(baseMetaclass.getBase() == containerBaseMetaClass.getBase()) {
+ return baseMetaclass;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+
+ }
+
+ protected void proceedTheOtherWayCompatibleIntoIncompatible(Combination combination, boolean iAmNotARequired) {
+
+ for(BaseMetaclass meta : ((Combination)combination).getMembers()) {
+ // Build fake Combination that contain all the basemetaclass of the combinaison except the basemetaclass we are processing
+ Combination fakeCombination = ExtensiondefinitionFactory.eINSTANCE.createCombination();
+ for(BaseMetaclass metaFake : ((Combination)combination).getMembers()) {
+ if(meta != metaFake) {
+ fakeCombination.getMembers().add(metaFake);
+ }
+ }
+ // fake Combination + the general basemetaclass that own this combinaison
+ if(iAmNotARequired) {
+ BaseMetaclass containerBaseMetaClass = (BaseMetaclass)((Combination)combination).eContainer();
+ // BaseMetaclass general = findCorrespondingGeneral(containerBaseMetaClass);
+ BaseMetaclass general = containerBaseMetaClass;
+ fakeCombination.getMembers().add(general);
+ }
+
+ // if (!EditionUtils.containsOnlyRequired(fakeCombination)) {
+ // We go through the compatible combinaison of this basemeta and try to find the fake
+ Combination combinaison = EditionUtils.getCombinationThatMatch(meta.getCompatibleStereotypes(), fakeCombination);
+ if(combinaison != null) {
+ transformAllCompatibleIntoIncompatible(meta, combinaison);
+ } else {
+ System.err.println("Problem to find combinaison CompatibleIntoIncompatible");
+ }
+ // }
+ }
+ }
+
+ protected void proceedTheOtherWayImcompatibleIntoCompatible(Combination combination, boolean iAmNotARequired) {
+ for(BaseMetaclass meta : ((Combination)combination).getMembers()) {
+ // Build fake Combination that contain all the basemetaclass of the combinaison except the basemetaclass we are processing
+ Combination fakeCombination = ExtensiondefinitionFactory.eINSTANCE.createCombination();
+ for(BaseMetaclass metaFake : ((Combination)combination).getMembers()) {
+ if(meta != metaFake) {
+ fakeCombination.getMembers().add(metaFake);
+ }
+ }
+ // fake Combination + the basemetaclass that own this combinaison
+ if(iAmNotARequired) {
+ BaseMetaclass containerBaseMetaClass = (BaseMetaclass)((Combination)combination).eContainer();
+ // BaseMetaclass general = findCorrespondingGeneral(containerBaseMetaClass);
+ BaseMetaclass general = containerBaseMetaClass;
+ fakeCombination.getMembers().add(general);
+ }
+
+ // if (!EditionUtils.containsOnlyRequired(fakeCombination)) {
+ // We go through the incompatible combinaison of this basemeta and try to find the fake
+ Combination combinaison = EditionUtils.getCombinationThatMatch(meta.getIncompatibleStereotypes(), fakeCombination);
+ if(combinaison != null) {
+ transformAllImcompatibleIntoCompatible(meta, combinaison);
+ } else {
+ System.err.println("Problem to find combinaison ImcompatibleIntoCompatible");
+ }
+ // }
+
+ }
+ }
+
+ // protected void updateRequiredIntoIncompatible(Facade facade, BaseMetaclass baseMetaclass, Combination combination) {
+ // for (ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if (extensionDefinition.getExtension().isRequired()) {
+ // for (BaseMetaclass baseMetaclass2 : extensionDefinition.getBaseMetaclasses()) {
+ // if (baseMetaclass2.getMetaclass() == baseMetaclass.getMetaclass()) {
+ // // Build fake combination
+ // Combination fakeCombination = FacadeMetamodelFactory.eINSTANCE.createCombination();
+ // for (BaseMetaclass metaFake : combination.getMetaClasses()) {
+ // fakeCombination.getMetaClasses().add(metaFake);
+ // }
+ // BaseMetaclass containerBaseMetaClass = (BaseMetaclass) combination.eContainer();
+ // BaseMetaclass general = findCorrespondingGeneral(containerBaseMetaClass);
+ // fakeCombination.getMetaClasses().add(general);
+ //
+ // // We go through the compatible combinaison of this basemeta and try to find the fake
+ // Combination combinaison = EditionUtils.getCombinationThatMatch(baseMetaclass2.getCompatibleStereotypes(), fakeCombination);
+ // if (combinaison != null) {
+ // transformCompatibleIntoIncompatible(baseMetaclass2, combinaison);
+ // } else {
+ // System.err.println("Problem to find combinaison-update");
+ // }
+ // }
+ //
+ // }
+ // }
+ //
+ // }
+ //
+ // }
+ //
+ // protected void updateRequiredIntoCompatible(Facade facade, BaseMetaclass baseMetaclass, Combination combination) {
+ // for (ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if (extensionDefinition.getExtension().isRequired()) {
+ // for (BaseMetaclass baseMetaclass2 : extensionDefinition.getBaseMetaclasses()) {
+ // if (baseMetaclass2.getMetaclass() == baseMetaclass.getMetaclass()) {
+ // // Build fake combination
+ // Combination fakeCombination = FacadeMetamodelFactory.eINSTANCE.createCombination();
+ // for (BaseMetaclass metaFake : combination.getMetaClasses()) {
+ // fakeCombination.getMetaClasses().add(metaFake);
+ // }
+ // BaseMetaclass containerBaseMetaClass = (BaseMetaclass) combination.eContainer();
+ // BaseMetaclass general = findCorrespondingGeneral(containerBaseMetaClass);
+ // fakeCombination.getMetaClasses().add(general);
+ //
+ // // We go through the compatible combinaison of this basemeta and try to find the fake
+ // Combination combinaison = EditionUtils.getCombinationThatMatch(baseMetaclass2.getIncompatibleStereotypes(), fakeCombination);
+ // if (combinaison != null) {
+ // transformImcompatibleIntoCompatible(baseMetaclass2, combinaison);
+ // } else {
+ // System.err.println("Problem to find combinaison-update");
+ // }
+ // }
+ //
+ // }
+ // }
+ //
+ // }
+ //
+ // }
+
+ protected void makeItImcompatible(BaseMetaclass baseMetaclass, Combination combination, boolean bothWays) {
+
+ // if (!EditionUtils.containsOnlyRequired(combination)) {
+ // Facade facade = baseMetaclass.getExtensionDefinition().getFacade();
+
+ // Make it incompatible
+ // First way
+ transformAllCompatibleIntoIncompatible(baseMetaclass, combination);
+
+ // if (!baseMetaclass.getExtensionDefinition().getExtension().isRequired()) {
+ // The other way
+ proceedTheOtherWayCompatibleIntoIncompatible(combination, true);
+
+ // updateRequiredIntoIncompatible(facade, baseMetaclass, combination);
+ // } else {
+ // if (bothWays) {
+ // if (((Combination) combination).getMetaClasses().size() == 1) {
+ // // System.err.println("Ici : " + ((Combination) combination).getMetaClasses().get(0).getExtensionDefinition().getStereotype());
+ // IsPossibleColumnEditingSupport.transformAllPossibleIntoImpossible(((Combination) combination).getMetaClasses().get(0));
+ // } else {
+ // proceedTheOtherWayCompatibleIntoIncompatible(combination, false);
+ // }
+ // }
+ // }
+ // } else {
+ // MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cannot because required", "All those stereotypes are required");
+ // }
+ }
+
+ protected void makeItCompatible(BaseMetaclass baseMetaclass, Combination combination, boolean bothWays) {
+ // Facade facade = baseMetaclass.getExtensionDefinition().getFacade();
+
+ // First way
+ transformAllImcompatibleIntoCompatible(baseMetaclass, (Combination)combination);
+
+ // if (!baseMetaclass.getExtensionDefinition().getExtension().isRequired()) {
+ // The other way
+ proceedTheOtherWayImcompatibleIntoCompatible(combination, true);
+
+ // updateRequiredIntoCompatible(facade, baseMetaclass, combination);
+ // } else {
+ // if (bothWays) {
+ // if (((Combination) combination).getMetaClasses().size() == 1) {
+ // // System.err.println("Ici : " + ((Combination) combination).getMetaClasses().get(0).getExtensionDefinition().getStereotype());
+ // IsPossibleColumnEditingSupport.transformAllImpossibleIntoPossible(((Combination) combination).getMetaClasses().get(0));
+ // } else {
+ // proceedTheOtherWayImcompatibleIntoCompatible(combination, false);
+ // }
+ // }
+ // }
+ }
+
+ @Override
+ protected void setValue(final Object element, final Object value) {
+ if(element instanceof Combination) {
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ dialog.run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Updating stereotypes definitions", IProgressMonitor.UNKNOWN);
+
+ ISelection selection = FacadeSpecificEditor.getExtensionDefintionTreeViewer().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ Object first = ((IStructuredSelection)selection).getFirstElement();
+
+ if(first instanceof BaseMetaclass) {
+ BaseMetaclass baseMetaclass = (BaseMetaclass)first;
+
+ if((Boolean)value == false) {
+ makeItImcompatible(baseMetaclass, (Combination)element, true);
+ } else {
+ // Make it compatible
+ makeItCompatible(baseMetaclass, (Combination)element, true);
+
+ }
+
+ }
+ }
+
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ getViewer().refresh();
+ FacadeSpecificEditor.getExtensionDefintionTreeViewer().refresh();
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if(element instanceof Combination) {
+ ISelection selection = FacadeSpecificEditor.getExtensionDefintionTreeViewer().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ Object first = ((IStructuredSelection)selection).getFirstElement();
+
+ if(first instanceof BaseMetaclass) {
+ EList<Combination> incompatibleStereotypes = ((BaseMetaclass)first).getIncompatibleStereotypes();
+ if(incompatibleStereotypes.contains(element)) {
+ return Boolean.valueOf(false);
+ } else {
+ return Boolean.valueOf(true);
+ }
+ }
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+
+ return new CheckboxCellEditor(parent);
+
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/glue/GlueGenerator.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/glue/GlueGenerator.java
new file mode 100644
index 00000000000..1b405cb1c32
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/glue/GlueGenerator.java
@@ -0,0 +1,127 @@
+package org.eclipse.papyrus.facadeSpecificEditor.glue;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+
+public class GlueGenerator extends MouseAdapter {
+
+ protected Facade facade;
+
+ public GlueGenerator(Facade facade) {
+ super();
+ this.facade = facade;
+
+ }
+
+ protected void printHead(PrintStream printStream) {
+ printStream.println("import java.io.IOException;");
+ printStream.println("import java.io.InputStream;");
+ printStream.println("import java.io.OutputStream;");
+ printStream.println("import java.util.Map;");
+
+ printStream.println("import org.eclipse.emf.common.util.URI;");
+ printStream.println("import org.eclipse.emf.ecore.resource.ResourceSet;");
+ printStream.println("import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;");
+ printStream.println("import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;");
+ printStream.println("import org.eclipse.papyrus.FacadeMetamodel.FacadeMetamodel.Facade;");
+ printStream.println("import org.eclipse.papyrus.facacemetamodel.interpreter.Loader;");
+ printStream.println("import org.eclipse.papyrus.facacemetamodel.interpreter.Saver;");
+
+ printStream.println("public class MetamodelResourceImpl extends XMIResourceImpl {");
+
+ printStream.println("public MetamodelResourceImpl(URI uri) {");
+ printStream.println("super(uri);");
+ printStream.println("}");
+
+ }
+
+ protected void printDoLoad(PrintStream printStream) {
+ printStream.println("@Override");
+ printStream.println("public void doLoad(InputStream inputStream, Map<?, ?> options) throws IOException {");
+
+ printStream.println("URI facadeURI = URI.createPlatformPluginURI(\"/vitualProfile/model/My.facademetamodel\", true);");
+ printStream.println("ResourceSet resourceSet = new ResourceSetImpl();");
+ printStream.println("try {");
+ printStream.println("Object facade = resourceSet.getResource(facadeURI, true).getContents().get(0);");
+ printStream.println("if (facade != null) {");
+ printStream.println("if (facade instanceof Facade) {");
+
+ printStream.println("Loader.doLoad(inputStream, options, (Facade) facade);");
+ printStream.println("} else {");
+ printStream.println("System.err.println(\"Facade is not of right kind\");");
+ printStream.println("}");
+ printStream.println("} else {");
+ printStream.println("System.err.println(\"Cannot open facade model\");");
+ printStream.println("}");
+
+ printStream.println("} catch (Exception e) {");
+ printStream.println("e.printStackTrace();");
+ printStream.println("}");
+ printStream.println("}");
+ }
+
+ protected void printDoSave(PrintStream printStream) {
+ printStream.println("@Override");
+ printStream.println("public void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException {");
+ printStream.println("URI facadeURI = URI.createPlatformPluginURI(\"/vitualProfile/model/My.facademetamodel\", true);");
+ printStream.println("ResourceSet resourceSet = new ResourceSetImpl();");
+ printStream.println("try {");
+ printStream.println("Object facade = resourceSet.getResource(facadeURI, true).getContents().get(0);");
+ printStream.println("if (facade != null) {");
+ printStream.println("if (facade instanceof Facade) {");
+
+ printStream.println("Saver.doSave(outputStream, options, (Facade) facade, this);");
+ printStream.println("} else {");
+ printStream.println("System.err.println(\"Facade is not of right kind\");");
+ printStream.println("}");
+ printStream.println("} else {");
+ printStream.println("System.err.println(\"Cannot open facade model\");");
+ printStream.println("}");
+
+ printStream.println("} catch (Exception e) {");
+ printStream.println("e.printStackTrace();");
+ printStream.println("}");
+ printStream.println("}");
+ }
+
+ protected void printTail(PrintStream printStream) {
+ printStream.println("}");
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+
+ URI facadeURI = facade.eResource().getURI();
+
+ URI glueURI = facadeURI.appendFileExtension("java");
+
+ URIConverter uriConverter = new ExtensibleURIConverterImpl();
+
+ try {
+ OutputStream outputStream = uriConverter.createOutputStream(glueURI);
+ PrintStream printStream = new PrintStream(outputStream);
+
+ printHead(printStream);
+
+ printDoSave(printStream);
+
+ printDoLoad(printStream);
+
+ printTail(printStream);
+
+ printStream.close();
+
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/CreatePreliminaryMetamodelListener.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/CreatePreliminaryMetamodelListener.java
new file mode 100644
index 00000000000..04e81f01547
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/CreatePreliminaryMetamodelListener.java
@@ -0,0 +1,332 @@
+package org.eclipse.papyrus.facadeSpecificEditor.metamodel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.Combination;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensiondefinitionFactory;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.FacadeSpecificEditor;
+import org.eclipse.papyrus.facadeSpecificEditor.editingSupport.EditionUtils;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.StereotypeUtils;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.internal.impl.UMLPackageImpl;
+
+public class CreatePreliminaryMetamodelListener extends MouseAdapter {
+
+ Facade facade;
+
+ AdapterFactoryEditingDomain editingDomain;
+
+ protected static EPackage umlMetamodel = UMLPackageImpl.eINSTANCE;
+
+ public CreatePreliminaryMetamodelListener(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ super();
+ this.facade = facade;
+ this.editingDomain = editingDomain;
+ }
+
+
+
+ protected void initGeneralization(ExtensionDefinition extensionDefinition) {
+
+ BaseMetaclass baseMetaclass = MetamodelUtils.findActualBaseMetaclass(extensionDefinition);
+
+ if(baseMetaclass != null) {
+ ArrayList<BaseMetaclass> stereotypes = new ArrayList<BaseMetaclass>();
+ stereotypes.add(baseMetaclass);
+ MetamodelUtils.addMetaclass(StereotypeUtils.findBase(extensionDefinition), stereotypes, extensionDefinition.getStereotype().getName(), facade, editingDomain);
+ // MetamodelUtils.addMetaclass(extensionDefinition.getStereotype(), stereotypes, extensionDefinition.getStereotype().getName(), facade, editingDomain);
+
+ if(MetamodelUtils.hasSiblings(extensionDefinition)) {
+ //Create a Stereotype interface
+ MetamodelUtils.addStereotypeInterface(baseMetaclass.getExtensionDefinition().getStereotype(), baseMetaclass.getExtensionDefinition().getStereotype().getName() + "_applied", facade, editingDomain);
+ }
+
+ } else {
+ System.err.println("initGeneralization: Error can't find actual base metaclass : " + extensionDefinition.getStereotype());
+ }
+
+
+ }
+
+
+
+ protected void initAssociation(ExtensionDefinition extensionDefinition) {
+
+ BaseMetaclass baseMetaclass = MetamodelUtils.findActualBaseMetaclass(extensionDefinition);
+ if(baseMetaclass != null) {
+ ArrayList<BaseMetaclass> stereotypes = new ArrayList<BaseMetaclass>();
+ stereotypes.add(baseMetaclass);
+ String name = ((EClass)baseMetaclass.getBase()).getName() + "_" + baseMetaclass.getExtensionDefinition().getStereotype().getName();
+
+ MetamodelUtils.addMetaclass(baseMetaclass.getBase(), stereotypes, name, facade, editingDomain);
+ // MetamodelUtils.addMetaclass(extensionDefinition.getStereotype(), stereotypes, name, facade, editingDomain);
+
+ //Create property in the virtualmetaclass that represents the base metaclass to facilitate navigation
+ if(MetamodelUtils.isActualExtensionDefinition(extensionDefinition)) {
+ //Find the base metaclass
+ VirtualMetaclass virtualMetaclass = MetamodelUtils.findMetaclassWithNoRealStereoThatMatch((EClass)baseMetaclass.getBase(), facade);
+ //Add the property
+ MetamodelUtils.addProperty(virtualMetaclass, extensionDefinition.getExtension().getMemberEnds().get(0), name, facade, editingDomain);
+ }
+
+ if(MetamodelUtils.hasSiblings(extensionDefinition)) {
+ //Create a Stereotype interface
+ MetamodelUtils.addStereotypeInterface(baseMetaclass.getExtensionDefinition().getStereotype(), baseMetaclass.getExtensionDefinition().getStereotype().getName() + "_applied", facade, editingDomain);
+ }
+ }
+
+ // for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ //
+ // if(baseMetaclass.getBase() == StereotypeUtils.findEClass(baseMetaclass.getExtensionDefinition().getExtension().getMetaclass())) {
+ // ArrayList<BaseMetaclass> stereotypes = new ArrayList<BaseMetaclass>();
+ // stereotypes.add(baseMetaclass);
+ // String name = ((EClass)baseMetaclass.getBase()).getName() + "_" + baseMetaclass.getExtensionDefinition().getStereotype().getName();
+ //
+ // MetamodelUtils.addMetaclass(baseMetaclass.getBase(), stereotypes, name, facade, editingDomain);
+ //
+ // if(baseMetaclass.getExtensionDefinition().getStereotype().getGenerals().isEmpty()) {
+ // VirtualMetaclass virtualMetaclass = MetamodelUtils.findMetaclassWithNoRealStereoThatMatch((EClass)baseMetaclass.getBase(), facade);
+ // MetamodelUtils.addProperty(virtualMetaclass, baseMetaclass.getExtensionDefinition().getExtension(), name, facade, editingDomain);
+ // }
+ // }
+ // }
+
+ }
+
+ protected void initMultiGeneralization(ExtensionDefinition extensionDefinition) {
+ // Prepare possible METACLASS combinations
+ HashMap<EClass, ArrayList<Combination>> possibleMetaclasses = new HashMap<EClass, ArrayList<Combination>>();
+
+
+
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+
+ ArrayList<Combination> possibleCombinations = new ArrayList<Combination>();
+ if(possibleMetaclasses.containsKey(baseMetaclass.getBase())) {
+ possibleCombinations = possibleMetaclasses.get(baseMetaclass.getBase());
+ }
+
+ // If I am possible I am a combination
+ if(baseMetaclass.isPossible()) {
+ Combination combination = ExtensiondefinitionFactory.eINSTANCE.createCombination();
+ combination.getMembers().add(baseMetaclass);
+ if(!EditionUtils.containsCombination(possibleCombinations, combination)) {
+ possibleCombinations.add(combination);
+ }
+ }
+
+ // I take the compatible combination
+ for(Combination possibleCombination : baseMetaclass.getCompatibleStereotypes()) {
+
+
+ Combination combination = ExtensiondefinitionFactory.eINSTANCE.createCombination();
+ combination.getMembers().add(baseMetaclass);
+ combination.getMembers().addAll(possibleCombination.getMembers());
+ if(!EditionUtils.containsCombination(possibleCombinations, combination)) {
+ possibleCombinations.add(combination);
+ }
+
+ }
+
+ possibleMetaclasses.put((EClass)baseMetaclass.getBase(), possibleCombinations);
+
+ }
+
+
+
+ // Generate the possible METACLASS combinations
+ for(EClass representedElement : possibleMetaclasses.keySet()) {
+ for(Combination combination : possibleMetaclasses.get(representedElement)) {
+
+ MetamodelUtils.addMetaclass(representedElement, combination.getMembers(), createName(representedElement, combination), facade, editingDomain);
+
+ //Each stereotype that is used in a MultiGeneralization must be declared as a Stereotype interface
+ for(BaseMetaclass baseMetaclass : combination.getMembers()) {
+ Stereotype stereotype = baseMetaclass.getExtensionDefinition().getStereotype();
+ MetamodelUtils.addStereotypeInterface(stereotype, stereotype.getName() + "_applied", facade, editingDomain);
+ }
+
+ }
+ }
+ }
+
+
+
+ protected void initFusion(ExtensionDefinition extensionDefinition) {
+
+ if(extensionDefinition.getStereotype().getGenerals().isEmpty()) {
+ //Find virtualmetaclass that will be fusion with
+ VirtualMetaclass toFusionWith = MetamodelUtils.findMetaclassWithNoRealStereoThatMatch(StereotypeUtils.findBase(extensionDefinition), facade);
+
+ BaseMetaclass baseMetaclass = MetamodelUtils.findActualBaseMetaclass(extensionDefinition);
+ if(baseMetaclass != null) {
+ //Add the stereotype to fusion to the virtualmetaclasse that represent the base metaclass of the stereotype
+ if(!toFusionWith.getAppliedStereotypes().contains(baseMetaclass)) {
+ toFusionWith.getAppliedStereotypes().add(baseMetaclass);
+ }
+ }
+ } else {
+ //For the stereotype that inherit from the stereotype to fusion with the base metaclss, create corresponding virtualmetaclasses
+ BaseMetaclass baseMetaclass = MetamodelUtils.findActualBaseMetaclass(extensionDefinition);
+ ArrayList<BaseMetaclass> stereotypes = new ArrayList<BaseMetaclass>();
+ stereotypes.add(baseMetaclass);
+ MetamodelUtils.addMetaclass(StereotypeUtils.findBase(extensionDefinition), stereotypes, extensionDefinition.getStereotype().getName(), facade, editingDomain);
+ }
+ }
+
+
+ protected void initMetamodel() {
+
+ // Generate for the UML metamodel
+ for(EClassifier classifier : umlMetamodel.getEClassifiers()) {
+ MetamodelUtils.createForType(classifier, facade, editingDomain);
+ }
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getKind() == ExtensionDefinitionKind.GENERALIZATION) {
+ initGeneralization(extensionDefinition);
+ } else if(extensionDefinition.getKind() == ExtensionDefinitionKind.FUSION) {
+ initFusion(extensionDefinition);
+ } else if(extensionDefinition.getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ initAssociation(extensionDefinition);
+ } else if(extensionDefinition.getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ initMultiGeneralization(extensionDefinition);
+ }
+ }
+
+ initStereotypeInterfaces();
+
+ initAbstractMetaclasses(MetamodelUtils.getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers()));
+
+ MetamodelUtils.createPropertiesForAll(facade, editingDomain);
+
+ MetamodelUtils.createOperationsForAll(facade, editingDomain);
+
+ MetamodelUtils.createGeneralizations(facade, editingDomain);
+
+ // // Create a metaclass for each required stereotype that is defined as METACLASS
+ // for (ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ // if (extensionDefinition.getKind() == ExtensionDefinitionKind.METACLASS) {
+ // // if (extensionDefinition.getExtension().isRequired()) {
+ // for (BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ // String name = ((ENamedElement) baseMetaclass.getMetaclass()).getName() + "_" + baseMetaclass.getExtensionDefinition().getStereotype().getName();
+ // List<BaseMetaclass> stereotypes = new ArrayList<BaseMetaclass>();
+ // stereotypes.add(baseMetaclass);
+ // MetamodelCreationUtils.addMetaclass(baseMetaclass.getMetaclass(), check, true, stereotypes, name, facade, editingDomain);
+ // }
+ // // }
+ // }
+ // }
+
+ }
+
+ private void initStereotypeInterfaces() {
+ // for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ // if(classifier instanceof VirtualMetaclass) {
+ // if(!MetamodelUtils.onlyOneKind(((VirtualMetaclass)classifier).getAppliedStereotypes())) {
+ // List<Stereotype> stereotypes = MetamodelUtils.getStereotypesFromBaseMetaclass(((VirtualMetaclass)classifier).getAppliedStereotypes());
+ // if(stereotypes.size() == 1) {
+ //
+ // } else {
+ // System.err.println("initStereotypeInterfaces: Error with number of different applied stereotypes");
+ // }
+ // }
+ // }
+ // }
+ }
+
+
+
+ protected void initAbstractMetaclasses(List<VirtualMetaclass> list) {
+ for(VirtualMetaclass metaclass : list) {
+ metaclass.setAbstract(MetamodelUtils.mustBeAbstract(metaclass));
+ }
+ }
+
+ protected String createName(EClass representedElement, Combination combination) {
+ String name = representedElement.getName();
+
+ for(BaseMetaclass baseMetaclass : combination.getMembers()) {
+ name += "_" + baseMetaclass.getExtensionDefinition().getStereotype().getName();
+ }
+
+ return name;
+ }
+
+ protected boolean isFeasible() {
+
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(extensionDefinition.getExtension().isRequired()) {
+ // Is there another that is required with common basemetaclasses
+ for(ExtensionDefinition extensionDefinition2 : facade.getExtensionDefinitions()) {
+ if(!ProfileUtils.getSiblings(extensionDefinition.getStereotype()).contains(extensionDefinition2.getStereotype())) {
+ if(extensionDefinition2.getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(extensionDefinition2.getExtension().isRequired()) {
+ if(extensionDefinition != extensionDefinition2) {
+
+ List<EClass> baseMetaclasses = StereotypeUtils.getAllExtendableMetaclasses(extensionDefinition.getExtension(), true);
+ List<EClass> baseMetaclasses2 = StereotypeUtils.getAllExtendableMetaclasses(extensionDefinition2.getExtension(), true);
+
+ for(EClass eClass : baseMetaclasses) {
+ if(baseMetaclasses2.contains(eClass)) {
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), "Cannot generate metamodel", "Two or more required stereotypes are defined as metaclass on " + eClass.getName() + ". \nYou must define only one as MultiGeneralization.");
+ return false;
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if(isFeasible()) {
+
+ boolean proceed = false;
+ if(facade.getVirtualmetamodel().eContents().isEmpty()) {
+ proceed = true;
+ } else {
+ if(MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirmation", "We are going to erase the preliminary metamodel")) {
+ proceed = true;
+ }
+ }
+
+ if(proceed) {
+ // Command to execute for development only
+ RemoveCommand commandMetaclasses = new RemoveCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), facade.getVirtualmetamodel().getVirtualClassifiers());
+ editingDomain.getCommandStack().execute(commandMetaclasses);
+
+ initMetamodel();
+
+ FacadeSpecificEditor.getMetamodelTreeViewer().refresh();
+ }
+ }
+
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/EcoreGenerator.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/EcoreGenerator.java
new file mode 100644
index 00000000000..295fdb660d3
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/EcoreGenerator.java
@@ -0,0 +1,978 @@
+package org.eclipse.papyrus.facadeSpecificEditor.metamodel;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.ui.dialogs.DiagnosticDialog;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualClassifier;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualDatatype;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualElement;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualEnum;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualLiteral;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualProperty;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.StereotypeUtils;
+import org.eclipse.papyrus.facademapping.FacadeMappping;
+import org.eclipse.papyrus.facademapping.FacademappingFactory;
+import org.eclipse.papyrus.facademapping.Mapping;
+import org.eclipse.papyrus.facademapping.StereotypedMapping;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.types.TypesPackage;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.ExtensionEnd;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
+
+public class EcoreGenerator extends MouseAdapter {
+
+ Facade facade;
+
+ AdapterFactoryEditingDomain editingDomain;
+
+ protected Resource ecoreResource;
+
+ protected Resource mappingResource;
+
+ protected HashSet<VirtualMetaclass> propertiesProcessed;
+
+ protected HashSet<VirtualMetaclass> generalizationProcessed;
+
+ protected HashMap<VirtualProperty, EObject> processedProperty;
+
+ protected HashMap<VirtualLiteral, EObject> processedLiteral;
+
+ protected HashMap<VirtualClassifier, EClassifier> processedClassifier;
+
+ // protected HashMap<Stereotype, EClass> processedStereotype;
+
+ protected HashMap<VirtualProperty, EStructuralFeature> processedPropertyFeature;
+
+ protected static EPackage ecoreMetamodel = EcorePackage.eINSTANCE;
+
+ public EcoreGenerator(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ super();
+ this.facade = facade;
+ this.editingDomain = editingDomain;
+
+ propertiesProcessed = new HashSet<VirtualMetaclass>();
+ processedProperty = new HashMap<VirtualProperty, EObject>();
+ processedClassifier = new HashMap<VirtualClassifier, EClassifier>();
+ generalizationProcessed = new HashSet<VirtualMetaclass>();
+ processedLiteral = new HashMap<VirtualLiteral, EObject>();
+ // processedStereotype = new HashMap<Stereotype, EClass>();
+ processedPropertyFeature = new HashMap<VirtualProperty, EStructuralFeature>();
+ }
+
+ protected EObject createEcoreFile() {
+ URI ecoreURI = facade.eResource().getURI();
+ ecoreURI = ecoreURI.trimSegments(1);
+ ecoreURI = ecoreURI.appendSegment(facade.getVirtualmetamodel().getName() + ".ecore");
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ // Resource resource = resourceSet.getResource(ecoreURI, true);
+ ecoreResource = resourceSet.createResource(ecoreURI);
+
+ ecoreResource.getContents().clear();
+ EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ root.setName(facade.getVirtualmetamodel().getName());
+ root.setNsPrefix(facade.getVirtualmetamodel().getNsPrefix());
+ root.setNsURI(facade.getVirtualmetamodel().getNsURI());
+ ecoreResource.getContents().add(root);
+
+ EObject ecoreModel = ecoreResource.getContents().get(0);
+
+ return ecoreModel;
+ }
+
+ protected EObject createMappingFile() {
+ URI ecoreURI = facade.eResource().getURI();
+ ecoreURI = ecoreURI.trimSegments(1);
+ ecoreURI = ecoreURI.appendSegment(facade.getVirtualmetamodel().getName() + ".facademapping");
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ // Resource resource = resourceSet.getResource(ecoreURI, true);
+ mappingResource = resourceSet.createResource(ecoreURI);
+
+ mappingResource.getContents().clear();
+ FacadeMappping root = FacademappingFactory.eINSTANCE.createFacadeMappping();
+ mappingResource.getContents().add(root);
+
+ EObject mappingModel = mappingResource.getContents().get(0);
+
+ return mappingModel;
+ }
+
+ protected void save() {
+ try {
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, "UTF-8");
+
+ ecoreResource.save(options);
+
+ mappingResource.save(options);
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+
+ protected void setRepresenting(VirtualElement element, EObject representingElement, FacadeMappping facadeMappingModel) {
+
+ if(element instanceof VirtualMetaclass) {
+ if(!((VirtualMetaclass)element).getAppliedStereotypes().isEmpty()) {
+
+ StereotypedMapping mappingToEdit = FacademappingFactory.eINSTANCE.createStereotypedMapping();
+
+ List<Stereotype> stereotypes = new ArrayList<Stereotype>();
+
+ for(BaseMetaclass baseMetaclass : ((VirtualMetaclass)element).getAppliedStereotypes()) {
+ stereotypes.add(baseMetaclass.getExtensionDefinition().getStereotype());
+ }
+
+ if(MetamodelUtils.onlyOneKind(((VirtualMetaclass)element).getAppliedStereotypes(), ExtensionDefinitionKind.ASSOCIATION)) {
+ mappingToEdit.setKind(org.eclipse.papyrus.facademapping.ExtensionDefinitionKind.ASSOCIATION);
+ } else if(MetamodelUtils.onlyOneKind(((VirtualMetaclass)element).getAppliedStereotypes(), ExtensionDefinitionKind.GENERALIZATION)) {
+ mappingToEdit.setKind(org.eclipse.papyrus.facademapping.ExtensionDefinitionKind.GENERALIZATION);
+ } else if(MetamodelUtils.onlyOneKind(((VirtualMetaclass)element).getAppliedStereotypes(), ExtensionDefinitionKind.MULTI_GENERALIZATION)) {
+ mappingToEdit.setKind(org.eclipse.papyrus.facademapping.ExtensionDefinitionKind.MULTI_GENERALIZATION);
+ } else if(MetamodelUtils.onlyOneKind(((VirtualMetaclass)element).getAppliedStereotypes(), ExtensionDefinitionKind.FUSION)) {
+ mappingToEdit.setKind(org.eclipse.papyrus.facademapping.ExtensionDefinitionKind.FUSION);
+ } else {
+ System.err.println("setRepresenting : stereotypes are not only onekind on " + element.getRepresentedElement());
+ }
+
+ mappingToEdit.setUmlElement(element.getRepresentedElement());
+ mappingToEdit.setSpecificDomainElement(representingElement);
+ ((StereotypedMapping)mappingToEdit).getAppliedStereotypes().addAll(stereotypes);
+
+ facadeMappingModel.getMappings().add(mappingToEdit);
+
+ return;
+ }
+ }
+
+ Mapping mapping = FacademappingFactory.eINSTANCE.createMapping();
+ mapping.setUmlElement(element.getRepresentedElement());
+ mapping.setSpecificDomainElement(representingElement);
+
+ facadeMappingModel.getMappings().add(mapping);
+
+
+
+ // SetCommand command = new SetCommand(editingDomain, element, FacadePackage.eINSTANCE.getVirtualElement_RepresentingElement(), representingElement);
+ // editingDomain.getCommandStack().execute(command);
+ }
+
+
+ protected void createEnum(VirtualEnum virtualEnum, EPackage ecoreRoot, FacadeMappping facadeMappping) {
+ if(virtualEnum.getRepresentedElement() instanceof EEnum) {
+
+
+ EEnum enumeration = EcoreFactory.eINSTANCE.createEEnum();
+ enumeration.setName(virtualEnum.getAliasName());
+
+ for(VirtualLiteral literal : virtualEnum.getLiterals()) {
+ if(literal.getRepresentedElement() instanceof EEnumLiteral) {
+ EEnumLiteral enumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
+ enumLiteral.setName(literal.getAliasName());
+
+ enumLiteral.setValue(((EEnumLiteral)literal.getRepresentedElement()).getValue());
+ enumeration.getELiterals().add(enumLiteral);
+ setRepresenting(literal, enumLiteral, facadeMappping);
+ processedLiteral.put(literal, enumLiteral);
+ } else {
+ System.err.println("Litral : know the kind of enum literal : " + virtualEnum.getRepresentedElement());
+ }
+ }
+
+ ecoreRoot.getEClassifiers().add(enumeration);
+ setRepresenting(virtualEnum, enumeration, facadeMappping);
+ processedClassifier.put(virtualEnum, enumeration);
+
+ } else if(virtualEnum.getRepresentedElement() instanceof Enumeration) {
+ EEnum enumeration = EcoreFactory.eINSTANCE.createEEnum();
+ enumeration.setName(virtualEnum.getAliasName());
+
+ int i = 0;
+ for(VirtualLiteral literal : virtualEnum.getLiterals()) {
+ if(literal.getRepresentedElement() instanceof EnumerationLiteral) {
+ EEnumLiteral enumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
+ enumLiteral.setName(literal.getAliasName());
+
+ enumLiteral.setValue(i);
+ enumeration.getELiterals().add(enumLiteral);
+ setRepresenting(literal, enumLiteral, facadeMappping);
+ processedLiteral.put(literal, enumLiteral);
+ i++;
+ } else {
+ System.err.println("Litral : Don't know the kind of enum literal : " + literal.getRepresentedElement());
+ }
+ }
+
+ ecoreRoot.getEClassifiers().add(enumeration);
+ setRepresenting(virtualEnum, enumeration, facadeMappping);
+ processedClassifier.put(virtualEnum, enumeration);
+ } else {
+ System.err.println("Enum : We don't know the kind of represented Element: " + virtualEnum.getRepresentedElement());
+ }
+ }
+
+ protected void createDatatype(VirtualDatatype datatype, EPackage ecoreRoot, FacadeMappping facadeMappping) {
+ if(datatype.getRepresentedElement() instanceof EDataType) {
+ EDataType eDataType = EcoreFactory.eINSTANCE.createEDataType();
+ eDataType.setName(datatype.getAliasName());
+ eDataType.setInstanceTypeName(((EDataType)datatype.getRepresentedElement()).getInstanceTypeName());
+
+ ecoreRoot.getEClassifiers().add(eDataType);
+ setRepresenting(datatype, eDataType, facadeMappping);
+ processedClassifier.put(datatype, eDataType);
+ }
+ if(datatype.getRepresentedElement() instanceof PrimitiveType) {
+ EDataType eDataType = EcoreFactory.eINSTANCE.createEDataType();
+ eDataType.setName(datatype.getAliasName());
+
+ Stereotype stereotype = ((PrimitiveType)datatype.getRepresentedElement()).getAppliedStereotype("Ecore::EDataType");
+ if(stereotype != null) {
+ Object value = ((PrimitiveType)datatype.getRepresentedElement()).getValue(stereotype, "instanceClassName");
+ if(value instanceof String) {
+ eDataType.setInstanceTypeName((String)value);
+ }
+ }
+
+
+ ecoreRoot.getEClassifiers().add(eDataType);
+ setRepresenting(datatype, eDataType, facadeMappping);
+ processedClassifier.put(datatype, eDataType);
+ } else {
+ System.err.println("Datatype : We don't know the kind of represented Element: " + datatype.getRepresentedElement());
+ }
+ }
+
+ protected void createMetaclass(VirtualMetaclass metaclass, EPackage ecoreRoot, FacadeMappping facadeMappping) {
+
+ if(!processedClassifier.containsKey(metaclass)) {
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ eClass.setName(metaclass.getAliasName());
+ eClass.setAbstract(metaclass.isAbstract());
+
+ ecoreRoot.getEClassifiers().add(eClass);
+
+ setRepresenting(metaclass, eClass, facadeMappping);
+ processedClassifier.put(metaclass, eClass);
+ }
+ }
+
+ // protected void processEOppositeStereotypeProperty(Property attrStereotype, EReference attrib, EClass representingStereotype, FacadeMappping facadeMappping) {
+ // for(Property member : attrStereotype.getAssociation().getMemberEnds()) {
+ // if(member != attrStereotype) {
+ // if(!processedPropertyFeature.containsKey(member)) {
+ // EReference attribOpposite = EcoreFactory.eINSTANCE.createEReference();
+ // attribOpposite.setName(member.getName());
+ // attribOpposite.setLowerBound(member.getLower());
+ // attribOpposite.setUpperBound(member.getUpper());
+ //
+ // attribOpposite.setEType((EClassifier)processedClassifier.get(attrStereotype.getType()));
+ //
+ // representingStereotype.getEStructuralFeatures().add(attribOpposite);
+ // updateRepresenting(attrStereotype, attribOpposite, facadeMappping);
+ // processedPropertyFeature.put(attrStereotype, attribOpposite);
+ //
+ // attrib.setEOpposite(attribOpposite);
+ // } else {
+ // EStructuralFeature representingStereotrypeProperty = processedPropertyFeature.get(member);
+ // if(representingStereotrypeProperty instanceof EReference) {
+ // attrib.setEOpposite((EReference)representingStereotrypeProperty);
+ // } else {
+ // System.err.println("problem with kind of representingStereotrypeProperty : " + representingStereotrypeProperty);
+ // }
+ // }
+ // }
+ // }
+ // }
+
+ protected void createBooleanAttribute(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+ EAttribute attrib = EcoreFactory.eINSTANCE.createEAttribute();
+ attrib.setName(virtualProperty.getAliasName());
+ attrib.setLowerBound(virtualProperty.getLower());
+ attrib.setUpperBound(virtualProperty.getUpper());
+ attrib.setEType(EcorePackage.Literals.EBOOLEAN);
+
+ representingElement.getEStructuralFeatures().add(attrib);
+ setRepresenting(virtualProperty, attrib, facadeMappping);
+ // updateRepresenting(property, attrib, facadeMappping);
+ processedPropertyFeature.put(virtualProperty, attrib);
+ }
+
+ protected void createStringAttribute(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+ EAttribute attrib = EcoreFactory.eINSTANCE.createEAttribute();
+ attrib.setName(virtualProperty.getAliasName());
+ attrib.setLowerBound(virtualProperty.getLower());
+ attrib.setUpperBound(virtualProperty.getUpper());
+ attrib.setEType(EcorePackage.Literals.ESTRING);
+
+ representingElement.getEStructuralFeatures().add(attrib);
+ setRepresenting(virtualProperty, attrib, facadeMappping);
+ // updateRepresenting(property, attrib, facadeMappping);
+ processedPropertyFeature.put(virtualProperty, attrib);
+ }
+
+ protected void createIntegerAttribute(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+ EAttribute attrib = EcoreFactory.eINSTANCE.createEAttribute();
+ attrib.setName(virtualProperty.getAliasName());
+ attrib.setLowerBound(virtualProperty.getLower());
+ attrib.setUpperBound(virtualProperty.getUpper());
+ attrib.setEType(EcorePackage.Literals.EINT);
+
+ representingElement.getEStructuralFeatures().add(attrib);
+ setRepresenting(virtualProperty, attrib, facadeMappping);
+ // updateRepresenting(property, attrib, facadeMappping);
+ processedPropertyFeature.put(virtualProperty, attrib);
+ }
+
+ protected void createUnlimitedNaturalAttribute(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+ createIntegerAttribute(virtualProperty, representingElement, facadeMappping);
+ }
+
+ protected void createRealAttribute(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+ EAttribute attrib = EcoreFactory.eINSTANCE.createEAttribute();
+ attrib.setName(virtualProperty.getAliasName());
+ attrib.setLowerBound(virtualProperty.getLower());
+ attrib.setUpperBound(virtualProperty.getUpper());
+ attrib.setEType(EcorePackage.Literals.EFLOAT);
+
+ representingElement.getEStructuralFeatures().add(attrib);
+ setRepresenting(virtualProperty, attrib, facadeMappping);
+ // updateRepresenting(property, attrib, facadeMappping);
+ processedPropertyFeature.put(virtualProperty, attrib);
+ }
+
+ protected void processPropertyFeature(VirtualProperty virtualProperty, EClass representingElement, FacadeMappping facadeMappping) {
+
+ if(!processedPropertyFeature.containsKey(virtualProperty)) {
+ Property property = (Property)virtualProperty.getRepresentedElement();
+ // if(!property.getName().startsWith("base_")) {
+
+ EObject eType = StereotypeUtils.findEClass((Classifier)((Property)property).getType());
+
+ if(eType == TypesPackage.eINSTANCE.getBoolean()) {
+ createBooleanAttribute(virtualProperty, representingElement, facadeMappping);
+ } else if(eType == TypesPackage.eINSTANCE.getString()) {
+ createStringAttribute(virtualProperty, representingElement, facadeMappping);
+ } else if(eType == TypesPackage.eINSTANCE.getInteger()) {
+ createIntegerAttribute(virtualProperty, representingElement, facadeMappping);
+ } else if(eType == TypesPackage.eINSTANCE.getUnlimitedNatural()) {
+ createUnlimitedNaturalAttribute(virtualProperty, representingElement, facadeMappping);
+ } else if(eType == TypesPackage.eINSTANCE.getReal()) {
+ createRealAttribute(virtualProperty, representingElement, facadeMappping);
+ } else {
+
+ // VirtualClassifier typeVirtualMetaclass;
+ // EClassifier representingType = null;
+ // if(property instanceof ExtensionEnd) {
+ // EClassifier eClass = StereotypeUtils.findEClass((Classifier)property.getType());
+ // if(eClass != null) {
+ // typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(eClass, facade);
+ // representingType = processedClassifier.get(typeVirtualMetaclass);
+ // }
+ // } else {
+ // typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(property.getType(), facade);
+ // representingType = processedClassifier.get(typeVirtualMetaclass);
+ // }
+
+ EClassifier representingType = null;
+ if(eType != null) {
+ if(eType instanceof EClassifier) {
+ VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(eType, facade);
+ representingType = processedClassifier.get(typeVirtualMetaclass);
+ }
+ } else if(property instanceof ExtensionEnd) {
+ Property otherEnd = ((ExtensionEnd)property).getOtherEnd();
+ VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findMetaclassThatMatch(StereotypeUtils.findEClass((Classifier)otherEnd.getType()), (Stereotype)property.getType(), facade);
+ representingType = processedClassifier.get(typeVirtualMetaclass);
+ } else {
+ VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(property.getType(), facade);
+ representingType = processedClassifier.get(typeVirtualMetaclass);
+ }
+
+
+
+ // EClassifier representingType = null;
+ // EClassifier eClass = StereotypeUtils.findEClass((Classifier)property.getType());
+ // if(eClass != null) {
+ // VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(eClass, facade);
+ // representingType = processedClassifier.get(typeVirtualMetaclass);
+ // }
+
+ // VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(property.getType(), facade);
+ // EClassifier representingType = processedClassifier.get(typeVirtualMetaclass);
+
+ if(representingType != null) {
+ EStructuralFeature attrib;
+ if(representingType instanceof EDataType) {
+ attrib = EcoreFactory.eINSTANCE.createEAttribute();
+ } else {
+ attrib = EcoreFactory.eINSTANCE.createEReference();
+ }
+
+ attrib.setName(virtualProperty.getAliasName());
+ attrib.setLowerBound(virtualProperty.getLower());
+ attrib.setUpperBound(virtualProperty.getUpper());
+
+ if(attrib instanceof EReference) {
+ if(virtualProperty.getRepresentedElement() instanceof Property) {
+ if(((Property)virtualProperty.getRepresentedElement()).getClass_() instanceof Stereotype) {
+ if(!(((Property)virtualProperty.getRepresentedElement()).getType() instanceof Stereotype) && !(((Property)virtualProperty.getRepresentedElement()).getAssociation() instanceof Extension)) {
+ if(((Property)virtualProperty.getRepresentedElement()).getType().eClass().getEPackage() != UMLPackage.eINSTANCE) {
+ ((EReference)attrib).setContainment(true);
+ }
+ }
+ }
+
+ if(virtualProperty.getRepresentedElement() instanceof ExtensionEnd) {
+ ((EReference)attrib).setContainment(true);
+ }
+ }
+ }
+
+ if(property.getAssociation() != null) {
+ if(property.getAssociation().getOwnedEnds().size() == 1) {
+ if(property.getAssociation().getMemberEnds().size() == 2) {
+ // Do nothing
+ } else {
+ System.err.println("Don't know how to handle association because wrong number of member end : " + property.getAssociation());
+ }
+ } else {
+ System.err.println("Don't know how to handle association because wrong number of owned member : " + property.getAssociation());
+ }
+ }
+
+ attrib.setEType(representingType);
+
+ representingElement.getEStructuralFeatures().add(attrib);
+ setRepresenting(virtualProperty, attrib, facadeMappping);
+ // updateRepresenting(property, attrib, facadeMappping);
+ processedPropertyFeature.put(virtualProperty, attrib);
+ } else {
+ System.err.println("Property : Type not found for : " + property);
+ System.err.println("Property : Type not found for : " + property.getType());
+ }
+
+
+ }
+ // else if(processedStereotype.containsValue(propertyElement.getType())) {
+ // EReference attrib = EcoreFactory.eINSTANCE.createEReference();
+ // attrib.setName(propertyElement.getName());
+ // attrib.setLowerBound(propertyElement.getLower());
+ // attrib.setUpperBound(propertyElement.getUpper());
+ //
+ // if(propertyElement.getAssociation() != null) {
+ // if(propertyElement.getAssociation().getOwnedEnds().size() == 1) {
+ // if(propertyElement.getAssociation().getMemberEnds().size() == 2) {
+ // // Do nothing
+ // } else {
+ // System.err.println("Don't know how to handle association because wrong number of member end : " + propertyElement.getAssociation());
+ // }
+ // } else {
+ // System.err.println("Don't know how to handle association because wrong number of owned member : " + propertyElement.getAssociation());
+ // }
+ // }
+ //
+ // attrib.setEType((EClassifier)processedStereotype.get(propertyElement.getType()));
+ //
+ // representingElement.getEStructuralFeatures().add(attrib);
+ // updateRepresenting(propertyElement, attrib, facadeMappping);
+ // processedPropertyFeature.put(propertyElement, attrib);
+ // }
+ // else {
+ // System.err.println("problem to find representing type for property : " + propertyElement);
+ // System.err.println("\t-> " + propertyElement.getType());
+ // // for(EObject value : processedClassifier.values()) {
+ // // System.err.println("\t\t-" + value);
+ // // }
+ // }
+
+ // }
+ } else {
+ System.err.println("Virtual property already processed: " + virtualProperty);
+ }
+
+ }
+
+ // protected void createAppliedStereotypeElement(EPackage root, FacadeMappping facadeMappping) {
+ // HashSet<Stereotype> stereotypes = new HashSet<Stereotype>();
+ //
+ // for(VirtualMetaclass metaclass : MetamodelUtils.getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers())) {
+ // if(!metaclass.getAppliedStereotypes().isEmpty()) {
+ // for(BaseMetaclass baseMetaclass : metaclass.getAppliedStereotypes()) {
+ // if(baseMetaclass.getExtensionDefinition().getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ // stereotypes.add(baseMetaclass.getExtensionDefinition().getStereotype());
+ // }
+ // }
+ // }
+ // }
+ //
+ // // Create metaclass
+ // for(Stereotype stereotype : stereotypes) {
+ // EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ // eClass.setName(stereotype.getName() + "_applied");
+ // eClass.setAbstract(true);
+ //
+ // root.getEClassifiers().add(eClass);
+ // processedStereotype.put(stereotype, eClass);
+ // }
+ //
+ // // Create features
+ // for(Stereotype stereotype : processedStereotype.keySet()) {
+ // EClass representingStereotype = processedStereotype.get(stereotype);
+ //
+ // if(representingStereotype != null) {
+ //
+ // for(Property attrStereotype : stereotype.getAttributes()) {
+ // processStereotypeFeature(attrStereotype, representingStereotype, facadeMappping);
+ // }
+ //
+ // } else {
+ // System.err.println("problem to find representing appliedStereotype for : " + stereotype);
+ // }
+ // }
+ //
+ // }
+
+ // protected void updateRepresenting(Property attrStereotype, EStructuralFeature attrib, FacadeMappping facadeMapping) {
+ // boolean found = false;
+ // for(VirtualMetaclass virtualMetaclass : MetamodelUtils.getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers())) {
+ // for(VirtualProperty virtualProperty : virtualMetaclass.getProperties()) {
+ // if(virtualProperty.getRepresentedElement() == attrStereotype) {
+ // found = true;
+ // // setRepresenting(virtualProperty, attrib, facadeMappping,true);
+ // for(Mapping mapping : facadeMapping.getMappings()) {
+ // if(virtualProperty.getRepresentedElement() == mapping.getUmlElement()) {
+ // mapping.setUmlElement(virtualProperty.getRepresentedElement());
+ // mapping.setSpecificDomainElement(attrib);
+ // break;
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // if(!found) {
+ // System.err.println("Problem to find : " + attrStereotype);
+ // }
+ // }
+
+ protected void createGeneralisations(VirtualMetaclass metaclass, EPackage root, FacadeMappping facadeMappping) {
+
+ if(!generalizationProcessed.contains(metaclass)) {
+ EObject representingElement = processedClassifier.get(metaclass);
+ if(representingElement != null) {
+
+ generalizationProcessed.add(metaclass);
+
+ // Add generalization
+ for(VirtualMetaclass father : metaclass.getParents()) {
+ EObject elementReprensentingFather = processedClassifier.get(father);
+ if(representingElement instanceof EClass) {
+ if(elementReprensentingFather instanceof EClass) {
+ ((EClass)representingElement).getESuperTypes().add((EClass)elementReprensentingFather);
+ } else {
+ System.err.println("Problem with elementReprensentingFather kind: " + elementReprensentingFather);
+ }
+ } else {
+ System.err.println("Problem with representingElement kind: " + representingElement);
+
+ }
+ }
+
+ } else {
+ System.err.println("Problem with metaclass generalization generation for : " + metaclass);
+ }
+ } else {
+ System.err.println("Generalization already processed: " + metaclass);
+ }
+ }
+
+ protected void createProperties(VirtualMetaclass metaclass, EPackage root, FacadeMappping facadeMappping) {
+
+ if(!propertiesProcessed.contains(metaclass)) {
+ EObject representingElement = processedClassifier.get(metaclass);
+ if(representingElement != null) {
+
+
+ propertiesProcessed.add(metaclass);
+
+ // Create features
+ if(representingElement instanceof EClass) {
+ for(VirtualProperty property : metaclass.getProperties()) {
+ if(property.isKept()) {
+
+ if(property.getRepresentedElement() instanceof EAttribute) {
+ VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(((EAttribute)property.getRepresentedElement()).getEType(), facade);
+ EClassifier representingType = processedClassifier.get(typeVirtualMetaclass);
+ if(representingType != null) {
+ EAttribute attrib = (EAttribute)EcoreUtil.copy(property.getRepresentedElement());
+ attrib.setName(property.getAliasName());
+ attrib.setEType(representingType);
+
+ ((EClass)representingElement).getEStructuralFeatures().add(attrib);
+
+ setRepresenting(property, attrib, facadeMappping);
+ processedProperty.put(property, attrib);
+ } else {
+ System.err.println("EAttribute : Type not found for : " + property);
+ }
+ } else if(property.getRepresentedElement() instanceof EReference) {
+ VirtualClassifier typeVirtualMetaclass = MetamodelUtils.findClassifierThatMatch(((EReference)property.getRepresentedElement()).getEType(), facade);
+ EClassifier representingType = processedClassifier.get(typeVirtualMetaclass);
+ if(representingType != null) {
+ EReference attrib = (EReference)EcoreUtil.copy(property.getRepresentedElement());
+ attrib.setName(property.getAliasName());
+ attrib.setEType(representingType);
+
+ ((EClass)representingElement).getEStructuralFeatures().add(attrib);
+
+ setRepresenting(property, attrib, facadeMappping);
+ processedProperty.put(property, attrib);
+ } else {
+ System.err.println("EReference : Type not found for : " + property);
+ }
+ }
+ // else if(property.getRepresentedElement() instanceof Extension) {
+ // VirtualMetaclass associationStereotypeVirtualMetaclass = MetamodelUtils.findMetaclassThatMatch((EClass)StereotypeUtils.findEClass(((Extension)property.getRepresentedElement()).getMetaclass()), ((Extension)property.getRepresentedElement()).getStereotype(), facade);
+ // EObject representingAssociationStereotype = processedClassifier.get(associationStereotypeVirtualMetaclass);
+ // if(representingAssociationStereotype != null) {
+ //
+ // // The feature
+ // EReference attrib = EcoreFactory.eINSTANCE.createEReference();
+ // attrib.setName(property.getAliasName());
+ // attrib.setContainment(true);
+ // attrib.setEType((EClassifier)representingAssociationStereotype);
+ // if(((Extension)property.getRepresentedElement()).isRequired()) {
+ // attrib.setLowerBound(1);
+ // } else {
+ // attrib.setLowerBound(0);
+ // }
+ // attrib.setUpperBound(1);
+ //
+ // // And the opposite
+ // EReference attribOpposite = EcoreFactory.eINSTANCE.createEReference();
+ // attribOpposite.setName("base_" + ((Extension)property.getRepresentedElement()).getMetaclass().getName());
+ //
+ // attribOpposite.setEType((EClassifier)representingElement);
+ // attribOpposite.setLowerBound(1);
+ // attribOpposite.setUpperBound(1);
+ //
+ // ((EClass)representingAssociationStereotype).getEStructuralFeatures().add(attribOpposite);
+ // setRepresenting(property, attribOpposite, facadeMappping);
+ // processedProperty.put(property, attribOpposite);
+ //
+ // ((EClass)representingElement).getEStructuralFeatures().add(attrib);
+ // setRepresenting(property, attrib, facadeMappping);
+ // processedProperty.put(property, attrib);
+ //
+ // attrib.setEOpposite(attribOpposite);
+ // attribOpposite.setEOpposite(attrib);
+ //
+ // } else {
+ // System.err.println("Type not found for : " + property);
+ // }
+
+ // }
+ else if(property.getRepresentedElement() instanceof Property) {
+ processPropertyFeature(property, (EClass)representingElement, facadeMappping);
+ } else {
+ System.err.println("We don't know the kind of represented Property: " + property.getRepresentedElement());
+ }
+ }
+ }
+ } else {
+ System.err.println("Problem of type for metaclass properties generation for : " + metaclass);
+ }
+ } else {
+ System.err.println("Problem with metaclass properties generation for : " + metaclass);
+ }
+ } else {
+ System.err.println("Properties already processed: " + metaclass);
+ }
+
+ }
+
+ protected EReference findEOpposite(EReference eOpposite) {
+ VirtualMetaclass oppositeTypeVirtualMetaclass = MetamodelUtils.findMetaclassWithNoRealStereoThatMatch((EClassifier)eOpposite.eContainer(), facade);
+
+ VirtualProperty oppositeVirtualProperty = null;
+
+ if(oppositeTypeVirtualMetaclass != null) {
+ for(VirtualProperty virtualProperty : oppositeTypeVirtualMetaclass.getProperties()) {
+ EObject virtualPropertyRepresentedElement = virtualProperty.getRepresentedElement();
+
+ if(virtualPropertyRepresentedElement instanceof ENamedElement) {
+ if(((ENamedElement)virtualPropertyRepresentedElement).getName().equals(eOpposite.getName())) {
+ oppositeVirtualProperty = virtualProperty;
+ break;
+ }
+ } else if(virtualPropertyRepresentedElement instanceof ExtensionEnd) {
+
+ } else {
+ System.err.println("Don't know kind oppositeVirtualProperty : " + virtualPropertyRepresentedElement);
+ }
+ }
+
+ if(oppositeVirtualProperty != null) {
+ if(processedProperty.containsKey(oppositeVirtualProperty)) {
+ if(processedProperty.get(oppositeVirtualProperty) instanceof EReference) {
+ return (EReference)processedProperty.get(oppositeVirtualProperty);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ protected EObject findRepresenting(EObject umlElement, FacadeMappping facadeMappping) {
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(mapping.getUmlElement() == umlElement) {
+ return mapping.getSpecificDomainElement();
+ }
+ }
+ return null;
+ }
+
+ protected void processEOpposites(EPackage root, FacadeMappping facadeMappping) {
+ TreeIterator<EObject> it = root.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = (EObject)it.next();
+ if(eObject instanceof EReference) {
+ EReference reference = (EReference)eObject;
+
+ EReference eOpposite = reference.getEOpposite();
+
+ if(eOpposite != null) {
+ // if(!attrib.getName().startsWith("base_")) {
+ // if(!eOpposite.getName().startsWith("base_")) {
+ EReference representingEOpposite = findEOpposite(eOpposite);
+ if(representingEOpposite == null) {
+ System.err.println("Warning : Problem to update eopposite : " + eOpposite);
+ }
+ reference.setEOpposite(representingEOpposite);
+
+ // }
+ // }
+ } else {
+ for(Mapping mapping : facadeMappping.getMappings()) {
+ if(mapping.getSpecificDomainElement() == eObject) {
+ EObject umlElement = mapping.getUmlElement();
+ if(umlElement instanceof Property) {
+ Property otherEnd = ((Property)umlElement).getOtherEnd();
+ if(otherEnd != null) {
+ EObject otherEndRepresenting = findRepresenting(otherEnd, facadeMappping);
+ if(otherEndRepresenting instanceof EReference) {
+ reference.setEOpposite((EReference)otherEndRepresenting);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ // else if (eObject instanceof EAnnotation) {
+ // EcoreUtil.remove(eObject);
+ // }
+
+ }
+ }
+
+ protected void processEAnnotations(EPackage root) {
+ TreeIterator<EObject> it = root.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = (EObject)it.next();
+
+ if(eObject instanceof EAnnotation) {
+ String source = ((EAnnotation)eObject).getSource();
+ if(source.equals("subsets") || source.equals("redefines")) {
+ ArrayList<EObject> newList = new ArrayList<EObject>();
+ for(EObject reference : ((EAnnotation)eObject).getReferences()) {
+
+ VirtualProperty correspondingVirtualProperty = MetamodelUtils.findProperty(reference, facade);
+ if(correspondingVirtualProperty != null) {
+ EObject representing = processedProperty.get(correspondingVirtualProperty);
+ if(representing != null) {
+ newList.add(representing);
+ } else {
+ representing = processedPropertyFeature.get(correspondingVirtualProperty);
+ if(representing != null) {
+ newList.add(representing);
+ } else {
+ System.err.println("processEAnnotations: couldn't find representing for : " + correspondingVirtualProperty);
+ }
+ }
+ } else {
+ System.err.println("processEAnnotations: couldn't find correspondingVirtualMetaclass for : " + reference);
+ }
+ }
+
+ ((EAnnotation)eObject).getReferences().clear();
+ ((EAnnotation)eObject).getReferences().addAll(newList);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+ if(!facade.getVirtualmetamodel().getName().equals("") && !facade.getVirtualmetamodel().getNsPrefix().equals("") && !facade.getVirtualmetamodel().getNsURI().equals("")) {
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ dialog.run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Generate ecore metamodel", IProgressMonitor.UNKNOWN);
+
+ propertiesProcessed.clear();
+ generalizationProcessed.clear();
+ processedProperty.clear();
+ processedLiteral.clear();
+ processedClassifier.clear();
+ // processedStereotype.clear();
+ processedPropertyFeature.clear();
+
+ // Create files
+ EObject ecoreModel = createEcoreFile();
+ EObject facadeMapppingModel = createMappingFile();
+
+ if(ecoreModel instanceof EPackage) {
+ EPackage root = (EPackage)ecoreModel;
+ if(facadeMapppingModel instanceof FacadeMappping) {
+ FacadeMappping facadeMappping = (FacadeMappping)facadeMapppingModel;
+
+ // Create metaclasses first
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier.isKept()) {
+ if(classifier instanceof VirtualMetaclass) {
+ createMetaclass((VirtualMetaclass)classifier, root, facadeMappping);
+ } else if(classifier instanceof VirtualEnum) {
+ createEnum((VirtualEnum)classifier, root, facadeMappping);
+ } else if(classifier instanceof VirtualDatatype) {
+ createDatatype((VirtualDatatype)classifier, root, facadeMappping);
+ } else {
+ System.err.println("I don't know the kind of that classifier");;
+ }
+ }
+ }
+
+ // Create stereotyped element
+ // createAppliedStereotypeElement(root, facadeMappping);
+
+ // Hierarchy and features among metaclasses
+ for(VirtualMetaclass metaclass : MetamodelUtils.getOnlyVirtualMetaclasses(processedClassifier.keySet())) {
+ createGeneralisations(metaclass, root, facadeMappping);
+ createProperties(metaclass, root, facadeMappping);
+ }
+
+
+ // Process eOpposites
+ processEOpposites(root, facadeMappping);
+
+ //Clean eAnnotations
+ processEAnnotations(root);
+
+ // Save
+ save();
+
+ // Sanity check
+ TreeIterator<EObject> it = facade.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = (EObject)it.next();
+ if(eObject instanceof VirtualElement) {
+ // if(((VirtualElement)eObject).getRepresentingElement() == null) {
+ // System.err.println("This element doesn't have representing element : " + eObject);
+ // System.err.println("\tin " + eObject.eContainer());
+ // System.err.println("\tfor " + ((VirtualElement)eObject).getRepresentedElement());
+ // }
+ if(((VirtualElement)eObject).getRepresentedElement() == null) {
+ System.err.println("This element doesn't have represented element : " + eObject);
+ System.err.println("\tin " + eObject.eContainer());
+ System.err.println("\tfor " + ((VirtualElement)eObject).getRepresentedElement());
+ }
+ }
+ }
+
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(root);
+
+
+ if(diagnostic.getSeverity() == Diagnostic.OK) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Validation of the generated metamodel", "The generated metamodel seems OK. ");
+
+ } else {
+ DiagnosticDialog dialog = new DiagnosticDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Validation of the generated metamodel", "The generated metamodel contains issues that you must fix in the preliminary metamodel. \nYou may open the generated metamodel to spot the problem but don't fix it manualy. ", diagnostic, Diagnostic.OK | Diagnostic.INFO | Diagnostic.WARNING | Diagnostic.ERROR);
+
+ dialog.open();
+
+ }
+
+ monitor.done();
+ }
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), "Metamodel name, nsPrefix and nsURI", "Metamodel name, nsPrefix and nsURI must not be empty");
+ }
+
+ }
+
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/MetamodelUtils.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/MetamodelUtils.java
new file mode 100644
index 00000000000..20019d1e4ca
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/metamodel/MetamodelUtils.java
@@ -0,0 +1,1029 @@
+package org.eclipse.papyrus.facadeSpecificEditor.metamodel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualClassifier;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualDatatype;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualEnum;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualLiteral;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualOperation;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualParameter;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualProperty;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelFactory;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualmetamodelPackage;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.StereotypeUtils;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class MetamodelUtils {
+
+ public static boolean containsOnlyRequiredBaseMetaclass(List<BaseMetaclass> list) {
+ if(!list.isEmpty()) {
+ for(BaseMetaclass baseMetaclass : list) {
+ if(baseMetaclass.getExtensionDefinition().getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(!baseMetaclass.getExtensionDefinition().getExtension().isRequired()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean containsAbstractStereotype(EList<BaseMetaclass> list) {
+ for(BaseMetaclass baseMetaclass : list) {
+ if(baseMetaclass.getExtensionDefinition().getStereotype().isAbstract()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static List<VirtualMetaclass> getOnlyVirtualMetaclasses(Collection<VirtualClassifier> list) {
+ List<VirtualMetaclass> result = new ArrayList<VirtualMetaclass>();
+ for(VirtualClassifier classifier : list) {
+ if(classifier instanceof VirtualMetaclass) {
+ result.add((VirtualMetaclass)classifier);
+ }
+ }
+ return result;
+ }
+
+ public static boolean containsOnlyAbstractStereotype(EList<BaseMetaclass> list) {
+ if(!list.isEmpty()) {
+ for(BaseMetaclass baseMetaclass : list) {
+ if(!baseMetaclass.getExtensionDefinition().getStereotype().isAbstract()) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static VirtualClassifier findClassifierThatMatch(EObject element, Facade facade) {
+
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+
+ if(classifier.getRepresentedElement() == element) {
+ if(classifier instanceof VirtualMetaclass) {
+
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().isEmpty() || onlyOneKind(((VirtualMetaclass)classifier).getAppliedStereotypes(), ExtensionDefinitionKind.FUSION)) {
+ return ((VirtualMetaclass)classifier);
+ }
+
+ } else {
+ return classifier;
+ }
+ }
+ }
+
+ //Try to find as an association
+ if(element instanceof Stereotype) {
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier instanceof VirtualMetaclass) {
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().size() == 1) {
+ if(onlyOneKind(((VirtualMetaclass)classifier).getAppliedStereotypes(), ExtensionDefinitionKind.ASSOCIATION)) {
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype() == element) {
+ return classifier;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ return null;
+ }
+
+ public static VirtualMetaclass findMetaclassWithNoRealStereoThatMatch(EObject eClassifier, Facade facade) {
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+
+ if(classifier instanceof VirtualMetaclass) {
+ if(((VirtualMetaclass)classifier).getRepresentedElement() == eClassifier) {
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().isEmpty() || onlyOneKind(((VirtualMetaclass)classifier).getAppliedStereotypes(), ExtensionDefinitionKind.FUSION)) {
+
+ return ((VirtualMetaclass)classifier);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static VirtualProperty findProperty(EObject feature, Facade facade) {
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier instanceof VirtualMetaclass)
+ for(VirtualProperty property : ((VirtualMetaclass)classifier).getProperties()) {
+ if(property.getRepresentedElement() == feature) {
+ return property;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static BaseMetaclass findActualBaseMetaclass(ExtensionDefinition extensionDefinition) {
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ if(baseMetaclass.getBase() == StereotypeUtils.findBase(extensionDefinition)) {
+ return baseMetaclass;
+
+ }
+ }
+ return null;
+
+ }
+
+ public static VirtualMetaclass findMetaclassThatMatch(EObject eClass, Stereotype stereo, Facade facade) {
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier.getRepresentedElement() == eClass) {
+
+ if(classifier instanceof VirtualMetaclass) {
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().size() == 1) {
+
+ if(((VirtualMetaclass)classifier).getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype() == stereo) {
+ return ((VirtualMetaclass)classifier);
+ }
+
+ }
+ }
+ }
+
+ }
+ return null;
+ }
+
+ public static boolean isActualExtensionDefinition(ExtensionDefinition extensionDefinition) {
+
+ if(extensionDefinition.getExtension().getStereotype() == extensionDefinition.getStereotype()) {
+ return true;
+ }
+
+ return false;
+
+ }
+
+ public static boolean onlyOneKind(List<BaseMetaclass> list, ExtensionDefinitionKind kind) {
+ for(BaseMetaclass baseMetaclass : list) {
+ if(baseMetaclass.getExtensionDefinition().getKind() != kind) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean hasSiblings(ExtensionDefinition extensionDefinition) {
+ Facade facade = extensionDefinition.getFacade();
+
+ for(ExtensionDefinition otherExtensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition != otherExtensionDefinition) {
+ if(extensionDefinition.getStereotype() == otherExtensionDefinition.getStereotype()) {
+ return true;
+ }
+
+ }
+ }
+ return false;
+ }
+
+ public static ArrayList<VirtualMetaclass> findThoseToSpecialize(VirtualMetaclass metaclassInput, Facade facade) {
+ ArrayList<VirtualMetaclass> output = new ArrayList<VirtualMetaclass>();
+ BaseMetaclass requiredBaseMetaclass = null;
+
+ // Find the required one
+ for(BaseMetaclass baseMetaclass : metaclassInput.getAppliedStereotypes()) {
+ if(baseMetaclass.getExtensionDefinition().getExtension().isRequired()) {
+ requiredBaseMetaclass = baseMetaclass;
+ break;
+ }
+ }
+
+ if(requiredBaseMetaclass != null) {
+
+ // System.err.println("For \"" + metaclassInput.getAliasName() + "\"The required : " + requiredBaseMetaclass.getExtensionDefinition().getStereotype().getName());
+
+ output.add(findMetaclassThatMatch((EClass)requiredBaseMetaclass.getBase(), requiredBaseMetaclass.getExtensionDefinition().getStereotype(), facade));
+ // HashSet<Stereotype> siblings = ProfileUtils.getSiblings(requiredBaseMetaclass.getExtensionDefinition().getStereotype());
+ // for (Stereotype stereotype : siblings) {
+ // if (!stereotype.isAbstract()) {
+ // // Find metaclass corresponding
+ // output.add(findMetaclassThatMatch((EClass) requiredBaseMetaclass.getBase(), stereotype, facade));
+ // }
+ // }
+
+ } else {
+ output.add(findMetaclassWithNoRealStereoThatMatch((EClass)metaclassInput.getRepresentedElement(), facade));
+ }
+
+ return output;
+
+ }
+
+ public static List<VirtualMetaclass> getAllFathers(VirtualMetaclass metaclass) {
+
+ List<VirtualMetaclass> toProcess = new ArrayList<VirtualMetaclass>();
+ List<VirtualMetaclass> output = new ArrayList<VirtualMetaclass>();
+
+ toProcess.addAll(getFathers(metaclass));
+ while(!toProcess.isEmpty()) {
+ VirtualMetaclass father = toProcess.remove(0);
+ output.add(father);
+ toProcess.addAll(getFathers(father));
+ }
+
+ return output;
+
+ }
+
+ public static List<VirtualMetaclass> getFathers(VirtualMetaclass metaclass) {
+ List<VirtualMetaclass> output = new ArrayList<VirtualMetaclass>();
+
+ // System.err.println("\t+" + metaclass);
+ // System.err.println("\t++" + metaclass.getMetamodel());
+ // System.err.println("\t+++" + metaclass.getMetamodel().getFacade());
+ Facade facade = ((VirtualMetaclass)metaclass).getMetamodel().getFacade();
+
+ if(metaclass.getAppliedStereotypes().isEmpty() || onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.FUSION)) {
+ if(metaclass.getRepresentedElement() instanceof EClass) {
+ EList<EClass> supers = ((EClass)metaclass.getRepresentedElement()).getESuperTypes();
+ for(EClass eClass : supers) {
+ VirtualMetaclass meta = findMetaclassWithNoRealStereoThatMatch(eClass, facade);
+ if(meta != null) {
+ output.add(meta);
+ }
+ }
+ }
+ } else if(onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.MULTI_GENERALIZATION)) {
+ if(MetamodelUtils.containsOnlyRequiredBaseMetaclass(metaclass.getAppliedStereotypes())) {
+ if(metaclass.getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype().getGenerals().isEmpty()) {
+ output.add(findMetaclassWithNoRealStereoThatMatch((EClass)metaclass.getAppliedStereotypes().get(0).getBase(), facade));
+ } else {
+ EList<Classifier> supersStereo = metaclass.getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype().getGenerals();
+ for(Classifier superStereo : supersStereo) {
+ output.add(findMetaclassThatMatch(metaclass.getRepresentedElement(), (Stereotype)superStereo, facade));
+ }
+ }
+ } else {
+ // Get the one that we must extend
+ output.addAll(findThoseToSpecialize(metaclass, facade));
+ }
+
+ //Add the StereotypeInterface to generals
+ for(BaseMetaclass stereotype : metaclass.getAppliedStereotypes()) {
+ output.add(findStereotypeInterface(stereotype));
+ }
+
+ }
+ // else {
+ // for(BaseMetaclass baseMetaclass : metaclass.getAppliedStereotypes()) {
+ // if(baseMetaclass.getExtensionDefinition().getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ // EList<Classifier> supersStereo = baseMetaclass.getExtensionDefinition().getStereotype().getGenerals();
+ // for(Classifier superStereo : supersStereo) {
+ // output.add(findMetaclassThatMatch((Stereotype)superStereo, (Stereotype)superStereo, facade));
+ // }
+ //
+ // } else if(baseMetaclass.getExtensionDefinition().getKind() == ExtensionDefinitionKind.GENERALIZATION) {
+ // EList<Classifier> supersStereo = baseMetaclass.getExtensionDefinition().getStereotype().getGenerals();
+ // if(!supersStereo.isEmpty()) {
+ // for(Classifier superStereo : supersStereo) {
+ // output.add(findMetaclassThatMatch(metaclass.getRepresentedElement(), (Stereotype)superStereo, facade));
+ // // output.add(findMetaclassThatMatch((Stereotype)superStereo, (Stereotype)superStereo, facade));
+ // }
+ // } else {
+ // output.add(findMetaclassWithNoRealStereoThatMatch(metaclass.getRepresentedElement(), facade));
+ // // output.add(findMetaclassWithNoRealStereoThatMatch(StereotypeUtils.findBase(metaclass.getAppliedStereotypes().get(0).getExtensionDefinition()), facade));
+ // }
+ // } else {
+ // System.err.println("Don't know how to represent : " + metaclass.getAliasName());
+ // }
+ // }
+ // }
+ else if(onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.ASSOCIATION)) {
+ // EList<Classifier> supersStereo = metaclass.getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype().getGenerals();
+ for(BaseMetaclass baseMetaclass : metaclass.getAppliedStereotypes()) {
+ EList<Classifier> supersStereo = baseMetaclass.getExtensionDefinition().getStereotype().getGenerals();
+ for(Classifier superStereo : supersStereo) {
+ output.add(findMetaclassThatMatch(metaclass.getRepresentedElement(), (Stereotype)superStereo, facade));
+ }
+ }
+
+ if(hasSiblings(metaclass.getAppliedStereotypes().get(0).getExtensionDefinition())) {
+ //Add the StereotypeInterface to generals
+ for(BaseMetaclass stereotype : metaclass.getAppliedStereotypes()) {
+ output.add(findStereotypeInterface(stereotype));
+ }
+ }
+ } else if(onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.GENERALIZATION)) {
+ for(BaseMetaclass baseMetaclass : metaclass.getAppliedStereotypes()) {
+ // EList<Classifier> supersStereo = metaclass.getAppliedStereotypes().get(0).getExtensionDefinition().getStereotype().getGenerals();
+ EList<Classifier> supersStereo = baseMetaclass.getExtensionDefinition().getStereotype().getGenerals();
+ if(!supersStereo.isEmpty()) {
+ for(Classifier superStereo : supersStereo) {
+ output.add(findMetaclassThatMatch(metaclass.getRepresentedElement(), (Stereotype)superStereo, facade));
+ // output.add(findMetaclassThatMatch((Stereotype)superStereo, (Stereotype)superStereo, facade));
+ }
+ } else {
+ // output.add(findMetaclassWithNoRealStereoThatMatch(metaclass.getRepresentedElement(), facade));
+ output.add(findMetaclassWithNoRealStereoThatMatch(StereotypeUtils.findBase(metaclass.getAppliedStereotypes().get(0).getExtensionDefinition()), facade));
+ }
+ }
+
+ if(hasSiblings(metaclass.getAppliedStereotypes().get(0).getExtensionDefinition())) {
+ //Add the StereotypeInterface to generals
+ for(BaseMetaclass stereotype : metaclass.getAppliedStereotypes()) {
+ output.add(findStereotypeInterface(stereotype));
+ }
+ }
+ } else {
+ System.err.println("Don't know how to get fathers : " + metaclass.getAliasName());
+ }
+
+
+ return output;
+ }
+
+ public static VirtualMetaclass findStereotypeInterface(BaseMetaclass stereotype) {
+ List<VirtualMetaclass> allVirtualMetaclasses = getOnlyVirtualMetaclasses(stereotype.getExtensionDefinition().getFacade().getVirtualmetamodel().getVirtualClassifiers());
+
+ for(VirtualMetaclass virtualMetaclass : allVirtualMetaclasses) {
+ if(virtualMetaclass.isStereotypeInterface()) {
+ if(virtualMetaclass.getRepresentedElement() == stereotype.getExtensionDefinition().getStereotype()) {
+ return virtualMetaclass;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static List<VirtualMetaclass> getChildren(VirtualMetaclass parent) {
+ List<VirtualMetaclass> children = new ArrayList<VirtualMetaclass>();
+
+ for(VirtualClassifier classifier : parent.getMetamodel().getVirtualClassifiers()) {
+
+ if(classifier instanceof VirtualMetaclass)
+ if(MetamodelUtils.getFathers((VirtualMetaclass)classifier).contains(parent)) {
+ children.add((VirtualMetaclass)classifier);
+ }
+ }
+
+ return children;
+ }
+
+ public static List<VirtualMetaclass> getAllChildren(VirtualMetaclass parent) {
+ List<VirtualMetaclass> toProcess = new ArrayList<VirtualMetaclass>();
+ List<VirtualMetaclass> output = new ArrayList<VirtualMetaclass>();
+
+ toProcess.addAll(getChildren(parent));
+ while(!toProcess.isEmpty()) {
+ VirtualMetaclass child = toProcess.remove(0);
+ output.add(child);
+ toProcess.addAll(getChildren(child));
+ }
+
+ return output;
+ }
+
+ public static boolean mustBeAbstract(VirtualMetaclass metaclass) {
+ if(metaclass.isStereotypeInterface()) {
+ return true;
+ }
+ if(metaclass.getAppliedStereotypes().isEmpty()) {
+ if(metaclass.getRepresentedElement() instanceof EClass) {
+ if(((EClass)metaclass.getRepresentedElement()).isAbstract()) {
+ return true;
+ } else {
+
+ if(containsOnlyRequired(getChildren(metaclass))) {
+ return true;
+ }
+ }
+ }
+ } else {
+ if(containsOnlyAbstractStereotype(metaclass.getAppliedStereotypes())) {
+ return true;
+ }
+ }
+
+ return false;
+
+ }
+
+ private static boolean containsOnlyRequired(List<VirtualMetaclass> children) {
+ if(!children.isEmpty()) {
+ for(VirtualMetaclass metaclass : children) {
+ if(!containsOnlyRequiredBaseMetaclass(metaclass.getAppliedStereotypes())) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean canBeAbstract(VirtualMetaclass metaclass) {
+
+ Facade facade = metaclass.getMetamodel().getFacade();
+ if(!mustBeAbstract(metaclass)) {
+ for(VirtualMetaclass child : getAllChildren(metaclass)) {
+ if(child.isKept()) {
+ if(!child.isAbstract()) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+
+ }
+
+ public static boolean isStereotypableByMetaclassKind(EClass classifier, Facade facade) {
+ for(ExtensionDefinition extensionDefinition : facade.getExtensionDefinitions()) {
+ if(extensionDefinition.getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ for(BaseMetaclass baseMetaclass : extensionDefinition.getBaseMetaclasses()) {
+ if(baseMetaclass.isPossible() == true) {
+ if(baseMetaclass.getBase() == classifier) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static List<Stereotype> getStereotypesFromBaseMetaclass(List<BaseMetaclass> list) {
+ List<Stereotype> result = new ArrayList<Stereotype>();
+ for(BaseMetaclass baseMetaclass : list) {
+ if(!result.contains(baseMetaclass.getExtensionDefinition().getStereotype())) {
+ result.add(baseMetaclass.getExtensionDefinition().getStereotype());
+ }
+ }
+ return result;
+ }
+
+ public static VirtualClassifier addMetaclass(EObject representedElement, List<BaseMetaclass> stereotypes, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+
+ VirtualClassifier output = null;
+
+ //Verify that the virtualmetaclass doesn't exist already
+ boolean found = false;
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+
+ if(classifier.getRepresentedElement() == representedElement) {
+ if(stereotypes != null) {
+ List<Stereotype> classifierStereotypes = getStereotypesFromBaseMetaclass(((VirtualMetaclass)classifier).getAppliedStereotypes());
+ List<Stereotype> stereotypesToAdd = getStereotypesFromBaseMetaclass(stereotypes);
+ if(classifierStereotypes.size() == stereotypesToAdd.size()) {
+
+ if(classifierStereotypes.containsAll(stereotypesToAdd)) {
+ output = ((VirtualMetaclass)classifier);
+ found = true;
+ break;
+ }
+ }
+ } else {
+ output = classifier;
+ found = true;
+ break;
+ }
+
+ }
+ }
+
+ if(!found) {
+ if(representedElement instanceof PrimitiveType) {
+ VirtualDatatype datatype = VirtualmetamodelFactory.eINSTANCE.createVirtualDatatype();
+ datatype.setKept(true);
+ datatype.setRepresentedElement(representedElement);
+ datatype.setAliasName(alias);
+ AddCommand command = new AddCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), datatype);
+ editingDomain.getCommandStack().execute(command);
+
+ output = datatype;
+ } else {
+ VirtualMetaclass metaclass = VirtualmetamodelFactory.eINSTANCE.createVirtualMetaclass();
+ metaclass.setKept(true);
+ metaclass.setRepresentedElement(representedElement);
+ metaclass.setAbstract(false);
+ metaclass.setStereotypeInterface(false);
+ if(stereotypes != null) {
+ metaclass.getAppliedStereotypes().addAll(stereotypes);
+ }
+ metaclass.setAliasName(alias);
+ AddCommand command = new AddCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), metaclass);
+ editingDomain.getCommandStack().execute(command);
+
+ output = metaclass;
+ }
+ } else {
+ // if(stereotypes != null) {
+ // for(BaseMetaclass stereo : stereotypes) {
+ // if(!output.getAppliedStereotypes().contains(stereo)) {
+ // output.getAppliedStereotypes().add(stereo);
+ // }
+ // }
+ // }
+ System.err.println("addMetaclass: I didn't add because already represented : " + representedElement);
+ }
+
+ return output;
+ }
+
+ public static VirtualEnum addEnum(EObject representedElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ VirtualEnum output = null;
+ // System.err.println("checkIfExists : " + checkIfExists);
+
+
+ boolean found = false;
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier instanceof VirtualEnum)
+ if(classifier.getRepresentedElement() == representedElement) {
+ output = (VirtualEnum)classifier;
+ found = true;
+ break;
+ }
+ }
+
+ if(!found) {
+
+ VirtualEnum enumeration = VirtualmetamodelFactory.eINSTANCE.createVirtualEnum();
+ enumeration.setKept(true);
+ enumeration.setRepresentedElement(representedElement);
+ enumeration.setAliasName(alias);
+ AddCommand command = new AddCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), enumeration);
+ editingDomain.getCommandStack().execute(command);
+
+ if(enumeration.getRepresentedElement() instanceof EEnum) {
+ EList<EEnumLiteral> literals = ((EEnum)enumeration.getRepresentedElement()).getELiterals();
+ for(EEnumLiteral literal : literals) {
+ MetamodelUtils.addLiteral(enumeration, literal, literal.getName(), facade, editingDomain);
+ }
+ } else if(enumeration.getRepresentedElement() instanceof Enumeration) {
+ EList<EnumerationLiteral> literals = ((Enumeration)enumeration.getRepresentedElement()).getOwnedLiterals();
+ for(EnumerationLiteral literal : literals) {
+ MetamodelUtils.addLiteral(enumeration, literal, literal.getName(), facade, editingDomain);
+ }
+ } else {
+ System.err.println("I don't know how to create literal for the type : " + enumeration.getRepresentedElement());
+ }
+
+ output = enumeration;
+
+ }
+
+ return output;
+ }
+
+ public static VirtualOperation addOperation(VirtualMetaclass metaclass, EObject operationElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ VirtualOperation output = null;
+ // System.err.println("checkIfExists : " + checkIfExists);
+
+
+ boolean found = false;
+ for(VirtualOperation operation : metaclass.getOperations()) {
+ if(operation.getRepresentedElement() == operationElement) {
+ output = operation;
+ found = true;
+ break;
+ }
+ }
+
+ if(!found) {
+
+ VirtualOperation operation = VirtualmetamodelFactory.eINSTANCE.createVirtualOperation();
+ operation.setKept(true);
+ operation.setRepresentedElement(operationElement);
+ operation.setAliasName(alias);
+ AddCommand command = new AddCommand(editingDomain, metaclass, VirtualmetamodelPackage.eINSTANCE.getVirtualMetaclass_Operations(), operation);
+ editingDomain.getCommandStack().execute(command);
+
+ if(operation.getRepresentedElement() instanceof EOperation) {
+ EList<EParameter> parameters = ((EOperation)operation.getRepresentedElement()).getEParameters();
+ for(EParameter param : parameters) {
+ MetamodelUtils.addParameter(operation, param, param.getName(), facade, editingDomain);
+ }
+ } else if(operation.getRepresentedElement() instanceof Operation) {
+ EList<Parameter> parameters = ((Operation)operation.getRepresentedElement()).getOwnedParameters();
+ for(Parameter param : parameters) {
+ MetamodelUtils.addParameter(operation, param, param.getName(), facade, editingDomain);
+ }
+ } else {
+ System.err.println("I don't know how to create parameters for the operation : " + operation.getRepresentedElement());
+ }
+
+ output = operation;
+ }
+
+ return output;
+ }
+
+ public static VirtualDatatype addDatatype(EObject representedElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+
+ VirtualDatatype output = null;
+ // System.err.println("checkIfExists : " + checkIfExists);
+
+
+ boolean found = false;
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier instanceof VirtualDatatype)
+ if(classifier.getRepresentedElement() == representedElement) {
+ output = (VirtualDatatype)classifier;
+ found = true;
+ break;
+ }
+ }
+
+
+
+ if(!found) {
+
+ VirtualDatatype datatype = VirtualmetamodelFactory.eINSTANCE.createVirtualDatatype();
+ datatype.setKept(true);
+ datatype.setRepresentedElement(representedElement);
+ datatype.setAliasName(alias);
+ AddCommand command = new AddCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), datatype);
+ editingDomain.getCommandStack().execute(command);
+
+ output = datatype;
+
+ }
+
+ return output;
+ }
+
+ public static VirtualMetaclass addStereotypeInterface(Stereotype representedElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+
+ VirtualMetaclass output = null;
+
+ boolean found = false;
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier instanceof VirtualMetaclass)
+ if(((VirtualMetaclass)classifier).isStereotypeInterface()) {
+ if(classifier.getRepresentedElement() == representedElement) {
+ output = (VirtualMetaclass)classifier;
+ found = true;
+ break;
+ }
+ }
+ }
+
+
+
+ if(!found) {
+ VirtualMetaclass metaclass = VirtualmetamodelFactory.eINSTANCE.createVirtualMetaclass();
+ metaclass.setKept(true);
+ metaclass.setRepresentedElement(representedElement);
+ metaclass.setAliasName(alias);
+ metaclass.setAbstract(true);
+ metaclass.setStereotypeInterface(true);
+ AddCommand command = new AddCommand(editingDomain, facade.getVirtualmetamodel(), VirtualmetamodelPackage.eINSTANCE.getVirtualMetamodel_VirtualClassifiers(), metaclass);
+ editingDomain.getCommandStack().execute(command);
+
+
+
+
+
+ output = metaclass;
+ } else {
+ System.err.println("addStereotypeInterface: I didn't add because already represented : " + representedElement);
+ }
+
+
+
+ return output;
+ }
+
+ public static VirtualClassifier createForType(EObject classifier, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ if(classifier instanceof EClass) {
+ VirtualClassifier metaclass = MetamodelUtils.addMetaclass(classifier, null, ((EClass)classifier).getName(), facade, editingDomain);
+ return metaclass;
+ } else if(classifier instanceof EDataType) {
+ if(classifier instanceof EEnum) {
+ VirtualEnum enumeration = MetamodelUtils.addEnum(classifier, ((EEnum)classifier).getName(), facade, editingDomain);
+ return enumeration;
+ } else {
+ VirtualDatatype datatype = MetamodelUtils.addDatatype(classifier, ((EDataType)classifier).getName(), facade, editingDomain);
+ return datatype;
+ }
+ } else if(classifier instanceof DataType) {
+ VirtualClassifier dataype = MetamodelUtils.addMetaclass(classifier, null, ((DataType)classifier).getName(), facade, editingDomain);
+ return dataype;
+ } else if(classifier instanceof PrimitiveType) {
+ // VirtualClassifier dataype = MetamodelUtils.addMetaclass(classifier, null, ((PrimitiveType)classifier).getName(), facade, editingDomain);
+ // return dataype;
+ }
+ return null;
+ }
+
+ public static void addProperty(VirtualMetaclass metaclass, EObject propertyElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+
+
+ boolean found = false;
+ for(VirtualProperty property : metaclass.getProperties()) {
+ if(property.getRepresentedElement() == propertyElement) {
+ found = true;
+ }
+ }
+
+
+ if(!found) {
+ int lower = 0;
+ int upper = 0;
+
+
+
+ // Check if the type of this property exists and if not create the appropriate metaclass and properties
+ if(propertyElement instanceof EStructuralFeature) {
+ lower = ((EStructuralFeature)propertyElement).getLowerBound();
+ upper = ((EStructuralFeature)propertyElement).getUpperBound();
+
+ EClassifier eType = ((EStructuralFeature)propertyElement).getEType();
+
+ if(!containtsType(eType, facade)) {
+ VirtualClassifier newType = createForType(eType, facade, editingDomain);
+ if(newType instanceof VirtualMetaclass) {
+ createProperties((VirtualMetaclass)newType, facade, editingDomain);
+ }
+ }
+ } else if(propertyElement instanceof Property) {
+
+ lower = ((Property)propertyElement).getLower();
+ upper = ((Property)propertyElement).getUpper();
+
+ if(((Property)propertyElement).getType() instanceof Stereotype) {
+ //System.err.println("Applied stereotype will be generated to type : " + element);
+ } else {
+
+ if(((Property)propertyElement).getType() instanceof Enumeration) {
+ EObject eType = ((Property)propertyElement).getType();
+ String name = ((Property)propertyElement).getType().getName();
+ if(!containtsType(eType, facade)) {
+ VirtualEnum virtualEnum = MetamodelUtils.addEnum(eType, name, facade, editingDomain);
+ }
+ } else if(((Property)propertyElement).getType() instanceof DataType) {
+ if(((Property)propertyElement).getType() instanceof PrimitiveType) {
+ //Check if it is a UML primitivetype
+ EObject eType = StereotypeUtils.findEClass((Classifier)((Property)propertyElement).getType());
+ if(eType != null) {
+ if(!containtsType(eType, facade)) {
+ VirtualClassifier virtualClassifier = createForType((EClassifier)eType, facade, editingDomain);
+ if(virtualClassifier instanceof VirtualMetaclass) {
+ createProperties((VirtualMetaclass)virtualClassifier, facade, editingDomain);
+ }
+ }
+ } else {
+ VirtualClassifier virtualClassifier = createForType(((Property)propertyElement).getType(), facade, editingDomain);
+ }
+ } else {
+
+ VirtualClassifier virtualClassifier = createForType(((Property)propertyElement).getType(), facade, editingDomain);
+ if(virtualClassifier instanceof VirtualMetaclass) {
+ createProperties((VirtualMetaclass)virtualClassifier, facade, editingDomain);
+ }
+
+
+ }
+ } else if(((Property)propertyElement).getType() instanceof Class) {
+ EClassifier eClass = StereotypeUtils.findEClass((Classifier)((Property)propertyElement).getType());
+ if(eClass == null) {
+ System.err.println("Stereotype properties typed by a Class (that are not part of UML metamodel) are not supported yet");
+ }
+ } else {
+ System.err.println("I don't know how to process the type : " + ((Property)propertyElement).getType());
+ }
+ }
+
+ } else {
+ System.err.println("I don't know how to process the element for property : " + propertyElement);
+ }
+
+ VirtualProperty property = VirtualmetamodelFactory.eINSTANCE.createVirtualProperty();
+ property.setKept(true);
+ property.setAliasName(alias);
+ property.setRepresentedElement(propertyElement);
+ property.setLower(lower);
+ property.setUpper(upper);
+
+ AddCommand command = new AddCommand(editingDomain, metaclass, VirtualmetamodelPackage.eINSTANCE.getVirtualMetaclass_Properties(), property);
+ editingDomain.getCommandStack().execute(command);
+ } else {
+ System.err.println("addProperty: I didn't add because already represented : " + propertyElement);
+ }
+
+ }
+
+ public static VirtualParameter addParameter(VirtualOperation operation, EObject parameterElement, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ VirtualParameter virtualParameter = VirtualmetamodelFactory.eINSTANCE.createVirtualParameter();
+ virtualParameter.setKept(true);
+ virtualParameter.setAliasName(alias);
+ virtualParameter.setRepresentedElement(parameterElement);
+
+ AddCommand command = new AddCommand(editingDomain, operation, VirtualmetamodelPackage.eINSTANCE.getVirtualOperation_Parameters(), virtualParameter);
+ editingDomain.getCommandStack().execute(command);
+
+ return virtualParameter;
+ }
+
+ public static VirtualLiteral addLiteral(VirtualEnum enumeration, EObject element, String alias, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ VirtualLiteral literal = VirtualmetamodelFactory.eINSTANCE.createVirtualLiteral();
+ literal.setKept(true);
+ literal.setAliasName(alias);
+ literal.setRepresentedElement(element);
+
+ AddCommand command = new AddCommand(editingDomain, enumeration, VirtualmetamodelPackage.eINSTANCE.getVirtualEnum_Literals(), literal);
+ editingDomain.getCommandStack().execute(command);
+
+ return literal;
+ }
+
+
+ public static void createStereotypeProperties(VirtualMetaclass metaclass, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ // Add stereotype properties only if it is not already added to a father
+
+ for(BaseMetaclass appliedStereotype : metaclass.getAppliedStereotypes()) {
+ List<VirtualMetaclass> allFathers = MetamodelUtils.getAllFathers(metaclass);
+
+ boolean alreadyApplied = false;
+ for(VirtualMetaclass virtualMetaclass : allFathers) {
+ if(virtualMetaclass.getAppliedStereotypes().contains(appliedStereotype)) {
+ alreadyApplied = true;
+ }
+ }
+
+ if(!alreadyApplied) {
+
+ if(!hasSiblings(appliedStereotype.getExtensionDefinition())) {
+
+
+ EList<Property> stereotypeProperties = appliedStereotype.getExtensionDefinition().getStereotype().getAttributes();
+ for(Property property : stereotypeProperties) {
+
+ if(appliedStereotype.getExtensionDefinition().getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ if(!property.getName().startsWith("base_")) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ } else {
+ if(appliedStereotype.getExtensionDefinition().getExtension().getMemberEnds().contains(property)) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ }
+ }
+ } else {
+ if(!property.getName().startsWith("base_")) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ }
+ }
+ }
+
+ } else {
+ EList<Property> stereotypeProperties = appliedStereotype.getExtensionDefinition().getStereotype().getAttributes();
+ for(Property property : stereotypeProperties) {
+
+ if(appliedStereotype.getExtensionDefinition().getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ if(property.getName().startsWith("base_")) {
+ if(appliedStereotype.getExtensionDefinition().getExtension().getMemberEnds().contains(property)) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ System.err.println("Stereotype is already applied to a parent");
+ }
+ }
+ }
+
+ public static void createProperties(VirtualMetaclass metaclass, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ if(metaclass.isStereotypeInterface()) {
+ EList<Property> stereotypeProperties = ((Stereotype)metaclass.getRepresentedElement()).getAttributes();
+ for(Property property : stereotypeProperties) {
+ if(!property.getName().startsWith("base_")) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ }
+ }
+ } else {
+ if(!onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.MULTI_GENERALIZATION) || metaclass.getAppliedStereotypes().isEmpty()) {
+ if(metaclass.getRepresentedElement() instanceof EClass) {
+ if(onlyOneKind(metaclass.getAppliedStereotypes(), ExtensionDefinitionKind.FUSION) || metaclass.getAppliedStereotypes().isEmpty()) {
+ EList<EStructuralFeature> properties = ((EClass)metaclass.getRepresentedElement()).getEStructuralFeatures();
+ for(EStructuralFeature eStructuralFeature : properties) {
+ MetamodelUtils.addProperty(metaclass, eStructuralFeature, eStructuralFeature.getName(), facade, editingDomain);
+ }
+ }
+ } else if(metaclass.getRepresentedElement() instanceof DataType) {
+ EList<Property> properties = ((DataType)metaclass.getRepresentedElement()).getAttributes();
+ for(Property property : properties) {
+ MetamodelUtils.addProperty(metaclass, property, property.getName(), facade, editingDomain);
+ }
+ } else {
+ System.err.println("I don't know how to create properties for the type : " + metaclass.getRepresentedElement());
+ }
+
+ createStereotypeProperties(metaclass, facade, editingDomain);
+ }
+ }
+ }
+
+ public static void createPropertiesForAll(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ //Only VirtualMetaclasses can have properties
+ for(VirtualMetaclass metaclass : getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers())) {
+ createProperties(metaclass, facade, editingDomain);
+ }
+ }
+
+ protected static boolean containtsType(EObject type, Facade facade) {
+ for(VirtualClassifier classifier : facade.getVirtualmetamodel().getVirtualClassifiers()) {
+ if(classifier.isKept()) {
+ if(classifier.getRepresentedElement() == type) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public static List<VirtualClassifier> getElements(Facade inputElement) {
+
+ List<VirtualClassifier> elements = new ArrayList<VirtualClassifier>();
+ if(inputElement.getVirtualmetamodel() != null) {
+ for(VirtualClassifier classifier : inputElement.getVirtualmetamodel().getVirtualClassifiers()) {
+
+ if(classifier instanceof VirtualMetaclass) {
+ if(MetamodelUtils.getFathers((VirtualMetaclass)classifier).isEmpty()) {
+ elements.add((VirtualMetaclass)classifier);
+ }
+ } else {
+ elements.add(classifier);
+ }
+
+ }
+ }
+
+ return elements;
+
+ }
+
+ public static void createGeneralizations(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ for(VirtualMetaclass metaclass : MetamodelUtils.getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers())) {
+ List<VirtualMetaclass> fathers = getFathers(metaclass);
+
+ List<VirtualMetaclass> fathersToAdd = new ArrayList<VirtualMetaclass>();
+ for(VirtualMetaclass father : fathers) {
+ if(!metaclass.getParents().contains(father)) {
+ fathersToAdd.add(father);
+ }
+ }
+
+ AddCommand command = new AddCommand(editingDomain, metaclass, VirtualmetamodelPackage.eINSTANCE.getVirtualMetaclass_Parents(), fathersToAdd);
+ editingDomain.getCommandStack().execute(command);
+ }
+ }
+
+ public static void createOperationsForAll(Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ //Only VirtualMetaclasses can have operations
+ for(VirtualMetaclass metaclass : getOnlyVirtualMetaclasses(facade.getVirtualmetamodel().getVirtualClassifiers())) {
+ createOperations(metaclass, facade, editingDomain);
+ }
+ }
+
+ private static void createOperations(VirtualMetaclass metaclass, Facade facade, AdapterFactoryEditingDomain editingDomain) {
+ if(metaclass.getRepresentedElement() instanceof EClass) {
+ EList<EOperation> operations = ((EClass)metaclass.getRepresentedElement()).getEOperations();
+ for(EOperation eOperation : operations) {
+ addOperation(metaclass, eOperation, eOperation.getName(), facade, editingDomain);
+ }
+ }
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionContentProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionContentProvider.java
new file mode 100644
index 00000000000..f07c342bda7
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionContentProvider.java
@@ -0,0 +1,88 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+
+public class ExtensionDefintionContentProvider implements ITreeContentProvider {
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Object[] getElements(Object inputElement) {
+
+ HashSet<ExtensionDefinition> output = new HashSet<ExtensionDefinition>();
+
+ if(inputElement instanceof Facade) {
+
+ EList<ExtensionDefinition> extensionsDefinitions = ((Facade)inputElement).getExtensionDefinitions();
+ for(ExtensionDefinition extensionDefinition : extensionsDefinitions) {
+
+ output.add(extensionDefinition);
+
+ // if (StereotypeTools.findEClass(((Extension) extensionDefinition.getExtension()).getMetaclass()) == extensionDefinition.getBaseMetaclass()) {
+ // output.add(extensionDefinition);
+ // }
+
+ }
+
+ }
+
+ return output.toArray();
+
+ }
+
+
+ public Object[] getChildren(Object parentElement) {
+ List<BaseMetaclass> output = new ArrayList<BaseMetaclass>();
+ if(parentElement instanceof ExtensionDefinition) {
+
+ ExtensionDefinition parent = (ExtensionDefinition)parentElement;
+
+ if(parent.getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ for(BaseMetaclass baseMetaclass : parent.getBaseMetaclasses()) {
+ if(!((EClass)baseMetaclass.getBase()).isAbstract()) {
+ output.add(baseMetaclass);
+ }
+ }
+ }
+ }
+ return output.toArray();
+ }
+
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public boolean hasChildren(Object element) {
+ if(getChildren(element).length != 0) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionLabelProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionLabelProvider.java
new file mode 100644
index 00000000000..7d983399f33
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/ExtensionDefintionLabelProvider.java
@@ -0,0 +1,176 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinitionKind;
+import org.eclipse.papyrus.facadeSpecificEditor.Activator;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.StereotypeUtils;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+
+import com.swtdesigner.ResourceManager;
+
+public class ExtensionDefintionLabelProvider implements ITableLabelProvider, ILabelProvider, IFontProvider {
+
+
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+
+ break;
+ case 1:
+ if(element instanceof ExtensionDefinition) {
+ if(((ExtensionDefinition)element).getKind() == ExtensionDefinitionKind.ASSOCIATION) {
+ if(((ExtensionDefinition)element).getExtension().isRequired()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/associationRequired.png");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/association.png");
+ }
+ } else if(((ExtensionDefinition)element).getKind() == ExtensionDefinitionKind.GENERALIZATION) {
+ if(((ExtensionDefinition)element).getExtension().isRequired()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/generalizationRequired.png");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/generalization.png");
+ }
+
+ } else if(((ExtensionDefinition)element).getKind() == ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(((ExtensionDefinition)element).getExtension().isRequired()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/multigeneralizationRequired.png");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/multigeneralization.png");
+ }
+
+ } else if(((ExtensionDefinition)element).getKind() == ExtensionDefinitionKind.FUSION) {
+ if(((ExtensionDefinition)element).getExtension().isRequired()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/fusionRequired.png");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/fusion.png");
+ }
+
+ }
+
+ }
+ break;
+ case 2:
+ if(element instanceof BaseMetaclass) {
+ if(!((BaseMetaclass)element).getExtensionDefinition().getExtension().isRequired()) {
+ if(((BaseMetaclass)element).isPossible()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/checked.gif");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/unchecked.gif");
+ }
+ }
+
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+
+ public String getColumnText(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+ if(element instanceof ExtensionDefinition) {
+
+ String name = ((ExtensionDefinition)element).getStereotype().getQualifiedName();
+ if(!((ExtensionDefinition)element).getStereotype().getGenerals().isEmpty()) {
+ name += " [-> ";
+ name += ((ExtensionDefinition)element).getStereotype().getGenerals().get(0).getQualifiedName();
+ if(((ExtensionDefinition)element).getStereotype().getGenerals().size() > 1) {
+ for(int i = 1; i < ((ExtensionDefinition)element).getStereotype().getGenerals().size(); i++) {
+ name += ", " + ((ExtensionDefinition)element).getStereotype().getGenerals().get(i).getQualifiedName();
+ }
+ }
+ name += "]";
+ }
+ name += " on";
+ if(((ExtensionDefinition)element).getKind() != ExtensionDefinitionKind.MULTI_GENERALIZATION) {
+ if(StereotypeUtils.findBase((ExtensionDefinition)element) != null) {
+ name += " " + StereotypeUtils.findBase((ExtensionDefinition)element).getName();
+ }
+ }
+ return name;
+
+ } else if(element instanceof BaseMetaclass) {
+ if(((BaseMetaclass)element).getBase() instanceof EClass) {
+
+ String name = ((EClass)((BaseMetaclass)element).getBase()).getName();
+ return name;
+ }
+ }
+
+ break;
+ case 1:
+ if(element instanceof ExtensionDefinition) {
+ return ((ExtensionDefinition)element).getKind().getName();
+ }
+ break;
+ case 2:
+
+ break;
+
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+ public Image getImage(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+
+
+ public Font getFont(Object element) {
+
+ if(element instanceof ExtensionDefinition) {
+
+ if(((ExtensionDefinition)element).getStereotype().isAbstract()) {
+ return JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
+ }
+ }
+
+ return JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesContentProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesContentProvider.java
new file mode 100644
index 00000000000..eeb42f57867
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesContentProvider.java
@@ -0,0 +1,40 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import java.util.HashSet;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.Combination;
+
+public class IncompatibilitiesContentProvider implements IStructuredContentProvider {
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Object[] getElements(Object inputElement) {
+
+ HashSet<Combination> output = new HashSet<Combination>();
+ if(inputElement instanceof BaseMetaclass) {
+ // output.addAll(((BaseMetaclass) inputElement).getIncompatibleStereotypes());
+
+ // output.addAll(ProfileUtils.getPossibleCombinaisons((BaseMetaclass) inputElement));
+ output.addAll(((BaseMetaclass)inputElement).getIncompatibleStereotypes());
+ output.addAll(((BaseMetaclass)inputElement).getCompatibleStereotypes());
+
+ }
+ return output.toArray();
+
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesLabelProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesLabelProvider.java
new file mode 100644
index 00000000000..046659b38ef
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/IncompatibilitiesLabelProvider.java
@@ -0,0 +1,168 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.papyrus.facade.extensiondefinition.BaseMetaclass;
+import org.eclipse.papyrus.facade.extensiondefinition.Combination;
+import org.eclipse.papyrus.facade.extensiondefinition.ExtensionDefinition;
+import org.eclipse.papyrus.facadeSpecificEditor.Activator;
+import org.eclipse.papyrus.facadeSpecificEditor.FacadeSpecificEditor;
+import org.eclipse.papyrus.facadeSpecificEditor.utils.ProfileUtils;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Stereotype;
+
+import com.swtdesigner.ResourceManager;
+
+public class IncompatibilitiesLabelProvider implements ITableLabelProvider, IFontProvider {
+
+
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+ if(element instanceof Combination) {
+
+ // if (((Extension) ((BaseMetaclass) element).getExtensionDefinition().getExtension()).isRequired()) {
+ // return ResourceManager.getPluginImage("org.eclipse.papyrus.FacadeSpecificEditor", "icons/generalizationRequired.png");
+ // } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/combinaison.png");
+ // }
+
+ }
+ break;
+ case 1:
+ if(element instanceof Combination) {
+ ISelection selection = FacadeSpecificEditor.getExtensionDefintionTreeViewer().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ Object first = ((IStructuredSelection)selection).getFirstElement();
+
+ if(first instanceof BaseMetaclass) {
+ EList<Combination> incompatibleStereotypes = ((BaseMetaclass)first).getIncompatibleStereotypes();
+ if(incompatibleStereotypes.contains(element)) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/unchecked.gif");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/checked.gif");
+ }
+ }
+ }
+
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+ protected String produceSiblingList(Stereotype stereotype) {
+ String output = "";
+ HashSet<Stereotype> siblings = ProfileUtils.getSiblings(stereotype);
+ List<Classifier> siblingsList = new ArrayList<Classifier>(siblings);
+ if(siblingsList.size() > 1) {
+ output += "[";
+ }
+
+ if(!siblingsList.isEmpty()) {
+ output += siblingsList.get(0).getQualifiedName();
+
+ if(siblingsList.size() > 1) {
+ for(int i = 1; i < siblingsList.size(); i++) {
+ output += ", ";
+ output += siblingsList.get(i).getQualifiedName();
+ }
+ }
+
+ }
+
+ if(siblings.size() > 1) {
+ output += "]";
+ }
+ return output;
+ }
+
+
+ public String getColumnText(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+ String name = "";
+ if(element instanceof Combination) {
+
+ Combination combination = (Combination)element;
+ if(!combination.getMembers().isEmpty()) {
+ // name += produceSiblingList(combination.getMembers().get(0).getExtensionDefinition().getStereotype());
+ name += combination.getMembers().get(0).getExtensionDefinition().getStereotype().getName();
+ if(((Combination)element).getMembers().size() > 1) {
+ for(int i = 1; i < combination.getMembers().size(); i++) {
+ name += ", ";
+ name += combination.getMembers().get(i).getExtensionDefinition().getStereotype().getName();
+ // name += produceSiblingList(combination.getMembers().get(i).getExtensionDefinition().getStereotype());
+ }
+ }
+
+ return name;
+ }
+
+ }
+
+ break;
+ case 1:
+
+ break;
+
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+
+ public Font getFont(Object element) {
+
+ if(element instanceof ExtensionDefinition) {
+
+ if(((ExtensionDefinition)element).getStereotype().isAbstract()) {
+ return JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
+ }
+ }
+
+ return JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
+ }
+
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelContentProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelContentProvider.java
new file mode 100644
index 00000000000..0b9148f5022
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelContentProvider.java
@@ -0,0 +1,74 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.facade.Facade;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualClassifier;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualElement;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facadeSpecificEditor.metamodel.MetamodelUtils;
+
+public class MetamodelContentProvider implements ITreeContentProvider {
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Object[] getElements(Object inputElement) {
+
+ List<VirtualElement> elements = new ArrayList<VirtualElement>();
+
+ if(inputElement instanceof Facade) {
+ elements.addAll(MetamodelUtils.getElements((Facade)inputElement));
+ }
+
+ return elements.toArray();
+ }
+
+
+ public Object[] getChildren(Object parentElement) {
+ List<VirtualMetaclass> children = new ArrayList<VirtualMetaclass>();
+
+ if(parentElement instanceof VirtualMetaclass)
+ for(VirtualClassifier classifier : ((VirtualMetaclass)parentElement).getMetamodel().getVirtualClassifiers()) {
+
+ if(classifier instanceof VirtualMetaclass)
+
+ if(((VirtualMetaclass)classifier).getParents().contains(parentElement)) {
+ children.add((VirtualMetaclass)classifier);
+ }
+
+ }
+
+ return children.toArray();
+ }
+
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public boolean hasChildren(Object element) {
+
+ if(getChildren(element).length == 0) {
+ return false;
+ } else {
+ return true;
+ }
+ // return true;
+ }
+}
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelLabelProvider.java b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelLabelProvider.java
new file mode 100644
index 00000000000..b104aeda502
--- /dev/null
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.definition.editor/src/org/eclipse/papyrus/facadeSpecificEditor/providers/MetamodelLabelProvider.java
@@ -0,0 +1,195 @@
+package org.eclipse.papyrus.facadeSpecificEditor.providers;
+
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualDatatype;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualElement;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualEnum;
+import org.eclipse.papyrus.facade.virtualmetamodel.VirtualMetaclass;
+import org.eclipse.papyrus.facadeSpecificEditor.Activator;
+import org.eclipse.papyrus.facadeSpecificEditor.metamodel.MetamodelUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.NamedElement;
+
+import com.swtdesigner.ResourceManager;
+
+public class MetamodelLabelProvider implements ITableLabelProvider, ILabelProvider, IFontProvider, IColorProvider {
+
+
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+ if(element instanceof VirtualMetaclass) {
+ if(((VirtualMetaclass)element).isStereotypeInterface()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/virtualmetamodel/StereotypeInterface.gif");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/virtualmetamodel/VirtualMetaclass.gif");
+ }
+ } else if(element instanceof VirtualDatatype) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/virtualmetamodel/VirtualDatatype.gif");
+ } else if(element instanceof VirtualEnum) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/virtualmetamodel/VirtualEnum.gif");
+ }
+
+ break;
+ case 1:
+ if(element instanceof VirtualElement) {
+ if(((VirtualElement)element).isKept()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/checked.gif");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/unchecked.gif");
+ }
+
+ }
+ break;
+ case 2:
+
+ break;
+
+ case 3:
+ if(element instanceof VirtualMetaclass) {
+ if(MetamodelUtils.canBeAbstract((VirtualMetaclass)element)) {
+ if(((VirtualMetaclass)element).isAbstract()) {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/checked.gif");
+ } else {
+ return ResourceManager.getPluginImage(Activator.getDefault(), "icons/unchecked.gif");
+ }
+ }
+
+ }
+ break;
+
+ default:
+ break;
+ }
+ return null;
+ }
+
+
+ public String getColumnText(Object element, int columnIndex) {
+ switch(columnIndex) {
+ case 0:
+ String result = "Unknow";
+ if(element instanceof VirtualElement) {