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
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
-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
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java29
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/queries/IsTableContainer.java34
6 files changed, 111 insertions, 45 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;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom
index 776714a0ea2..bc4c1539533 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom
@@ -31,26 +31,26 @@
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/gmf/runtime/1.0.2/notation#//Diagram"/>
<query xsi:type="query:OperationCallQuery" operation="//DiagramContainer.1/DiagramsRefContent"/>
</facetElements>
- <facetOperations name="DiagramsRefVisibility" documentation="Return true if the element contains diagrams">
+ <!-- facetOperations name="DiagramsRefVisibility" documentation="Return true if the element contains diagrams">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eParameters name="eStructuralFeature">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/>
</eParameters>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries.IsDiagramContainer"/>
<override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/>
- </facetOperations>
+ </facetOperations-->
<facetOperations name="DiagramsRefContent" upperBound="-1" documentation="Get the collection of all contained diagrams">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/gmf/runtime/1.0.2/notation#//Diagram"/>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries.GetContainedDiagrams"/>
</facetOperations>
- <facetOperations name="DiagramsRefCollapse">
+ <!-- facetOperations name="DiagramsRefCollapse">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eParameters name="eStructuralFeature">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/>
</eParameters>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries.DiagramsRefCollapseQuery"/>
<override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/collapseLink"/>
- </facetOperations>
+ </facetOperations -->
<extendedFacets href="../../../plugin/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom#//DiagramContainer"/>
<customizedFacet href="../../../plugin/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom#//DiagramContainer"/>
</eClassifiers>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java
index 026a7992aca..8eab806acd3 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java
@@ -1,53 +1,50 @@
/**
* Copyright (c) 2011 Atos.
- *
+ *
* 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:
* Atos - Initial API and implementation
- *
+ *
*/
package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries;
import java.util.Iterator;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
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;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery;
public class IsDiagramContainer extends AbstractEditorContainerQuery implements IJavaQuery2<EObject, Boolean> {
/**
- * Return true if the element is a Diagram Container
+ * Return true if the element is a Diagram Container
*/
-
public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
- Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source);
- if(roots == null) {
- return false;
- }
+ Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source);
+ if(roots != null) {
while(roots.hasNext()) {
EObject root = roots.next();
if(root instanceof Diagram) {
- if (EcoreUtil.equals(DiagramUtils.getOwner((Diagram) root), source)) {
+ if(EcoreUtil.equals(DiagramUtils.getOwner((Diagram)root), source)) {
return true;
}
}
}
- return false;
+ }
+
+ return false; //Return super...
}
-} \ No newline at end of file
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom
index ce3b78ed3e2..d04b67ceace 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom
@@ -31,26 +31,26 @@
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/papyrus/nattable/model#//Table"/>
<query xsi:type="query:OperationCallQuery" operation="//TableContainer.1/TablesRefContent"/>
</facetElements>
- <facetOperations name="TablesRefVisibility" documentation="Return true if the element contains tables">
+ <!-- facetOperations name="TablesRefVisibility" documentation="Return true if the element contains tables">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eParameters name="eStructuralFeature">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/>
</eParameters>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.nattable.modelexplorer.queries.DisplayTablesRef"/>
<override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/>
- </facetOperations>
+ </facetOperations-->
<facetOperations name="TablesRefContent" upperBound="-1" documentation="Get the collection of all contained tables">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/papyrus/nattable/model#//Table"/>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.nattable.modelexplorer.queries.GetContainedTables"/>
</facetOperations>
- <facetOperations name="TablesRefCollapse">
+ <!-- facetOperations name="TablesRefCollapse">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eParameters name="eStructuralFeature">
<eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/>
</eParameters>
<query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.infra.nattable.modelexplorer.queries.TablesRefCollapseQuery"/>
<override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/collapseLink"/>
- </facetOperations>
+ </facetOperations-->
<customizedFacet href="../../../plugin/org.eclipse.papyrus.infra.nattable.modelexplorer/resources/PapyrusTable.custom#//TableContainer"/>
</eClassifiers>
</custom:Customization>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/queries/IsTableContainer.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/queries/IsTableContainer.java
index f9a39dbedf9..21de42275e1 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/queries/IsTableContainer.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/queries/IsTableContainer.java
@@ -1,26 +1,23 @@
/**
* Copyright (c) 2011 Atos.
- *
+ *
* 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:
* Atos - Initial API and implementation
- *
+ *
*/
package org.eclipse.papyrus.infra.nattable.modelexplorer.queries;
import java.util.Iterator;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
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;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
@@ -32,22 +29,21 @@ public class IsTableContainer extends AbstractEditorContainerQuery implements IJ
/**
* Return true if the element is a Table Container
*/
-
+ @Override
public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source);
+ if(roots == null) {
+ return false;
+ }
- Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source);
- if (roots == null) {
- return false;
- }
-
- while (roots.hasNext()) {
- EObject root = roots.next();
- if (root instanceof Table) {
- if (EcoreUtil.equals(((Table) root).getOwner(), source)) {
- return true;
- }
+ while(roots.hasNext()) {
+ EObject root = roots.next();
+ if(root instanceof Table) {
+ if(EcoreUtil.equals(((Table)root).getOwner(), source)) {
+ return true;
}
}
+ }
return false;
}
-} \ No newline at end of file
+}

Back to the top