Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick tessier2014-02-10 12:45:32 +0000
committerPatrick tessier2014-02-10 12:45:32 +0000
commitdf1d4d493dc8ea4b4a81ad8da993f91df220431a (patch)
treef9621c66abaacba819a508e5626c3ced2c43b056 /plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core
parent74550693a485c6ff27748a6c5a9bfdae21b8bd5b (diff)
downloadorg.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.tar.gz
org.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.tar.xz
org.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.zip
386118: [EMF Facet] Papyrus should progressively support EMF Facet 0.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386118 Import EMF Facet
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.checkstyle9
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.pmd7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.project46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.core.resources.prefs4
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF26
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties17
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties21
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml45
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd127
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd108
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd95
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd122
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/FacetUtils.java705
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IDerivedTypedElementManager.java201
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IEFacetManager.java87
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetAction.java135
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetActions.java45
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactory.java193
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactoryFactory.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManager.java244
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerFactory.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerListener.java28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManager.java26
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java26
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/DerivedTypedElementException.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/FacetManagerException.java37
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryException.java39
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryExecutionException.java41
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryTypeCheckingException.java36
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Activator.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/CastUtils.java88
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementManager.java877
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java70
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EFacetManager.java197
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EmfUtils.java103
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionImpl.java205
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActions2Impl.java231
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionsImpl.java78
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java30
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java511
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManager.java593
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerContext.java554
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerFactory.java54
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Messages.java28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/ResolverManager.java113
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java58
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java72
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java44
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java37
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java21
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java21
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java45
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolver.java61
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolverManager.java28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java208
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/messages.properties13
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java121
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java48
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java35
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java52
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java36
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java80
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java35
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java35
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java68
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java100
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java114
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtils.java121
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java64
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java49
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java36
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java48
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java36
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java34
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java29
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/SerializationManager.java432
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java92
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java93
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java54
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryCollectionImplementation.java97
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluator.java111
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java42
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementation.java85
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementationFactory.java45
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryUtils.java45
101 files changed, 9740 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.checkstyle b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.checkstyle
new file mode 100644
index 00000000000..d18c65877b9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.checkstyle
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <local-check-config name="EmfFacet" location="../org.eclipse.emf.facet.archi.tech.rules/checkstyle/EmfFacet.checkstyle" type="project" description=""/>
+ <fileset name="all" enabled="true" check-config-name="EmfFacet" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ <file-match-pattern match-pattern="Messages.java" include-pattern="false"/>
+ </fileset>
+</fileset-config>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath
new file mode 100644
index 00000000000..45f024e850e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.pmd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.pmd
new file mode 100644
index 00000000000..efcd2dbd830
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.pmd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <ruleSetFile>../org.eclipse.emf.facet.archi.tech.rules/pmd/ruleset.xml</ruleSetFile>
+ <includeDerivedFiles>false</includeDerivedFiles>
+ <violationsAsErrors>true</violationsAsErrors>
+</pmd>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.project b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.project
new file mode 100644
index 00000000000..4f29aa24113
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.project
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.emf.facet.efacet.core</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>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..0d9ebf5995c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,4 @@
+#Thu Sep 22 10:54:33 CEST 2011
+eclipse.preferences.version=1
+encoding//src/org/eclipse/emf/facet/efacet/core/internal/messages.properties=ISO-8859-1
+encoding/<project>=UTF-8
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..060c5ee3d2e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.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/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..23efb85ec1d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.core;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.emf.facet.efacet.core.internal.Activator
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0",
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.papyrus.emf.facet.efacet.catalog;bundle-version="0.1.0";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.util.emf.core;bundle-version="0.1.0";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.util.core;bundle-version="0.1.0",
+ org.eclipse.emf.edit;bundle-version="2.6.0",
+ org.eclipse.emf.facet.efacet.metamodel;bundle-version="0.2.0",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.emf.facet.efacet;bundle-version="0.2.0";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.util.emf.ui;bundle-version="0.3.0",
+ org.eclipse.emf.facet.util.pde.core;bundle-version="0.4.0"
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %Bundle-Vendor
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.emf.facet.efacet.core,
+ org.eclipse.emf.facet.efacet.core.exception,
+ org.eclipse.emf.facet.efacet.core.internal.exported,
+ org.eclipse.emf.facet.efacet.core.internal.incubatingapi,
+ org.eclipse.emf.facet.efacet.core.internal.query,
+ org.eclipse.emf.facet.efacet.core.query
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..1b22fb0d477
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,17 @@
+###########################################################################
+# Copyright (c) 2011, 2012 Mia-Software.
+#
+# 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:
+# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
+###########################################################################
+#Properties file for org.eclipse.emf.facet.efacet.core
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = EMF Facet Core (Incubation)
+queryEvaluatorRegistration.extension-point.name = QueryEvaluatorRegistration
+derivedTypedElementImplementationRegistration.extension-point.name = Derived Typed Element Evaluator Registration \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html
new file mode 100644
index 00000000000..05cdf47ada9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>January 10, 2011</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties
new file mode 100644
index 00000000000..f7d2767d4da
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties
@@ -0,0 +1,21 @@
+###########################################################################
+# Copyright (c) 2011 Mia-Software.
+#
+# 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:
+# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
+###########################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ about.html,\
+ plugin.xml,\
+ schema/
+src.includes = about.html
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml
new file mode 100644
index 00000000000..53778bd8fa7
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+
+<!--
+ Copyright (c) 2011 Mia-Software.
+
+ 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:
+ Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
+ Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
+ Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ -->
+
+<plugin>
+ <extension-point id="org.eclipse.emf.facet.efacet.core.query.evaluatorregistration" name="%queryEvaluatorRegistration.extension-point.name" schema="schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd"/>
+ <extension-point id="derivedTypedElementImplementationRegistration" name="%derivedTypedElementImplementationRegistration.extension-point.name" schema="schema/derivedTypedElementImplementationRegistration.exsd"/>
+ <extension-point id="queryImplementationRegistration" name="EMF Facet Query implementation registration" schema="schema/queryImplementationRegistration.exsd"/>
+ <extension-point id="org.eclipse.emf.facet.efacet.core.internal.resolver" name="Resolver" schema="schema/internal.resolver.exsd"/>
+
+ <extension point="org.eclipse.emf.facet.util.emf.core.catalogmanager">
+ <catalog class="org.eclipse.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager"/>
+ <catalog class="org.eclipse.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager2"/>
+ </extension>
+
+ <extension point="org.eclipse.emf.facet.efacet.core.queryImplementationRegistration">
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.NavigationQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.IsOneOfQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.StringLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.FalseLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.TrueLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.NullLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.EObjectLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.FloatLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.IntegerLiteralQueryImplementationFactory"/>
+ <queryImplementationRegistration class="org.eclipse.emf.facet.efacet.core.internal.query.OperationCallQueryImplementationFactory"/>
+ </extension>
+</plugin>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd
new file mode 100644
index 00000000000..382d10b4e40
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd
@@ -0,0 +1,127 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.facet.efacet.core" id="derivedTypedElementImplementationRegistration" name="Derived Typed Element Evaluator Registration"/>
+ </appinfo>
+ <documentation>
+ Allow the registration of an IderivedTypedElementImplementationFactory, that instantiates IDerivedTypedElementImplementation that conform to the EMF Facet framework.
+The IDerivedTypedElementImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...)
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element deprecated="true" replacement="queryImplementationRegistration" />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="derivedTypedElementImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="derivedTypedElementImplementationRegistration">
+ <annotation>
+ <appinfo>
+ <meta.element deprecated="true"/>
+ </appinfo>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Provides an implementation for a IDerivedTypedElementImplementationFactory, which instantiates IDerivedTypedElementImplementation for a given type of queries.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.emf.facet.efacet.core.derivedTypedElementImplementationRegistration&quot;&gt;
+ &lt;derivedTypedElementImplementationRegistration
+ class=&quot;org.eclipse.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory&quot;&gt;
+ &lt;/derivedTypedElementImplementationRegistration&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ &lt;p&gt;
+See plug-ins:
+&lt;ul&gt;
+&lt;li&gt;org.eclipse.emf.facet.query.java.core
+&lt;/ul&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011 Mia-Software.
+
+ 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:
+ Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd
new file mode 100644
index 00000000000..ecdcc741fd3
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd
@@ -0,0 +1,108 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.facet.efacet.core" id="internal.resolver" name="Resolver"/>
+ </appinfo>
+ <documentation>
+ This is an internal extension point. It must only be used by EMF Facet&apos;s components.
+
+This extension allows to plug specific behavior in to the facet components. It has been created avoid to have dependences from the main EMF Facet components to the aggregate components.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="resolver"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="resolver">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.facet.efacet.core.internal.exported.IResolver"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;extension
+ point=&quot;org.eclipse.emf.facet.efacet.core.internal.resolver&quot;&gt;
+ &lt;resolver
+ class=&quot;org.eclipse.emf.facet.aggregate.metamodel.notgenerated.internal.Resolver&quot;&gt;
+ &lt;/resolver&gt;
+ &lt;/extension&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2012 CEA-LIST.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List&lt;ETypedElement&gt;, List&lt;FacetSet&gt;)
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd
new file mode 100644
index 00000000000..0e51031ea76
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd
@@ -0,0 +1,95 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.facet.efacet.core.query.evaluatorregistration" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.facet.efacet.core.query.evaluatorregistration" id="evaluatorregistration" name="QueryEvaluatorRegistration"/>
+ </appinfo>
+ <documentation>
+ Allow the registration of a queryEvaluatorFactory.
+This factory allows the user to create queryEvaluators conform to the EMF Facet framework.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="queryEvaluatorRegistration" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="queryEvaluatorRegistration">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.facet.efacet.core.query.IQueryEvaluatorFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.1.0
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011 Mia-Software.
+
+ 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:
+ - Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd
new file mode 100644
index 00000000000..69514675381
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd
@@ -0,0 +1,122 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.facet.efacet.core" id="queryImplementationRegistration" name="EMF Facet Query Implementation Registration"/>
+ </appinfo>
+ <documentation>
+ Used to register an IQueryImplementationFactory, that creates instances of IQueryImplementation. The IQueryImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...)
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="queryImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="queryImplementationRegistration">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Provides an implementation for an IQueryImplementationFactory, which instantiates IQueryImplementation for a given type of queries.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.emf.facet.efacet.core.queryImplementationRegistration&quot;&gt;
+ &lt;queryImplementationRegistration
+ class=&quot;org.eclipse.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory&quot;&gt;
+ &lt;/queryImplementationRegistration&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ &lt;p&gt;
+See plug-ins:
+&lt;ul&gt;
+&lt;li&gt;org.eclipse.emf.facet.query.java.core
+&lt;/ul&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011, 2012 Mia-Software.
+
+ 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:
+ Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/FacetUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/FacetUtils.java
new file mode 100644
index 00000000000..7e92efd86aa
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/FacetUtils.java
@@ -0,0 +1,705 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Mia-Software
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Nicolas Bros (Mia-Software) - Bug 361817 - [Restructuring] Dynamic load to the facet catalog
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 371367 - Hierarchical FacetSets
+ * Gregoire Dupe (Mia-Software) - Bug 371367 - Hierarchical FacetSets
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Gregoire Dupe (Mia-Software) - Bug 373510 - EditingDomain, ResourceSet, Catalogs, etc. have to be properly managed between editors and views
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
+ * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet
+ * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Gregoire Dupe (Mia-Software) - Bug 377870 - [EFacet] ETypedElementDialog doesn't show all available ETypedElement (library example problem?)
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 391442 - Select ETypedElement Dialog doesn't used the subpackages (subEFacetSet)
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.efacet.core.internal.exported.IResolverManager;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+import org.eclipse.emf.facet.util.emf.core.ModelUtils;
+import org.eclipse.emf.facet.util.emf.core.internal.EMFUtils;
+
+/**
+ * @since 0.2
+ */
+public final class FacetUtils {
+
+ private FacetUtils() {
+ // static methods only
+ }
+
+ /**
+ * Find a Facet in a FacetSet
+ *
+ * @param facetSet
+ * the FacetSet
+ * @param facetName
+ * the name of the Facet to look for
+ * @return the Facet with the given name in the given FacetSet
+ */
+ public static Facet getFacet(final FacetSet facetSet, final String facetName) {
+ Facet result = null;
+ final List<Facet> facets = FacetUtils.getFacets(facetSet);
+ for (Facet facet : facets) {
+ if (facetName.equals(facet.getName())) {
+ result = facet;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public static <T extends ETypedElement> T getETypedElement(
+ final Facet facet, final String name, final Class<T> classs) {
+ T result = null;
+ final List<ETypedElement> eTypedElements = new ArrayList<ETypedElement>();
+ eTypedElements.addAll(facet.getFacetElements());
+ eTypedElements.addAll(facet.getFacetOperations());
+ for (ETypedElement eTypedElement : eTypedElements) {
+ if (name.equals(eTypedElement.getName())
+ && classs.isInstance(eTypedElement)) {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This assignment is check by
+ // the call 'classs.isInstance(structuralFeature)'
+ final T castResult = (T) eTypedElement;
+ result = castResult;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public static Object getResultValue(final ETypedElementResult eTEresult) {
+ Object result = null;
+ if (eTEresult instanceof ETypedElementEObjectListResult<?>) {
+ final ETypedElementEObjectListResult<?> eObjectList = (ETypedElementEObjectListResult<?>) eTEresult;
+ result = eObjectList.getResultList();
+ } else if (eTEresult instanceof ETypedElementEObjectResult<?>) {
+ final ETypedElementEObjectResult<?> eObjectRef = (ETypedElementEObjectResult<?>) eTEresult;
+ result = eObjectRef.getResult();
+ } else if (eTEresult instanceof ETypedElementPrimitiveTypeListResult<?>) {
+ final ETypedElementPrimitiveTypeListResult<?> objectList = (ETypedElementPrimitiveTypeListResult<?>) eTEresult;
+ result = objectList.getDerivedTypedElement();
+ } else if (eTEresult instanceof ETypedElementPrimitiveTypeResult<?>) {
+ final ETypedElementPrimitiveTypeResult<?> objectRef = (ETypedElementPrimitiveTypeResult<?>) eTEresult;
+ result = objectRef.getResult();
+ } else {
+ throw new IllegalStateException(
+ "Unknown ETypedElementResult type: " + eTEresult.getClass()); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Find a FacetSet with the given name among the given list of FacetSets. If several FacetSets have the same name,
+ * then return the first one.
+ *
+ * @param facetSets
+ * where to look for
+ * @param name
+ * the name of the FacetSet to find
+ * @return the FacetSet, or <code>null</code> if not found in the given list
+ */
+ public static FacetSet getFacetSet(final Collection<FacetSet> facetSets, final String name) {
+ FacetSet result = null;
+ for (FacetSet facetSet : facetSets) {
+ if (name.equals(facetSet.getName())) {
+ result = facetSet;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find all FacetSets with the given name among the given list of FacetSets.
+ *
+ * @param facetSets
+ * where to look for
+ * @param name
+ * the name of the FacetSets to find
+ * @return the FacetSets with the given name
+ */
+ public static List<FacetSet> getFacetSets(
+ final Collection<FacetSet> facetSets, final String name) {
+ final List<FacetSet> result = new ArrayList<FacetSet>();
+ for (FacetSet facetSet : facetSets) {
+ if (name.equals(facetSet.getName())) {
+ result.add(facetSet);
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param facetSet
+ * a facetSet
+ * @return a set with all the EPackage extended by the facetSet and its
+ * owned facetSet
+ * @since 0.2
+ */
+ public static Set<EPackage> getAllExtendedEPackage(final FacetSet facetSet) {
+ final Set<EPackage> extendedEPackages = new HashSet<EPackage>();
+ final EPackage res1 = getExtendedEPackage(facetSet);
+ if (res1 != null) {
+ extendedEPackages.add(res1);
+ }
+ for (FacetSet current : facetSet.getFacetSets()) {
+ extendedEPackages.addAll(getAllExtendedEPackage(current));
+ }
+ final EList<EPackage> pack = facetSet.getESubpackages();
+ for (EPackage current : pack) {
+ if (current instanceof FacetSet) {
+ extendedEPackages
+ .addAll(getAllExtendedEPackage((FacetSet) current));
+ }
+ }
+ return extendedEPackages;
+ }
+
+ /**
+ * Find all the FacetSets with the given path among the given list of root
+ * FacetSets. For example: <code>getFacetSetsByPath("a", "b", "c")</code>
+ * returns a FacetSet named "c", contained in a FacetSet named "b",
+ * contained in a registered FacetSet named "a".
+ *
+ * @param path
+ * a list of FacetSet names, starting from the root registered
+ * FacetSets, and leading to the wanted FacetSet(s)
+ * @return the FacetSets that have the given path
+ */
+ public static List<FacetSet> getFacetSetsByPath(
+ final Collection<FacetSet> rootFacetSets, final String... path) {
+ if (path.length == 0) {
+ throw new IllegalArgumentException("The given path cannot be empty"); //$NON-NLS-1$
+ }
+ List<FacetSet> facetSets = new ArrayList<FacetSet>(rootFacetSets);
+ for (int i = 0; i < path.length; i++) {
+ if (i > 0) {
+ facetSets = getSubFacetSets(facetSets);
+ }
+ final String name = path[i];
+ facetSets = getFacetSets(facetSets, name);
+ if (facetSets.isEmpty()) {
+ break;
+ }
+
+ }
+ return facetSets;
+ }
+
+ private static List<FacetSet> getSubFacetSets(
+ final Collection<FacetSet> parents) {
+ final List<FacetSet> subFacetSets = new ArrayList<FacetSet>();
+ for (FacetSet facetSet : parents) {
+ final EList<EPackage> eSubpackages = facetSet.getESubpackages();
+ for (EPackage ePackage : eSubpackages) {
+ if (ePackage instanceof FacetSet) {
+ final FacetSet subFacetSet = (FacetSet) ePackage;
+ subFacetSets.add(subFacetSet);
+ }
+ }
+ }
+ return subFacetSets;
+ }
+
+ /**
+ * Find a Facet with the given name among the given list of Facets.
+ *
+ * @param facets
+ * where to look
+ * @param name
+ * the name of the Facet that is being looked for
+ * @return the first {@link Facet} with this name, or <code>null</code> if
+ * none
+ */
+ public static Facet getFacet(final Collection<Facet> facets,
+ final String name) {
+ Facet result = null;
+ for (Facet facet : facets) {
+ if (name.equals(facet.getName())) {
+ result = facet;
+ }
+ }
+ return result;
+ }
+
+ public static FacetSet getRootFacetSet(final Facet facet) {
+ FacetSet result = (FacetSet) facet.eContainer();
+ while (result != null && result.eContainer() instanceof FacetSet) {
+ result = (FacetSet) result.eContainer();
+ }
+ return result;
+ }
+
+ public static FacetSet getRootFacetSet(final FacetSet facetSet) {
+ FacetSet result = facetSet;
+ while (result != null && result.eContainer() instanceof FacetSet) {
+ result = (FacetSet) result.eContainer();
+ }
+ return result;
+ }
+
+ /**
+ * This methods returns all the known (registered) eTypedElements.
+ *
+ * @param resourceSet
+ * the eTypedElement search will be done in/using this resourceSet
+ * @return all the known (registered) eTypedElements
+ */
+ public static Set<? extends ETypedElement> getETypedElements(
+ final ResourceSet resourceSet) {
+ final Set<ETypedElement> result = new HashSet<ETypedElement>();
+ final Collection<Object> ePackages = EPackage.Registry.INSTANCE
+ .values();
+ for (Object object : ePackages) {
+ EPackage ePackage = null;
+ if (object instanceof EPackage) {
+ ePackage = (EPackage) object;
+ } else if (object instanceof EPackage.Descriptor) {
+ final EPackage.Descriptor descriptor = (EPackage.Descriptor) object;
+ ePackage = descriptor.getEPackage();
+ }
+ if (ePackage != null) {
+ result.addAll(getETypedElements(ePackage));
+ }
+ }
+ result.addAll(getFacetETypedElements(resourceSet));
+ return result;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static Set<? extends ETypedElement> getFacetETypedElements(
+ final ResourceSet resourceSet) {
+ final Set<ETypedElement> result = new HashSet<ETypedElement>();
+ final Collection<FacetSet> facetSets = IFacetSetCatalogManagerFactory.DEFAULT
+ .getOrCreateFacetSetCatalogManager(resourceSet)
+ .getRegisteredFacetSets();
+ for (FacetSet facetSet : facetSets) {
+ result.addAll(getETypedElements(facetSet));
+ }
+ return result;
+ }
+
+ public static List<ETypedElement> getETypedElements(final EPackage ePackage) {
+ final List<ETypedElement> result = new LinkedList<ETypedElement>();
+ for (EClassifier eClassifier : ePackage.getEClassifiers()) {
+ result.addAll(getETypedElements(eClassifier));
+ }
+ for (EPackage subPackage : ePackage.getESubpackages()) {
+ result.addAll(getETypedElements(subPackage));
+ }
+ return result;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static List<ETypedElement> getETypedElements(
+ final EClassifier eClassifier) {
+ final List<ETypedElement> result = new ArrayList<ETypedElement>();
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ result.addAll(facet.getFacetElements());
+ result.addAll(facet.getFacetOperations());
+ } else if (eClassifier instanceof EClass) {
+ final EClass eClass = (EClass) eClassifier;
+ result.addAll(eClass.getEAllStructuralFeatures());
+ result.addAll(eClass.getEAllOperations());
+ }
+ return result;
+ }
+
+ public static List<Facet> getFacets(final FacetSet facetSet) {
+ final List<Facet> result = new LinkedList<Facet>();
+ for (EClassifier eClassifier : facetSet.getEClassifiers()) {
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ result.add(facet);
+ }
+ }
+ return result;
+ }
+
+ public static FacetSet getFacetSet(final Facet facet) {
+ FacetSet result = null;
+ if (facet.getEPackage() instanceof FacetSet) {
+ result = (FacetSet) facet.getEPackage();
+ }
+ return result;
+ }
+
+ // Moved from
+ // org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.impl.FacetSetImpl
+ public static EPackage getExtendedEPackage(final FacetSet facetSet) {
+ final List<Facet> facets = FacetUtils.getFacets(facetSet);
+ EPackage result = null;
+ for (Facet facet : facets) {
+ final EClass extendedMetaclass = facet.getExtendedMetaclass();
+ if (extendedMetaclass != null) {
+ final EPackage ePackage = extendedMetaclass.getEPackage();
+ if (ePackage != null) {
+ if (result != null && !ePackage.equals(result)) {
+ throw new IllegalStateException(
+ "The Facets in a FacetSet must all extend EClasses from the same EPackage"); //$NON-NLS-1$
+ }
+ result = ePackage;
+ }
+ }
+ }
+ return result;
+ }
+
+ // Copied (and refactored) from
+ // org.eclipse.emf.facet.efacet.core.internal.FacetManager
+ public static <T extends ETypedElement> Set<T> getETypedElements(
+ final EObject eObject, final Class<T> classs,
+ final IFacetManager facetManager) throws FacetManagerException {
+ final Set<T> result = new HashSet<T>();
+ for (FacetSet facetSet : facetManager.getManagedFacetSets()) {
+ result.addAll(getETypedElements(eObject, facetSet, classs,
+ facetManager));
+ }
+ return result;
+ }
+
+ // Copied (and refactored) from
+ // org.eclipse.emf.facet.efacet.core.internal.FacetManager
+ private static <T extends ETypedElement> Set<T> getETypedElements(
+ final EObject eObject, final FacetSet facetSet,
+ final Class<T> classs, final IFacetManager manager)
+ throws FacetManagerException {
+ final Set<T> result = new HashSet<T>();
+ for (EClassifier eClassifier : facetSet.getEClassifiers()) {
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ if (manager.isConforming(eObject, facet)) {
+ result.addAll(getETypedElement(classs, facet));
+ }
+ }
+ }
+ // hierarchical FacetSets
+ for (EPackage ePackage : facetSet.getESubpackages()) {
+ if (ePackage instanceof FacetSet) {
+ final FacetSet subFacetSet = (FacetSet) ePackage;
+ result.addAll(getETypedElements(eObject, subFacetSet, classs,
+ manager));
+ }
+ }
+ // aggregates
+ for (FacetSet subFacetSet : facetSet.getFacetSets()) {
+ result.addAll(getETypedElements(eObject, subFacetSet, classs,
+ manager));
+ }
+ return result;
+ }
+
+ private static <T> Set<T> getETypedElement(final Class<T> classs,
+ final Facet facet) {
+ final Set<T> result = new HashSet<T>();
+ for (ETypedElement eTypedElement : getAllETypedElements(facet)) {
+ if (classs.isInstance(eTypedElement)) {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This type has been
+ // checked using isInstance
+ final T typedSF = (T) eTypedElement;
+ final T resolvedTE = IResolverManager.DEFAULT
+ .resolve(typedSF, classs);
+ if (resolvedTE == null) {
+ result.add(typedSF);
+ } else {
+ result.add(resolvedTE);
+ }
+ }
+ }
+ return result;
+ }
+
+ // Copied (and refactored) from
+ // org.eclipse.emf.facet.efacet.core.internal.FacetManager
+ private static List<ETypedElement> getAllETypedElements(
+ final Facet facet) {
+ final List<ETypedElement> structFeatures = new LinkedList<ETypedElement>();
+ structFeatures.addAll(facet.getFacetElements());
+ structFeatures.addAll(facet.getFacetOperations());
+ for (Facet extFacet : facet.getExtendedFacets()) {
+ structFeatures.addAll(getAllETypedElements(extFacet));
+ }
+ return structFeatures;
+ }
+
+ /**
+ * @param eTypedElement
+ * @return
+ * @since 0.2
+ */
+ public static FacetSet getFacetSet(final ETypedElement eTypedElement) {
+ FacetSet result = null;
+ if (eTypedElement.eContainer() instanceof Facet) {
+ final Facet facet = (Facet) eTypedElement.eContainer();
+ if (facet.eContainer() instanceof FacetSet) {
+ result = (FacetSet) facet.eContainer();
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param facetOperation
+ * @return
+ * @since 0.2
+ */
+ public static DerivedTypedElement getSignature(
+ final FacetOperation facetOperation) {
+ DerivedTypedElement current = facetOperation;
+ while (current.getOverride() != null) {
+ current = current.getOverride();
+ }
+ return current;
+ }
+
+ /**
+ *
+ * @param facet
+ * @return
+ * @since 0.2
+ */
+ public static EClass getExtendedMetaclass(final Facet facet) {
+ EClass result = facet.getExtendedMetaclass();
+ if (result == null) {
+ final List<EClass> eClasses = new LinkedList<EClass>();
+ for (Facet extfacet : facet.getExtendedFacets()) {
+ eClasses.add(getExtendedMetaclass(extfacet));
+ }
+ result = EMFUtils.computeLeastCommonSupertype(eClasses);
+ }
+ return result;
+ }
+
+ /**
+ * Find the top level feature in the override chain
+ *
+ * @param feature
+ * @return The top level feature in the override chain or the feature
+ * parameter itself if no override
+ * @throws FacetManagerException
+ * @since 0.2
+ *
+ */
+ // Copied from
+ // org.eclipse.emf.facet.efacet.core.internal.FacetManagerContext
+ // * Contributors:
+ // * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet
+ // customization meta-model
+ // * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user
+ // must be able to navigate into a model using the Facet.
+ // * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet
+ // customization meta-model
+ // * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") cf. comment in the method body
+ public static <T extends DerivedTypedElement> T getTopOverrideFeature(
+ final T feature) throws FacetManagerException {
+ T signatureFeature = feature;
+ while (signatureFeature.getOverride() != null) {
+ if (feature.getClass().isInstance(signatureFeature.getOverride())) {
+ // @SuppressWarnings("unchecked") the if test check the
+ // assignment using the method 'isInstance'
+ signatureFeature = (T) signatureFeature.getOverride();
+ } else {
+ // signature feature type name
+ final String sfTypeName = signatureFeature.eClass().getName();
+ // signature feature name
+ final String sfName = ModelUtils
+ .getQualifiedName(signatureFeature);
+ final String ofName = signatureFeature.getOverride().eClass()
+ .getName(); // overridden feature type name
+ throw new FacetManagerException("The " + sfTypeName + " '" //$NON-NLS-1$ //$NON-NLS-2$
+ + sfName + "' overides a " + ofName); //$NON-NLS-1$
+ }
+ }
+ return signatureFeature;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static EClass findExtendedEClass(final Facet facet) {
+ EClass result = facet.getExtendedMetaclass();
+ if (result == null) {
+ for (Facet extFacet : facet.getExtendedFacets()) {
+ result = findExtendedEClass(extFacet);
+ if (result != null) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static DerivedTypedElement getContainingDerivedTypedElement(
+ final EObject eObject) {
+ DerivedTypedElement dte = null;
+ if (eObject instanceof DerivedTypedElement) {
+ dte = (DerivedTypedElement) eObject;
+ } else if (eObject != null) {
+ dte = getContainingDerivedTypedElement(eObject.eContainer());
+ }
+ return dte;
+ }
+
+ /**
+ * Return the main facetSet.
+ *
+ * @param eObject
+ * the element in the model selected.
+ * @return the main facetSet.
+ * @since 0.3
+ */
+ public static FacetSet getContainingFacetSet(final EObject eObject) {
+ FacetSet result = null;
+ if (eObject instanceof FacetSet) {
+ result = (FacetSet) eObject;
+ } else {
+ final EObject container = eObject.eContainer();
+ if (container != null) {
+ result = getContainingFacetSet(container);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return all the operations of the model.
+ *
+ * @param parent
+ * the first FacetSet of the model.
+ * @return the list of operations.
+ * @since 0.3
+ */
+ public static Map<String, FacetOperation> getAllOperationsByName(
+ final FacetSet parent) {
+ final Map<String, FacetOperation> operations = new HashMap<String, FacetOperation>();
+ for (final EClassifier facet : parent.getEClassifiers()) {
+ for (final FacetOperation operation : ((Facet) facet)
+ .getFacetOperations()) {
+ operations.put(operation.getName(), operation);
+ }
+ }
+ for (final EPackage element : parent.getESubpackages()) {
+ operations.putAll(getAllOperationsByName((FacetSet) element));
+ }
+ return operations;
+ }
+
+ /**
+ * Return all the facets of the model.
+ *
+ * @param parent
+ * the first FacetSet of the model.
+ * @return the list of facets.
+ * @since 0.3
+ */
+ public static Map<String, Facet> getAllFacetsByName(final FacetSet parent) {
+ final Map<String, Facet> facets = new HashMap<String, Facet>();
+ for (final EClassifier facet : parent.getEClassifiers()) {
+ facets.put(facet.getName(), (Facet) facet);
+ }
+ for (final EPackage element : parent.getESubpackages()) {
+ facets.putAll(getAllFacetsByName((FacetSet) element));
+ }
+
+ return facets;
+ }
+
+ /**
+ * Return all the facets of the model.
+ *
+ * @param parent
+ * the first FacetSet of the model.
+ * @return the list of facets.
+ * @since 0.3
+ */
+ public static Map<String, FacetSet> getAllFacetSetsByName(
+ final EPackage parent) {
+ final Map<String, FacetSet> facetSets = new HashMap<String, FacetSet>();
+ if (parent instanceof FacetSet) {
+ final FacetSet facetSet = (FacetSet) parent;
+ facetSets.put(parent.getName(), facetSet);
+ }
+ for (final EPackage element : parent.getESubpackages()) {
+ facetSets.putAll(getAllFacetSetsByName(element));
+ }
+ return facetSets;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static List<Facet> getAllFacet(final FacetSet facetSet) {
+ final List<Facet> result = new ArrayList<Facet>();
+ for (EClassifier eClassifier : facetSet.getEClassifiers()) {
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ result.add(facet);
+ }
+ }
+ for (EPackage ePackage : facetSet.getESubpackages()) {
+ if (ePackage instanceof FacetSet) {
+ final FacetSet subFacetSet = (FacetSet) ePackage;
+ result.addAll(getAllFacet(subFacetSet));
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IDerivedTypedElementManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IDerivedTypedElementManager.java
new file mode 100644
index 00000000000..c1c7e2cf4a1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IDerivedTypedElementManager.java
@@ -0,0 +1,201 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.DerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+
+/**
+ * Used to evaluate derived typed elements through their queries.
+ *
+ * @since 0.2
+ */
+public interface IDerivedTypedElementManager {
+ IDerivedTypedElementManager INSTANCE = new DerivedTypedElementManager();
+
+ /**
+ * Evaluates a derived typed element on a model element.
+ * <p>
+ * <b>Note:</b> this method does not return a typed result, and it does not
+ * check the result type. Use
+ * {@link IDerivedTypedElementManager#evaluateSingleValued(DerivedTypedElement, EObject, List, Class)
+ * evaluateSingleValued} or
+ * {@link IDerivedTypedElementManager#evaluateMultiValued(DerivedTypedElement, EObject, List, Class)
+ * evaluateMultiValued} instead if you want a typed and type-checked result.
+ *
+ * @param derivedTE
+ * the derived typed element to evaluate
+ * @param source
+ * the model element on which the derived typed element must be
+ * evaluated
+ * @param parameterValues
+ * the arguments of the derived typed element (in the case of a
+ * {@link FacetOperation}; can be <code>null</code> if there are
+ * no parameters)
+ * @return the derived typed element result: a single Object in the case of
+ * a single-valued derived typed element, or a List in the case of a
+ * multi-valued derived typed element.
+ * @throws DerivedTypedElementException
+ * <ul>
+ * <li>in case of error in the derived typed element</li> <li>in
+ * case of error when evaluating the derived typed element</li>
+ * </ul>
+ */
+ Object evaluate(DerivedTypedElement derivedTE, EObject source,
+ List<ParameterValue> parameterValues, IFacetManager facetManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * Evaluates a query on a model element. Calling this method is discouraged. You should evaluate a
+ * {@link DerivedTypedElement}s (which contains a query) instead of trying to evaluate a {@link Query} directly.
+ * Since the source type, return type and multiplicity of a query are carried by the {@link DerivedTypedElement}
+ * that normally contains it, this method doesn't check the source type, return type or multiplicity.
+ *
+ * @param query
+ * the query to evaluate
+ * @param source
+ * the model element on which the query must be evaluated
+ * @param parameterValues
+ * the arguments of the query (in the case of a query for a {@link FacetOperation}; can be
+ * <code>null</code> if there are no parameters)
+ * @return the query result: may be a single Object or a List.
+ * @throws DerivedTypedElementException
+ * if the evaluation failed
+ */
+ Object evaluate(Query query, EObject source, List<ParameterValue> parameterValues, IFacetManager facetManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * Evaluates a single valued derived typed element on a model element.
+ *
+ * @param derivedTE
+ * the derived typed element to evaluate
+ * @param source
+ * the model element on which the derived typed element is
+ * evaluated
+ * @param parameterValues
+ * the arguments of the derived typed element (in the case of a
+ * {@link FacetOperation}; can be <code>null</code> if there are
+ * no parameters)
+ * @param resultType
+ * the type that the returned value must have
+ * @return the result of the evaluation
+ * @throws DerivedTypedElementException
+ * <ul>
+ * <li>in case of error in the derived typed element</li>
+ * <li>in case of error when evaluating the derived typed
+ * element</li>
+ * <li>
+ * if the effective return type does not match the expected type
+ * </li>
+ * </ul>
+ */
+ <T> T evaluateSingleValued(DerivedTypedElement derivedTE, EObject source,
+ List<ParameterValue> parameterValues, Class<T> resultType,
+ IFacetManager facetManager) throws DerivedTypedElementException;
+
+ /**
+ * Evaluates a multi-valued derived typed element on a model element.
+ *
+ * @param derivedTypedElement
+ * the derived typed element to evaluate
+ * @param source
+ * the model element on which the derived typed element must be
+ * evaluated
+ * @param parameterValues
+ * the arguments of the derived typed element (in the case of a
+ * {@link FacetOperation}; can be <code>null</code> if there are
+ * no parameters)
+ * @param resultType
+ * the type that the returned value must have
+ * @return the result of the evaluation
+ * @throws DerivedTypedElementException
+ * <ul>
+ * <li>in case of error in the derived typed element</li>
+ * <li>in case of error when evaluating the derived typed
+ * element</li>
+ * <li>if the effective return type does not match the expected
+ * type</li>
+ * </ul>
+ */
+ <T> List<T> evaluateMultiValued(DerivedTypedElement derivedTE,
+ EObject source, List<ParameterValue> parameterValues,
+ Class<T> resultType, IFacetManager facetManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * Evaluates a derived typed element on a list of model elements in a single
+ * call.
+ *
+ * @param derivedTE
+ * the derived typed element to evaluate
+ * @param sources
+ * the model elements on which the derived typed element must be
+ * evaluated
+ * @param parameterValues
+ * the arguments of the derived typed element (in the case of a
+ * {@link FacetOperation}; can be <code>null</code> if there are
+ * no parameters)
+ * @param resultType
+ * the expected type of the returned list:
+ * <ul>
+ * <li> {@link DerivedTypedElementEObjectResult} if the
+ * {@link DerivedTypedElement} is a single-valued
+ * {@link EReference} or {@link EOperation} that returns EObjects
+ * <li>{@link DerivedTypedElementEObjectListResult} if the
+ * {@link DerivedTypedElement} is a multi-valued
+ * {@link EReference} or {@link EOperation} that returns EObjects
+ * <li>{@link DerivedTypedElementPrimitiveTypeResult} if the
+ * {@link DerivedTypedElement} is a single-valued
+ * {@link EAttribute} or {@link EOperation} that returns a
+ * primitive type value
+ * <li>{@link DerivedTypedElementPrimitiveTypeListResult} if the
+ * {@link DerivedTypedElement} is a multi-valued
+ * {@link EAttribute} or {@link EOperation} that returns a list
+ * of primitive type values
+ * </ul>
+ * @return one derived typed element result for each source element that was
+ * evaluated
+ * @throws DerivedTypedElementException
+ * <ul>
+ * <li>in case of error in the derived typed element.
+ * <b>Note</b>: an error that happens when evaluating the
+ * derived typed element on any of the given sources is not
+ * thrown but stored in the corresponding element result.</li>
+ * <li>if the effective return type does not match the expected
+ * type</li>
+ * </ul>
+ */
+ <T extends ETypedElementResult> List<T> batchEvaluate(
+ DerivedTypedElement derivedTE,
+ Collection<? extends EObject> sources,
+ List<ParameterValue> parameterValues, Class<T> resultType,
+ IFacetManager facetManager) throws DerivedTypedElementException;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IEFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IEFacetManager.java
new file mode 100644
index 00000000000..70e95a52cc2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IEFacetManager.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.QueryContext;
+import org.eclipse.emf.facet.efacet.QueryResult;
+import org.eclipse.emf.facet.efacet.core.exception.QueryException;
+import org.eclipse.emf.facet.efacet.core.internal.EFacetManager;
+
+/**
+ * This interface allows the user to use the EMF Facet API for Query and Facet.
+ *
+ * @deprecated use {@link IDerivedTypedElementManager} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381225)
+ */
+@Deprecated
+public interface IEFacetManager {
+ IEFacetManager INSTANCE = new EFacetManager();
+
+ /**
+ * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking
+ * into consideration some {@link ParameterValue}
+ */
+ QueryResult evaluate(final Query query, final EObject eObject,
+ final List<ParameterValue> parameterValues);
+
+ /**
+ * This method is used to evaluate the given {@link Query} on the given {@link EObject}
+ */
+ QueryResult evaluate(final Query query, final EObject eObject);
+
+ /**
+ * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject, List)} but rather
+ * than return the errors into a {@link QueryResult} instance, it throws an exception.
+ *
+ * @param eObject
+ * The query evaluation context
+ * @return The query result.
+ * @throws QueryException
+ */
+ Object basicEvaluate(final Query query, final EObject eObject,
+ final List<ParameterValue> parameterValues) throws QueryException;
+
+ /**
+ * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject)} but rather than
+ * return the errors into a {@link QueryResult} instance, it throws an exception.
+ *
+ * @param eObject
+ * The query evaluation context
+ * @return The query result.
+ * @throws QueryException
+ */
+ Object basicEvaluate(final Query query, final EObject eObject)
+ throws QueryException;
+
+ /**
+ * Evaluate the query on a set of models and model elements described by the
+ * <code>queryContext</code> parameter.
+ *
+ * The query is evaluated on each contextually referred model element and on each element of a
+ * contextually referred model.
+ *
+ * @param queryContext
+ * The query evaluation context described by a QueryContext instance.
+ * @param parameterValues
+ * The query parameter values.
+ * @return A list of QueryResult (one per evaluation)
+ * @throws QueryException
+ */
+ List<QueryResult> evaluate(final Query query,
+ final QueryContext queryContext,
+ final List<ParameterValue> parameterValues) throws QueryException;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetAction.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetAction.java
new file mode 100644
index 00000000000..86eefb3817f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetAction.java
@@ -0,0 +1,135 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.core.internal.FacetActionImpl;
+import org.eclipse.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+
+/**
+ * This interface contains methods declaration to deal with {@link Facet} and
+ * {@link FacetSet}.
+ *
+ * @since 0.1
+ * @noimplement
+ * @noextend
+ * @deprecated use {@link IFacetActions2} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381226)
+ */
+@Deprecated
+public interface IFacetAction {
+
+ IFacetAction INSTANCE = new FacetActionImpl();
+
+ /**
+ * Add the given facetSet to the given facetSet model file, which will be created
+ *
+ * @param facetSet
+ * the facetSet to be created. Cannot be <code>null</code>
+ * @param project
+ * the new file in which the facetSet has to be created. Cannot be <code>null</code>,
+ * and cannot already exist
+ * @since 0.2
+ */
+ void createFacetSet(FacetSet facetSet, IFile file) throws IOException,
+ InvalidFacetSetException;
+
+ /**
+ * Add the given {@link Facet} to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the parent facetSet, cannot be null
+ * @param facet
+ * the {@link Facet}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add EMF command, cannot be null
+ */
+ Facet createFacetInFacetSet(FacetSet facetSet, Facet facet,
+ EditingDomain editingDomain);
+
+ /**
+ * Add the given {@link FacetAttribute} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetAttribute
+ * the {@link FacetAttribute}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute,
+ EditingDomain editingDomain);
+
+ /**
+ * Add the given {@link FacetReference} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetReference
+ * the {@link FacetReference}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addReferenceInFacet(Facet facet, FacetReference facetReference,
+ EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link FacetOperation} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetOperation
+ * the new {@link FacetOperation}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addOperationInFacet(Facet facet, FacetOperation facetOperation,
+ EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link EParameter} to the given {@link FacetOperation}
+ *
+ * @param operation
+ * the parent {@link EOperation}
+ * @param parameter
+ * the new {@link EParameter}
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addParameterInOperation(FacetOperation operation,
+ EParameter parameter, EditingDomain editingDomain);
+
+ /**
+ * Set the given URI to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the {@link FacetSet} to be modified
+ * @param nsUri
+ * the Uri
+ * @param editingDomain
+ * the editing domain needed to perform the Set Emf command, cannot be null
+ */
+ void setFacetSetNsUri(FacetSet facetSet, String nsUri,
+ EditingDomain editingDomain);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetActions.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetActions.java
new file mode 100644
index 00000000000..c09141dc386
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetActions.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.facet.efacet.core.internal.FacetActionsImpl;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+
+/**
+ * This interface contains methods to create {@link FacetSet}s.
+ *
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IFacetActions {
+
+ IFacetActions INSTANCE = new FacetActionsImpl();
+
+ /**
+ * Add the given facetSet to the given facetSet model file, which will be
+ * created
+ *
+ * @param facetSet
+ * the facetSet to be created. Cannot be <code>null</code>
+ * @param file
+ * the new file in which the facetSet has to be created. Cannot
+ * be <code>null</code>, and cannot already exist
+ */
+ void saveFacetSet(FacetSet facetSet, IFile file) throws IOException,
+ InvalidFacetSetException;
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactory.java
new file mode 100644
index 00000000000..be139944096
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactory.java
@@ -0,0 +1,193 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+/**
+ * This interface provide a command factory. A command modify the editingDomain.
+ *
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IFacetCommandFactory {
+
+ /**
+ * Create the command to add a FacetSet (facetSet) to an existing FacetSet
+ * (parent).
+ *
+ * @param parent
+ * the parent of the facetSet to add.
+ * @param facetSet
+ * the facetSet to add.
+ * @return the command.
+ */
+ Command createFacetSetInFacetSetCommand(FacetSet parent, FacetSet facetSet);
+
+ /**
+ * Create the command to add a Facet (facet) to an existing FacetSet
+ * (parent).
+ *
+ * @param parent
+ * the parent of the facet to add.
+ * @param facet
+ * the facet to add.
+ * @return the command.
+ */
+ Command createFacetInFacetSetCommand(FacetSet parent, Facet facet);
+
+ /**
+ * Create the command to add an Attribute (facetAttrbute) to an existing
+ * Facet (parent).
+ *
+ * @param parent
+ * the parent of the attribute to add.
+ * @param facetAttrbute
+ * the attribute to add.
+ * @return the command.
+ */
+ Command createEditFacetStructuralFeatureCommand(
+ final DerivedTypedElement feature, final Facet container,
+ final String name, final int lowerBd, final int upperBd,
+ final EClassifier type, final boolean ordered,
+ final boolean unique, final Query query, final boolean volatilee,
+ final boolean change, final boolean derived,
+ final boolean transientt);
+
+ /**
+ * Create the command to add a Reference (facetReference) to an existing
+ * Facet (parent).
+ *
+ * @param parent
+ * the parent of the reference to add.
+ * @param facetReference
+ * the reference to add.
+ * @return the command.
+ */
+ Command createAddReferenceInFacetCommand(Facet parent,
+ FacetReference facetReference);
+
+ /**
+ * Create the command to add an Operation (FacetOperation) to an existing
+ * Facet (parent).
+ *
+ * @param parent
+ * the parent of the operation to add.
+ * @param facetOperation
+ * the operation to add.
+ * @return the command.
+ */
+ Command createAddOperationInFacetCommand(Facet parent,
+ FacetOperation facetOperation);
+
+ /**
+ * Create the command to add a Parameter (operationParameter) to an existing
+ * Operation (parent).
+ *
+ * @param parent
+ * the parent of the operation to add.
+ * @param facetOperation
+ * the operation to add.
+ * @return the command.
+ */
+ Command createAddParameterInOperationCommand(FacetOperation parent,
+ EParameter opeParameter);
+
+ /**
+ * Create the command to change the owner of an element.
+ *
+ * @param element
+ * @param newOwner
+ * @return
+ */
+ Command createChangeOwnerCommand(Object element, Object newOwner);
+
+ /**
+ * Create the command to change the attributes of a FacetSet.
+ *
+ * @param initialElement
+ * @param newElement
+ * @param newElement
+ * @return
+ */
+ Command createEditFacetSetCommand(final FacetSet editedFacetSet,
+ final FacetSet container, final String name);
+
+ /**
+ * Create the command to change the attributes of a Facet.
+ *
+ * @param initialElement
+ * @param newElement
+ * @return
+ */
+ Command createEditFacetCommand(Facet facet, FacetSet container,
+ String name, ETypedElement conformance, EClass extendEClass,
+ FacetSet extendedFacetSet);
+
+ /**
+ * Create the command to change the attributes of a FacetAttribute.
+ *
+ * @param initialElement
+ * @param newElement
+ * @return
+ */
+ Command createSetFacetAttributeCommand(final Facet initialContainer,
+ final FacetAttribute initialElement,
+ final FacetAttribute newElement);
+
+ /**
+ * Create the command to change the attributes of a FacetReference.
+ *
+ * @param initialElement
+ * @param newElement
+ * @return
+ */
+ Command createSetFacetReferenceCommand(final Facet initialContainer,
+ final FacetReference initialElement,
+ final FacetReference newElement);
+
+ /**
+ * Create the command to change the attributes of a FacetOperation.
+ *
+ * @param initialElement
+ * @param newElement
+ * @return
+ */
+ Command createEditFacetOperationCommand(DerivedTypedElement dte,
+ Facet facetContainer, String name, int lowerBound, int upperBound,
+ EClassifier type, boolean ordered, boolean unique, Query query);
+
+ /**
+ * Create the command to change the attributes of a FacetAttribute.
+ *
+ * @param initialElement
+ * @param newElement
+ * @return
+ */
+ Command createEditOperationParameterCommand(EParameter parameter,
+ FacetOperation container, String name, int lowerBound,
+ int upperBound, EClassifier type, boolean ordered, boolean unique);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactoryFactory.java
new file mode 100644
index 00000000000..fbd6cec84a6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetCommandFactoryFactory.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.internal.FacetCommandFactoryFactory;
+
+/**
+ * @since 0.3
+ */
+public interface IFacetCommandFactoryFactory {
+
+ IFacetCommandFactoryFactory DEFAULT = new FacetCommandFactoryFactory();
+
+ IFacetCommandFactory createCommandFactory(EditingDomain editingDomain);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManager.java
new file mode 100644
index 00000000000..395ab0e8264
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManager.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API
+ * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+
+/**
+ * This interface allows clients to use the EMF Facet API to get and set the values of virtually
+ * added {@link EReference}s and {@link EAttribute}s, and invoke {@link EOperation}s.
+ * <p>
+ * Derived {@link FacetAttribute}s and {@link FacetReference}s are computed by queries, whereas
+ * non-derived {@link FacetAttribute}s and {@link EAttribute}s and {@link EReference}s and
+ * {@link FacetReference}s are stored in the serialization {@link Resource} specified in the
+ * {@link IFacetManagerFactory} that created this {@link IFacetManager}.
+ *
+ * @since 0.2
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IFacetManager {
+
+ /**
+ * Serialize the model containing the structural feature instances.
+ */
+ void saveStructuralFeatureInstanceModel() throws FacetManagerException;
+
+ /**
+ * Returns whether the given model element conforms to the given Facet
+ *
+ * @param eObject
+ * the model element
+ * @param facet
+ * the Facet the applicability of which is being tested
+ * @throws FacetManagerException
+ * if there is an error evaluating the Facet's conformance typed element
+ * @return whether the given model element should be seen as an instance of the given Facet
+ */
+ boolean isConforming(final EObject eObject, final Facet facet)
+ throws FacetManagerException;
+
+ /**
+ * Set the value of the given {@link EStructuralFeature} on the given
+ * {@link EObject} to the given {@link Object} value.
+ *
+ * @param eObject
+ * the model element whose feature must be set
+ * @param structuralFeature
+ * the feature to set
+ * @param newValue
+ * the new value
+ * @param editingDomain
+ * @throws FacetManagerException
+ * <ul>
+ * <li>if the eObject doesn't conform to the Facet of the given
+ * attribute (in the case of a FacetAttribute)</li>
+ * <li>if the Facet of the given attribute is not applicable to
+ * the given eObject (in the case of a FacetAttribute)</li>
+ * <li>
+ * if there is an error evaluating the Facet's conformance typed
+ * element</li>
+ * </ul>
+ */
+ void set(EObject eObject, EStructuralFeature structuralFeature,
+ Object newValue, EditingDomain editingDomain)
+ throws FacetManagerException;
+
+ /**
+ * Evaluate the given {@link EOperation} of the given {@link EObject}. The
+ * returned value has to be of the given expectedType {@link Class}
+ *
+ * @param eObject
+ * the model element on which the operation is evaluated
+ * @param operation
+ * the operation to evaluate
+ * @param resultType
+ * the expected type of the returned value; if the effective type
+ * is not compatible, an UnmatchingExpectedTypeException will be
+ * thrown
+ * @param arguments
+ * the values of the parameters of the EOperation that is
+ * evaluated: they must match both in size, types and
+ * multiplicity
+ * @return the return value of the operation
+ * @throws FacetManagerException
+ * <ul>
+ * <li>if the effective type does not match the expected type</li>
+ * <li>in case of an error in the query that returns the value
+ * (can only happen in the case of a FacetOperation)</li>
+ * <li>in case of an error when delegating to the Ecore
+ * reflexive API (if the given EOperation is not a
+ * FacetOperation)</li>
+ * <li>if the eObject doesn't conform to the Facet of the given
+ * operation (in the case of a FacetOperation)</li>
+ * <li>if the Facet of the given operation is not applicable to
+ * the given eObject (in the case of a FacetOperation)</li>
+ * <li>if there is an error evaluating the Facet's conformance
+ * typed element</li>
+ * <li>if the given actual parameters don't match the
+ * EOperation's formal parameters</li>
+ * </ul>
+ */
+ <T> T invoke(EObject eObject, EOperation operation,
+ Class<T> resultType, EditingDomain editingDomain,
+ Object... arguments) throws FacetManagerException;
+
+ /**
+ * Invoke the given {@link EOperation} on each element of the given
+ * collection of {@link EObject}s.
+ *
+ * @param eObjects
+ * the model elements on which the operation is evaluated
+ * @param operation
+ * the operation to evaluate
+ * @param arguments
+ * the values of the parameters of the EOperation that is
+ * evaluated: they must match both in size, types and
+ * multiplicity
+ * @return the list of results, one for each model element of the given
+ * <code>eObjects</code>
+ * @throws FacetManagerException
+ * <ul>
+ * <li>in case of an error when delegating to the Ecore
+ * reflexive API (if the given EOperation is not a
+ * FacetOperation)</li>
+ * <li>
+ * in case of an error in the derived typed element that returns
+ * the value</li>
+ * </ul>
+ */
+ List<ETypedElementResult> batchInvoke(Collection<EObject> eObjects,
+ EOperation operation, Object... arguments)
+ throws FacetManagerException;
+
+ /**
+ * This method returns the list of loaded facet sets.
+ *
+ * @return a modifiable list of all FacetSets that
+ * constitute the working context of the FacetManager
+ */
+ List<FacetSet> getManagedFacetSets();
+
+ /** @return the resourceSet used to manage the facet models. */
+ ResourceSet getResourceSet();
+
+ <T> T getOrInvoke(EObject element, ETypedElement query, Class<T> aClass)
+ throws FacetManagerException;
+
+ <T> List<T> getOrInvokeMultiValued(EObject eObject, ETypedElement feature,
+ Class<T> aClass) throws FacetManagerException;
+
+ <T> List<ETypedElementResult> batchGetOrInvoke(Collection<EObject> sources,
+ ETypedElement query, Class<T> aClass) throws FacetManagerException;
+
+ /**
+ * Get virtual references from an EObject. References must be defined in a
+ * FacetSet
+ *
+ * @param eObject
+ * Model element
+ * @return All not duplicated virtual references
+ * @throws FacetManagerException
+ * @since 0.4
+ */
+ Set<EReference> getReferences(EObject eObject) throws FacetManagerException;
+
+ /**
+ * Get virtual attributes from an EObject. References must be defined in a
+ * FacetSet
+ *
+ * @param eObject
+ * Model element
+ * @return All not duplicated virtual attributes
+ * @throws FacetManagerException
+ * @since 0.4
+ */
+ Set<EAttribute> getAttributes(EObject eObject) throws FacetManagerException;
+
+ /**
+ * Get virtual references and attributes from an EObject. References must be
+ * defined in a FacetSet
+ *
+ * @param eObject
+ * Model element
+ * @return All not duplicated virtual references and attributes
+ * @throws FacetManagerException
+ * @since 0.4
+ */
+ Set<EStructuralFeature> getStructuralFeature(EObject eObject)
+ throws FacetManagerException;
+
+ /**
+ * Adds a listener to this manager that will be notified when this manager's
+ * state changes.
+ *
+ * @param listener
+ * The listener to be added
+ * @since 0.4
+ */
+ void addListener(IFacetManagerListener listener);
+
+ /**
+ * Removes a listener from this manager.
+ *
+ * @param listener
+ * The listener to be removed
+ * @since 0.4
+ */
+ void removeListener(IFacetManagerListener listener);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerFactory.java
new file mode 100644
index 00000000000..569a56a8e82
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerFactory.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.efacet.core.internal.FacetManagerFactory;
+
+/**
+ * Factory for {@link IFacetManager}.
+ *
+ * @since 0.2
+ */
+public interface IFacetManagerFactory {
+
+ /**
+ * The singleton instance of the factory.
+ */
+ IFacetManagerFactory DEFAULT = new FacetManagerFactory();
+
+ /**
+ * Create an {@link IFacetManager}.
+ *
+ * @param resource
+ * the {@link Resource} in which virtual {@link EStructuralFeature}s are serialized.
+ * Can be null if no EStructuralFeature provided a Facet are used.
+ */
+ IFacetManager getOrCreateFacetManager(Resource resource);
+
+ /**
+ * Create an {@link IFacetManager}.
+ *
+ * @param resourceSet
+ * the resourceSet which will be used to manage the facet models.
+ *
+ */
+ IFacetManager getOrCreateFacetManager(ResourceSet resourceSet);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerListener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerListener.java
new file mode 100644
index 00000000000..555af8b0854
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetManagerListener.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Mia-Maint
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core;
+
+/**
+ * This interface allows clients to manage listeners added on the
+ * {@link IFacetManager}
+ *
+ * @since 0.4
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IFacetManagerListener {
+
+ /**
+ * Notifies that the {@link IFacetManager} has changed.
+ */
+ void facetManagerChanged();
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManager.java
new file mode 100644
index 00000000000..a155b11a84a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManager.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core;
+
+import java.util.Collection;
+
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+
+/**
+ * @since 0.2
+ */
+public interface IFacetSetCatalogManager {
+
+ Collection<FacetSet> getRegisteredFacetSets();
+
+ void registerFacetSet(FacetSet facetSet);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java
new file mode 100644
index 00000000000..d79d7eed028
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.efacet.core;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.efacet.core.internal.FacetCatalogManagerFactory;
+
+/**
+ * @since 0.2
+ */
+public interface IFacetSetCatalogManagerFactory {
+
+ IFacetSetCatalogManagerFactory DEFAULT = new FacetCatalogManagerFactory();
+
+ IFacetSetCatalogManager getOrCreateFacetSetCatalogManager(ResourceSet resourceSet);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/DerivedTypedElementException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/DerivedTypedElementException.java
new file mode 100644
index 00000000000..f8ab410c436
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/DerivedTypedElementException.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ */
+package org.eclipse.emf.facet.efacet.core.exception;
+
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+
+/**
+ * This exception is raised when something is wrong with a query, and there is not a more specific
+ * sub-class to describe the error (e.g. {@link DerivedTypedElementEvaluationException} )
+ * @since 0.2
+ */
+public class DerivedTypedElementException extends Exception {
+
+ // This class is a copy of :
+ // org.eclipse.emf.facet.infra.query.core.exception.ModelQueryException
+
+ private static final long serialVersionUID = -3203874059325745157L;
+
+ public DerivedTypedElementException(final String message) {
+ super(message);
+ }
+
+ public DerivedTypedElementException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public DerivedTypedElementException(final Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/FacetManagerException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/FacetManagerException.java
new file mode 100644
index 00000000000..ee949cf9ef8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/FacetManagerException.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ */
+package org.eclipse.emf.facet.efacet.core.exception;
+
+/**
+ * @since 0.2
+ */
+public class FacetManagerException extends Exception {
+
+ private static final long serialVersionUID = -4670132391244495825L;
+
+ public FacetManagerException() {
+ super();
+ }
+
+ public FacetManagerException(final String message) {
+ super(message);
+ }
+
+ public FacetManagerException(final Throwable cause) {
+ super(cause);
+ }
+
+ public FacetManagerException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryException.java
new file mode 100644
index 00000000000..88c9db848b7
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryException.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ */
+package org.eclipse.emf.facet.efacet.core.exception;
+
+/**
+ * This exception is raised when something is wrong with a query, and there is not a more specific
+ * sub-class to describe the error (e.g. {@link QueryExecutionException} )
+ *
+ * @deprecated replaced by {@link DerivedTypedElementException}
+ */
+@Deprecated
+public class QueryException extends Exception {
+
+ // This class is a copy of :
+ // org.eclipse.emf.facet.infra.query.core.exception.ModelQueryException
+
+ private static final long serialVersionUID = -3203874059325745157L;
+
+ public QueryException(final String message) {
+ super(message);
+ }
+
+ public QueryException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public QueryException(final Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryExecutionException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryExecutionException.java
new file mode 100644
index 00000000000..2bad4a43d81
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryExecutionException.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ */
+package org.eclipse.emf.facet.efacet.core.exception;
+
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+
+/**
+ * This exception occurs when something goes wrong during the execution of a
+ * query.
+ *
+ * @deprecated replaced by {@link DerivedTypedElementEvaluationException} cf.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=374678
+ */
+@Deprecated
+public class QueryExecutionException extends QueryException {
+ // This class is a copy of
+ // org.eclipse.emf.facet.infra.query.core.ModelQueryExecutionException
+
+ private static final long serialVersionUID = -8464252257666617685L;
+
+ public QueryExecutionException(final String message) {
+ super(message);
+ }
+
+ public QueryExecutionException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public QueryExecutionException(final Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryTypeCheckingException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryTypeCheckingException.java
new file mode 100644
index 00000000000..6026cc1426c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/exception/QueryTypeCheckingException.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ */
+package org.eclipse.emf.facet.efacet.core.exception;
+
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException;
+
+/**
+ * This exception occurs when the type of a query result is not the one expected
+ *
+ * @deprecated replaced by {@link DerivedTypedElementTypeCheckingException}
+ */
+@Deprecated
+public class QueryTypeCheckingException extends QueryException {
+
+ private static final long serialVersionUID = -9064274334817642819L;
+
+ public QueryTypeCheckingException(final String message) {
+ super(message);
+ }
+
+ public QueryTypeCheckingException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public QueryTypeCheckingException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Activator.java
new file mode 100644
index 00000000000..172b3f45387
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Activator.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends Plugin {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return Activator.context;
+ }
+
+ @Override
+ public void start(final BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ Activator.context = bundleContext;
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ Activator.plugin = null;
+ super.stop(bundleContext);
+ }
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static Plugin getDefault() {
+ return Activator.plugin;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/CastUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/CastUtils.java
new file mode 100644
index 00000000000..3af72f2f222
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/CastUtils.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+
+public final class CastUtils {
+
+ private CastUtils() {
+ //Must no be used.
+ }
+
+ /**
+ * Cast the given value to a List of the given type
+ *
+ * @param value
+ * the list
+ * @param expectedType
+ * the expected type of the list elements
+ * @param checkType
+ * whether to check the type of each element in the given list; should be
+ * <code>true</code> if the list comes from outside the framework, and
+ * <code>false</code> if the list is managed by the framework (and so already
+ * checked)
+ * @return the cast list
+ * @throws UnmatchingExpectedTypeException
+ */
+ @SuppressWarnings("unchecked")
+ //@SuppressWarnings("unchecked") The cast is checked by the both if statement.
+ public static <T> List<T> castToExpectedListType(final Object value, final Class<T> expectedType, final boolean checkType)
+ throws UnmatchingExpectedTypeException {
+ List<T> newList = new LinkedList<T>();
+ if (value instanceof List) {
+ newList = (List<T>) value;
+ } else {
+ newList.add((T) value);
+ }
+ final List<T> list = newList;
+ if (checkType) {
+ checkTypeOfAllListElements(list, expectedType);
+ }
+ return list;
+ }
+
+ @SuppressWarnings("unchecked")
+ //@SuppressWarnings("unchecked") This method is used to isolate unsafe cast.
+ public static <T> T castToExpectedType(final Object value, final Class<T> expectedType)
+ throws UnmatchingExpectedTypeException {
+ try {
+ return (T) value;
+ } catch (ClassCastException e) {
+ throw new UnmatchingExpectedTypeException("Type mismatch. Expected: " + //$NON-NLS-1$
+ expectedType.getClass().getName() + ", got " + value.getClass().getName(), e); //$NON-NLS-1$);
+ }
+ }
+
+ public static void checkTypeOfAllListElements(final List<?> list, final Class<?> expectedType) throws UnmatchingExpectedTypeException {
+ if (expectedType == null) {
+ // null means match everything
+ return;
+ }
+ final Iterator<?> iterator = list.iterator();
+ int index = -1;
+ while (iterator.hasNext()) {
+ final Object object = iterator.next();
+ index++;
+ if (object != null && !expectedType.isInstance(object)) {
+ throw new UnmatchingExpectedTypeException("Type mismatch at index " + index, expectedType, object); //$NON-NLS-1$
+ }
+ }
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementManager.java
new file mode 100644
index 00000000000..cb5d53f4665
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementManager.java
@@ -0,0 +1,877 @@
+/**
+ * Copyright (c) 2011, 2012, 2013 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+import org.eclipse.emf.facet.efacet.core.internal.query.DerivedTypedElementImplementationFactoryRegistry;
+import org.eclipse.emf.facet.efacet.core.internal.query.QueryImplementationFactoryRegistry;
+import org.eclipse.emf.facet.efacet.core.internal.query.QueryUtils;
+import org.eclipse.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+import org.eclipse.emf.facet.util.core.Logger;
+
+public class DerivedTypedElementManager implements IDerivedTypedElementManager {
+
+ public Object evaluate(final DerivedTypedElement derivedTypedElement,
+ final EObject source, final List<ParameterValue> parameterValues,
+ final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ Object result;
+ if (derivedTypedElement.isMany()) {
+ result = evaluateMultiValued(derivedTypedElement, source, parameterValues, null, facetManager);
+ } else {
+ result = evaluateSingleValued(derivedTypedElement, source, parameterValues, null, facetManager);
+ }
+ return result;
+ }
+
+ public Object evaluate(final Query query, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ final IQueryImplementation evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
+ final DerivedTypedElement derivedTE = QueryUtils.getOwningDerivedTypedElement(query);
+ Object result;
+ try {
+ result = evaluator.getValue(query, derivedTE, source, parameterValues, facetManager);
+ } catch (Exception e) {
+ throw new DerivedTypedElementEvaluationException(e);
+ }
+ return result;
+ }
+
+ public <T> T evaluateSingleValued(final DerivedTypedElement derivedTypedElement,
+ final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ if (derivedTypedElement.isMany()) {
+ throw new IllegalArgumentException("This method doesn't accept a multi-valued derived typed element."); //$NON-NLS-1$
+ }
+
+ Query query = derivedTypedElement.getQuery();
+ if (query == null) {
+ throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
+ }
+ Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query);
+
+ // expectedResultType == null means match everything
+ // And a null value for queryResult matches any type
+ if (expectedType != null && queryResult != null && !expectedType.isInstance(queryResult)) {
+ Exception e1 = new UnmatchingExpectedTypeException(
+ "The derived typed element did not evaluate to the expected type", expectedType, queryResult); //$NON-NLS-1$
+ throw new DerivedTypedElementException(e1);
+ }
+ // just checked
+ @SuppressWarnings("unchecked")
+ T typedQueryResult = (T) queryResult;
+ return typedQueryResult;
+ }
+
+ public <T> List<T> evaluateMultiValued(final DerivedTypedElement derivedTypedElement,
+ final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ if (!derivedTypedElement.isMany()) {
+ throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$
+ }
+
+ Query query = derivedTypedElement.getQuery();
+ if (query == null) {
+ throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
+ }
+ Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query);
+ queryResult = setAsList(queryResult);
+ List<T> result;
+ if (queryResult instanceof List<?>) {
+ List<?> queryListResult = (List<?>) queryResult;
+ for (Object queryResultElement : queryListResult) {
+ // expectedType == null means match everything
+ // And a null queryResultElement for queryResult matches any type
+ if (expectedType != null && queryResultElement != null && !expectedType.isInstance(queryResultElement)) {
+ Exception e1 = new UnmatchingExpectedTypeException(
+ "The derived typed element did not evaluate to the expected type"); //$NON-NLS-1$
+ throw new DerivedTypedElementException(e1);
+ }
+ }
+ // just checked
+ @SuppressWarnings("unchecked")
+ List<T> typedQueryListResult = (List<T>) queryListResult;
+ result = typedQueryListResult;
+ } else {
+ throw new DerivedTypedElementException("The given multi-valued derived typed element did not evaluate to a List."); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ protected Object evaluate(final DerivedTypedElement derivedTE, final EObject source, final List<ParameterValue> parameterValues,
+ final IFacetManager facetManager, final Query query) throws DerivedTypedElementException {
+ Object queryResult;
+ IQueryImplementation evaluator = null;
+ IDerivedTypedElementImplementation evaluator2 = null;
+ try {
+ evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
+ } catch (DerivedTypedElementException exc) {
+ final String message = String.format(
+ "%s will try to use a deprected implementation", //$NON-NLS-1$
+ this.getClass().getName());
+ Logger.logError(exc, message, Activator.getDefault());
+ evaluator2 = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
+ }
+ if (evaluator == null) {
+ queryResult = evaluateAndCheck(derivedTE, source, parameterValues, evaluator2, facetManager);
+ } else {
+ queryResult = evaluateAndCheck(derivedTE.getQuery(), source, parameterValues, evaluator, facetManager);
+ }
+ return queryResult;
+ }
+
+ /** @deprecated support for the deprecated {@link IDerivedTypedElementImplementation} */
+ @Deprecated
+ private static Object evaluateAndCheck(final DerivedTypedElement derivedTE, final EObject source,
+ final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation evaluator, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ Query query = derivedTE.getQuery();
+ checkQuery(query, source);
+ Object result;
+ try {
+ result = evaluator.getValue(derivedTE, source, parameterValues, facetManager);
+ } catch (Throwable e) {
+ if (e instanceof DerivedTypedElementEvaluationException) {
+ throw (DerivedTypedElementEvaluationException) e;
+ }
+ throw new DerivedTypedElementEvaluationException(e);
+ }
+ // result = setAsList(result);
+ // gdupe: I don't understand why the result is wrapped in a list
+ checkResult(query, result, evaluator.getCheckResultType(),
+ isPrimitive(QueryUtils.getReturnType(query)));
+ return result;
+ }
+
+ private static Object evaluateAndCheck(final Query query, final EObject source, final List<ParameterValue> parameterValues,
+ final IQueryImplementation evaluator, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ checkQuery(query, source);
+ Object result;
+ try {
+ result = evaluator.getValue(query, QueryUtils.getOwningDerivedTypedElement(query), source, parameterValues, facetManager);
+ } catch (Throwable e) {
+ if (e instanceof DerivedTypedElementEvaluationException) {
+ throw (DerivedTypedElementEvaluationException) e;
+ }
+ throw new DerivedTypedElementEvaluationException(e);
+ }
+ checkResult(query, result, evaluator.isCheckResultType(), isPrimitive(QueryUtils.getReturnType(query)));
+ return result;
+ }
+
+ private static void checkQuery(final Query query, final EObject source) throws DerivedTypedElementException {
+ if (query == null) {
+ throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
+ }
+
+ EClassifier sourceType = QueryUtils.getSourceType(query);
+ if (sourceType == null && source != null) {
+ throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$
+ }
+
+ // a null value for eObject matches any type
+ if (sourceType != null && source != null && !sourceType.isInstance(source)) {
+ StringBuffer message = new StringBuffer();
+ message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$
+ message.append(source.eClass().getName());
+ message.append("' found; expected '"); //$NON-NLS-1$
+ message.append(sourceType.getName());
+ message.append("'."); //$NON-NLS-1$
+ throw new DerivedTypedElementTypeCheckingException(message.toString());
+ }
+ }
+
+ // public List<? extends AbstractDerivedTypedElementResult> evaluate(final DerivedTypedElement
+ // derivedTypedElement, final Collection<EObject> sources,
+ // final List<ParameterValue> parameterValues) throws DerivedTypedElementException {
+ // if (derivedTypedElement.isMany()) {
+ // try {
+ // return evaluateSingleValued(derivedTypedElement, sources, parameterValues, null);
+ // } catch (UnmatchingExpectedTypeException e) {
+ // // should never happen
+ // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$
+ // }
+ // } else {
+ // try {
+ // return evaluateMultiValued(derivedTypedElement, sources, parameterValues, null);
+ // } catch (UnmatchingExpectedTypeException e) {
+ // // should never happen
+ // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$
+ // }
+ // }
+ // }
+
+
+ // batch evaluation disabled : Bug 365429 - DerivedTypedElementManager : re-implement batch evaluation
+
+ public <T extends ETypedElementResult> List<T> batchEvaluate(final DerivedTypedElement derivedTypedElement,
+ final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+
+ throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
+
+// if (derivedTypedElement == null) {
+// throw new IllegalArgumentException("The given derived typed element must not be null"); //$NON-NLS-1$
+// }
+//
+// List<T> abstractResultList;
+//
+// Query query = derivedTypedElement.getQuery();
+// if (query == null) {
+// throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
+// }
+// EClassifier eType = derivedTypedElement.getEType();
+// if (eType == null) {
+// throw new DerivedTypedElementException("The given derived typed element has a null type"); //$NON-NLS-1$
+// }
+// IDerivedTypedElementImplementation evaluator = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query);
+// if (evaluator == null) {
+// throw new DerivedTypedElementEvaluationException("No evaluator was found for a query of type " + query.getClass().getName()); //$NON-NLS-1$
+// }
+//
+// final boolean primitiveType = isPrimitive(eType);
+//
+// // if the evaluator implements multiple evaluation itself, then use it
+// if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
+// IDerivedTypedElementCollectionImplementation collectionEvaluator = (IDerivedTypedElementCollectionImplementation) evaluator;
+// if (derivedTypedElement.isMany()) {
+// if (primitiveType) {
+// if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, collectionEvaluator);
+// // we just checked the type parameter T through expectedType
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) listResultList;
+// abstractResultList = castList;
+// } else {
+// if (expectedType != DerivedTypedElementEObjectListResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, collectionEvaluator);
+// // we just checked the type parameter T through expectedType
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) listResultList;
+// abstractResultList = castList;
+// }
+// } else {
+// if (primitiveType) {
+// if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, collectionEvaluator);
+// // we just checked the type parameter T through expectedType
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) resultList;
+// abstractResultList = castList;
+// } else {
+// if (expectedType != DerivedTypedElementEObjectResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, collectionEvaluator);
+// // we just checked the type parameter T through expectedType
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) resultList;
+// abstractResultList = castList;
+// }
+// }
+//
+// } else {
+// // otherwise, do multiple evaluation by calling the evaluator's
+// // single evaluation multiple times
+//
+// if (derivedTypedElement.isMany()) {
+// if (primitiveType) {
+// if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator(
+// derivedTypedElement, sources, parameterValues, evaluator);
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) listResultList;
+// abstractResultList = castList;
+// } else {
+// if (expectedType != DerivedTypedElementEObjectListResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator(
+// derivedTypedElement, sources, parameterValues, evaluator);
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) listResultList;
+// abstractResultList = castList;
+// }
+// } else {
+// if (primitiveType) {
+// if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, evaluator);
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) resultList;
+// abstractResultList = castList;
+// } else {
+// if (expectedType != DerivedTypedElementEObjectResult.class) {
+// throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$
+// "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$
+// }
+// List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator(
+// derivedTypedElement, sources, parameterValues, null);
+// @SuppressWarnings("unchecked")
+// List<T> castList = (List<T>) resultList;
+// abstractResultList = castList;
+// }
+// }
+// }
+// return abstractResultList;
+ }
+
+// private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementCollectionImplementation collectionEvaluator)
+// throws DerivedTypedElementException {
+//
+// List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator
+// .getValues(derivedTypedElement, sources, parameterValues);
+//
+// // check the return type from the evaluator in order to be able to cast safely
+// for (int index = 0; index < listResultList.size(); index++) {
+// AbstractDerivedTypedElementResult elementResult = listResultList.get(index);
+// if (elementResult instanceof DerivedTypedElementPrimitiveTypeListResult<?>) {
+// DerivedTypedElementPrimitiveTypeListResult<?> derivedTypedElementPrimitiveTypeListResult = (DerivedTypedElementPrimitiveTypeListResult<?>) elementResult;
+// checkResult(derivedTypedElement.getQuery(), derivedTypedElementPrimitiveTypeListResult.getResultList(),
+// collectionEvaluator.getCheckResultType());
+// } else {
+// throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage(
+// "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$
+// DerivedTypedElementPrimitiveTypeListResult.class, elementResult));
+// }
+// }
+//
+// // just checked
+// @SuppressWarnings("unchecked")
+// List<DerivedTypedElementPrimitiveTypeListResult<?>> result = (List<DerivedTypedElementPrimitiveTypeListResult<?>>) listResultList;
+// return result;
+// }
+//
+// private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementCollectionImplementation collectionEvaluator)
+// throws DerivedTypedElementException {
+// List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator
+// .getValues(derivedTypedElement, sources, parameterValues);
+//
+// // check the return type from the evaluator in order to be able to cast safely
+// for (int index = 0; index < listResultList.size(); index++) {
+// AbstractDerivedTypedElementResult elementResult = listResultList.get(index);
+// if (elementResult instanceof DerivedTypedElementEObjectListResult<?>) {
+// DerivedTypedElementEObjectListResult<?> derivedTypedElementEObjectListResult = (DerivedTypedElementEObjectListResult<?>) elementResult;
+// checkResult(derivedTypedElement.getQuery(), derivedTypedElementEObjectListResult.getResultList(),
+// collectionEvaluator.getCheckResultType());
+// } else {
+// throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage(
+// "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$
+// DerivedTypedElementEObjectListResult.class, elementResult));
+// }
+// }
+//
+// // just checked
+// @SuppressWarnings("unchecked")
+// List<DerivedTypedElementEObjectListResult<?>> result = (List<DerivedTypedElementEObjectListResult<?>>) listResultList;
+// return result;
+// }
+//
+// private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementCollectionImplementation collectionEvaluator)
+// throws DerivedTypedElementException {
+// // TODO Auto-generated method stub
+// return null;
+// }
+//
+// private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementCollectionImplementation collectionEvaluator) throws DerivedTypedElementException {
+// // TODO Auto-generated method stub
+// return null;
+// }
+//
+// private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementImplementation evaluator) {
+//
+// Query query = derivedTypedElement.getQuery();
+//
+// List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = new ArrayList<DerivedTypedElementPrimitiveTypeListResult<?>>();
+// for (EObject eObject : sources) {
+// DerivedTypedElementPrimitiveTypeListResult<Object> primitiveTypeListResult = EFacetFactory.eINSTANCE
+// .createDerivedTypedElementPrimitiveTypeListResult();
+//
+// Throwable error = null;
+// try {
+// primitiveTypeListResult.setSource(eObject);
+// primitiveTypeListResult.setDerivedTypedElement(derivedTypedElement);
+// setParameterValues(primitiveTypeListResult.getParameterValues(), parameterValues);
+// checkSourceType(query.getSourceType(), query, eObject);
+// } catch (Throwable e) {
+// error = e;
+// }
+// if (error != null) {
+// primitiveTypeListResult.setException(error);
+// } else {
+// try {
+// Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
+// checkResult(query, evaluationResult, evaluator.getCheckResultType());
+// // checked by checkResult
+// Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult;
+// for (Object object : evaluationResultCollection) {
+// primitiveTypeListResult.getResultList().add(object);
+// }
+// } catch (Throwable e) {
+// primitiveTypeListResult.setException(e);
+// }
+// }
+// listResultList.add(primitiveTypeListResult);
+//
+// }
+// return listResultList;
+// }
+//
+// private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementImplementation evaluator) {
+// Query query = derivedTypedElement.getQuery();
+//
+// List<DerivedTypedElementEObjectListResult<?>> listResultList = new ArrayList<DerivedTypedElementEObjectListResult<?>>();
+// for (EObject eObject : sources) {
+// DerivedTypedElementEObjectListResult<EObject> eObjectListResult = EFacetFactory.eINSTANCE
+// .createDerivedTypedElementEObjectListResult();
+//
+// Throwable error = null;
+// try {
+// eObjectListResult.setSource(eObject);
+// eObjectListResult.setDerivedTypedElement(derivedTypedElement);
+// setParameterValues(eObjectListResult.getParameterValues(), parameterValues);
+// checkSourceType(query.getSourceType(), query, eObject);
+// } catch (Throwable e) {
+// error = e;
+// }
+// if (error != null) {
+// eObjectListResult.setException(error);
+// } else {
+// try {
+// Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
+// checkResult(query, evaluationResult, evaluator.getCheckResultType(), false);
+// // checked by checkResult
+// @SuppressWarnings("unchecked")
+// Collection<? extends EObject> evaluationResultCollection = (Collection<? extends EObject>) evaluationResult;
+// for (EObject e : evaluationResultCollection) {
+// eObjectListResult.getResultList().add(e);
+// }
+// } catch (Throwable e) {
+// eObjectListResult.setException(e);
+// }
+// }
+// listResultList.add(eObjectListResult);
+//
+// }
+// return listResultList;
+// }
+//
+// private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementImplementation evaluator)
+// throws DerivedTypedElementException {
+// // TODO Auto-generated method stub
+// return null;
+// }
+//
+// private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator(
+// final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
+// final IDerivedTypedElementImplementation evaluator)
+// throws DerivedTypedElementException {
+// // TODO Auto-generated method stub
+// return null;
+// }
+
+// public <T> List<DerivedTypedElementListResult<T>> evaluateMultiValued(final DerivedTypedElement derivedTypedElement,
+// final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues,
+// final Class<T> expectedType)
+// throws DerivedTypedElementException, UnmatchingExpectedTypeException {
+// if (!derivedTypedElement.isMany()) {
+// throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$
+// }
+//
+// Query query = derivedTypedElement.getQuery();
+// if (query == null) {
+// throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
+// }
+// IDerivedTypedElementImplementation evaluator =
+// DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query);
+//
+// List<?> queryResult = batchEvaluateAndCheck(derivedTypedElement, sources, parameterValues,
+// evaluator);
+// // Java doesn't support co- or contra-variance on generics,
+// // so we can't return the right type
+// @SuppressWarnings("unchecked")
+// List<DerivedTypedElementListResult<T>> multiResultList =
+// (List<DerivedTypedElementListResult<T>>) queryResult;
+//
+// // check each result element in each result list
+// if (expectedType != null) {
+// int sourceIndex = 0;
+// for (DerivedTypedElementListResult<?> derivedTypedElementResult : multiResultList) {
+// EList<?> resultList = derivedTypedElementResult.getResultList();
+// int index = 0;
+// for (Object resultElement : resultList) {
+// // a null value for resultElement matches any type
+// if (resultElement != null && !expectedType.isInstance(resultElement)) {
+// throw new UnmatchingExpectedTypeException(
+// "The element at index " + index + " in the list that resulted from the evaluation of the multi-valued " //$NON-NLS-1$ //$NON-NLS-2$
+// + "derived typed element does not match the expected type " //$NON-NLS-1$
+// + "for the source element at index " + sourceIndex, expectedType, resultElement); //$NON-NLS-1$
+// }
+// index++;
+// }
+// sourceIndex++;
+// }
+// }
+// return multiResultList;
+// }
+//
+// private static List<?> batchEvaluateAndCheck(final DerivedTypedElement derivedTypedElement,
+// final Collection<EObject> eObjects,
+// final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation
+// evaluator)
+// throws DerivedTypedElementException {
+// List<?> result;
+//
+// Query query = derivedTypedElement.getQuery();
+// if (query == null) {
+// throw new IllegalArgumentException("the query cannot be null"); //$NON-NLS-1$
+// }
+//
+// EClassifier sourceType = query.getSourceType();
+//
+// final boolean primitiveType = derivedTypedElement instanceof EAttribute;
+//
+// if (derivedTypedElement.isMany()) {
+// if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
+// IDerivedTypedElementCollectionImplementation collectionEvaluator =
+// (IDerivedTypedElementCollectionImplementation) evaluator;
+// // List<? extends AbstractDerivedTypedElementResult> listResultList =
+// // collectionEvaluator
+// // .getValues(derivedTypedElement, eObjects, parameterValues);
+// // int index = 0;
+// // for (AbstractDerivedTypedElementResult listResult : listResultList) {
+// // EList<?> resultList;
+// // if (primitiveType && listResult instanceof
+// // DerivedTypedElementPrimitiveTypeListResult<?>) {
+// // DerivedTypedElementPrimitiveTypeListResult<?> primitiveListResult =
+// // (DerivedTypedElementPrimitiveTypeListResult<?>) listResult;
+// // resultList = primitiveListResult.getResultList();
+// // } else if (!primitiveType && listResult instanceof
+// // DerivedTypedElementEObjectListResult<?>) {
+// // DerivedTypedElementEObjectListResult<?> eObjectListResult =
+// // (DerivedTypedElementEObjectListResult<?>) listResult;
+// // resultList = eObjectListResult.getResultList();
+// // } else {
+// // throw new DerivedTypedElementEvaluationException(
+// // "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$
+// // }
+// // checkResult(query, resultList, evaluator.getCheckResultType());
+// // index++;
+// // }
+// // result = listResultList;
+// } else {
+//
+// // List<AbstractDerivedTypedElementResult> listResultList = new
+// // ArrayList<AbstractDerivedTypedElementResult>();
+// // for (EObject eObject : eObjects) {
+// // AbstractDerivedTypedElementResult listResult;
+// // List<?> resultList;
+// // if (primitiveType) {
+// // DerivedTypedElementPrimitiveTypeListResult<?> primitiveTypeListResult =
+// // EFacetFactory.eINSTANCE
+// // .createDerivedTypedElementPrimitiveTypeListResult();
+// // listResult = primitiveTypeListResult;
+// // resultList = primitiveTypeListResult.getResultList();
+// // } else {
+// // DerivedTypedElementEObjectListResult<?> eObjectTypeListResult =
+// // EFacetFactory.eINSTANCE
+// // .createDerivedTypedElementEObjectListResult();
+// // listResult = eObjectTypeListResult;
+// // resultList = eObjectTypeListResult.getResultList();
+// // }
+// //
+// // Throwable error = null;
+// // try {
+// // listResult.setSource(eObject);
+// // listResult.setDerivedTypedElement(derivedTypedElement);
+// // setParameterValues(listResult.getParameterValues(), parameterValues);
+// // checkSourceType(sourceType, query, eObject);
+// // } catch (Throwable e) {
+// // error = e;
+// // }
+// // if (error != null) {
+// // listResult.setException(error);
+// // } else {
+// // try {
+// // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject,
+// // parameterValues);
+// // checkResult(query, evaluationResult, evaluator.getCheckResultType());
+// // // checked by checkResult
+// // Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult;
+// // for (Object object : evaluationResultCollection) {
+// // resultList.add(object);
+// // }
+// // } catch (Throwable e) {
+// // listResult.setException(e);
+// // }
+// // }
+// // listResultList.add(listResult);
+// //
+// // }
+// // result = listResultList;
+//
+// }
+// } else {
+// // if the evaluator implements multiple evaluation itself, then use it
+// if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
+// IDerivedTypedElementCollectionImplementation collectionEvaluator =
+// (IDerivedTypedElementCollectionImplementation) evaluator;
+// List<? extends AbstractDerivedTypedElementResult> singleResultList = collectionEvaluator
+// .getValues(derivedTypedElement, eObjects, parameterValues);
+// int index = 0;
+// for (AbstractDerivedTypedElementResult singleResult : singleResultList) {
+// Object resultElement;
+// if (primitiveType && singleResult instanceof DerivedTypedElementPrimitiveTypeResult<?>) {
+// DerivedTypedElementPrimitiveTypeResult<?> primitiveResult =
+// (DerivedTypedElementPrimitiveTypeResult<?>) singleResult;
+// resultElement = primitiveResult.getResult();
+// } else if (!primitiveType && singleResult instanceof DerivedTypedElementEObjectResult<?>) {
+// DerivedTypedElementEObjectResult<?> eObjectResult = (DerivedTypedElementEObjectResult<?>)
+// singleResult;
+// resultElement = eObjectResult.getResult();
+// } else {
+// throw new DerivedTypedElementEvaluationException(
+// "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$
+// }
+// checkResult(query, result, evaluator.getCheckResultType());
+// index++;
+// }
+// } else {
+// // otherwise, do multiple evaluation by calling the evaluator's
+// // single evaluation multiple times
+// List<DerivedTypedElementResult<?>> resultList = new
+// ArrayList<DerivedTypedElementResult<?>>();
+// for (EObject eObject : eObjects) {
+// DerivedTypedElementResult<Object> singleResult =
+// EFacetFactory.eINSTANCE.createDerivedTypedElementResult();
+// Throwable error = null;
+// try {
+// singleResult.setSource(eObject);
+// singleResult.setDerivedTypedElement(derivedTypedElement);
+// setParameterValues(singleResult.getParameterValues(), parameterValues);
+// checkSourceType(sourceType, query, eObject);
+// } catch (Throwable e) {
+// error = e;
+// }
+// if (error != null) {
+// singleResult.setException(error);
+// } else {
+// try {
+// Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
+// checkResult(query, evaluationResult, evaluator.getCheckResultType());
+// singleResult.setResult(evaluationResult);
+// } catch (Throwable e) {
+// singleResult.setException(e);
+// }
+// }
+// resultList.add(singleResult);
+// }
+// result = resultList;
+// }
+// }
+//
+// return result;
+// }
+
+// private static void checkSourceType(final EClassifier sourceType, final Query query, final EObject eObject)
+// throws DerivedTypedElementException {
+// if (sourceType != null) {
+// // a null value for eObject matches any type
+// if (eObject != null && !sourceType.isInstance(eObject)) {
+// StringBuffer message = new StringBuffer();
+// message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$
+// message.append(eObject.eClass().getName());
+// message.append("' found; expected '"); //$NON-NLS-1$
+// message.append(sourceType.getName());
+// message.append("'."); //$NON-NLS-1$
+// throw new DerivedTypedElementTypeCheckingException(message.toString());
+// }
+// } else {
+// if (eObject != null) {
+// throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$
+// }
+// }
+// }
+//
+// private static void setParameterValues(final EList<ParameterValue> target, final List<ParameterValue> parameterValues) {
+// if (parameterValues != null) {
+// for (ParameterValue parameterValue : parameterValues) {
+// if (parameterValue == null) {
+// throw new IllegalArgumentException("null parameter value"); //$NON-NLS-1$
+// }
+// // containment link -> we need to copy since we can have the same
+// // parameter for several results
+// target.add(EcoreUtil.copy(parameterValue));
+// }
+// }
+// }
+
+ private static final void checkResult(final Query query, final Object result,
+ final boolean checkResultType, final boolean primitive) throws DerivedTypedElementTypeCheckingException {
+ if (QueryUtils.isMany(query)) {
+ if (!(result instanceof Collection<?>)) {
+ String strResult;
+ if (result == null) {
+ strResult = "null"; //$NON-NLS-1$
+ } else {
+ strResult = "an instance of " + result.getClass().getName(); //$NON-NLS-1$
+ }
+ throw new DerivedTypedElementTypeCheckingException(
+ "A collection is expected as result. The result is " //$NON-NLS-1$
+ + strResult + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (checkResultType) {
+ for (Object collectionElement : (Collection<?>) result) {
+ if (collectionElement != null
+ && !(QueryUtils.getReturnType(query)
+ .isInstance(collectionElement))) {
+ throw new DerivedTypedElementTypeCheckingException(
+ "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$
+ + "(" + QueryUtils.getReturnType(query).getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
+ + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
+ }
+ }
+ } else if (!primitive) {
+ // at least check that EObjects are returned
+ for (Object collectionElement : (Collection<?>) result) {
+ if (collectionElement != null && !(collectionElement instanceof EObject)) {
+ throw new DerivedTypedElementTypeCheckingException(
+ "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$
+ + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
+ + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
+ }
+ }
+ }
+ } else {
+ if (result instanceof Collection<?>) {
+ throw new DerivedTypedElementTypeCheckingException("A " //$NON-NLS-1$
+ + QueryUtils.getSourceType(query).getName()
+ + " instance is expected as result. The result is: " //$NON-NLS-1$
+ + result + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ if (checkResultType) {
+ if (result != null && !(QueryUtils.getReturnType(query).isInstance(result))) {
+ throw new DerivedTypedElementTypeCheckingException("Wrong result type: " //$NON-NLS-1$
+ + result.getClass().getName()
+ + " is returned while " //$NON-NLS-1$
+ + QueryUtils.getReturnType(query).getInstanceClassName()
+ + " is expected." + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ } else if (!primitive) {
+ // at least check that an EObject is returned
+ if (result != null && !(result instanceof EObject)) {
+ throw new DerivedTypedElementTypeCheckingException(
+ "Wrong result collection element type: " + result.getClass().getName() //$NON-NLS-1$
+ + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
+ + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ private static boolean isPrimitive(final EClassifier eType) {
+ final boolean primitiveType;
+ if (eType instanceof EDataType) {
+ primitiveType = true;
+ } else if (eType instanceof EClass) {
+ primitiveType = false;
+ } else {
+ throw new IllegalArgumentException("unhandled derived typed element type: " + eType.getName()); //$NON-NLS-1$
+ }
+ return primitiveType;
+ }
+
+ /**
+ * Transform the element in parameter in list (if necessary).
+ *
+ * @param element
+ * the element to transform
+ * @return a list.
+ */
+ protected static List<Object> setAsList(final Object element) {
+ List<Object> newList = new LinkedList<Object>();
+ if (element instanceof List) {
+ @SuppressWarnings("unchecked")
+ //@SuppressWarnings("unchecked") the cast is safe because were
+ //casting a List to a List<Object>
+ final List<Object> tmpList = (List<Object>) element;
+ newList = tmpList;
+ } else {
+ newList.add(element);
+ }
+ return newList;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java
new file mode 100644
index 00000000000..883b1910d01
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+
+public final class DerivedTypedElementUtils {
+
+ private DerivedTypedElementUtils() {
+ // Must not be used
+ }
+
+ private static <T> List<ParameterValue> createAndCheckOperationParameterValues(final EOperation operation,
+ final Object... arguments) throws UnmatchingExpectedTypeException {
+ final EList<EParameter> operationParameters = operation.getEParameters();
+ //Begin precondition checking
+ if (arguments.length > 0
+ && operationParameters.size() != arguments.length) {
+ throw new IllegalArgumentException("Facet operation '" + operation.getName() + //$NON-NLS-1$
+ "' expects " + operationParameters.size() + " parameters. Got " + arguments.length); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //End precondition checking
+ final List<ParameterValue> parameterValues = new ArrayList<ParameterValue>();
+ for (int i = 0; i < arguments.length; i++) {
+ final Object argument = arguments[i];
+ final EParameter eParameter = operationParameters.get(i);
+ //Begin precondition checking
+ EmfUtils.checkAssignment(argument, eParameter);
+ //End precondition checking
+ final ParameterValue parameterValue = EFacetFactory.eINSTANCE.createParameterValue();
+ parameterValue.setParameter(eParameter);
+ parameterValue.setValue(argument);
+ parameterValues.add(parameterValue);
+ }
+ return parameterValues;
+ }
+
+ public static Object evaluate(final EObject eObject, final EOperation operation, final IFacetManager facetManager, final Object... arguments) throws UnmatchingExpectedTypeException,
+ DerivedTypedElementException {
+ Object result;
+ final List<ParameterValue> parameterValues = DerivedTypedElementUtils.createAndCheckOperationParameterValues(operation, arguments);
+ result = IDerivedTypedElementManager.INSTANCE.evaluate((FacetOperation) operation, eObject, parameterValues, facetManager);
+ return result;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EFacetManager.java
new file mode 100644
index 00000000000..2c443525cc8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EFacetManager.java
@@ -0,0 +1,197 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.QueryContext;
+import org.eclipse.emf.facet.efacet.QueryResult;
+import org.eclipse.emf.facet.efacet.core.IEFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.QueryException;
+import org.eclipse.emf.facet.efacet.core.exception.QueryTypeCheckingException;
+import org.eclipse.emf.facet.efacet.core.internal.query.QueryEvaluatorFactoryRegistry;
+import org.eclipse.emf.facet.efacet.core.query.IQueryEvaluator;
+
+/** @deprecated replaced by {@link DerivedTypedElementManager} */
+@Deprecated
+public final class EFacetManager implements IEFacetManager {
+
+ /**
+ * This method looks for a valid evaluator for the query and calls it to perform its
+ * basicEvaluate
+ */
+ public Object basicEvaluate(final Query query, final EObject eObject,
+ final List<ParameterValue> parameterValues) throws QueryException {
+ IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query);
+ evaluator.startEvaluate();
+ Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator);
+ evaluator.endEvaluate();
+ return result;
+ }
+
+ private Object evaluateAndCheck(final Query query, final EObject eObject,
+ final List<ParameterValue> parameterValues, final IQueryEvaluator evaluator)
+ throws QueryException {
+
+ if (!query.getScope().isInstance(eObject)) {
+ StringBuffer message = new StringBuffer();
+ message.append("Wrong context type (for query " + toString() + "): "); //$NON-NLS-1$ //$NON-NLS-2$
+ message.append(eObject.eClass().getName());
+ message.append(" found; expected scopes are {"); //$NON-NLS-1$
+ message.append(query.getScope().getName());
+ message.append("}"); //$NON-NLS-1$
+ QueryTypeCheckingException e = new QueryTypeCheckingException(message.toString());
+ throw e;
+ }
+ Object result = evaluator.basicEvaluate(query, eObject, parameterValues);
+ checkResult(query, result, evaluator.getCheckResultType());
+ return result;
+ }
+
+ /**
+ * This method is equivalent to {@link EFacetManager#basicEvaluate(Query, EObject, List)} with
+ * no query parameters.
+ */
+ public final Object basicEvaluate(final Query query, final EObject eObject)
+ throws QueryException {
+ return basicEvaluate(query, eObject, null);
+ }
+
+ /**
+ * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking
+ * into consideration some {@link ParameterValue}s
+ */
+ public final QueryResult evaluate(final Query query, final EObject context,
+ final List<ParameterValue> parameterValues) {
+ QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult();
+ try {
+ queryResult.setSource(context);
+ queryResult.setResult(basicEvaluate(query, context, parameterValues));
+ } catch (Exception e) {
+ queryResult.setException(e);
+ }
+ return queryResult;
+ }
+
+ /**
+ * Evaluate the query on a set of models and model elements described by the context parameter.
+ *
+ * The query is evaluated on each contextually referred model element and on each element of a
+ * contextually referred model.
+ *
+ * @param queryContext
+ * The query evaluation context described by a QueryContext instance.
+ * @param parameterValues
+ * The query parameter values.
+ * @return A list of QueryResult (one per evaluation)
+ * @throws QueryException
+ */
+ public final synchronized List<QueryResult> evaluate(final Query query,
+ final QueryContext queryContext, final List<ParameterValue> parameterValues)
+ throws QueryException {
+ List<QueryResult> resultList = new ArrayList<QueryResult>();
+ IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query);
+ try {
+ evaluator.startEvaluate();
+ for (EObject eObject : queryContext.getSelectedModelElements()) {
+ QueryResult queryResult = executeQuery(query, parameterValues, eObject, evaluator);
+ resultList.add(queryResult);
+ }
+ for (Resource resource : queryContext.getSelectedModels()) {
+ TreeIterator<EObject> treeIterator = resource.getAllContents();
+ while (treeIterator.hasNext()) {
+ EObject eObject = treeIterator.next();
+ QueryResult queryResult = executeQuery(query, parameterValues, eObject,
+ evaluator);
+ resultList.add(queryResult);
+ }
+ }
+ } finally {
+ evaluator.endEvaluate();
+ }
+ return resultList;
+ }
+
+ /**
+ * This method is used to evaluate the given {@link Query} on the given {@link EObject}
+ */
+ public final QueryResult evaluate(final Query query, final EObject eObject) {
+ QueryResult queryResult = evaluate(query, eObject, null);
+ return queryResult;
+ }
+
+ private final QueryResult executeQuery(final Query query,
+ final List<ParameterValue> parameterValues, final EObject eObject,
+ final IQueryEvaluator evaluator) {
+ QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult();
+ queryResult.setSource(eObject);
+ try {
+ Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator);
+ queryResult.setResult(result);
+ } catch (QueryException e) {
+ queryResult.setException(e);
+ }
+ return queryResult;
+ }
+
+ private final void checkResult(final Query query, final Object object,
+ final boolean checkResultType) throws QueryTypeCheckingException {
+ if (query.getUpperBound() > 1 || query.getUpperBound() == -1) {
+ if (!(object instanceof Collection<?>)) {
+ throw new QueryTypeCheckingException(
+ "A collection is expected as result. The result is: " //$NON-NLS-1$
+ + object + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ for (Object collectionElement : (Collection<?>) object) {
+ if (checkResultType) {
+ if (!(query.getEType().isInstance(collectionElement))) {
+ QueryTypeCheckingException e = new QueryTypeCheckingException(
+ "Wrong result collection element type (" //$NON-NLS-1$
+ + query.getEType().getName() + " is expected): " //$NON-NLS-1$
+ + collectionElement + " (on " //$NON-NLS-1$
+ + toString() + ")"); //$NON-NLS-1$
+ throw e;
+ }
+ }
+ }
+ } else {
+ if (object instanceof Collection<?>) {
+ throw new QueryTypeCheckingException("A " //$NON-NLS-1$
+ + query.getEType().getName()
+ + " instance is expected as result. The result is: " //$NON-NLS-1$
+ + object + " (on " + toString() + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ if (checkResultType) {
+ if (!(query.getEType().isInstance(object))) {
+ if (object != null) {
+ throw new QueryTypeCheckingException("Wrong result type: " //$NON-NLS-1$
+ + object.getClass().getName()
+ + " is returned while " //$NON-NLS-1$
+ + query.getEType().getInstanceClassName()
+ + " is expected." + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ }
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EmfUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EmfUtils.java
new file mode 100644
index 00000000000..c43eb9f95b6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/EmfUtils.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+
+public final class EmfUtils {
+
+ private EmfUtils() {
+ //Must not be used
+ }
+
+ public static void checkAssignment(final Object value, final ETypedElement eTypedElement)
+ throws UnmatchingExpectedTypeException {
+ final String typedElementName = getTypeElementDescription(eTypedElement);
+ //Begin checking precondition
+ if (eTypedElement.getEType() == null) {
+ throw new IllegalArgumentException(typedElementName + " has a null type"); //$NON-NLS-1$
+ }
+ //End checking precondition
+ if (value == null && (eTypedElement.getLowerBound() > 0)) {
+ throw new IllegalArgumentException(
+ "The assigned value cannot be null for " + typedElementName + " because multiplicity is " + eTypedElement.getLowerBound() + ".." + eTypedElement.getUpperBound()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ if (value != null) {
+ if (eTypedElement.getUpperBound() == 1) {
+ if (!eTypedElement.getEType().isInstance(value)) {
+ throw new IllegalArgumentException(
+ "Type mismatch for " + EcoreUtil.getURI(eTypedElement) + ": expected '" + eTypedElement.getEType().getName() + "' but got '" + value.getClass().getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ } else { // expect a list for multiplicity-many
+ if (!(value instanceof List<?>)) {
+ throw new IllegalArgumentException("Type mismatch for " + typedElementName + "': expected a List because the parameter is multiplicity-many. But got a " + //$NON-NLS-1$ //$NON-NLS-2$
+ value.getClass().getName() + "'."); //$NON-NLS-1$
+ }
+ final List<?> argumentList = (List<?>) value;
+ try {
+ CastUtils.checkTypeOfAllListElements(argumentList, eTypedElement.getEType().getInstanceClass());
+ //FIXME What happens if we use a not generated meta-model ?
+ } catch (UnmatchingExpectedTypeException e) {
+ throw new UnmatchingExpectedTypeException(
+ "Type mismatch for an element of the list value " + typedElementName , e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ private static String getTypeElementDescription(final ETypedElement eTypedElement) {
+ String containerName = ""; //$NON-NLS-1$
+ if (eTypedElement.eContainer() instanceof ENamedElement) {
+ final ENamedElement namedContainer = (ENamedElement) eTypedElement.eContainer();
+ containerName = "the " + namedContainer.eClass().getName() + " named '" + namedContainer.getName() + "'"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return "the " + eTypedElement.eClass().getName() + " named '" + eTypedElement.getName() + "' in " + containerName; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static Object ecoreInvoke(final EObject eObject, final EOperation operation, final Object... arguments) throws InvocationTargetException {
+ // delegate to Ecore
+ final BasicEList<Object> operationParams = new BasicEList<Object>();
+ for (Object param : arguments) {
+ operationParams.add(param);
+ }
+ return eObject.eInvoke(operation, operationParams);
+ }
+
+ public static <T> T checkAssignment(final EStructuralFeature eStructuralFeature, final Class<T> expectedType, final Object value)
+ throws UnmatchingExpectedTypeException {
+ if (eStructuralFeature.isMany() && expectedType != null) {
+ if (expectedType != Object.class
+ && !Collection.class.isAssignableFrom(expectedType)) {
+ throw new UnmatchingExpectedTypeException("The required eStructuralFeature is multi-valued, so expectedType must be a subtype of Collection."); //$NON-NLS-1$
+ }
+ if (!expectedType.isInstance(value)) {
+ throw new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type", Collection.class, value); //$NON-NLS-1$
+ }
+ }
+ return CastUtils.castToExpectedType(value, expectedType);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionImpl.java
new file mode 100644
index 00000000000..4d208326f51
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionImpl.java
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EParameter;
+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.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.EFacetPackage;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManager;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+import org.eclipse.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
+
+/** @deprecated */
+@Deprecated
+public class FacetActionImpl implements IFacetAction {
+
+ public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet,
+ final EditingDomain editingDomain) {
+
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+ if (facet.eResource() != null || facet.eContainer() != null) {
+ throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ // If the current editingDomain's resourceSet does not contain the facetSet resource, then
+ // we need to add it so that we can edit the facetSet
+ if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) {
+ editingDomain.getResourceSet().getResources().add(facetSet.eResource());
+ }
+
+ Command command = new AddCommand(editingDomain, facetSet,
+ EFacetPackage.eINSTANCE.getFacetSet_Facets(), facet);
+ editingDomain.getCommandStack().execute(command);
+ return facet;
+ }
+
+ public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute,
+ final EditingDomain editingDomain) {
+
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+ if (facetAttribute == null) {
+ throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$
+ }
+ if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ Command command = new AddCommand(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public void addReferenceInFacet(final Facet facet, final FacetReference facetReference,
+ final EditingDomain editingDomain) {
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$
+ }
+ if (facetReference == null) {
+ throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$
+ }
+ if (facetReference.eResource() != null || facetReference.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$
+ }
+
+ Command command = new AddCommand(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation,
+ final EditingDomain editingDomain) {
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+ if (facetOperation == null) {
+ throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
+ }
+ if (facetOperation.eResource() != null || facetOperation.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+
+ Command command = new AddCommand(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetOperation);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri,
+ final EditingDomain editingDomain) {
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ Command command = new SetCommand(editingDomain, facetSet,
+ EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public void addParameterInOperation(final FacetOperation operation, final EParameter parameter,
+ final EditingDomain editingDomain) {
+ if (operation == null) {
+ throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
+ }
+ if (parameter == null) {
+ throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$
+ }
+ if (parameter.eResource() != null || parameter.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given EParameter cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ Command command = new AddCommand(editingDomain, operation,
+ EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public void createFacetSet(final FacetSet facetSet, final IFile file) throws IOException,
+ InvalidFacetSetException {
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ if (file == null) {
+ throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
+ }
+ if (file.exists()) {
+ throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
+ }
+
+ // Create a resource set
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the facetSet the resource contents.
+ resource.getContents().add(facetSet);
+
+ // Save the contents of the resource to the file system.
+ resource.save(null);
+
+ try {
+ BuildPropertiesUtils.addToBuild(file);
+ } catch (Exception e) {
+ Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
+ + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
+ }
+ ICatalogSetManager.INSTANCE.registerModelDeclaration(file);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActions2Impl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActions2Impl.java
new file mode 100644
index 00000000000..a45bc2e9ab8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActions2Impl.java
@@ -0,0 +1,231 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.emf.facet.util.emf.core.ICatalogSetManager
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EParameter;
+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.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManager2;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+import org.eclipse.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
+
+public class FacetActions2Impl implements IFacetActions2 {
+
+ public void saveFacetSet(final FacetSet facetSet, final IFile file) throws IOException,
+ InvalidFacetSetException {
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ if (file == null) {
+ throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
+ }
+ if (file.exists()) {
+ throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
+ }
+
+ // Create a resource set
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the facetSet the resource contents.
+ resource.getContents().add(facetSet);
+
+ // Save the contents of the resource to the file system.
+ resource.save(null);
+
+ try {
+ BuildPropertiesUtils.addToBuild(file);
+ } catch (Exception e) {
+ Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
+ + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
+ }
+ ICatalogSetManager2.INSTANCE.registerModelDeclaration(file);
+ }
+
+ public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet,
+ final EditingDomain editingDomain) {
+ Command command = createCreateFacetInFacetSetCommand(facetSet, facet, editingDomain);
+ // If the current editingDomain's resourceSet does not contain the facetSet resource, then
+ // we need to add it so that we can edit the facetSet
+ if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) {
+ editingDomain.getResourceSet().getResources().add(facetSet.eResource());
+ }
+ editingDomain.getCommandStack().execute(command);
+ return facet;
+ }
+
+ public Command createCreateFacetInFacetSetCommand(final FacetSet facetSet, final Facet facet,
+ final EditingDomain editingDomain) {
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+ if (facet.eResource() != null || facet.eContainer() != null) {
+ throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(editingDomain, facetSet,
+ EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet);
+ }
+
+ public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute,
+ final EditingDomain editingDomain) {
+ Command command = createAddAttributeInFacetCommand(facet, facetAttribute, editingDomain);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public Command createAddAttributeInFacetCommand(final Facet facet,
+ final FacetAttribute facetAttribute, final EditingDomain editingDomain) {
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+ if (facetAttribute == null) {
+ throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$
+ }
+ if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute);
+ }
+
+ public void addReferenceInFacet(final Facet facet, final FacetReference facetReference,
+ final EditingDomain editingDomain) {
+ Command command = createAddReferenceInFacetCommand(facet, facetReference, editingDomain);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public Command createAddReferenceInFacetCommand(final Facet facet,
+ final FacetReference facetReference, final EditingDomain editingDomain) {
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$
+ }
+ if (facetReference == null) {
+ throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$
+ }
+ if (facetReference.eResource() != null || facetReference.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference);
+ }
+
+ public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation,
+ final EditingDomain editingDomain) {
+ Command command = createAddOperationInFacetCommand(facet, facetOperation, editingDomain);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public Command createAddOperationInFacetCommand(final Facet facet,
+ final FacetOperation facetOperation, final EditingDomain editingDomain) {
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+ if (facetOperation == null) {
+ throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
+ }
+ if (facetOperation.eResource() != null || facetOperation.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (facet == null) {
+ throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_FacetOperations(), facetOperation);
+ }
+
+ public void addParameterInOperation(final FacetOperation operation, final EParameter parameter,
+ final EditingDomain editingDomain) {
+ Command command = createAddParameterInOperationCommand(operation, parameter, editingDomain);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public Command createAddParameterInOperationCommand(final FacetOperation operation,
+ final EParameter parameter, final EditingDomain editingDomain) {
+ if (operation == null) {
+ throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
+ }
+ if (parameter == null) {
+ throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$
+ }
+ if (parameter.eResource() != null || parameter.eContainer() != null) {
+ throw new IllegalArgumentException(
+ "The given EParameter cannot be contained by a resource"); //$NON-NLS-1$
+ }
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(editingDomain, operation,
+ EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter);
+ }
+
+ public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri,
+ final EditingDomain editingDomain) {
+ Command command = createSetFacetSetNsUriCommand(facetSet, nsUri, editingDomain);
+ editingDomain.getCommandStack().execute(command);
+ }
+
+ public Command createSetFacetSetNsUriCommand(final FacetSet facetSet, final String nsUri,
+ final EditingDomain editingDomain) {
+ if (editingDomain == null) {
+ throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
+ }
+ if (facetSet == null) {
+ throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ return SetCommand.create(editingDomain, facetSet,
+ EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionsImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionsImpl.java
new file mode 100644
index 00000000000..cf6a4bbf250
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetActionsImpl.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+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.facet.efacet.core.IFacetActions;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.core.internal.Activator;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManager2;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManagerFactory;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+import org.eclipse.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
+
+/**
+ * Concrete implementation of {@link IFacetActions}.
+ */
+public class FacetActionsImpl implements IFacetActions {
+
+ public void saveFacetSet(final FacetSet facetSet, final IFile file)
+ throws IOException, InvalidFacetSetException {
+ if (facetSet == null) {
+ throw new IllegalArgumentException(
+ "The given FacetSet cannot be null"); //$NON-NLS-1$
+ }
+ if (file == null) {
+ throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
+ }
+ if (file.exists()) {
+ throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
+ }
+
+ // Create a resource set
+ final ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ final URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
+ .toString(), true);
+
+ // Create a resource for this file.
+ final Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the facetSet the resource contents.
+ resource.getContents().add(facetSet);
+
+ // Save the contents of the resource to the file system.
+ resource.save(null);
+
+ try {
+ BuildPropertiesUtils.addToBuild(file);
+ } catch (final Exception e) {
+ Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
+ + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
+ }
+
+ final ICatalogSetManager2 catalogSetManager = ICatalogSetManagerFactory.DEFAULT
+ .createICatalogSetManager(resourceSet);
+ catalogSetManager.registerModelDeclaration(file);
+
+ // ICatalogSetManager.INSTANCE.registerModelDeclaration(file);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java
new file mode 100644
index 00000000000..e83233c3a4c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.efacet.core.IFacetSetCatalogManager;
+import org.eclipse.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManagerFactory;
+
+public class FacetCatalogManagerFactory implements IFacetSetCatalogManagerFactory {
+
+ public IFacetSetCatalogManager getOrCreateFacetSetCatalogManager(
+ final ResourceSet resourceSet) {
+ return ICatalogSetManagerFactory.DEFAULT
+ .createICatalogSetManager(resourceSet)
+ .getCatalogManagerByType(IFacetSetCatalogManager.class)
+ .get(0);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java
new file mode 100644
index 00000000000..1e598391c9c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.IFacetCommandFactoryFactory;
+import org.eclipse.emf.facet.efacet.core.IFacetCommandFactory;
+
+public class FacetCommandFactoryFactory implements IFacetCommandFactoryFactory {
+
+ public IFacetCommandFactory createCommandFactory(
+ final EditingDomain editingDomain) {
+ return new FacetCommandFactoryImpl(editingDomain);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java
new file mode 100644
index 00000000000..9a428f7f589
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java
@@ -0,0 +1,511 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.IFacetCommandFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.util.emf.core.command.EmfCommandUtils;
+
+/**
+ * Concrete implementation of {@link IFacetCommandFactory}.
+ */
+public class FacetCommandFactoryImpl implements IFacetCommandFactory {
+
+ private static final String VALUE_NOT_NULL = "The given value cannot be null"; //$NON-NLS-1$
+ private static final String PARENT_NOT_NULL = "The given parent cannot be null"; //$NON-NLS-1$
+ private static final Object NAME = "name"; //$NON-NLS-1$
+ private static final Object LOWER_BOUND = "lowerBound"; //$NON-NLS-1$
+ private static final Object UPPER_BOUND = "upperBound"; //$NON-NLS-1$
+ private static final Object VOLATILE = "volatile"; //$NON-NLS-1$
+ private static final Object CHANGEABLE = "changeable"; //$NON-NLS-1$
+ private static final Object DERIVED = "derived"; //$NON-NLS-1$
+ private static final Object TRANSIENT = "transient"; //$NON-NLS-1$
+ private static final Object ORDERED = "ordered"; //$NON-NLS-1$
+ private static final Object UNIQUE = "unique"; //$NON-NLS-1$
+ private final EditingDomain editingDomain;
+
+ public FacetCommandFactoryImpl(final EditingDomain editingDomain) {
+ this.editingDomain = editingDomain;
+ }
+
+ /**
+ * Create an {@link AddCommand} to add the element to the owner.
+ *
+ * @param owner
+ * the owner.
+ * @param element
+ * the element to add.
+ * @return the command.
+ */
+ private Command createAddCommand(final Object owner, final Object element) {
+
+ if (owner == null) {
+ throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$
+ }
+
+ if (element == null) {
+ throw new IllegalArgumentException(
+ "The given element cannot be null"); //$NON-NLS-1$
+ }
+
+ return AddCommand.create(this.editingDomain, owner,
+ getEStructuralFeature(element), element);
+ }
+
+ /**
+ * Create an {@link SetCommand} to add the element to the owner.
+ *
+ * @param initialObject
+ * the owner.
+ * @param newObject
+ * the element to add.
+ * @return the command.
+ */
+ public Command createSetCommand(final Object initialObject,
+ final Object feature, final Object newValue) {
+
+ if (initialObject == null) {
+ throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$
+ }
+
+ if (feature == null) {
+ throw new IllegalArgumentException(
+ "The given feature cannot be null"); //$NON-NLS-1$
+ }
+
+ if (newValue == null) {
+ throw new IllegalArgumentException(
+ "The given newValue cannot be null"); //$NON-NLS-1$
+ }
+
+ return SetCommand.create(this.editingDomain, initialObject, feature,
+ newValue);
+ }
+
+ /**
+ * Return the {@link EStructuralFeature} for a given element.
+ *
+ * @param element
+ * the element.
+ * @return the eStructuralFeature for the element.
+ */
+ private static EStructuralFeature getEStructuralFeature(final Object element) {
+ EStructuralFeature result = null;
+ if (element instanceof FacetSet) {
+ result = EcorePackage.eINSTANCE.getEPackage_ESubpackages();
+ } else if (element instanceof Facet) {
+ result = EcorePackage.eINSTANCE.getEPackage_EClassifiers();
+ } else if ((element instanceof FacetAttribute)
+ || (element instanceof FacetReference)) {
+ result = EFacetPackage.eINSTANCE.getFacet_FacetElements();
+ } else if (element instanceof FacetOperation) {
+ result = EFacetPackage.eINSTANCE.getFacet_FacetOperations();
+ }
+ return result;
+
+ }
+
+ public Command createFacetSetInFacetSetCommand(final FacetSet owner,
+ final FacetSet facetSet) {
+ return createAddCommand(owner, facetSet);
+ }
+
+ public Command createFacetInFacetSetCommand(final FacetSet parent,
+ final Facet facet) {
+ return createAddCommand(parent, facet);
+ }
+
+ public Command createEditFacetStructuralFeatureCommand(
+ final DerivedTypedElement feature, final Facet container,
+ final String name, final int lowerBound, final int upperBound,
+ final EClassifier type, final boolean ordered,
+ final boolean unique, final Query query, final boolean volatilee,
+ final boolean change, final boolean derived,
+ final boolean transientt) {
+ if (feature == null) {
+ throw new IllegalArgumentException(
+ "The parameter facetOperation must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ if (feature.eContainer() != container) {
+ final Command command = new AddCommand(this.editingDomain,
+ container,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(), feature);
+ commands.add(command);
+ }
+ if (feature instanceof EStructuralFeature) {
+ final EStructuralFeature structuralFeature = (EStructuralFeature) feature;
+ if (structuralFeature.isVolatile() != volatilee) {
+ final Command command = new SetCommand(this.editingDomain,
+ structuralFeature,
+ EcorePackage.eINSTANCE.getEStructuralFeature_Volatile(),
+ Boolean.valueOf(volatilee));
+ commands.add(command);
+ }
+ if (structuralFeature.isChangeable() != change) {
+ final Command command = new SetCommand(this.editingDomain,
+ structuralFeature,
+ EcorePackage.eINSTANCE
+ .getEStructuralFeature_Changeable(),
+ Boolean.valueOf(change));
+ commands.add(command);
+ }
+ if (structuralFeature.isDerived() != derived) {
+ final Command command = new SetCommand(this.editingDomain,
+ structuralFeature,
+ EcorePackage.eINSTANCE.getEStructuralFeature_Derived(),
+ Boolean.valueOf(ordered));
+ commands.add(command);
+ }
+ if (structuralFeature.isTransient() != transientt) {
+ final Command command = new SetCommand(this.editingDomain,
+ structuralFeature,
+ EcorePackage.eINSTANCE
+ .getEStructuralFeature_Transient(),
+ Boolean.valueOf(unique));
+ commands.add(command);
+ }
+ }
+ commands.add(createEditDerivedTypeElementCommand(feature,
+ name, lowerBound, upperBound, type, ordered, unique, query));
+ return EmfCommandUtils.createResult(commands,
+ "edit facet structural feature"); //$NON-NLS-1$
+ }
+
+ public Command createAddOperationInFacetCommand(final Facet parent,
+ final FacetOperation facetOperation) {
+ return createAddCommand(parent, facetOperation);
+ }
+
+ public Command createAddReferenceInFacetCommand(final Facet parent,
+ final FacetReference facetReference) {
+ return createAddCommand(parent, facetReference);
+ }
+
+ public Command createAddParameterInOperationCommand(
+ final FacetOperation parent, final EParameter opParameter) {
+ return createAddCommand(parent, opParameter);
+ }
+
+ public Command createChangeOwnerCommand(final Object element,
+ final Object newOwner) {
+ if (element == null) {
+ throw new IllegalArgumentException(
+ "The given element cannot be null"); //$NON-NLS-1$
+ }
+ if (newOwner == null) {
+ throw new IllegalArgumentException(
+ "The given element cannot be null"); //$NON-NLS-1$
+ }
+ return createAddCommand(newOwner, element);
+ }
+
+ public Command createEditFacetSetCommand(final FacetSet editedFacetSet,
+ final FacetSet container, final String name) {
+ if (editedFacetSet == null) {
+ throw new IllegalArgumentException(
+ "The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ commands.add(createEditENamedElementcommand(editedFacetSet, name));
+ if (editedFacetSet.eContainer() != container) {
+ final Command command = new AddCommand(this.editingDomain,
+ container,
+ EcorePackage.eINSTANCE.getEPackage_ESubpackages(),
+ editedFacetSet);
+ commands.add(command);
+ }
+ return EmfCommandUtils.createResult(commands, "Edit FacetSet"); //$NON-NLS-1$
+ }
+
+ public Command createEditFacetCommand(final Facet facet,
+ final FacetSet container, final String name,
+ final ETypedElement conformance, final EClass extendMetaclass,
+ final FacetSet extendedFacetSet) {
+ final List<Command> commands = new ArrayList<Command>();
+ commands.add(createEditENamedElementcommand(facet, name));
+ if (facet.eContainer() != container) {
+ final Command command = new AddCommand(this.editingDomain,
+ container,
+ EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet);
+ commands.add(command);
+ }
+ if (facet.getConformanceTypedElement() != conformance) {
+ final Command command = new SetCommand(this.editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_ConformanceTypedElement(),
+ conformance);
+ commands.add(command);
+ }
+ if (extendedFacetSet != null
+ && (facet.getExtendedFacets().isEmpty() || facet
+ .getExtendedFacets().get(0) != extendedFacetSet)) {
+ final Command command = new SetCommand(this.editingDomain,
+ facet,
+ EFacetPackage.eINSTANCE.getFacet_ExtendedFacets(),
+ Collections.singletonList(extendedFacetSet));
+ commands.add(command);
+ }
+ if (facet.getExtendedMetaclass() != extendMetaclass) {
+ final Command command = new SetCommand(this.editingDomain, facet,
+ EFacetPackage.eINSTANCE.getFacet_ExtendedMetaclass(),
+ extendMetaclass);
+ commands.add(command);
+ }
+ return EmfCommandUtils.createResult(commands, "Edit Facet"); //$NON-NLS-1$
+ }
+
+ private Command createEditENamedElementcommand(
+ final ENamedElement namedElement, final String name) {
+ if (namedElement == null) {
+ throw new IllegalArgumentException(
+ "The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ if (namedElement.getName() != name) {
+ final Command command = new SetCommand(this.editingDomain,
+ namedElement,
+ EcorePackage.eINSTANCE.getENamedElement_Name(), name);
+ commands.add(command);
+ }
+ return EmfCommandUtils.createResult(commands, "Edit NamedElement"); //$NON-NLS-1$
+ }
+
+ public Command createSetFacetAttributeCommand(final Facet initialContainer,
+ final FacetAttribute initialElement, final FacetAttribute newElement) {
+ if (initialElement == null) {
+ throw new IllegalArgumentException(PARENT_NOT_NULL);
+ }
+ if (newElement == null) {
+ throw new IllegalArgumentException(VALUE_NOT_NULL);
+ }
+ final CompoundCommand commands = new CompoundCommand();
+ final List<EAttribute> facetAttributes = EFacetPackage.eINSTANCE
+ .getFacetAttribute().getEAllAttributes();
+ setEStructuralFeatureAttributes(initialElement, newElement, commands,
+ facetAttributes);
+ setETypedElementAttributes(initialElement, newElement, commands,
+ facetAttributes);
+ final Command changeOwner = createChangeOwnerCommand(newElement,
+ initialContainer);
+ commands.append(changeOwner);
+ return commands;
+ }
+
+ public Command createSetFacetReferenceCommand(final Facet initialContainer,
+ final FacetReference initialElement, final FacetReference newElement) {
+ if (initialElement == null) {
+ throw new IllegalArgumentException(PARENT_NOT_NULL);
+ }
+ if (newElement == null) {
+ throw new IllegalArgumentException(VALUE_NOT_NULL);
+ }
+ final CompoundCommand commands = new CompoundCommand();
+ final List<EAttribute> facetReferences = EFacetPackage.eINSTANCE
+ .getFacetReference().getEAllAttributes();
+ setEStructuralFeatureAttributes(initialElement, newElement, commands,
+ facetReferences);
+ setETypedElementAttributes(initialElement, newElement, commands,
+ facetReferences);
+ final Command changeOwner = createChangeOwnerCommand(newElement, initialContainer);
+ commands.append(changeOwner);
+ return commands;
+ }
+
+ public Command createEditFacetOperationCommand(
+ final FacetOperation facetOperation, final Facet container,
+ final String name, final int lowerBound, final int upperBound,
+ final EClassifier type, final boolean ordered,
+ final boolean unique, final Query query) {
+ if (facetOperation == null) {
+ throw new IllegalArgumentException(
+ "The parameter facetOperation must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ if (facetOperation.eContainer() != container) {
+ final Command command = new AddCommand(this.editingDomain,
+ container,
+ EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
+ facetOperation);
+ commands.add(command);
+ }
+ commands.add(createEditDerivedTypeElementCommand(facetOperation, name,
+ lowerBound, upperBound, type, ordered, unique, query));
+ return EmfCommandUtils.createResult(commands, "Edit facet operation"); //$NON-NLS-1$
+ }
+
+ private Command createEditDerivedTypeElementCommand(
+ final DerivedTypedElement dte, final String name,
+ final int lowerBound, final int upperBound, final EClassifier type,
+ final boolean ordered, final boolean unique, final Query query) {
+ if (dte == null) {
+ throw new IllegalArgumentException(
+ "The parameter facetOperation must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ commands.add(createEditETypedElementCommand(dte, name, lowerBound,
+ upperBound, type, ordered, unique));
+ if (dte.getQuery() != query) {
+ final Command command = new SetCommand(this.editingDomain, dte,
+ EFacetPackage.eINSTANCE.getDerivedTypedElement_Query(),
+ query);
+ commands.add(command);
+ }
+ return EmfCommandUtils.createResult(commands,
+ "Edit derived typed element"); //$NON-NLS-1$
+ }
+
+ private Command createEditETypedElementCommand(
+ final ETypedElement typedElement, final String name,
+ final int lowerBound, final int upperBound, final EClassifier type,
+ final boolean ordered, final boolean unique) {
+ final List<Command> commands = new ArrayList<Command>();
+ commands.add(createEditENamedElementcommand(typedElement, name));
+ if (typedElement.getLowerBound() != lowerBound) {
+ final Command command = new SetCommand(this.editingDomain,
+ typedElement,
+ EcorePackage.eINSTANCE.getETypedElement_LowerBound(),
+ Integer.valueOf(lowerBound));
+ commands.add(command);
+ }
+ if (typedElement.getUpperBound() != upperBound) {
+ final Command command = new SetCommand(this.editingDomain,
+ typedElement,
+ EcorePackage.eINSTANCE.getETypedElement_LowerBound(),
+ Integer.valueOf(upperBound));
+ commands.add(command);
+ }
+ if (typedElement.isOrdered() != ordered) {
+ final Command command = new SetCommand(this.editingDomain,
+ typedElement,
+ EcorePackage.eINSTANCE.getETypedElement_Ordered(),
+ Boolean.valueOf(ordered));
+ commands.add(command);
+ }
+ if (typedElement.isUnique() != unique) {
+ final Command command = new SetCommand(this.editingDomain,
+ typedElement,
+ EcorePackage.eINSTANCE.getETypedElement_Ordered(),
+ Boolean.valueOf(unique));
+ commands.add(command);
+ }
+ if (typedElement.getEType() != type) {
+ final Command command = new SetCommand(this.editingDomain,
+ typedElement,
+ EcorePackage.eINSTANCE.getETypedElement_EType(), type);
+ commands.add(command);
+ }
+ return EmfCommandUtils.createResult(commands, "Edit ETypedElement"); //$NON-NLS-1$
+ }
+
+ public Command createEditOperationParameterCommand(
+ final EParameter parameter, final FacetOperation facetOperation,
+ final String name, final int lowerBound, final int upperBound,
+ final EClassifier type, final boolean ordered, final boolean unique) {
+ if (parameter == null) {
+ throw new IllegalArgumentException(
+ "The parameter parameter must not be null"); //$NON-NLS-1$
+ }
+ final List<Command> commands = new ArrayList<Command>();
+ commands.add(createEditETypedElementCommand(parameter, name,
+ lowerBound, upperBound, type, ordered, unique));
+ return EmfCommandUtils.createResult(commands,
+ "Edit operation parameter"); //$NON-NLS-1$
+ }
+
+ private void setEStructuralFeatureAttributes(
+ final EStructuralFeature initialElement,
+ final EStructuralFeature newElement,
+ final CompoundCommand commands,
+ final List<EAttribute> facetOperations) {
+ for (final EAttribute attribute : facetOperations) {
+ if (attribute.getName().equals(TRANSIENT)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isTransient())));
+ }
+ if (attribute.getName().equals(VOLATILE)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isVolatile())));
+ }
+ if (attribute.getName().equals(CHANGEABLE)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isChangeable())));
+ }
+ if (attribute.getName().equals(DERIVED)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isDerived())));
+ }
+ }
+ }
+
+ private void setETypedElementAttributes(final ETypedElement initialElement,
+ final ETypedElement newElement, final CompoundCommand commands,
+ final List<EAttribute> facetOperations) {
+ for (final EAttribute attribute : facetOperations) {
+ if (attribute.getName().equals(NAME)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ newElement.getName()));
+ }
+ if (attribute.getName().equals(LOWER_BOUND)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Integer.valueOf(newElement.getLowerBound())));
+ }
+ if (attribute.getName().equals(UPPER_BOUND)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Integer.valueOf(newElement.getUpperBound())));
+ }
+ if (attribute.getName().equals(ORDERED)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isOrdered())));
+ }
+ if (attribute.getName().equals(UNIQUE)) {
+ commands.append(createSetCommand(initialElement, attribute,
+ Boolean.valueOf(newElement.isUnique())));
+ }
+ }
+ }
+
+
+ public Command createEditFacetOperationCommand(
+ final DerivedTypedElement dte, final Facet facetContainer,
+ final String name, final int lowerBound, final int upperBound,
+ final EClassifier type, final boolean ordered,
+ final boolean unique, final Query query) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManager.java
new file mode 100644
index 00000000000..f6f98979df1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManager.java
@@ -0,0 +1,593 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel*
+ * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Olivier Remaud (Mia-Software) - Bug 374348 - Infinite loop in Facet override resolution
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet
+ * Nicolas Bros (Mia-Software) - Bug 378475 - unit test failures after table refactoring
+ * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API
+ * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.FacetUtils;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManagerListener;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.FacetConformanceEvaluationException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.NonApplicableFacetException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.NonConformingEObjectException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+import org.eclipse.emf.facet.efacet.core.internal.serialization.SerializationManager;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.RuntimeFactory;
+import org.eclipse.emf.facet.util.core.Logger;
+
+public class FacetManager implements IFacetManager, Adapter {
+
+ private static final EClassifier EBOOLEAN = EcorePackage.eINSTANCE.getEBoolean();
+ private static final EClassifier EBOOLEAN_OBJECT = EcorePackage.eINSTANCE.getEBooleanObject();
+ private final FacetManagerContext context;
+ private final SerializationManager serializationMgr;
+ private final ResourceSet resourceSet;
+
+ public FacetManager(final Resource resource) {
+ this.serializationMgr = new SerializationManager(resource);
+ this.context = new FacetManagerContext(this);
+ this.resourceSet = resource.getResourceSet();
+ }
+
+ public FacetManager(final ResourceSet resourceSet) {
+ this.serializationMgr = new SerializationManager(null);
+ this.context = new FacetManagerContext(this);
+ this.resourceSet = resourceSet;
+ }
+
+ public void saveStructuralFeatureInstanceModel()
+ throws FacetManagerException {
+ this.serializationMgr.saveStructuralFeatureInstanceModel();
+ }
+
+ /**
+ * Returns whether the given model element conforms to the given Facet
+ *
+ * @param eObject
+ * the model element
+ * @param facet
+ * the Facet the applicability of which is being tested
+ * @return whether the given model element should be seen as an instance of the given Facet
+ */
+ public boolean isConforming(final EObject eObject, final Facet facet)
+ throws FacetManagerException {
+ return getConformanceState(eObject, facet) == FacetManager.ConformanceState.Conformant;
+ }
+
+ public enum ConformanceState {
+ Conformant, NonConformingMetaclass, NonConformingElement
+ }
+
+ private void checkConformance(final EObject eObject, final Facet facet)
+ throws FacetManagerException {
+ final ConformanceState conformanceState = getConformanceState(eObject, facet);
+ if (conformanceState == FacetManager.ConformanceState.NonConformingMetaclass) {
+ throw new FacetManagerException("NonApplicableFacetException"); //$NON-NLS-1$
+ }
+ if (conformanceState == FacetManager.ConformanceState.NonConformingElement) {
+ throw new FacetManagerException("NonConformingEObjectException"); //$NON-NLS-1$
+ }
+ }
+
+ protected ConformanceState getConformanceState(final EObject eObject,
+ final Facet facet) throws FacetManagerException {
+ // Begin of precondition section
+ if (eObject == null) {
+ throw new IllegalArgumentException("eObject cannot be null"); //$NON-NLS-1$
+ }
+ if (facet == null) {
+ throw new IllegalArgumentException("facet cannot be null"); //$NON-NLS-1$
+ }
+ // End of precondition section
+ ConformanceState result;
+ final EClass extendedMetaclass = FacetUtils.getExtendedMetaclass(facet);
+ if (extendedMetaclass != null
+ && (extendedMetaclass.isSuperTypeOf(eObject.eClass()) || extendedMetaclass == EcorePackage.eINSTANCE.getEObject())) {
+ final ETypedElement typeElement = facet.getConformanceTypedElement();
+ if (typeElement == null) {
+ result = FacetManager.ConformanceState.Conformant;
+ } else {
+ final Boolean isConforming = getConformanceValue(eObject, typeElement);
+ if (isConforming.booleanValue()) {
+ result = FacetManager.ConformanceState.Conformant;
+ } else {
+ result = FacetManager.ConformanceState.NonConformingElement;
+ }
+ }
+ } else {
+ result = FacetManager.ConformanceState.NonConformingMetaclass;
+ }
+ // The conformance constraint is inherited from the super facet.
+ if (result == FacetManager.ConformanceState.Conformant) {
+ for (Facet extFacet : facet.getExtendedFacets()) {
+ result = getConformanceState(eObject, extFacet);
+ if (result != FacetManager.ConformanceState.Conformant) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ private Boolean getConformanceValue(final EObject eObject,
+ final ETypedElement typeElement) throws FacetManagerException {
+ // Begin precondition checking
+ if (typeElement.isMany()) {
+ throw new FacetManagerException(
+ "The Facet's conformance typed element must not be multi-valued"); //$NON-NLS-1$
+ }
+ if (typeElement.getEType() != FacetManager.EBOOLEAN && typeElement.getEType() != FacetManager.EBOOLEAN_OBJECT) {
+ throw new FacetManagerException(
+ "The Facet conformance typed element evaluated to a wrong type."); //$NON-NLS-1$
+ }
+ // End precondition checking
+ Boolean result; // conformance typedElement Value
+ try {
+ if (typeElement instanceof EStructuralFeature) {
+ final EStructuralFeature structuralFeature = (EStructuralFeature) typeElement;
+ // basicGet = true in order to avoid an infinite recursion
+ result = internalGet(eObject, structuralFeature, Boolean.class, true);
+ } else if (typeElement instanceof EOperation) {
+ final EOperation operation = (EOperation) typeElement;
+ if (operation.getEParameters().size() > 0) {
+ throw new FacetConformanceEvaluationException("The Facet's conformance operation cannot have parameters"); //$NON-NLS-1$
+ }
+ // basicInvoke = true in order to avoid an infinite recursion,
+ // ie don't check conformance and don't resolve overrides
+ result = internalInvoke(eObject, operation, Boolean.class, true);
+ } else {
+ throw new FacetConformanceEvaluationException("Unsupported conformance typed element type: " + typeElement.getClass().getName()); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ throw new FacetManagerException(e);
+ }
+ if (result == null) {
+ throw new FacetManagerException(
+ "The Facet conformance typed element evaluated to null"); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ public void set(final EObject eObject,
+ final EStructuralFeature structuralFeature, final Object newValue,
+ final EditingDomain editingDomain) throws FacetManagerException {
+ if (structuralFeature.isMany() && !(newValue instanceof Collection<?>)) {
+ throw new IllegalArgumentException("newValue should be a Collection because eStructuralFeature is an EReference"); //$NON-NLS-1$
+ // TODO: check the type of the elements of the list.
+ }
+ final EObject eContainer = structuralFeature.eContainer();
+ if (eContainer instanceof Facet) {
+ final Facet facet = (Facet) eContainer;
+ checkConformance(eObject, facet);
+ if (structuralFeature instanceof EAttribute) {
+ final EAttribute eAttribute = (EAttribute) structuralFeature;
+ if (structuralFeature instanceof FacetAttribute) {
+ // TODO We still have to implement the setting of a derived facet attribute. Cf.
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726
+ throw new UnsupportedOperationException("Setting a FacetAttribute is not yet implemented"); //$NON-NLS-1$
+ } // else { // instanceof EAttribute
+ this.serializationMgr.setAttribute(eObject, eAttribute, newValue);
+ // }
+ } else if (structuralFeature instanceof EReference) {
+ final EReference reference = (EReference) structuralFeature;
+ if (reference instanceof FacetReference) {
+ // TODO We still have to implement the setting of a derived facet attribute. Cf.
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726
+ throw new UnsupportedOperationException("Setting a FacetReference is not yet implemented"); //$NON-NLS-1$
+ } // else { // instanceof EReference
+ this.serializationMgr.setReference(eObject, reference, newValue);
+ // }
+ } else {
+ throw new UnsupportedOperationException(
+ "Setting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ eObject.eSet(structuralFeature, newValue);
+ }
+ }
+
+ public <T> T get(final EObject eObject,
+ final EStructuralFeature structuralFeature,
+ final Class<T> expectedType) throws FacetManagerException {
+ return internalGet(eObject, structuralFeature, expectedType, false);
+ }
+
+ private <T> T internalGet(final EObject eObject,
+ final EStructuralFeature structuralFeature,
+ final Class<T> expectedType, final boolean basicGet)
+ throws FacetManagerException {
+ try {
+ Object value;
+ if (structuralFeature.eContainer() instanceof Facet) {
+
+ EStructuralFeature baseFeature = structuralFeature;
+
+ if (!basicGet) {
+ baseFeature = this.context.resolveOverrides(structuralFeature, eObject);
+ final Facet facet = (Facet) baseFeature.eContainer();
+ checkConformance(eObject, facet);
+ }
+ if (baseFeature.isDerived()) {
+ if (!(baseFeature instanceof DerivedTypedElement)) {
+ throw new UnsupportedOperationException("Cannot evaluate a derived structural feature that is not a DerivedTypedElement : not implemented"); //$NON-NLS-1$
+ }
+ value = IDerivedTypedElementManager.INSTANCE.evaluate((DerivedTypedElement) baseFeature, eObject, null, this);
+ } else {
+ if (baseFeature instanceof DerivedTypedElement) {
+ throw new IllegalArgumentException("A DerivedTypedElement must always be derived"); //$NON-NLS-1$
+ }
+ value = this.serializationMgr.getNotDerivedValue(eObject, baseFeature);
+ }
+ } else { // Regular structural feature
+ if (structuralFeature instanceof DerivedTypedElement) {
+ throw new IllegalStateException("The given DerivedTypedElement is not contained in a Facet"); //$NON-NLS-1$
+ }
+ value = eObject.eGet(structuralFeature, true);
+ }
+ return EmfUtils.checkAssignment(structuralFeature, expectedType, value);
+ } catch (Exception e) {
+ throw new FacetManagerException(e);
+ }
+ }
+
+ public <T> List<T> getMultiValued(final EObject eObject,
+ final EStructuralFeature structuralFeature,
+ final Class<T> expectedType) throws FacetManagerException {
+ final Object result = internalGet(eObject, structuralFeature, null, false);
+ // return the original list, which must be modifiable by the caller
+ try {
+ return CastUtils.castToExpectedListType(result, expectedType, true);
+ } catch (UnmatchingExpectedTypeException e) {
+ throw new UnmatchingExpectedTypeException("Failed to cast the value of '" + structuralFeature.getName() + "' to a list of " + expectedType.getName(), e); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+
+ public <T> T invoke(final EObject eObject, final EOperation operation,
+ final Class<T> expectedType, final EditingDomain editingDomain, final Object... arguments)
+ throws FacetManagerException {
+ try {
+ return internalInvoke(eObject, operation, expectedType, false, arguments);
+ } catch (Exception e) {
+ throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public <T> List<T> invokeMultiValued(final EObject eObject, final EOperation operation,
+ final Class<T> expectedType, final Object... arguments)
+ throws FacetManagerException {
+ Object result;
+ try {
+ result = internalInvoke(eObject, operation, null, false, arguments);
+ } catch (Exception e) {
+ throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return CastUtils.castToExpectedListType(result, expectedType, true);
+ }
+
+ private <T> T internalInvoke(final EObject eObject, final EOperation operation, final Class<T> expectedType,
+ final boolean basicInvoke, final Object... arguments)
+ throws DerivedTypedElementException, InvocationTargetException,
+ FacetConformanceEvaluationException, NonApplicableFacetException,
+ NonConformingEObjectException, FacetManagerException {
+ Object result;
+ if (operation.eContainer() instanceof Facet) {
+ final Facet facet = (Facet) operation.eContainer();
+
+ if (!basicInvoke) {
+ checkConformance(eObject, facet);
+ }
+ if (operation instanceof FacetOperation) {
+ final FacetOperation facetOperation = (FacetOperation) operation;
+ FacetOperation baseOperation = facetOperation;
+ if (!basicInvoke) {
+ baseOperation = this.context.resolveOverrides(facetOperation, eObject);
+ }
+ result = DerivedTypedElementUtils.evaluate(eObject, baseOperation, this, arguments);
+ } else {
+ result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments);
+ }
+ } else { // Regular eOperation
+ if (operation instanceof FacetOperation) {
+ throw new IllegalStateException("The given FacetOperation is not contained in a Facet"); //$NON-NLS-1$
+ }
+ result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments);
+ }
+ return CastUtils.castToExpectedType(result, expectedType);
+ }
+
+ public List<ETypedElementResult> get(final Collection<EObject> eObjects, final EStructuralFeature structuralFeature)
+ throws DerivedTypedElementException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
+ }
+
+ public List<ETypedElementResult> batchInvoke(
+ final Collection<EObject> eObjects, final EOperation operation,
+ final Object... arguments) throws FacetManagerException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
+ }
+
+ public List<FacetSet> getManagedFacetSets() {
+ return this.context;
+ }
+
+ public void setManagedFacetSets(final List<FacetSet> facetSets) {
+ this.context.setManagedFacetSets(facetSets);
+ }
+
+ public void removeFacetSet(final FacetSet facetSet) {
+ this.context.removeFacetSet(facetSet);
+ }
+
+ public ResourceSet getResourceSet() {
+ return this.resourceSet;
+ }
+
+ public List<ETypedElement> getAppliedFeatures() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
+ }
+
+ public Set<EAttribute> getAttributes(final EObject eObject)
+ throws FacetManagerException {
+ return getEStructuralFeatures(eObject, EAttribute.class);
+ }
+
+ public Set<EStructuralFeature> getStructuralFeature(final EObject eObject)
+ throws FacetManagerException {
+ return getEStructuralFeatures(eObject, EStructuralFeature.class);
+ }
+
+ public <T extends ETypedElement> Set<T> getEStructuralFeatures(
+ final EObject eObject, final Class<T> classs)
+ throws FacetManagerException {
+ final Set<T> result = new HashSet<T>();
+ for (FacetSet facetSet : this.context.getManagedFacetSets()) {
+ result.addAll(getETypedElements(eObject, facetSet, classs));
+ }
+ return result;
+ }
+
+ private <T extends ETypedElement> Collection<T> getETypedElements(
+ final EObject eObject, final FacetSet facetSet,
+ final Class<T> classs) throws FacetManagerException {
+ final Set<T> result = new HashSet<T>();
+ for (EClassifier eClassifier : facetSet.getEClassifiers()) {
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ if (isConforming(eObject, facet)) {
+ for (EStructuralFeature eStructuralFeature : getAllEStructuralFeatures(facet)) {
+ if (classs.isInstance(eStructuralFeature)) {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This type has been
+ // checked using isInstance
+ final T typedSF = (T) eStructuralFeature;
+ result.add(typedSF);
+ }
+ }
+ }
+ }
+ }
+ // hierarchical FacetSets
+ for (EPackage ePackage : facetSet.getESubpackages()) {
+ if (ePackage instanceof FacetSet) {
+ final FacetSet subFacetSet = (FacetSet) ePackage;
+ result.addAll(getETypedElements(eObject,
+ subFacetSet, classs));
+ }
+ }
+ // aggregates
+ for (FacetSet subFacetSet : facetSet.getFacetSets()) {
+ result.addAll(getETypedElements(eObject, subFacetSet, classs));
+ }
+ return result;
+ }
+
+ private List<EStructuralFeature> getAllEStructuralFeatures(final Facet facet) {
+ final List<EStructuralFeature> structFeatures = new LinkedList<EStructuralFeature>();
+ structFeatures.addAll(facet.getFacetElements());
+ for (Facet extFacet : facet.getExtendedFacets()) {
+ structFeatures.addAll(getAllEStructuralFeatures(extFacet));
+ }
+ return structFeatures;
+ }
+
+ public Set<EReference> getReferences(final EObject eObject)
+ throws FacetManagerException {
+ return getEStructuralFeatures(eObject, EReference.class);
+ }
+
+ public Collection<? extends EStructuralFeature> getSF(final EObject eObject)
+ throws FacetManagerException {
+ return getEStructuralFeatures(eObject, EStructuralFeature.class);
+ }
+
+ @Deprecated
+ public void addFacets(final EList<Facet> facets) {
+ for (Facet facetToLoad : facets) {
+ this.context.addFrontManagedFacetSet((FacetSet) facetToLoad
+ .getEPackage());
+ }
+ }
+
+ @Deprecated
+ public void unLoadAllFacets() {
+ removeAllManagedFacetSets();
+ }
+
+ public void removeAllManagedFacetSets() {
+ this.context.clear();
+ }
+
+ public <T> List<T> getOrInvokeMultiValued(final EObject eObject,
+ final ETypedElement eTypedElement, final Class<T> classs)
+ throws FacetManagerException {
+ List<T> result = null;
+ if (eTypedElement instanceof EStructuralFeature) {
+ final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement;
+ result = getMultiValued(eObject, structuralFeature, classs);
+ } else if (eTypedElement instanceof EOperation) {
+ final EOperation eOperation = (EOperation) eTypedElement;
+ result = invokeMultiValued(eObject, eOperation, classs);
+ }
+ return result;
+ }
+
+ public <T> T getOrInvoke(final EObject eObject,
+ final ETypedElement eTypedElement, final Class<T> classs)
+ throws FacetManagerException {
+ T result = null;
+ if (eTypedElement instanceof EStructuralFeature) {
+ final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement;
+ result = get(eObject, structuralFeature, classs);
+ } else if (eTypedElement instanceof EOperation) {
+ final EOperation eOperation = (EOperation) eTypedElement;
+ result = invoke(eObject, eOperation, classs, null);
+ }
+ return result;
+ }
+
+ public List<Facet> getManagedFacets() {
+ throw new IllegalStateException("Not implemented, and never will since it's deprecated"); //$NON-NLS-1$
+ }
+
+ public <T> List<ETypedElementResult> batchGetOrInvoke(final Collection<EObject> sources, final ETypedElement query, final Class<T> classs)
+ throws FacetManagerException {
+ final List<ETypedElementResult> results = new LinkedList<ETypedElementResult>();
+ for (EObject source : sources) {
+ ETypedElementResult result = null;
+ Exception exception = null;
+ if (query.getEType() instanceof EClass) {
+ if (query.getUpperBound() == 1) {
+ final ETypedElementEObjectResult<EObject> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementEObjectResult();
+ try {
+ eObjectResult.setResult(this.getOrInvoke(source, query, EObject.class));
+ } catch (Exception e) {
+ exception = e;
+ }
+ result = eObjectResult;
+ } else {
+ final ETypedElementEObjectListResult<EObject> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementEObjectListResult();
+ try {
+ eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, EObject.class));
+ } catch (Exception e) {
+ exception = e;
+ }
+ result = eObjectResultList;
+ }
+ } else {
+ if (query.getUpperBound() == 1) {
+ final ETypedElementPrimitiveTypeResult<Object> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeResult();
+ try {
+ eObjectResult.setResult(this.getOrInvoke(source, query, Collection.class));
+ } catch (Exception e) {
+ exception = e;
+ }
+ result = eObjectResult;
+ } else {
+ final ETypedElementPrimitiveTypeListResult<Object> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeListResult();
+ eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, Object.class));
+ result = eObjectResultList;
+ }
+ }
+ if (exception != null) {
+ result.setException(exception);
+ Logger.logWarning(exception, Activator.getDefault());
+ }
+ result.setDerivedTypedElement(query);
+ result.setSource(source);
+ results.add(result);
+ }
+ return results;
+ }
+
+ public void addBackManagedFacetSet(final FacetSet facetSet) {
+ this.context.addBackManagedFacetSet(facetSet);
+ }
+
+ public void addFrontManagedFacetSet(final FacetSet facetSet) {
+ this.context.addFrontManagedFacetSet(facetSet);
+ }
+
+ public void notifyChanged(final Notification notification) {
+ // Nothing to do
+ }
+
+ public Notifier getTarget() {
+ return null;
+ }
+
+ public void setTarget(final Notifier newTarget) {
+ // Nothing to do
+ }
+
+ public boolean isAdapterForType(final Object type) {
+ return false;
+ }
+
+ public void addListener(final IFacetManagerListener listener) {
+ this.context.addListener(listener);
+ }
+
+ public void removeListener(final IFacetManagerListener listener) {
+ this.context.removeListener(listener);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerContext.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerContext.java
new file mode 100644
index 00000000000..650bd5d7544
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerContext.java
@@ -0,0 +1,554 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ * Gregoire Dupe (Mia-Software) - Bug 377178 - [EFacet] infinite recursion in override resolution
+ * Gregoire Dupe (Mia-software) - Bug 383418 - [Table] FacetManagerContext.getOverrideCandidateFeatures(...) is empty
+ * Gregoire Dupe (Mia-software) - Bug 420093 - [EFacet] The facetManger list doesn't deal with uniqueness
+ * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
+ * Fabien Treguer (Soft-Maint) - Bug 423285 - [Table] FacetSets not stored in a resource cause model manager crashes
+ *******************************************************************************/
+
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.facet.efacet.core.FacetUtils;
+import org.eclipse.emf.facet.efacet.core.IFacetManagerListener;
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.efacet.core.internal.FacetManager.ConformanceState;
+import org.eclipse.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
+import org.eclipse.emf.facet.efacet.core.internal.exported.IResolverManager;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.core.internal.exported.ListUtils;
+import org.eclipse.emf.facet.util.emf.core.ModelUtils;
+
+/**
+ * @author oremaud
+ *
+ * FacetManager Context
+ *
+ * Defines which FacetSets will be taken into account, and in which
+ * order ('front' FacetSets have higher precedence)
+ *
+ * Responsible of overrides resolution for Facets and Customs
+ */
+class FacetManagerContext implements List<FacetSet> {
+
+ private static final String SILENT_OPTION = "org.eclipse.emf.facet.efacet.core.internal.FacetManagerContext.getOverrideCandidateFeatures.silent"; //$NON-NLS-1$
+ private static final boolean SILENT = Boolean
+ .getBoolean(FacetManagerContext.SILENT_OPTION);
+
+ // We cannot use the interface (i.e, List) instead because we need to use
+ // the methods addLast and addFirst
+ private LinkedList<FacetSet> managedFacetSets = new LinkedList<FacetSet>(); // NOPMD by gdupe on 15/03/12 10:36
+ private final transient FacetManager manager;
+ /**
+ * This field is used to avoid to have to many error messages in the log.
+ */
+ private final Set<ETypedElement> failingFeatures = new HashSet<ETypedElement>();
+
+ private final Set<IFacetManagerListener> listeners = new HashSet<IFacetManagerListener>();
+
+ public FacetManagerContext(final FacetManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ *
+ * @param baseFeature
+ * @param eObject
+ * @return
+ * @throws FacetConformanceEvaluationException
+ * @throws UnmatchingExpectedTypeException
+ * @throws FacetManagerException
+ */
+ public <T extends ETypedElement> T resolveOverrides(final T baseFeature,
+ final EObject eObject) throws FacetManagerException {
+ T result = baseFeature;
+ if (baseFeature instanceof DerivedTypedElement) {
+ final DerivedTypedElement derivedResult = resolveOverrides(
+ (DerivedTypedElement) baseFeature, eObject);
+ if (derivedResult != null
+ && !(derivedResult instanceof ETypedElement)) {
+ throw new UnmatchingExpectedTypeException(
+ "Type mismatch in override resolution '" + baseFeature.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ result = (T) derivedResult;
+ }
+ // If nothing is found, return the original basefeature
+ if (result == null) {
+ result = baseFeature;
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param baseFeature
+ * @param eObject
+ * @return
+ * @throws FacetConformanceEvaluationException
+ * @throws FacetManagerException
+ */
+ public <T extends DerivedTypedElement> T resolveOverrides(
+ final T baseFeature, final EObject eObject)
+ throws FacetManagerException {
+ try {
+ // -- Find master override
+ // If the baseFeature overrides another feature, then we follow the
+ // override chain to find the top feature
+ // The main idea behind this is that the baseFeature does not really
+ // represents a specific feature but a
+ // feature signature (as in java method invocation)
+ final T signatureFeature = FacetUtils
+ .getTopOverrideFeature(baseFeature);
+
+ // -- Find all candidates
+ // Get all Facet referenced by the FacetManager to get all features
+ // matching this signature
+ // Note : candidates are searched ine the order provided by the current
+ // FacetManager,
+ // so they are already ordered by the wanted priority
+ // XXX : Debug check that DerivedTypedElement only contained by Facet
+ final List<T> orderedCandidates = getOverrideCandidateFeatures(eObject,
+ signatureFeature);
+
+ // -- Find the most specific feature
+ return findMostSpecificFeature(orderedCandidates);
+ } catch (Exception e) {
+ throw new FacetManagerException(e);
+ }
+ }
+
+ public List<FacetSet> getManagedFacetSets() {
+ return Collections.unmodifiableList(this.managedFacetSets);
+ }
+
+ public void setManagedFacetSets(final List<FacetSet> facetSets) {
+ this.managedFacetSets = new LinkedList<FacetSet>(facetSets);
+ notifyListeners();
+ }
+
+ public void addBackManagedFacetSet(final FacetSet facetSet) {
+ // adding an already managed FacetSet again moves it to the right position
+ this.managedFacetSets.remove(facetSet);
+ this.managedFacetSets.addLast(facetSet);
+ notifyListeners();
+ }
+
+ public void addFrontManagedFacetSet(final FacetSet facetSet) {
+ if (this.managedFacetSets == null) {
+ this.managedFacetSets = new LinkedList<FacetSet>();
+ }
+ // adding an already managed FacetSet again moves it to the right position
+ this.managedFacetSets.remove(facetSet);
+ this.managedFacetSets.addFirst(facetSet);
+ notifyListeners();
+ }
+
+ /**
+ * Find the most specific feature in the candidates list. The most specific
+ * is the feature that : - is the most specific (in terms of Facet
+ * inheritance) : the lowest in the inheritance tree (per branch) - is
+ * encountered first. The order is given by the FacetManager context.
+ *
+ * @param candidates
+ * The list of candidates features. Can be empty.
+ * @return
+ */
+ private static <T extends DerivedTypedElement> T findMostSpecificFeature(
+ final List<T> orderedCandidates) {
+ T result = null;
+ if (!orderedCandidates.isEmpty()) {
+ final Iterator<T> candidatesIt = orderedCandidates.iterator();
+ result = candidatesIt.next();
+ // We have the highest priority feature, we just have to check
+ // that there is no more specific one in the override chain (from
+ // top to bottom)
+ while (candidatesIt.hasNext()) {
+ final T candidate = candidatesIt.next();
+ if (isOverridenBy(candidate, result)) {
+ result = candidate;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find matching candidates.
+ *
+ * @param eObject
+ * @param baseFeature
+ * @return A list of candidates, in the right order for conflict resolution
+ * @throws FacetManagerException
+ */
+ private <T extends DerivedTypedElement> List<T> getOverrideCandidateFeatures(
+ final EObject eObject, final T baseFeature)
+ throws FacetManagerException {
+ final ResourceSet baserFeatureRS = baseFeature.eResource().getResourceSet();
+ final List<T> result = new LinkedList<T>();
+ // Iterate over all Facets from all facetSets to find conforming
+ // features
+ final List<FacetSet> managedFSets = getManagedFacetSets();
+ final List<FacetSet> allFacetSets = new ArrayList<FacetSet>(managedFSets);
+ // add aggregated FacetSets
+ for (FacetSet facetSet : managedFSets) {
+ //FIXME Should handle recursive containment.
+ for (FacetSet subFacetSet : facetSet.getFacetSets()) {
+ final FacetSet resolvedFacetSet = IResolverManager.DEFAULT
+ .resolve(subFacetSet, FacetSet.class);
+ allFacetSets.add(resolvedFacetSet);
+ }
+ }
+ for (FacetSet facetSet : allFacetSets) {
+ final Resource resource = facetSet.eResource();
+ if (resource == null) {
+ final String message = String.format(
+ "The facetSet %s (%s) is not stored in a resource.", //$NON-NLS-1$
+ facetSet.getName(), facetSet.getNsURI());
+ Logger.logWarning(message, Activator.getDefault());
+ } else {
+ final ResourceSet facetSetRS = resource.getResourceSet();
+ if (!facetSetRS.equals(baserFeatureRS)) {
+ Logger.logWarning(
+ "The facet manager is dealing with more than one resource set.", //$NON-NLS-1$
+ Activator.getDefault());
+ }
+ }
+ for (Facet facet : FacetUtils.getFacets(facetSet)) {
+ final T matchingFeature = getMatchingFeature(eObject, facet,
+ baseFeature);
+ if (matchingFeature != null) {
+ result.add(matchingFeature);
+ }
+ }
+ }
+ if (result.isEmpty()) {
+ if (!this.failingFeatures.contains(baseFeature)
+ && !FacetManagerContext.SILENT) {
+ Logger.logWarning(
+ "The result of " //$NON-NLS-1$
+ + this.getClass().getSimpleName()
+ + ".getOverrideCandidateFeatures(...) is empty! baseFeature=" //$NON-NLS-1$
+ + EcoreUtil.getURI(baseFeature)
+ + " (This message will be sent only once)", //$NON-NLS-1$
+ Activator.getDefault());
+ // This avoid to have to many error messages in the log.
+ this.failingFeatures.add(baseFeature);
+ }
+ result.add(baseFeature);
+ }
+ return result;
+ }
+
+ /**
+ * Test whether a feature is overridden by another (directly or not)
+ *
+ * @param targetParent
+ * @param child
+ * @return true if child is directly or indirectly overridden by parent,
+ * false otherwise
+ */
+ private static boolean isOverridenBy(final DerivedTypedElement child,
+ final DerivedTypedElement targetParent) {
+
+ boolean result = false;
+ if (child.equals(targetParent)) {
+ result = true;
+ } else {
+ DerivedTypedElement currentParent = child.getOverride();
+ while (!result && currentParent != null) {
+ if (currentParent.equals(targetParent)) {
+ result = true;
+ } else {
+ currentParent = currentParent.getOverride();
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find DerivedTypedElement features that matches the 'signature'
+ *
+ * @param eObject
+ * EObject used to test conformance
+ * @param facet
+ * @param signatureFeature
+ * reference feature that serves as 'signature'
+ * @throws FacetManagerException
+ */
+ private <T extends DerivedTypedElement> T getMatchingFeature(
+ final EObject eObject, final Facet facet, final T signatureFeature)
+ throws FacetManagerException {
+ T result = null;
+ EList<? extends ETypedElement> eTypedElements;
+ if (signatureFeature instanceof EOperation) {
+ eTypedElements = facet.getFacetOperations();
+ } else {
+ eTypedElements = facet.getFacetElements();
+ }
+ // For each eTypedElement check is it override the signature feature and
+ // if the eTypedElement is owned by a facet to which the eObject
+ // conforms.
+ for (ETypedElement feature : eTypedElements) {
+ if (isMatchingFeature2(signatureFeature, feature)) {
+ // The conformance check is done after the check on the override
+ // to avoid infinite recursion.
+ final ConformanceState conformanceState = this.manager
+ .getConformanceState(eObject, facet);
+ if (conformanceState == ConformanceState.Conformant) {
+ if (!signatureFeature.getClass().isInstance(feature)) {
+ throw new FacetManagerException(
+ ModelUtils.getQualifiedName(feature)
+ + " overrides " //$NON-NLS-1$
+ + ModelUtils
+ .getQualifiedName(signatureFeature)
+ + " but both are not of the same kind."); //$NON-NLS-1$
+ }
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") check by
+ // "if (!signatureFeature.getClass().isInstance(feature))"
+ final T tmpFeature = (T) feature;
+ result = tmpFeature;
+ break;
+ // Two features from the same Facet cannot
+ // override a feature, so only one can be find
+ // in this Facet => stop search here.
+ }
+ }
+ }
+ return result;
+ }
+
+ private static <T extends DerivedTypedElement> boolean isMatchingFeature2(
+ final T signatureFeature, final ETypedElement feature)
+ throws FacetManagerException {
+ boolean result = false;
+ // We're focusing on DerivedTypedElements
+ // ECore native features could not be overridden by Facets
+ // (EMF facet is supposed to be non intrusive)
+
+ if (signatureFeature.getClass().isInstance(feature)) {
+ final T element = (T) feature;
+ // Just check that the top override is the same as the base feature
+ // i.e. that the current feature matches the 'signature'
+ final DerivedTypedElement topFeature = FacetUtils
+ .getTopOverrideFeature(element);
+ if (topFeature == signatureFeature) {
+ // found a match
+ result = true;
+ } else {
+ final Resource topResource = topFeature.eResource();
+ final Resource signatureResource = signatureFeature.eResource();
+ if (topResource == null || signatureResource == null || topFeature.eResource().getResourceSet() != signatureFeature.eResource().getResourceSet()) {
+ Logger.logWarning(
+ "topOverrideFeature.eResource().getResourceSet() != signatureFeature.eResource().getResourceSet()", //$NON-NLS-1$
+ Activator.getDefault());
+ }
+ }
+ }
+ return result;
+ }
+
+ public void removeFacetSet(final FacetSet facetSet) {
+ final boolean removed = this.managedFacetSets.remove(facetSet);
+ if (removed) {
+ notifyListeners();
+ }
+ }
+
+ public void clear() {
+ final boolean empty = this.managedFacetSets.isEmpty();
+ if (!empty) {
+ this.managedFacetSets.clear();
+ notifyListeners();
+ }
+ }
+
+ public int size() {
+ return this.managedFacetSets.size();
+ }
+
+ public boolean isEmpty() {
+ return this.managedFacetSets.isEmpty();
+ }
+
+ public boolean contains(final Object object) {
+ return this.managedFacetSets.contains(object);
+ }
+
+ public Iterator<FacetSet> iterator() {
+ return this.managedFacetSets.iterator();
+ }
+
+ public Object[] toArray() {
+ return this.managedFacetSets.toArray();
+ }
+
+ public <T> T[] toArray(final T[] array) {
+ return this.managedFacetSets.toArray(array);
+ }
+
+ public boolean add(final FacetSet object) {
+ boolean result = false;
+ this.managedFacetSets.remove(object);
+ if (object != null) {
+ result = this.managedFacetSets.add(object);
+ }
+ if (result) {
+ notifyListeners();
+ }
+ return result;
+ }
+
+ public boolean remove(final Object object) {
+ final boolean isRemoved = this.managedFacetSets.remove(object);
+ if (isRemoved) {
+ notifyListeners();
+ }
+ return isRemoved;
+ }
+
+ public boolean containsAll(final Collection<?> collection) {
+ return this.managedFacetSets.containsAll(collection);
+ }
+
+ public boolean addAll(final Collection<? extends FacetSet> collection) {
+ boolean result = false;
+ for (FacetSet facetSet : collection) {
+ this.managedFacetSets.remove(facetSet);
+ if (facetSet != null) {
+ final boolean addResult = this.managedFacetSets.add(facetSet);
+ result = result || addResult;
+ }
+ }
+ if (result) {
+ notifyListeners();
+ }
+ return result;
+ }
+
+ public boolean addAll(final int index,
+ final Collection<? extends FacetSet> collection) {
+ final List<FacetSet> filtered = new ArrayList<FacetSet>();
+ for (FacetSet facetSet : collection) {
+ if (!filtered.contains(facetSet)) {
+ filtered.add(facetSet);
+ }
+ }
+ this.managedFacetSets.removeAll(filtered);
+ final boolean isAdded = this.managedFacetSets.addAll(index,
+ ListUtils.cleanList(filtered));
+ if (isAdded) {
+ notifyListeners();
+ }
+ return isAdded;
+ }
+
+ public boolean removeAll(final Collection<?> collection) {
+ final boolean isRemoved = this.managedFacetSets.removeAll(collection);
+ if (isRemoved) {
+ notifyListeners();
+ }
+ return isRemoved;
+ }
+
+ public boolean retainAll(final Collection<?> collection) {
+ final boolean isRetained = this.managedFacetSets.retainAll(collection);
+ if (isRetained) {
+ notifyListeners();
+ }
+ return isRetained;
+ }
+
+ public FacetSet get(final int index) {
+ return this.managedFacetSets.get(index);
+ }
+
+ public FacetSet set(final int index, final FacetSet element) {
+ final FacetSet oldElement = this.managedFacetSets.set(index, element);
+ if (!oldElement.equals(element)) {
+ notifyListeners();
+ }
+ return oldElement;
+ }
+
+ public void add(final int index, final FacetSet element) {
+ this.managedFacetSets.remove(element);
+ if (element != null) {
+ this.managedFacetSets.add(index, element);
+ notifyListeners();
+ }
+ }
+
+ public FacetSet remove(final int index) {
+ final FacetSet oldElement = this.managedFacetSets.remove(index);
+ notifyListeners();
+ return oldElement;
+ }
+
+ public int indexOf(final Object object) {
+ return this.managedFacetSets.indexOf(object);
+ }
+
+ public int lastIndexOf(final Object object) {
+ return this.managedFacetSets.lastIndexOf(object);
+ }
+
+ public ListIterator<FacetSet> listIterator() {
+ return this.managedFacetSets.listIterator();
+ }
+
+ public ListIterator<FacetSet> listIterator(final int index) {
+ return this.managedFacetSets.listIterator(index);
+ }
+
+ public List<FacetSet> subList(final int fromIndex, final int toIndex) {
+ return this.subList(fromIndex, toIndex);
+ }
+
+ public void addListener(final IFacetManagerListener listener) {
+ this.listeners.add(listener);
+ }
+
+ public void removeListener(final IFacetManagerListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ private void notifyListeners() {
+ for (IFacetManagerListener listener : this.listeners) {
+ listener.facetManagerChanged();
+ }
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerFactory.java
new file mode 100644
index 00000000000..b58af224cfb
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/FacetManagerFactory.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Thomas Cicognani (Soft-Maint) - Bug 416223 - IFacetManagerFactory.getOrCreateFacetManager should not create an instance per call
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManagerFactory;
+
+public class FacetManagerFactory implements IFacetManagerFactory {
+
+ public IFacetManager getOrCreateFacetManager(final Resource resource) {
+ FacetManager result = null;
+ for (Adapter adapter : resource.eAdapters()) {
+ if (adapter instanceof FacetManager) {
+ result = (FacetManager) adapter;
+ }
+ }
+ if (result == null) {
+ result = new FacetManager(resource);
+ resource.eAdapters().add(result);
+ }
+ return result;
+ }
+
+ public IFacetManager getOrCreateFacetManager(final ResourceSet resourceSet) {
+ FacetManager result = null;
+ for (Adapter adapter : resourceSet.eAdapters()) {
+ if (adapter instanceof FacetManager) {
+ result = (FacetManager) adapter;
+ }
+ }
+ if (result == null) {
+ result = new FacetManager(resourceSet);
+ resourceSet.eAdapters().add(result);
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Messages.java
new file mode 100644
index 00000000000..cac5c63c985
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/Messages.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+@SuppressWarnings("PMD")
+public final class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.emf.facet.efacet.core.internal.messages"; //$NON-NLS-1$
+ public static String EFacetCatalogManager_FacetSetCatalogName;
+ public static String EFacetCatalogManager_QuerySetCatalogName;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/ResolverManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/ResolverManager.java
new file mode 100644
index 00000000000..a115682419a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/ResolverManager.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ */
+package org.eclipse.emf.facet.efacet.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.facet.efacet.core.internal.exported.IResolver;
+import org.eclipse.emf.facet.efacet.core.internal.exported.IResolverManager;
+import org.eclipse.emf.facet.util.core.Logger;
+
+public class ResolverManager implements IResolverManager {
+
+ private static final String ATT_NAME = "class"; //$NON-NLS-1$
+ private static final String EXT_POINT_ID = "org.eclipse.emf.facet.efacet.core.internal.resolver"; //$NON-NLS-1$
+ private final List<IResolver> resolvers = new ArrayList<IResolver>();
+
+ public ResolverManager() {
+ final IConfigurationElement[] configs = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(ResolverManager.EXT_POINT_ID);
+ for (IConfigurationElement config : configs) {
+ try {
+ final Object object = config
+ .createExecutableExtension(ResolverManager.ATT_NAME);
+ if (object instanceof IResolver) {
+ final IResolver resolver = (IResolver) object;
+ this.resolvers.add(resolver);
+ }
+ } catch (CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+
+ }
+ }
+
+ public <T> T resolve(final Object object, final Class<T> aClass) {
+ T result = null;
+ for (IResolver resolver : this.resolvers) {
+ if (resolver.canHandle(object)) {
+ try {
+ result = resolver.resolve(object, aClass);
+ } catch (ClassCastException e) {
+ Logger.logWarning(e, Activator.getDefault());
+ // Nothing to: we will try with an other resolver or return
+ // null
+ }
+ if (result != null) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public <T> List<T> selectionPropagation(final Object selectedObject,
+ final Class<T> aClass) {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") The untyped list is an definitely
+ // empty list.
+ List<T> result = Collections.EMPTY_LIST;
+ for (IResolver resolver : this.resolvers) {
+ if (resolver.canHandle(selectedObject)) {
+ try {
+ result = resolver.selectionPropagation(selectedObject,
+ aClass);
+ } catch (ClassCastException e) {
+ Logger.logWarning(e, Activator.getDefault());
+ // Nothing to: we will try with an other resolver or return
+ // null
+ }
+ if (result != null) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public <T> T selectionRoot(final Object selectedObject,
+ final Class<T> aClass) {
+ T result = null;
+ for (IResolver resolver : this.resolvers) {
+ if (resolver.canHandle(selectedObject)) {
+ try {
+ result = resolver.selectionRoot(selectedObject,
+ aClass);
+ } catch (ClassCastException e) {
+ Logger.logWarning(e, Activator.getDefault());
+ // Nothing to: we will try with an other resolver or return
+ // null
+ }
+ if (result != null) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java
new file mode 100644
index 00000000000..d3bdc14e0a5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.internal.catalog;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.QuerySet;
+import org.eclipse.emf.facet.efacet.catalog.efacetcatalog.EfacetcatalogFactory;
+import org.eclipse.emf.facet.efacet.catalog.efacetcatalog.FacetSetCatalog;
+import org.eclipse.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
+import org.eclipse.emf.facet.efacet.core.internal.Messages;
+import org.eclipse.emf.facet.util.emf.catalog.CatalogSet;
+import org.eclipse.emf.facet.util.emf.core.ICatalogManager;
+
+/** @deprecated replaced by {@link EFacetCatalogManager2} for the new eFacet2 metamodel */
+@Deprecated
+public class EFacetCatalogManager implements ICatalogManager {
+
+ private final FacetSetCatalog facetSetCatalog;
+ private final QuerySetCatalog querySetCatalog;
+
+ public EFacetCatalogManager() {
+ this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE.createFacetSetCatalog();
+ this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName);
+ this.querySetCatalog = EfacetcatalogFactory.eINSTANCE.createQuerySetCatalog();
+ this.querySetCatalog.setName(Messages.EFacetCatalogManager_QuerySetCatalogName);
+ }
+
+ public boolean canBeManaged(final EObject root) {
+ return root instanceof QuerySet || root instanceof FacetSet;
+ }
+
+ public void manage(final EObject root) {
+ if (root instanceof FacetSet) {
+ FacetSet facetSet = (FacetSet) root;
+ this.facetSetCatalog.getInstalledEntries().add(facetSet);
+ } else if (root instanceof QuerySet) {
+ QuerySet querySet = (QuerySet) root;
+ this.querySetCatalog.getInstalledEntries().add(querySet);
+ }
+ }
+
+ public void setCatalogSet(final CatalogSet catalogSet) {
+ catalogSet.getCatalogs().add(this.facetSetCatalog);
+ catalogSet.getCatalogs().add(this.querySetCatalog);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java
new file mode 100644
index 00000000000..4bac9941198
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Nicolas Bros (Mia-Software) - Bug 361817 - [Restructuring] Dynamic load to the facet catalog
+ * Nicolas Bros (Mia-Software) - Bug 370110 - Rename efacetcatalog2.ecore
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.catalog;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetSetCatalogManager;
+import org.eclipse.emf.facet.efacet.core.internal.Messages;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.EfacetcatalogFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.FacetSetCatalog;
+import org.eclipse.emf.facet.util.emf.catalog.CatalogSet;
+import org.eclipse.emf.facet.util.emf.core.ICatalogManager;
+
+public class EFacetCatalogManager2 implements IFacetSetCatalogManager, ICatalogManager {
+
+ private final FacetSetCatalog facetSetCatalog;
+
+ public EFacetCatalogManager2() {
+ this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE
+ .createFacetSetCatalog();
+ this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName);
+ }
+
+ public boolean canBeManaged(final EObject root) {
+ return root instanceof FacetSet;
+ }
+
+ public void manage(final EObject root) {
+ if (root instanceof FacetSet) {
+ final FacetSet facetSet = (FacetSet) root;
+ this.facetSetCatalog.getInstalledEntries().add(facetSet);
+ }
+ }
+
+ public void setCatalogSet(final CatalogSet catalogSet) {
+ catalogSet.getCatalogs().add(this.facetSetCatalog);
+ }
+
+ public List<FacetSet> getRegisteredFacetSets() {
+ final BasicEList<FacetSet> result = new BasicEList<FacetSet>();
+ for (EObject eObject : this.facetSetCatalog.getInstalledEntries()) {
+ if (eObject instanceof FacetSet) {
+ final FacetSet facetSet = (FacetSet) eObject;
+ result.add(facetSet);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public void registerFacetSet(final FacetSet facetSet) {
+ this.facetSetCatalog.getInstalledEntries().add(facetSet);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java
new file mode 100644
index 00000000000..5a56a16ddf2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ */
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.util.core.internal.ErrorHandlingUtils;
+
+/**
+ * This exception occurs when something goes wrong during the execution of a query.
+ *
+ * @since 0.2
+ */
+public class DerivedTypedElementEvaluationException extends DerivedTypedElementException {
+ // This class is a copy of
+ // org.eclipse.emf.facet.infra.query.core.ModelQueryExecutionException
+
+ private static final long serialVersionUID = -8464252257666617685L;
+
+ public DerivedTypedElementEvaluationException(final String message) {
+ super(message);
+ }
+
+ public DerivedTypedElementEvaluationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public DerivedTypedElementEvaluationException(final Throwable cause) {
+ super(cause);
+ }
+
+ /** Constructor for evaluation exception due to wrong type */
+ public DerivedTypedElementEvaluationException(final String message, final Class<?> expectedType, final Object resultElement) {
+ super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement));
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java
new file mode 100644
index 00000000000..6af52e9ca25
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2009 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ */
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+
+/**
+ * This exception occurs when the type of the result of evaluating a derived typed element is not
+ * the one that was expected
+ *
+ * @since 0.2
+ */
+public class DerivedTypedElementTypeCheckingException extends DerivedTypedElementException {
+
+ private static final long serialVersionUID = -9064274334817642819L;
+
+ public DerivedTypedElementTypeCheckingException(final String message) {
+ super(message);
+ }
+
+ public DerivedTypedElementTypeCheckingException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public DerivedTypedElementTypeCheckingException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java
new file mode 100644
index 00000000000..bbdbeed0281
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+/**
+ * Happens when there is an error evaluating a Facet's conformance typed element.
+ *
+ * @since 0.2
+ */
+public class FacetConformanceEvaluationException extends Exception {
+ private static final long serialVersionUID = -5306430483154103388L;
+
+ public FacetConformanceEvaluationException(final String message) {
+ super(message);
+ }
+
+ public FacetConformanceEvaluationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public FacetConformanceEvaluationException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java
new file mode 100644
index 00000000000..cd3c4af722c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mia-Software
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+/**
+ * This exception is raised when an object cannot be extended by a facet because the class of the object does not correspond
+ * to the extended metaclass of the facet.
+ * @since 0.2
+ */
+public class NonApplicableFacetException extends Exception {
+
+ private static final long serialVersionUID = 2984069177830836577L;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java
new file mode 100644
index 00000000000..a4562303aa5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mia-Software
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+/**
+ * This exception is raised when an object cannot be extended by a facet because it is filtered by the conformance query
+ * of this facet.
+ * @since 0.2
+ */
+public class NonConformingEObjectException extends Exception {
+
+ private static final long serialVersionUID = -7778081627619345385L;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java
new file mode 100644
index 00000000000..ea924dc8de4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ */
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+
+/**
+ * This exception is raised when an IOException is caught when trying to save a structural feature instance model
+ * @since 0.2
+ */
+public class SaveStructuralFeatureInstanceModelException extends
+ FacetManagerException {
+
+ private static final long serialVersionUID = 7024009106572531846L;
+
+ /**
+ * Creates a new instance of UnmatchingExpectedTypeException
+ * with {@link Throwable} the exception at the origin of this exception
+ */
+ public SaveStructuralFeatureInstanceModelException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Creates a new instance of UnmatchingExpectedTypeException
+ * with {@link Throwable} the exception at the origin of this exception
+ */
+ public SaveStructuralFeatureInstanceModelException(final String message) {
+ super(message);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java
new file mode 100644
index 00000000000..1f68b161a44
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.exception;
+
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.util.core.internal.ErrorHandlingUtils;
+
+/**
+ * This exception is raised when a value's type does not match with the expected type
+ *
+ * @since 0.2
+ */
+public class UnmatchingExpectedTypeException extends FacetManagerException {
+
+ private static final long serialVersionUID = 1456802297756942271L;
+
+ public UnmatchingExpectedTypeException() {
+ super();
+ }
+
+ public UnmatchingExpectedTypeException(final String message) {
+ super(message);
+ }
+
+ public UnmatchingExpectedTypeException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnmatchingExpectedTypeException(final Throwable cause) {
+ super(cause);
+ }
+
+ public UnmatchingExpectedTypeException(final String message, final Class<?> expectedType, final Object resultElement) {
+ super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement));
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolver.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolver.java
new file mode 100644
index 00000000000..ac9bba1eaf3
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolver.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ */
+package org.eclipse.emf.facet.efacet.core.internal.exported;
+
+import java.util.List;
+
+/**
+ * The interface has to be implemented to contribute to the extension point
+ * 'org.eclipse.emf.facet.efacet.core.internal.resolver'.
+ */
+public interface IResolver {
+
+ /**
+ * Return true is the parameter object can be handle by the implementation
+ * of this interface.
+ *
+ * @param object
+ * @return
+ */
+ boolean canHandle(Object object);
+
+ /**
+ * If the parameter 'object' is a proxy, this method returns the
+ * corresponding a resolved object.
+ *
+ * @param object
+ * a proxy
+ * @param aClass
+ * the expected resolved object
+ */
+ <T> T resolve(Object object, Class<T> aClass);
+
+ /**
+ * This method returns the objects that have to be automatically selected
+ * when the parameter 'selectedObject' is selected.
+ *
+ * @param selectedObject
+ * @param aClass
+ * the expected list elements type.
+ */
+ <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass);
+
+ /**
+ * This method returns the root of the objects that have to be automatically
+ * selected when the parameter 'selectedObject' is selected.
+ *
+ * @param selectedObject
+ * @param aClass
+ * the expected list elements type.
+ */
+ <T> T selectionRoot(Object selectedObject, Class<T> aClass);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolverManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolverManager.java
new file mode 100644
index 00000000000..d4917507333
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/exported/IResolverManager.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ */
+package org.eclipse.emf.facet.efacet.core.internal.exported;
+
+import java.util.List;
+
+import org.eclipse.emf.facet.efacet.core.internal.ResolverManager;
+
+public interface IResolverManager {
+
+ IResolverManager DEFAULT = new ResolverManager();
+
+ <T> T resolve(Object object, Class<T> aClass);
+
+ <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass);
+
+ <T> T selectionRoot(Object selectedObject, Class<T> aClass);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java
new file mode 100644
index 00000000000..781eb598cf7
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java
@@ -0,0 +1,208 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.efacet.core.internal.incubatingapi;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.core.internal.FacetActions2Impl;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+import org.eclipse.emf.facet.util.emf.core.exception.InvalidFacetSetException;
+
+/**
+ * This interface contains methods to create {@link Facet}s.
+ *
+ * @since 0.2
+ */
+public interface IFacetActions2 {
+
+ IFacetActions2 INSTANCE = new FacetActions2Impl();
+
+ /**
+ * Add the given facetSet to the given facetSet model file, which will be created
+ *
+ * @param facetSet
+ * the facetSet to be created. Cannot be <code>null</code>
+ * @param project
+ * the new file in which the facetSet has to be created. Cannot be <code>null</code>,
+ * and cannot already exist
+ */
+ void saveFacetSet(FacetSet facetSet, IFile file) throws IOException,
+ InvalidFacetSetException;
+
+ /**
+ * Add the given {@link Facet} to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the parent facetSet, cannot be null
+ * @param facet
+ * the {@link Facet}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add EMF command, cannot be null
+ */
+ Facet createFacetInFacetSet(FacetSet facetSet, Facet facet,
+ EditingDomain editingDomain);
+
+ /**
+ * Create a command to add the given {@link Facet} to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the parent facetSet, cannot be null
+ * @param facet
+ * the {@link Facet}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add EMF command, cannot be null
+ */
+ Command createCreateFacetInFacetSetCommand(FacetSet facetSet, Facet facet,
+ EditingDomain editingDomain);
+
+ /**
+ * Add the given {@link FacetAttribute} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetAttribute
+ * the {@link FacetAttribute}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute,
+ EditingDomain editingDomain);
+
+ /**
+ * Create a command to add the given {@link FacetAttribute} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetAttribute
+ * the {@link FacetAttribute}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ Command createAddAttributeInFacetCommand(Facet facet, FacetAttribute facetAttribute,
+ EditingDomain editingDomain);
+
+ /**
+ * Add the given {@link FacetReference} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetReference
+ * the {@link FacetReference}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addReferenceInFacet(Facet facet, FacetReference facetReference,
+ EditingDomain editingDomain);
+
+ /**
+ * Create a command to add the given {@link FacetReference} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetReference
+ * the {@link FacetReference}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ Command createAddReferenceInFacetCommand(Facet facet,
+ FacetReference facetReference, EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link FacetOperation} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetOperation
+ * the new {@link FacetOperation}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addOperationInFacet(Facet facet, FacetOperation facetOperation,
+ EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link FacetOperation} to the given {@link Facet}
+ *
+ * @param facet
+ * the parent {@link Facet}, cannot be null
+ * @param facetOperation
+ * the new {@link FacetOperation}, cannot be null, or contained by a resource
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ Command createAddOperationInFacetCommand(Facet facet,
+ FacetOperation facetOperation, EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link EParameter} to the given {@link FacetOperation}
+ *
+ * @param operation
+ * the parent {@link EOperation}
+ * @param parameter
+ * the new {@link EParameter}
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ void addParameterInOperation(FacetOperation operation,
+ EParameter parameter, EditingDomain editingDomain);
+
+ /**
+ * Add a new {@link EParameter} to the given {@link FacetOperation}
+ *
+ * @param operation
+ * the parent {@link EOperation}
+ * @param parameter
+ * the new {@link EParameter}
+ * @param editingDomain
+ * the editing domain needed to perform the Add Emf command, cannot be null
+ */
+ Command createAddParameterInOperationCommand(FacetOperation operation,
+ EParameter parameter, EditingDomain editingDomain);
+
+ /**
+ * Set the given URI to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the {@link FacetSet} to be modified
+ * @param nsUri
+ * the Uri
+ * @param editingDomain
+ * the editing domain needed to perform the Set Emf command, cannot be null
+ */
+ void setFacetSetNsUri(FacetSet facetSet, String nsUri,
+ EditingDomain editingDomain);
+
+ /**
+ * Set the given URI to the given {@link FacetSet}
+ *
+ * @param facetSet
+ * the {@link FacetSet} to be modified
+ * @param nsUri
+ * the Uri
+ * @param editingDomain
+ * the editing domain needed to perform the Set Emf command, cannot be null
+ */
+ Command createSetFacetSetNsUriCommand(FacetSet facetSet, String nsUri,
+ EditingDomain editingDomain);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/messages.properties
new file mode 100644
index 00000000000..75dcf1429ef
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/messages.properties
@@ -0,0 +1,13 @@
+###########################################################################
+# Copyright (c) 2011 Mia-Software.
+#
+# 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:
+# Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+###########################################################################
+EFacetCatalogManager_FacetSetCatalogName=FacetSet catalog
+EFacetCatalogManager_QuerySetCatalogName=QuerySet catalog
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java
new file mode 100644
index 00000000000..7abf20adf20
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.emf.facet.util.emf.core.ICatalogSetManager
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.Activator;
+import org.eclipse.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManagerFactory;
+import org.osgi.framework.Bundle;
+
+/** @deprecated replaced by {@link QueryImplementationFactoryRegistry}. No tracking bug because this API has not been released yet. */
+@Deprecated
+public class DerivedTypedElementImplementationFactoryRegistry {
+ private static final String DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID = "org.eclipse.emf.facet.efacet.core.derivedTypedElementImplementationRegistration"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+ public static final DerivedTypedElementImplementationFactoryRegistry INSTANCE = new DerivedTypedElementImplementationFactoryRegistry();
+
+ private final List<IDerivedTypedElementImplementationFactory> derivedTypedElementImplementationFactories = new ArrayList<IDerivedTypedElementImplementationFactory>();
+
+ public DerivedTypedElementImplementationFactoryRegistry() {
+ initRegisteredEntries();
+ }
+
+ private void initRegisteredEntries() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extPoint = registry
+ .getExtensionPoint(DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID);
+ if (extPoint != null) {
+ for (IExtension ext : extPoint.getExtensions()) {
+ for (IConfigurationElement configElt : ext.getConfigurationElements()) {
+
+ IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory;
+ try {
+ derivedTypedElementImplementationFactory = (IDerivedTypedElementImplementationFactory) configElt
+ .createExecutableExtension(DerivedTypedElementImplementationFactoryRegistry.CLASS);
+ this.derivedTypedElementImplementationFactories.add(derivedTypedElementImplementationFactory);
+ } catch (CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the derived typed element evaluator that handles the given type of query
+ *
+ * @param query
+ * the type of query for which an {@link IDerivedTypedElementImplementation} is searched
+ * @param derivedTEManager
+ * @return the {@link IDerivedTypedElementImplementation}
+ * @throws DerivedTypedElementException
+ * if no factory implementation was registered for the type of the given query
+ */
+ public IDerivedTypedElementImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager derivedTEManager)
+ throws DerivedTypedElementException {
+ if (query == null) {
+ throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
+ }
+ IDerivedTypedElementImplementation derivedTypedElementImplementation = null;
+ boolean factoryFound = false;
+ for (IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory : this.derivedTypedElementImplementationFactories) {
+ factoryFound = derivedTypedElementImplementationFactory.getManagedQueryType() == query.eClass();
+ if (factoryFound) {
+ Resource queryResource = query.eResource();
+ Bundle bundle;
+ if (queryResource != null) {
+ bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource);
+ } else {
+ bundle = null;
+ }
+ derivedTypedElementImplementation = derivedTypedElementImplementationFactory.create(query, bundle, derivedTEManager);
+ break;
+ }
+ }
+ if (!factoryFound) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("No factory implementation found for "); //$NON-NLS-1$
+ sb.append(QueryUtils.getQueryDescription(query));
+ sb.append(".\nA factory should be registered through the " + DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID + " extension point."); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append("\nAvailable Query types are: "); //$NON-NLS-1$
+ for (int i = 0; i < this.derivedTypedElementImplementationFactories.size(); i++) {
+ if (i > 0) {
+ sb.append(", "); //$NON-NLS-1$
+ }
+ IDerivedTypedElementImplementationFactory queryEvaluatorFactory = this.derivedTypedElementImplementationFactories.get(i);
+ sb.append(queryEvaluatorFactory.getManagedQueryType().getName());
+ }
+ throw new DerivedTypedElementException(sb.toString());
+ }
+ return derivedTypedElementImplementation;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java
new file mode 100644
index 00000000000..26408a3f502
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.EObjectLiteralQuery;
+
+public class EObjectLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
+ final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return ((EObjectLiteralQuery) query).getElement();
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
+ final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..1fa6d0c6ca9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class EObjectLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getEObjectLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final EObjectLiteralQueryImplementation evaluator = new EObjectLiteralQueryImplementation();
+ evaluator.setCheckResultType(true);
+ return evaluator;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java
new file mode 100644
index 00000000000..feb64f6b16c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+public class FalseLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return Boolean.FALSE;
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..2d927390215
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class FalseLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getFalseLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final FalseLiteralQueryImplementation evaluator = new FalseLiteralQueryImplementation();
+ evaluator.setCheckResultType(false);
+ return evaluator;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java
new file mode 100644
index 00000000000..273684093c5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.FloatLiteralQuery;
+
+public class FloatLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return Float.valueOf(((FloatLiteralQuery) query).getValue());
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..c71db27d315
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class FloatLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getFloatLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final FloatLiteralQueryImplementation evaluator = new FloatLiteralQueryImplementation();
+ evaluator.setCheckResultType(true);
+ return evaluator;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java
new file mode 100644
index 00000000000..25584037bbe
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IntegerLiteralQuery;
+
+public class IntegerLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return Integer.valueOf(((IntegerLiteralQuery) query).getValue());
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..b7d9f787c3f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class IntegerLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getIntegerLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final IntegerLiteralQueryImplementation evaluator = new IntegerLiteralQueryImplementation();
+ evaluator.setCheckResultType(true);
+ return evaluator;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java
new file mode 100644
index 00000000000..41c9ee77c90
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IsOneOfQuery;
+
+public class IsOneOfQueryImplementation implements IQueryImplementation {
+
+ // This class is a modified copy of :
+ // org.eclipse.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return Boolean.valueOf(((IsOneOfQuery) query).getExpectedEObjects().contains(source));
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java
new file mode 100644
index 00000000000..ff224211f3e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class IsOneOfQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getIsOneOfQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final IsOneOfQueryImplementation evaluator = new IsOneOfQueryImplementation();
+ evaluator.setCheckResultType(false);
+ return evaluator;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java
new file mode 100644
index 00000000000..9360bf29d1f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 366055 - NavigationQuery
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Olivier Remaud (Soft-Maint) - Bug 373087 - [Improvement] Adaptable behavior on error
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.NavigationQuery;
+
+public class NavigationQueryImplementation implements IQueryImplementation {
+
+ // This class is a modified copy of :
+ // org.eclipse.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ final NavigationQuery navigationQuery = (NavigationQuery) query;
+ Object current = source;
+ for (final ETypedElement typedElement : navigationQuery.getPath()) {
+ if (current instanceof EObject) {
+ final EObject currentEObject = (EObject) current;
+ if (typedElement instanceof EOperation) {
+ final EOperation operation = (EOperation) typedElement;
+ try {
+ current = currentEObject.eInvoke(operation, null);
+ } catch (final InvocationTargetException e) {
+ throw new DerivedTypedElementEvaluationException("Invocation of " + operation.getName() + " failed.", e); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } else if (typedElement instanceof EStructuralFeature) {
+ final EStructuralFeature structuralFeature = (EStructuralFeature) typedElement;
+ current = currentEObject.eGet(structuralFeature);
+ } else {
+ throw new DerivedTypedElementEvaluationException("The " + typedElement.eClass().getName() + " is not supported."); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } else {
+ if (current != null || navigationQuery.isFailOnError()) {
+ throw new DerivedTypedElementEvaluationException("Invalid path"); //$NON-NLS-1$
+ }
+ }
+ }
+ return current;
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java
new file mode 100644
index 00000000000..44fadad33a0
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 366055 - NavigationQuery
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class NavigationQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getNavigationQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final NavigationQueryImplementation evaluator = new NavigationQueryImplementation();
+ evaluator.setCheckResultType(true);
+ return evaluator;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java
new file mode 100644
index 00000000000..9617193cc31
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+public class NullLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return null;
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..c4e437e5bc4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class NullLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getNullLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final NullLiteralQueryImplementation evaluator = new NullLiteralQueryImplementation();
+ evaluator.setCheckResultType(false);
+ return evaluator;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java
new file mode 100644
index 00000000000..42bb247da8a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.OperationCallQuery;
+
+public class OperationCallQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+ private final IDerivedTypedElementManager derivedTEManager;
+
+ public OperationCallQueryImplementation(final IDerivedTypedElementManager derivedTEManager) {
+ this.derivedTEManager = derivedTEManager;
+ }
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ Object result;
+ final OperationCallQuery opQuery = (OperationCallQuery) query;
+ final List<Object> operationArgs = new ArrayList<Object>();
+ for (final Query queryArgument : opQuery.getArguments()) {
+ operationArgs.add(this.derivedTEManager.evaluate(queryArgument, source, parameterValues, facetManager));
+ }
+
+ // FIXME: no EditingDomain is available here
+ try {
+ result = facetManager.invoke(source, opQuery.getOperation(), null, null, operationArgs.toArray());
+ } catch (final FacetManagerException e) {
+ throw new DerivedTypedElementEvaluationException("Operation call evaluation failed", e); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("A set operation cannot be performed through an operation call."); //$NON-NLS-1$
+
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java
new file mode 100644
index 00000000000..577c6bdf2fa
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class OperationCallQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getOperationCallQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager)
+ throws DerivedTypedElementException {
+ return new OperationCallQueryImplementation(manager);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java
new file mode 100644
index 00000000000..2f73e8e8ab9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Guyomar (Mia-Software) - Bug 349566 - Need some new query utils method for query creation
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.exception.QueryException;
+import org.eclipse.emf.facet.efacet.core.internal.Activator;
+import org.eclipse.emf.facet.efacet.core.query.IQueryEvaluator;
+import org.eclipse.emf.facet.efacet.core.query.IQueryEvaluatorFactory;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManager;
+
+/** @deprecated replaced by {@link DerivedTypedElementImplementationFactoryRegistry} with the new eFacet2 metamodel */
+@Deprecated
+public class QueryEvaluatorFactoryRegistry {
+ private static final String QUERY_EVALUATOR_REGISTRATION_ID = "org.eclipse.emf.facet.efacet.core.query.evaluatorregistration"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+ public static final QueryEvaluatorFactoryRegistry INSTANCE = new QueryEvaluatorFactoryRegistry();
+
+ private final List<IQueryEvaluatorFactory> queryEvaluatorFactories = new ArrayList<IQueryEvaluatorFactory>();
+
+ public QueryEvaluatorFactoryRegistry() {
+ initRegisteredEntries();
+ }
+
+ private void initRegisteredEntries() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extPoint = registry
+ .getExtensionPoint(QueryEvaluatorFactoryRegistry.QUERY_EVALUATOR_REGISTRATION_ID);
+ if (extPoint != null) {
+ for (IExtension ext : extPoint.getExtensions()) {
+ for (IConfigurationElement configElt : ext.getConfigurationElements()) {
+
+ IQueryEvaluatorFactory queryEvaluatorFactory;
+ try {
+ queryEvaluatorFactory = (IQueryEvaluatorFactory) configElt
+ .createExecutableExtension(QueryEvaluatorFactoryRegistry.CLASS);
+
+ this.queryEvaluatorFactories.add(queryEvaluatorFactory);
+ } catch (CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+ }
+ }
+ }
+
+ public IQueryEvaluator getEvaluatorFor(final Query query) throws QueryException {
+ IQueryEvaluator queryEvaluator = null;
+ boolean factoryFound = false;
+ for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) {
+ factoryFound = queryEvaluatorFactory.getManagedQueryType() == query.eClass();
+ if (factoryFound) {
+ queryEvaluator = queryEvaluatorFactory.create(query,
+ ICatalogSetManager.INSTANCE.getBundleByResource(query.eResource()));
+ break;
+ }
+ }
+ if (!factoryFound) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("No factory implementation found for: "); //$NON-NLS-1$
+ sb.append(query.eClass().getName());
+ sb.append(":"); //$NON-NLS-1$
+ sb.append(query.getName());
+ sb.append("\n Available Query types are: "); //$NON-NLS-1$
+ for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) {
+ sb.append(queryEvaluatorFactory.getManagedQueryType().getName());
+ sb.append(", "); //$NON-NLS-1$
+ }
+ QueryException e = new QueryException(sb.toString());
+ throw e;
+ }
+ return queryEvaluator;
+ }
+
+ public List<IQueryEvaluatorFactory> getInstalledQueryFactories() {
+ return this.queryEvaluatorFactories;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java
new file mode 100644
index 00000000000..752bfde7e35
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.Activator;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManagerFactory;
+import org.osgi.framework.Bundle;
+
+public class QueryImplementationFactoryRegistry {
+ private static final String EXT_ID = "org.eclipse.emf.facet.efacet.core.queryImplementationRegistration"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+ public static final QueryImplementationFactoryRegistry INSTANCE = new QueryImplementationFactoryRegistry();
+
+ private final List<IQueryImplementationFactory> factories = new ArrayList<IQueryImplementationFactory>();
+
+ public QueryImplementationFactoryRegistry() {
+ initRegisteredEntries();
+ }
+
+ private void initRegisteredEntries() {
+ final IExtensionRegistry registry = Platform.getExtensionRegistry();
+ final IExtensionPoint extPoint = registry.getExtensionPoint(QueryImplementationFactoryRegistry.EXT_ID);
+ if (extPoint != null) {
+ for (final IExtension ext : extPoint.getExtensions()) {
+ for (final IConfigurationElement configElt : ext.getConfigurationElements()) {
+ try {
+ final Object impl = configElt.createExecutableExtension(QueryImplementationFactoryRegistry.CLASS);
+ if (impl instanceof IQueryImplementationFactory) {
+ final IQueryImplementationFactory factory = (IQueryImplementationFactory) impl;
+ this.factories.add(factory);
+ } else {
+ Logger.logError("Invalid extension in " + ext.getNamespaceIdentifier() + "." + //$NON-NLS-1$ //$NON-NLS-2$
+ ". The factory must be an instance of " + IQueryImplementationFactory.class.getName(), Activator.getDefault()); //$NON-NLS-1$
+ }
+ } catch (final CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the query evaluator that handles the given type of query
+ *
+ * @param query
+ * the type of query for which an {@link IQueryImplementation} is searched
+ * @return the {@link IQueryImplementation}
+ * @throws DerivedTypedElementException
+ * if no factory implementation was registered for the type of the given query
+ */
+ public IQueryImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager manager)
+ throws DerivedTypedElementException {
+ if (query == null) {
+ throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
+ }
+ IQueryImplementation queryImpl = null;
+ boolean factoryFound = false;
+ for (final IQueryImplementationFactory queryImplFactory : this.factories) {
+ factoryFound = queryImplFactory.getManagedQueryType() == query.eClass();
+ if (factoryFound) {
+ final Resource queryResource = query.eResource();
+ Bundle bundle = null;
+ if (queryResource != null) {
+ bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource);
+ }
+ queryImpl = queryImplFactory.create(query, bundle, manager);
+ break;
+ }
+ }
+ if (!factoryFound) {
+ final StringBuffer buffer = new StringBuffer();
+ buffer.append("No factory implementation found for "); //$NON-NLS-1$
+ buffer.append(QueryUtils.getQueryDescription(query));
+ buffer.append(".\nA factory should be registered through the "); //$NON-NLS-1$
+ buffer.append(QueryImplementationFactoryRegistry.EXT_ID);
+ buffer.append(" extension point."); //$NON-NLS-1$ // NOPMD: cannot merge with extracted constant string
+ buffer.append("\nAvailable Query types are: "); //$NON-NLS-1$
+ for (int i = 0; i < this.factories.size(); i++) {
+ if (i > 0) {
+ buffer.append(", "); //$NON-NLS-1$
+ }
+ final IQueryImplementationFactory factory = this.factories.get(i);
+ buffer.append(factory.getManagedQueryType().getName());
+ }
+ throw new DerivedTypedElementException(buffer.toString());
+ }
+ return queryImpl;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtils.java
new file mode 100644
index 00000000000..c0152075508
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtils.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Mia-Software
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.efacet.core.FacetUtils;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+public final class QueryUtils {
+
+ private QueryUtils() {
+ // utility class
+ }
+
+ /** @return a description to help identify this query in error messages */
+ public static String getQueryDescription(final Query query) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("[Query eClass:"); //$NON-NLS-1$
+ sb.append(query.eClass().getName());
+ DerivedTypedElement owningDerivedTypedElement = QueryUtils
+ .getOwningDerivedTypedElement(query);
+ if (owningDerivedTypedElement != null) {
+ sb.append(" defined on "); //$NON-NLS-1$
+ sb.append(owningDerivedTypedElement.getClass().getSimpleName());
+ EClassifier eType = owningDerivedTypedElement.getEType();
+ if (eType != null) {
+ sb.append(" of type '"); //$NON-NLS-1$
+ sb.append(eType.getName());
+ sb.append("' named: '"); //$NON-NLS-1$
+ } else {
+ sb.append(" named: '"); //$NON-NLS-1$
+ }
+ sb.append(owningDerivedTypedElement.getName());
+ sb.append("'"); //$NON-NLS-1$
+ } else {
+ sb.append(" with a null owning derived typed element"); //$NON-NLS-1$
+ }
+ sb.append("]"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ // Moved from
+ // org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
+ public static EClassifier getReturnType(final Query query) {
+ EClassifier result = null;
+ final DerivedTypedElement owningDTE = QueryUtils
+ .getOwningDerivedTypedElement(query);
+ if (owningDTE != null) {
+ result = owningDTE.getEType();
+ }
+ return result;
+ }
+
+ // Moved from
+ // org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
+ public static EClassifier getSourceType(final Query query) {
+ EClassifier result = null;
+ final DerivedTypedElement owningDTE = QueryUtils
+ .getOwningDerivedTypedElement(query);
+ if (owningDTE != null) {
+ final EObject eContainer = QueryUtils.getOwningDerivedTypedElement(
+ query).eContainer();
+ if (eContainer instanceof Facet) {
+ final Facet facet = (Facet) eContainer;
+ result = FacetUtils.getExtendedMetaclass(facet);
+ } else if (eContainer instanceof ETypedElement) {
+ final ETypedElement typedElement = (ETypedElement) eContainer;
+ result = typedElement.getEType();
+ }
+ }
+ return result;
+ }
+
+ // Moved from
+ // org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
+ public static DerivedTypedElement getOwningDerivedTypedElement(
+ final Query query) {
+ DerivedTypedElement result = null;
+ EObject container = query.eContainer();
+ while (container != null) {
+ if (container instanceof DerivedTypedElement) {
+ result = (DerivedTypedElement) container;
+ break;
+ }
+ container = container.eContainer();
+ }
+ if (result == null) {
+ throw new IllegalStateException(
+ "Query must always be contained by a DerivedTypedElement"); //$NON-NLS-1$
+ }
+ return (DerivedTypedElement) container;
+
+ }
+
+ // Moved from
+ // org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
+ public static boolean isMany(final Query query) {
+ boolean result = false;
+ final DerivedTypedElement owningDTE = QueryUtils
+ .getOwningDerivedTypedElement(query);
+ if (owningDTE != null) {
+ result = owningDTE.isMany();
+ }
+ return result;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java
new file mode 100644
index 00000000000..bbabe0532fe
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.QuerySet;
+import org.eclipse.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
+import org.eclipse.emf.facet.efacet.core.query.IQueryUtils;
+import org.eclipse.emf.facet.util.emf.catalog.Catalog;
+import org.eclipse.emf.facet.util.emf.core.ICatalogSetManager;
+
+/**
+ * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there
+ * are no QuerySets anymore. Queries are used only in Facets.
+ */
+@Deprecated
+public class QueryUtilsImpl implements IQueryUtils {
+
+ public Query searchQuery(final String querySetName, final String queryName) {
+ List<QuerySetCatalog> querySetCatalogs = new ArrayList<QuerySetCatalog>();
+ List<Catalog> catalogs = ICatalogSetManager.INSTANCE.getCatalogSet()
+ .getCatalogs();
+ for (Catalog catalog : catalogs) {
+ if (catalog instanceof QuerySetCatalog) {
+ querySetCatalogs.add((QuerySetCatalog) catalog);
+ }
+ }
+
+ QuerySet searchedQuerySet = null;
+ for (QuerySetCatalog querySetCatalog : querySetCatalogs) {
+ List<QuerySet> querySets = querySetCatalog.getInstalledQuerySets();
+ for (QuerySet querySet : querySets) {
+ if (querySet.getName() != null
+ && querySet.getName().equals(querySetName)) {
+ searchedQuerySet = querySet;
+ }
+ }
+ }
+ Query searchedQuery = null;
+ if (searchedQuerySet != null) {
+ for (Query query : searchedQuerySet.getQueries()) {
+ if (query.getName() != null
+ && query.getName().equals(queryName)) {
+ searchedQuery = query;
+ }
+ }
+ }
+ return searchedQuery;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java
new file mode 100644
index 00000000000..90dae768242
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
+ Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.StringLiteralQuery;
+
+public class StringLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return ((StringLiteralQuery) query).getValue();
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..a07991634ac
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
+ Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class StringLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getStringLiteralQuery();
+ }
+
+ public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
+ final StringLiteralQueryImplementation evaluator = new StringLiteralQueryImplementation();
+ evaluator.setCheckResultType(true);
+ return evaluator;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java
new file mode 100644
index 00000000000..10409352d45
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+public class TrueLiteralQueryImplementation implements IQueryImplementation {
+
+ private boolean checkResultType = false;
+
+ public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
+ final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ return Boolean.TRUE;
+ }
+
+ public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
+ final Object newValue)
+ throws DerivedTypedElementException {
+ throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
+ }
+
+ public void setCheckResultType(final boolean checkResultType) {
+ this.checkResultType = checkResultType;
+ }
+
+ public boolean isCheckResultType() {
+ return this.checkResultType;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java
new file mode 100644
index 00000000000..afdb51b907c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.internal.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementation;
+import org.eclipse.emf.facet.efacet.core.query.IQueryImplementationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
+import org.osgi.framework.Bundle;
+
+public class TrueLiteralQueryImplementationFactory implements IQueryImplementationFactory {
+
+ public IQueryImplementation create(final Query query, final Bundle bundle, final IDerivedTypedElementManager derivedTEManager)
+ throws DerivedTypedElementException {
+ final TrueLiteralQueryImplementation evaluator = new TrueLiteralQueryImplementation();
+ evaluator.setCheckResultType(false);
+ return evaluator;
+ }
+
+ public EClass getManagedQueryType() {
+ return QueryPackage.eINSTANCE.getTrueLiteralQuery();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java
new file mode 100644
index 00000000000..9b015a2fc45
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.serialization;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
+
+/**
+ * Interface for the adapter that attaches {@link ExtendedEObjectReference} to {@link EObject}s.
+ *
+ * @since 0.2
+ */
+public interface ILinkToExtendedEObjectReference {
+
+ /**
+ * @return the current {@link ExtendedEObjectReference}.
+ */
+ public ExtendedEObjectReference getExtendedEObjectReference();
+
+ /**
+ * Replace the current ExtendedEObjectReference by {@link ExtendedEObjectReference}.
+ */
+ public void setExtendedEObjectReference(ExtendedEObjectReference extendedEObjectReference);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java
new file mode 100644
index 00000000000..db43a0ee7e7
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ */
+package org.eclipse.emf.facet.efacet.core.internal.serialization;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notifier;
+
+/**
+ * Factory to create {@link ILinkToExtendedEObjectReference} adapters.
+ *
+ */
+public interface ILinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactory {
+
+ /**
+ * Singleton {@link LinkToExtendedEObjectReferenceAdapterFactory}
+ */
+ public static ILinkToExtendedEObjectReferenceAdapterFactory INSTANCE = new LinkToExtendedEObjectReferenceAdapterFactory();
+
+ /**
+ * This method returns <code>true</code> if this factory is a factory for the given type
+ * {@link Object}, or <code>false</code> otherwise
+ */
+ public boolean isFactoryForType(final Object type);
+
+ /**
+ * Creates a new instance of Adapter for the given {@link Notifier}
+ */
+ public Adapter createAdapter(final Notifier target);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java
new file mode 100644
index 00000000000..e04dfea98ec
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.serialization;
+
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
+
+public class LinkToExtendedEObjectReferenceAdapter extends AdapterImpl implements
+ ILinkToExtendedEObjectReference {
+
+ private ExtendedEObjectReference extendedEObjectReference;
+
+ public ExtendedEObjectReference getExtendedEObjectReference() {
+ return this.extendedEObjectReference;
+ }
+
+ public void setExtendedEObjectReference(final ExtendedEObjectReference extendedEObjectReference) {
+ this.extendedEObjectReference = extendedEObjectReference;
+ }
+
+ @Override
+ public boolean isAdapterForType(final Object type) {
+ return type == ILinkToExtendedEObjectReference.class;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java
new file mode 100644
index 00000000000..3c4574013a5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.serialization;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+public class LinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactoryImpl implements ILinkToExtendedEObjectReferenceAdapterFactory {
+
+ @Override
+ public boolean isFactoryForType(final Object type) {
+ return type == ILinkToExtendedEObjectReference.class;
+ }
+
+ @Override
+ public Adapter createAdapter(final Notifier target) {
+ return new LinkToExtendedEObjectReferenceAdapter();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/SerializationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/SerializationManager.java
new file mode 100644
index 00000000000..f954a962fb2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/internal/serialization/SerializationManager.java
@@ -0,0 +1,432 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software
+ * 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:
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
+ * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.internal.serialization;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.efacet.core.internal.exception.SaveStructuralFeatureInstanceModelException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractAttributeInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractReferenceInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedAttributeInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedContainmentReferenceInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedReferenceInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SerializationFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedAttributeInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedContainmentReferenceInstance;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedReferenceInstance;
+
+public class SerializationManager {
+
+ private final Resource structuralFeatureInstancesResource;
+
+ public SerializationManager(final Resource structuralFeatureInstancesResource) {
+ this.structuralFeatureInstancesResource = structuralFeatureInstancesResource;
+ if (structuralFeatureInstancesResource != null) {
+ final EList<EObject> contents = structuralFeatureInstancesResource.getContents();
+ for (EObject eObject : contents) {
+ if (eObject instanceof ExtendedEObjectReference) {
+ final ExtendedEObjectReference extendedEObjectReference = (ExtendedEObjectReference) eObject;
+ final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE
+ .adapt(extendedEObjectReference.getExtendedEObject(),
+ ILinkToExtendedEObjectReference.class);
+ adapter.setExtendedEObjectReference(extendedEObjectReference);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
+ * the reference {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static MultiValuedContainmentReferenceInstance createMultiValuedContainmentReferenceInstance(final EReference reference,
+ final List<EObject> values,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final MultiValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE
+ .createMultiValuedContainmentReferenceInstance();
+ containmentReferenceInstance.setEReference(reference);
+ if (values != null) {
+ containmentReferenceInstance.getOwnedElements().addAll(values);
+ }
+ extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance);
+ return containmentReferenceInstance;
+ }
+
+ /**
+ * This method returns the {@link ExtendedEObjectReference} associated with the given
+ * {@link EObject} if it exists or <code>null</code> if it does not exist.
+ */
+ private static ExtendedEObjectReference getExtendedEObjectReference(final EObject eObject) {
+ ExtendedEObjectReference result = null;
+ for (final Adapter adapter : eObject.eAdapters()) {
+ if (adapter.isAdapterForType(ILinkToExtendedEObjectReference.class)) {
+ final LinkToExtendedEObjectReferenceAdapter linkToExtendedEObjectReferenceAdapter = (LinkToExtendedEObjectReferenceAdapter) adapter;
+ result = linkToExtendedEObjectReferenceAdapter.getExtendedEObjectReference();
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with
+ * the attribute {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static MultiValuedAttributeInstance createMultiValuedAttributeInstance(final EAttribute attribute, final List<Object> values,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final MultiValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createMultiValuedAttributeInstance();
+ attributeInstance.setEAttribute(attribute);
+ if (values != null) {
+ attributeInstance.getValues().addAll(values);
+ }
+ extendedEObjectReference.getAttributeInstances().add(attributeInstance);
+ return attributeInstance;
+ }
+
+ /**
+ * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
+ * the reference {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static MultiValuedReferenceInstance createMultiValuedReferenceInstance(final EReference reference, final List<EObject> values,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final MultiValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE
+ .createMultiValuedReferenceInstance();
+ referenceInstance.setEReference(reference);
+ if (values != null) {
+ referenceInstance.getReferencedElements().addAll(values);
+ }
+ extendedEObjectReference.getReferenceInstances().add(referenceInstance);
+ return referenceInstance;
+ }
+
+ private static SingleValuedAttributeInstance getSingleValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference,
+ final EAttribute eAttribute) {
+ SingleValuedAttributeInstance result = null;
+ final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances();
+ for (final AbstractAttributeInstance attributeInstance : attributeInstances) {
+ if (eAttribute.equals(attributeInstance.getEAttribute())) {
+ if (attributeInstance instanceof SingleValuedAttributeInstance) {
+ result = (SingleValuedAttributeInstance) attributeInstance;
+ break;
+ }
+ throw new IllegalStateException("single valued attribute should be associated to an instance of SingleValuedAttributeInstance"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ private static MultiValuedAttributeInstance getMultiValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference,
+ final EAttribute eAttribute) {
+ MultiValuedAttributeInstance result = null;
+ final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances();
+ for (final AbstractAttributeInstance attributeInstance : attributeInstances) {
+ if (eAttribute.equals(attributeInstance.getEAttribute())) {
+ if (attributeInstance instanceof MultiValuedAttributeInstance) {
+ result = (MultiValuedAttributeInstance) attributeInstance;
+ break;
+ }
+ throw new IllegalStateException("multi valued attribute should be associated to an instance of MultiValuedAttributeInstance"); //$NON-NLS-1$
+
+ }
+ }
+ return result;
+ }
+
+ private static SingleValuedReferenceInstance getSingleValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
+ final EReference eReference) {
+ SingleValuedReferenceInstance result = null;
+ final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
+ for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
+ if (eReference.equals(referenceInstance.getEReference())) {
+ if (referenceInstance instanceof SingleValuedReferenceInstance) {
+ result = (SingleValuedReferenceInstance) referenceInstance;
+ break;
+ }
+ throw new IllegalStateException(
+ "a single valued non-containment reference should be associated to an instance of SingleValuedReferenceInstance"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ private static SingleValuedContainmentReferenceInstance getSingleValuedContainmentReferenceInstance(
+ final ExtendedEObjectReference extendedEObjectReference,
+ final EReference eReference) {
+ SingleValuedContainmentReferenceInstance result = null;
+ final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
+ for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
+ if (eReference.equals(referenceInstance.getEReference())) {
+ if (referenceInstance instanceof SingleValuedContainmentReferenceInstance) {
+ result = (SingleValuedContainmentReferenceInstance) referenceInstance;
+ break;
+ }
+ throw new IllegalStateException(
+ "a single valued containment reference should be associated to an instance of SingleValuedContainmentReferenceInstance"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ private static MultiValuedReferenceInstance getMultiValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
+ final EReference eReference) {
+ MultiValuedReferenceInstance result = null;
+ final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
+ for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
+ if (eReference.equals(referenceInstance.getEReference())) {
+ if (referenceInstance instanceof MultiValuedReferenceInstance) {
+ result = (MultiValuedReferenceInstance) referenceInstance;
+ break;
+ }
+ throw new IllegalStateException(
+ "a multi valued non-containment reference should be associated to an instance of MultiValuedReferenceInstance"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ private static MultiValuedContainmentReferenceInstance getMultiValuedContainmentReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
+ final EReference eReference) {
+ MultiValuedContainmentReferenceInstance result = null;
+ final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
+ for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
+ if (eReference.equals(referenceInstance.getEReference())) {
+ if (referenceInstance instanceof MultiValuedContainmentReferenceInstance) {
+ result = (MultiValuedContainmentReferenceInstance) referenceInstance;
+ break;
+ }
+ throw new IllegalStateException(
+ "a multi valued containment reference should be associated to an instance of MultiValuedContainmentReferenceInstance"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ public void saveStructuralFeatureInstanceModel()
+ throws SaveStructuralFeatureInstanceModelException {
+ if (this.structuralFeatureInstancesResource == null) {
+ throw new SaveStructuralFeatureInstanceModelException("This facet manager has been initailized with a null structural feature instances resource"); //$NON-NLS-1$
+ }
+ try {
+ this.structuralFeatureInstancesResource.save(Collections.EMPTY_MAP);
+ } catch (final IOException e) {
+ throw new SaveStructuralFeatureInstanceModelException(e);
+ }
+ }
+
+ /**
+ * This method returns the ExtendedEObjectReference associated with the given {@link EObject} if
+ * it exists or creates it if it does not exist.
+ */
+ private ExtendedEObjectReference getOrCreateExtendedEObjectReference(final EObject eObject) {
+ ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject);
+ if (extendedEObjectReference == null) {
+ extendedEObjectReference = SerializationFactory.eINSTANCE.createExtendedEObjectReference();
+ extendedEObjectReference.setExtendedEObject(eObject);
+ if (this.structuralFeatureInstancesResource != null) {
+ this.structuralFeatureInstancesResource.getContents().add(extendedEObjectReference);
+ }
+ final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE
+ .adapt(eObject, ILinkToExtendedEObjectReference.class);
+ adapter.setExtendedEObjectReference(extendedEObjectReference);
+ }
+ return extendedEObjectReference;
+ }
+
+ public void setAttribute(final EObject eObject, final EAttribute attribute, final Object newValue) {
+ final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
+ if (attribute.isMany()) {
+ if (newValue instanceof List) {
+ // safe to cast
+ @SuppressWarnings("unchecked")
+ final List<Object> list = (List<Object>) newValue;
+ final MultiValuedAttributeInstance attributeInstance =
+ SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, attribute);
+ if (attributeInstance == null) {
+ SerializationManager.createMultiValuedAttributeInstance(attribute, list, extendedEObjectReference);
+ } else {
+ attributeInstance.getValues().clear();
+ attributeInstance.getValues().addAll(list);
+ }
+ } else {
+ throw new IllegalArgumentException("The given FacetAttribute is multiplicity-many, so the value must be a List"); //$NON-NLS-1$
+ }
+ } else {
+ final SingleValuedAttributeInstance attributeInstance =
+ SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, attribute);
+ if (attributeInstance == null) {
+ createSingleValuedAttributeInstance(attribute, newValue, extendedEObjectReference);
+ } else {
+ attributeInstance.setValue(newValue);
+ }
+ }
+
+ }
+
+
+ /**
+ * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with
+ * the attribute {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static SingleValuedAttributeInstance createSingleValuedAttributeInstance(final EAttribute attribute, final Object value,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final SingleValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createSingleValuedAttributeInstance();
+ attributeInstance.setEAttribute(attribute);
+ attributeInstance.setValue(value);
+ extendedEObjectReference.getAttributeInstances().add(attributeInstance);
+ return attributeInstance;
+ }
+
+ /**
+ * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
+ * the reference {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static SingleValuedReferenceInstance createSingleValuedReferenceInstance(final EReference reference, final EObject value,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final SingleValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE
+ .createSingleValuedReferenceInstance();
+ referenceInstance.setEReference(reference);
+ referenceInstance.setReferencedElement(value);
+ extendedEObjectReference.getReferenceInstances().add(referenceInstance);
+ return referenceInstance;
+ }
+
+ public void setReference(final EObject eObject, final EReference reference, final Object newValue) {
+ final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
+ if (reference.isMany()) {
+ throw new UnsupportedOperationException(
+ "The given FacetReference is multi-valued : add elements to the list returned by getMultiValuedReference() instead"); //$NON-NLS-1$
+ }
+ if (!(newValue instanceof EObject)) {
+ throw new IllegalArgumentException("newValue should be an EObject because eStructuralFeature is an EReference"); //$NON-NLS-1$
+ }
+ final EObject newEObjectValue = (EObject) newValue;
+ if (reference.isContainment()) {
+ final SingleValuedContainmentReferenceInstance referenceInstance =
+ SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, reference);
+ if (referenceInstance == null) {
+ createSingleValuedContainmentReferenceInstance(reference, newEObjectValue, extendedEObjectReference);
+ } else {
+ referenceInstance.setOwnedElement(newEObjectValue);
+ }
+ } else {
+ final SingleValuedReferenceInstance referenceInstance =
+ SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, reference);
+ if (referenceInstance == null) {
+ createSingleValuedReferenceInstance(reference, newEObjectValue, extendedEObjectReference);
+ } else {
+ referenceInstance.setReferencedElement(newEObjectValue);
+ }
+ }
+
+ }
+
+ /**
+ * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
+ * the reference {@link EStructuralFeature} and the value {@link Object}.
+ */
+ private static SingleValuedContainmentReferenceInstance createSingleValuedContainmentReferenceInstance(final EReference reference,
+ final EObject value,
+ final ExtendedEObjectReference extendedEObjectReference) {
+ final SingleValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE
+ .createSingleValuedContainmentReferenceInstance();
+ containmentReferenceInstance.setEReference(reference);
+ containmentReferenceInstance.setOwnedElement(value);
+ extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance);
+ return containmentReferenceInstance;
+ }
+
+ private Object getMultiValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) {
+ Object result = null;
+ final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
+ if (structuralFeature instanceof EAttribute) {
+ final EAttribute eAttribute = (EAttribute) structuralFeature;
+ final MultiValuedAttributeInstance attributeInstance =
+ SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, eAttribute);
+ if (attributeInstance != null) {
+ result = attributeInstance.getValues();
+ }
+ } else if (structuralFeature instanceof EReference) {
+ final EReference eReference = (EReference) structuralFeature;
+ if (eReference.isContainment()) {
+ MultiValuedContainmentReferenceInstance referenceInstance =
+ SerializationManager.getMultiValuedContainmentReferenceInstance(extendedEObjectReference, eReference);
+ if (referenceInstance == null) {
+ referenceInstance = SerializationManager.createMultiValuedContainmentReferenceInstance(eReference, null, extendedEObjectReference);
+ result = referenceInstance.getOwnedElements();
+ } else {
+ result = referenceInstance.getOwnedElements();
+ }
+ } else {
+ MultiValuedReferenceInstance referenceInstance =
+ SerializationManager.getMultiValuedReferenceInstance(extendedEObjectReference, eReference);
+ if (referenceInstance == null) {
+ referenceInstance = SerializationManager.createMultiValuedReferenceInstance(eReference, null, extendedEObjectReference);
+ result = referenceInstance.getReferencedElements();
+ } else {
+ result = referenceInstance.getReferencedElements();
+ }
+ }
+ } else {
+ throw new UnsupportedOperationException("Getting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return result;
+ }
+
+ private static Object getSingleValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) {
+ Object result = null;
+ final ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject);
+ if (extendedEObjectReference != null) {
+ if (structuralFeature instanceof EAttribute) {
+ final EAttribute eAttribute = (EAttribute) structuralFeature;
+ final SingleValuedAttributeInstance attributeInstance = SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, eAttribute);
+ if (attributeInstance != null) {
+ result = attributeInstance.getValue();
+ }
+ } else if (structuralFeature instanceof EReference) {
+ final EReference eReference = (EReference) structuralFeature;
+ if (eReference.isContainment()) {
+ final SingleValuedContainmentReferenceInstance referenceInstance =
+ SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, eReference);
+ result = referenceInstance.getOwnedElement();
+ } else {
+ final SingleValuedReferenceInstance referenceInstance =
+ SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, eReference);
+ result = referenceInstance.getReferencedElement();
+ }
+ } else {
+ throw new IllegalArgumentException("Unexpected structuralFeature kind"); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ public Object getNotDerivedValue(final EObject eObject, final EStructuralFeature structuralFeature) {
+ Object result;
+ if (structuralFeature.isMany()) {
+ result = this.getMultiValuedStructuralFeature(eObject, structuralFeature);
+ } else {
+ result = SerializationManager.getSingleValuedStructuralFeature(eObject, structuralFeature);
+ }
+ return result;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java
new file mode 100644
index 00000000000..5aac933e749
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+
+/**
+ * This interface can be implemented by EMF Facet derived typed element implementations that want to
+ * handle multiple evaluation themselves, presumably to improve the performance of the evaluation.
+ * <p>
+ * If only {@link IDerivedTypedElementImplementation} is implemented, then the framework will
+ * perform multiple-evaluation by calling the single evaluation multiple times, which may be slow in
+ * the case of high-latency implementations.
+ *
+ * @since 0.2
+ * @deprecated replaced by {@link IQueryCollectionImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377057.
+ */
+@Deprecated
+public interface IDerivedTypedElementCollectionImplementation extends IDerivedTypedElementImplementation {
+
+ /**
+ * This method must be implemented by each sub-class to evaluate the query of a derived typed element on a
+ * collection of elements. The query should be evaluated on each of the elements in the given collection.
+ * <p>
+ * This method should throw a {@link DerivedTypedElementException} only if the {@link DerivedTypedElement} is
+ * incorrect. But it must not throw an exception if the evaluation of one element fails. Instead, it must set the
+ * exception on the corresponding result ({@link AbstractDerivedTypedElementResult#setException(Throwable)}).
+ *
+ * @param derivedTypedElement
+ * The derived typed element for which to get the values
+ * @param sources
+ * The model elements on which the derived typed element is evaluated
+ * @param arguments
+ * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code>
+ * @return the result :
+ * <ul>
+ * <li> a list of {@link DerivedTypedElementPrimitiveTypeResult} if the derived typed element is
+ * single-valued and returns a primitive type <li> a list of
+ * {@link DerivedTypedElementPrimitiveTypeListResult} if the derived typed element is multi-valued and
+ * returns a primitive type <li> a list of {@link DerivedTypedElementEObjectResult} if the derived typed
+ * element is single-valued and returns a model element <li> a list of
+ * {@link DerivedTypedElementEObjectListResult} if the derived typed element is multi-valued and returns
+ * model elements
+ * </ul>
+ * @throws DerivedTypedElementException
+ * if the given derivedTypedElement is incorrect
+ */
+ List<? extends ETypedElementResult> getValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments)
+ throws DerivedTypedElementException;
+
+ /**
+ * This method must be implemented by each sub-class to set the values of a collection of elements. The derived
+ * typed element's query should be used to set the value of each of the elements in the given collection.
+ *
+ * @param query
+ * The query to evaluate
+ * @param source
+ * The model elements on which the query is evaluated
+ * @param arguments
+ * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be
+ * <code>null</code>
+ * @param newValues
+ * the new values for the sources; the size of this list must match the size of the list of sources
+ * @throws DerivedTypedElementException
+ * if the given derivedTypedElement is incorrect
+ * @throws DerivedTypedElementEvaluationException
+ * if the query of the derived typed element could not be evaluated correctly
+ * @throws IllegalArgumentException
+ * if the given list of values does not match the list of sources
+ */
+ void setValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments, List<? extends Object> newValues)
+ throws DerivedTypedElementException;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java
new file mode 100644
index 00000000000..a6f06d20cda
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+
+/**
+ * Interface implemented by all EMF Facet derived typed element evaluators.
+ * <p>
+ * A derived typed element evaluator may choose to implement
+ * {@link IDerivedTypedElementCollectionImplementation} instead if it wants to improve the
+ * performance of evaluation on collections of elements.
+ *
+ * @since 0.2
+ * @deprecated replaced by {@link IQueryImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377058.
+ */
+@Deprecated
+public interface IDerivedTypedElementImplementation {
+
+ /**
+ * This method must be implemented by each sub class to evaluate a derived
+ * typed element
+ *
+ * @param derivedTypedElement
+ * The derived typed element to evaluate
+ * @param source
+ * The model element on which the derived typed element is
+ * evaluated
+ * @param parameterValues
+ * The derived typed element's query parameter values (in the
+ * case of a {@link FacetOperation}), can be <code>null</code>
+ * @return the result, which can be either a single object or a collection
+ * of values depending on the multiplicity of the given derived
+ * typed element
+ * @throws DerivedTypedElementException
+ * if the query of the derived typed element could not be
+ * evaluated correctly to get the value
+ */
+ Object getValue(DerivedTypedElement derivedTypedElement, EObject source,
+ List<ParameterValue> parameterValues, IFacetManager facetManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * This method must be implemented by each sub class to set the value of a
+ * derived typed element
+ *
+ * @param derivedTypedElement
+ * The derived typed element to set
+ * @param source
+ * The model element on which the derived typed element is set
+ * @param parameterValues
+ * The derived typed element's query parameter values (in the
+ * case of a {@link FacetOperation}), can be <code>null</code>
+ * @param newValue
+ * the value to set on the derived typed element
+ * @throws DerivedTypedElementException
+ * if the query of the derived typed element could not be
+ * evaluated correctly to set the value
+ */
+ void setValue(DerivedTypedElement derivedTypedElement, EObject source,
+ List<ParameterValue> parameterValues, Object newValue)
+ throws DerivedTypedElementException;
+
+ /**
+ * Return whether to check the type of the derived typed element result after its evaluation
+ * <p>
+ * Normally, this is <code>true</code>, but the derived typed element evaluator can choose to
+ * skip the check, for example if the return type of the query can't be loaded.
+ *
+ * @return whether to check the type of the derived typed element result after its evaluation
+ */
+ boolean getCheckResultType();
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java
new file mode 100644
index 00000000000..d711643e24e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
+ * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.osgi.framework.Bundle;
+
+/**
+ * This factory allows clients to create a {@link IDerivedTypedElementImplementation} for queries
+ * corresponding to this type of factory.
+ *
+ * @since 0.2
+ * @deprecated replaced by {@link IQueryImplementationFactory}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377059.
+ */
+@Deprecated
+public interface IDerivedTypedElementImplementationFactory {
+ // Copy of org.eclipse.emf.facet.infra.query.core.IModelQueryFactory
+
+ /**
+ * Create a derived typed element implementation, for getting and setting the value of the
+ * derived typed element.
+ *
+ * @param derivedTypedElement
+ * the derived typed element to create an implementation for
+ * @param queryBundle
+ * the bundle in which the query used to get or set this derived typed element is
+ * defined. May be <code>null</code> if the query is not defined in a {@link Bundle}.
+ */
+ public IDerivedTypedElementImplementation create(Query derivedTypedElement, Bundle queryBundle, IDerivedTypedElementManager derivedTEManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * Return the type of query handled by this implementation.
+ *
+ * @return the type of query this implementation handles.
+ */
+ public EClass getManagedQueryType();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryCollectionImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryCollectionImplementation.java
new file mode 100644
index 00000000000..7ab82c0896e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryCollectionImplementation.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.query;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
+
+/**
+ * This interface can be implemented by EMF Facet query implementations that want to handle multiple evaluation
+ * themselves, presumably to improve the performance of the evaluation.
+ * <p>
+ * If only {@link IQueryImplementation} is implemented, then the framework will perform multiple-evaluation by calling
+ * the single evaluation multiple times, which may be slow in the case of high-latency implementations.
+ *
+ * @since 0.2
+ */
+public interface IQueryCollectionImplementation extends IQueryImplementation {
+
+ /**
+ * This method must be implemented by each sub-class to evaluate a query on a collection of elements. The query
+ * should be evaluated on each of the elements in the given collection.
+ * <p>
+ * This method should throw a {@link DerivedTypedElementException} only if the eTypedElement is an incorrect
+ * {@link DerivedTypedElement}. But it must not throw an exception if the evaluation of one element fails. Instead,
+ * it must set the exception on the corresponding result ({@link ETypedElementResult#setException(Throwable)}).
+ *
+ * @param query
+ * The query to evaluate
+ * @param eTypedElement
+ * The feature or operation to get on the sources
+ * @param sources
+ * The model elements on which the feature or operation is evaluated using the query
+ * @param arguments
+ * The parameter values for the eTypedElement (in the case of a {@link FacetOperation}); can be
+ * <code>null</code>
+ * @return the result :
+ * <ul>
+ * <li> a list of {@link ETypedElementPrimitiveTypeResult} if the eTypedElement is single-valued and returns
+ * a primitive type <li> a list of {@link ETypedElementPrimitiveTypeListResult} if the eTypedElement is
+ * multi-valued and returns a primitive type <li> a list of {@link ETypedElementEObjectResult} if the
+ * eTypedElement is single-valued and returns a model element <li> a list of
+ * {@link ETypedElementEObjectListResult} if the eTypedElement is multi-valued and returns model elements
+ * </ul>
+ * @throws DerivedTypedElementException
+ * if the given derivedTypedElement is incorrect
+ */
+ List<? extends ETypedElementResult> getValues(Query query, ETypedElement eTypedElement, Collection<? extends EObject> sources,
+ List<ParameterValue> arguments)
+ throws DerivedTypedElementException;
+
+ /**
+ * This method must be implemented by each sub-class to set the values of a collection of elements. The query should
+ * be used to set the value of each of the elements in the given collection.
+ *
+ * @param query
+ * The query to evaluate
+ * @param feature
+ * The derived typed element to set
+ * @param sources
+ * The model elements on which the query is evaluated
+ * @param arguments
+ * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be
+ * <code>null</code>
+ * @param newValues
+ * the new values for the sources; the size of this list must match the size of the list of sources
+ * @throws DerivedTypedElementException
+ * if the given derivedTypedElement is incorrect
+ * @throws DerivedTypedElementEvaluationException
+ * if the query could not be evaluated correctly
+ * @throws IllegalArgumentException
+ * if the given list of values does not match the list of sources
+ */
+ void setValues(Query query, DerivedTypedElement feature, Collection<? extends EObject> sources, List<ParameterValue> arguments,
+ List<? extends Object> newValues)
+ throws DerivedTypedElementException;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluator.java
new file mode 100644
index 00000000000..0d85184b87f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluator.java
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ * 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.QueryResult;
+import org.eclipse.emf.facet.efacet.core.exception.QueryException;
+import org.eclipse.emf.facet.efacet.core.exception.QueryExecutionException;
+
+/**
+ * This interface is the EMF Facet QueryEvaluator for query evaluation
+ *
+ * @deprecated use {@link IQueryImplementation} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381227)
+ */
+@Deprecated
+public interface IQueryEvaluator {
+
+ /**
+ * This method must be implemented by each sub class to evaluate a query
+ *
+ * @param query
+ * The query to evaluate
+ * @param context
+ * The model element on which the query is evaluated
+ * @param parameterValues
+ * The query parameter values, can be <code>null</code>
+ * @return A list of {@link QueryResult}s (one per evaluation)
+ * @throws QueryExecutionException
+ */
+ public Object basicEvaluate(final Query query, EObject context,
+ final List<ParameterValue> parameterValues) throws QueryException;
+
+ /**
+ * Return whether to check the query result after its evaluation
+ *
+ * @return whether to check the query result after its evaluation
+ */
+ public abstract boolean getCheckResultType();
+
+ /**
+ * Called when starting the evaluation of a query on one or several context
+ * elements (when
+ * {@link AbstractQueryEvaluator#evaluate(ModelQueryContext, List)} is
+ * called).
+ * <p>
+ * A subclass will receive in order:<br>
+ *
+ * <pre>
+ * startEvaluate()
+ * basicEvaluate(context1, parameters)
+ * basicEvaluate(context2, parameters)
+ * ...
+ * basicEvaluate(contextn, parameters)
+ * endEvaluate()
+ * </pre>
+ *
+ * </p>
+ *
+ * When evaluating a query on several context elements, basicEvaluate is
+ * called repeatedly with each context element. For some implementations
+ * that make use of a system with which you must establish a connection (e.g.
+ * a database) for each call, this is costly.
+ *
+ * The methods startEvaluate and endEvaluate satisfy this requirement
+ *
+ * @see {@link AbstractQueryEvaluator#endEvaluate()}
+ */
+ public void startEvaluate();
+
+ /**
+ * Called when ending the evaluation of a query on one or several context
+ * elements.
+ * <p>
+ * A subclass will receive in order:<br>
+ *
+ * <pre>
+ * startEvaluate()
+ * basicEvaluate(context1, parameters)
+ * basicEvaluate(context2, parameters)
+ * ...
+ * basicEvaluate(contextn, parameters)
+ * endEvaluate()
+ * </pre>
+ *
+ * </p>
+ * When evaluating a query on several context elements, basicEvaluate is
+ * called repeatedly with each context element. For some implementations
+ * that make use of a system with which you must establish a connection
+ * (e.g. a database) for each call, this is costly.
+ *
+ * The methods startEvaluate and endEvaluate satisfy this requirement
+ *
+ * @see {@link AbstractQueryEvaluator#startEvaluate()}
+ */
+ public void endEvaluate();
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java
new file mode 100644
index 00000000000..d2e0a2f2948
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2011, 2012 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.exception.QueryException;
+import org.osgi.framework.Bundle;
+
+/**
+ * This factory allows the user to create a {@link IQueryEvaluator} conforming to the EMF Facet
+ * framework.
+ *
+ * @deprecated use {@link IQueryImplementationFactory} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381229)
+ */
+@Deprecated
+public interface IQueryEvaluatorFactory {
+ // Copy of org.eclipse.emf.facet.infra.query.core.IModelQueryFactory
+
+ /**
+ * Create a query evaluator.
+ */
+ public IQueryEvaluator create(Query query, Bundle bundle) throws QueryException;
+
+ /**
+ * Return the type of query this evaluator can evaluate.
+ *
+ * @return the type of query this evaluator can evaluate.
+ */
+ public EClass getManagedQueryType();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementation.java
new file mode 100644
index 00000000000..2fe5aaa45f9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementation.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.query;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+
+/**
+ * Interface implemented by all EMF Facet query evaluators.
+ * <p>
+ * A query evaluator may choose to implement {@link IQueryCollectionImplementation} instead if it wants to improve the
+ * performance of evaluation on collections of elements.
+ *
+ * @since 0.2
+ */
+public interface IQueryImplementation {
+
+ /**
+ * This method must be implemented by each sub class to evaluate a query
+ *
+ * @param query
+ * The query to evaluate
+ * @param feature
+ * The feature or operation to get on the source
+ * @param source
+ * The model element on which the query is evaluated
+ * @param parameterValues
+ * The derived typed element's query parameter values (in the case of a {@link FacetOperation}); can be
+ * <code>null</code>
+ * @return the result, which can be either a single object or a collection of values depending on the multiplicity
+ * of the given derived typed element
+ * @throws DerivedTypedElementException
+ * if the query could not be evaluated correctly to get the value
+ */
+ Object getValue(Query query, DerivedTypedElement feature, EObject source,
+ List<ParameterValue> parameterValues, IFacetManager facetManager)
+ throws DerivedTypedElementException;
+
+ /**
+ * This method must be implemented by each sub class that allows to set the value of a derivedTypedElement using a
+ * query
+ *
+ * @param query
+ * The query that sets the value
+ * @param feature
+ * The derived typed element to set
+ * @param source
+ * The model element on which the derived typed element must be set
+ * @param parameterValues
+ * The query parameter values (in the case of a {@link FacetOperation}); can be <code>null</code>
+ * @param newValue
+ * the value to set on the derived typed element
+ * @throws DerivedTypedElementException
+ * if the query could not be evaluated correctly to set the value
+ */
+ void setValue(Query query, DerivedTypedElement feature, EObject source,
+ List<ParameterValue> parameterValues, Object newValue)
+ throws DerivedTypedElementException;
+
+ /**
+ * Return whether to check the type of the query result after its evaluation
+ * <p>
+ * Normally, this is <code>true</code>, but the query evaluator can choose to skip the check, for example if the
+ * return type of the query can't be loaded.
+ *
+ * @return whether to check the type of the query result after its evaluation
+ */
+ boolean isCheckResultType();
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementationFactory.java
new file mode 100644
index 00000000000..76d2d569f67
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryImplementationFactory.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.core.query;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.facet.efacet.core.IDerivedTypedElementManager;
+import org.eclipse.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.osgi.framework.Bundle;
+
+/**
+ * This factory allows clients to create a {@link IQueryImplementation} for queries corresponding to this type of
+ * factory.
+ *
+ * @since 0.2
+ */
+public interface IQueryImplementationFactory {
+
+ /**
+ * Create a query implementation for the given query.
+ *
+ * @param query
+ * the query to create an implementation for
+ * @param queryBundle
+ * the bundle in which the query is defined. May be <code>null</code> if the query is not defined in a
+ * {@link Bundle}.
+ */
+ IQueryImplementation create(Query query, Bundle queryBundle, IDerivedTypedElementManager manager)
+ throws DerivedTypedElementException;
+
+ /**
+ * Return the type of query handled by this implementation.
+ *
+ * @return the type of query this implementation handles.
+ */
+ EClass getManagedQueryType();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryUtils.java
new file mode 100644
index 00000000000..6af2b1e4240
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/emf/facet/efacet/core/query/IQueryUtils.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * 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:
+ * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
+ * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
+ */
+package org.eclipse.emf.facet.efacet.core.query;
+
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
+import org.eclipse.emf.facet.efacet.core.internal.query.QueryUtilsImpl;
+
+/**
+ * Utility methods for manipulating queries.
+ *
+ * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there
+ * are no QuerySets anymore. Queries are used only in Facets. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381230)
+ */
+@Deprecated
+public interface IQueryUtils {
+
+ /** The singleton {@link IQueryUtils} */
+ IQueryUtils INSTANCE = new QueryUtilsImpl();
+
+ /**
+ * This method searches a query in all registered {@link QuerySetCatalog}s.
+ *
+ * @param querySetName
+ * the name of the querySet to search into.
+ * @param queryName
+ * the name of the query to search for.
+ * @return the query if found; <code>null</code> otherwise
+ * @deprecated there are no QuerySets anymore. Queries are now a second-level concept only
+ * defined in Facets. An equivalent is to search for an attribute or operation on a
+ * Facet : see {@link IFacetUtils}
+ */
+ @Deprecated
+ public Query searchQuery(String querySetName, String queryName);
+}

Back to the top