Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-04-17 12:04:25 +0000
committerCamille Letavernier2014-04-17 12:31:00 +0000
commit40660af168166b3ea1efd5eece16ca86df2562bb (patch)
treea1fa8a59ad386a991f9575b79f6e49f62da8523b /plugins/facet/org.eclipse.papyrus.emf.facet.custom.core
parent4218a7bb1409d6c5353bb1ac5db7ccd8aaa282e7 (diff)
downloadorg.eclipse.papyrus-40660af168166b3ea1efd5eece16ca86df2562bb.tar.gz
org.eclipse.papyrus-40660af168166b3ea1efd5eece16ca86df2562bb.tar.xz
org.eclipse.papyrus-40660af168166b3ea1efd5eece16ca86df2562bb.zip
432850: [ModelExplorer / Tree Providers] Improve the EMF Facet 2
integration https://bugs.eclipse.org/bugs/show_bug.cgi?id=432850 - Fix the Properties View Editor customization (ui.uiCustom -> PropertiesUI.custom)
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.custom.core')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java69
1 files changed, 46 insertions, 23 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java
index 9c348111bd6..39e9764d1a9 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java
@@ -14,59 +14,82 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
public class SwitchQueryImplementation implements IQueryImplementation {
private static final String PARAM_NAME = "eStructuralFeature"; //$NON-NLS-1$
+
private final ETypedElementSwitchQuery query;
+
private boolean checkResultType = false;
/**
* @param query
* @param query
- * the javaQuery to be evaluated
+ * the javaQuery to be evaluated
*/
public SwitchQueryImplementation(final ETypedElementSwitchQuery query) {
this.query = query;
}
- public Object getValue(final Query query2,
- final DerivedTypedElement feature, final EObject source,
- final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- Object result = null;
+ public Object getValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException {
+
EStructuralFeature sfParam = null;
- for (final ParameterValue parameterValue : parameterValues) {
- if (parameterValue.getParameter().getName().equals(PARAM_NAME)) {
- sfParam = (EStructuralFeature) parameterValue.getValue();
+ Query subQuery = null;
+ for(final ParameterValue parameterValue : parameterValues) {
+ if(parameterValue.getParameter().getName().equals(PARAM_NAME)) {
+ sfParam = (EStructuralFeature)parameterValue.getValue();
}
}
- for (ETypedElementCase eTECase : this.query.getCases()) {
- if (eTECase.getCase() == sfParam) {
- final Query subquery = eTECase.getValue();
- if (subquery != null) {
- result = IDerivedTypedElementManager.INSTANCE.evaluate(
- subquery, source, parameterValues, facetManager);
+ for(ETypedElementCase eTECase : this.query.getCases()) {
+ if(eTECase.getCase() == sfParam) {
+ subQuery = eTECase.getValue();
+ if(subQuery != null) {
+ break;
}
- break;
}
}
- return result;
+
+ if(subQuery == null) {
+ //The case is not supported: call super operation if possible (Avoid NPEs for unsupported cases)
+ if(feature instanceof FacetOperation) {
+ FacetOperation operation = (FacetOperation)feature;
+ DerivedTypedElement superOperation = operation.getOverride();
+ if(superOperation == null) {
+ return null;
+ }
+ if(superOperation instanceof FacetOperation) {
+ FacetOperation superFacetOperation = (FacetOperation)superOperation;
+
+ //We call the super-operation's query
+ subQuery = superFacetOperation.getQuery();
+ } else {
+ //What does this mean?
+ throw new UnsupportedOperationException("Overridden typed element is not a FacetOperation");
+ }
+ }
+
+ if(subQuery == null) {
+ return null;
+ }
+
+ }
+
+ //Evaluate the nestedQuery
+ return IDerivedTypedElementManager.INSTANCE.evaluate(subQuery, source, parameterValues, facetManager);
}
- public void setValue(final Query query2, final DerivedTypedElement feature,
- final EObject source, final List<ParameterValue> parameterValues,
- final Object newValue) throws DerivedTypedElementException {
+ public void setValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) throws DerivedTypedElementException {
throw new UnsupportedOperationException("Not implemented yet"); //$NON-NLS-1$
}

Back to the top