Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-04-16 11:39:33 +0000
committerCamille Letavernier2014-04-16 11:39:33 +0000
commit8baf23d96716c05dbeb2a3868f6c3817ea1e352d (patch)
tree28d51817f5c92725b89e273e585e8913bcff7a41 /plugins/facet
parent75e746dea7e8a1588bbf197078732db42aec0b43 (diff)
downloadorg.eclipse.papyrus-8baf23d96716c05dbeb2a3868f6c3817ea1e352d.tar.gz
org.eclipse.papyrus-8baf23d96716c05dbeb2a3868f6c3817ea1e352d.tar.xz
org.eclipse.papyrus-8baf23d96716c05dbeb2a3868f6c3817ea1e352d.zip
432850: [ModelExplorer / Tree Providers] Improve the EMF Facet 2
integration https://bugs.eclipse.org/bugs/show_bug.cgi?id=432850 - Change the default query for visibility/collapse link - Simplify the Papyrus customizations
Diffstat (limited to 'plugins/facet')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet5
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java72
2 files changed, 75 insertions, 2 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet
index bdce9d8345a..0399612b056 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet
@@ -274,7 +274,8 @@
href="http://www.eclipse.org/emf/2002/Ecore#//ETypedElement"/>
</eParameters>
<query
- xsi:type="query:TrueLiteralQuery"/>
+ xsi:type="javaQuery:JavaQuery"
+ implementationClassName="org.eclipse.papyrus.emf.facet.custom.ui.internal.query.DefaultVisibilityQuery"/>
</facetOperations>
<facetOperations
name="selection"
@@ -304,7 +305,7 @@
href="http://www.eclipse.org/emf/2002/Ecore#//ETypedElement"/>
</eParameters>
<query
- xsi:type="query:TrueLiteralQuery"/>
+ xsi:type="query:FalseLiteralQuery"/>
</facetOperations>
</eClassifiers>
<eClassifiers
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java
new file mode 100644
index 00000000000..5df7496103b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
+
+import java.util.Collection;
+
+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.papyrus.emf.facet.efacet.core.IFacetManager;
+import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+
+/**
+ * Determines the default value for visibility
+ *
+ * False for EAttributes and empty references, true otherwise
+ *
+ * Default implementation in EMF Facet is always true (TrueLiteralQuery)
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class DefaultVisibilityQuery implements IJavaQuery2<EObject, Boolean> {
+
+ public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ ParameterValue paramValue = parameterValues.getParameterValueByName("eStructuralFeature");
+ if(paramValue == null) {
+ return true;
+ }
+
+ EStructuralFeature feature = (EStructuralFeature)paramValue.getValue();
+
+ if(feature == null) {
+ return true;
+ }
+
+ if(feature instanceof EAttribute) {
+ return false;
+ }
+
+ if(feature instanceof FacetReference) {
+ return true;
+ }
+
+ if(feature instanceof EReference) {
+ Object value = source.eGet(feature);
+ if(value == null) {
+ return false;
+ }
+ if(value instanceof Collection<?>) {
+ return !((Collection<?>)value).isEmpty();
+ }
+ }
+
+ return true;
+ }
+
+}

Back to the top