Bug 534511 - [Layers] Add a facet file to display the layers below the diagram in the
model explorer
Change-Id: I23e2b24f53017d9c862944dea56ac5a761c6e79f
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Also-by: Patrick Tessier <patrick.tessier@cea.fr>
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/META-INF/MANIFEST.MF b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/META-INF/MANIFEST.MF
index ca0f678..db8a2e9 100755
--- a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/META-INF/MANIFEST.MF
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/META-INF/MANIFEST.MF
@@ -33,7 +33,9 @@
org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
org.eclipse.papyrus.infra.gmfdiag.layers.model.edit;bundle-version="0.7.0",
org.eclipse.papyrus.infra.gmfdiag.layers.notationmodel.edit,
- org.eclipse.papyrus.infra.gmfdiag.css.properties
+ org.eclipse.papyrus.infra.gmfdiag.css.properties,
+ org.eclipse.papyrus.infra.internationalization.utils,
+ org.eclipse.papyrus.infra.viewpoints.policy
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.7.0.qualifier
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/plugin.xml b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/plugin.xml
index 01d7981..8592389 100755
--- a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/plugin.xml
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/plugin.xml
@@ -306,4 +306,10 @@
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
</extension>
+ <extension
+ point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration">
+ <modeldeclaration
+ file="resources/PapyrusDiagramLayer.custom">
+ </modeldeclaration>
+ </extension>
</plugin>
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/resources/PapyrusDiagramLayer.custom b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/resources/PapyrusDiagramLayer.custom
new file mode 100755
index 0000000..bad7412
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/resources/PapyrusDiagramLayer.custom
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<custom:Customization xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:custom="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:efacet="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet" xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" xmlns:query="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet/query" name="PapyrusDiagramLayer" documentation="Display contained diagram and their icons" mustBeLoadedByDefault="true" rank="-1000">
+ <eClassifiers xsi:type="custom:EClassCustomization" name="Diagram" documentation="Representation of diagram in model explorer">
+ <extendedMetaclass href="http://www.eclipse.org/gmf/runtime/1.0.2/notation#//Diagram"/>
+ <facetElements xsi:type="efacet:FacetReference" name="layers" upperBound="-1" volatile="true" transient="true" derived="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/papyrus/infra/gmfdiag/layers#//AbstractLayer"/>
+ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries.GetAssociatedLayers"/>
+ </facetElements>
+ <facetOperations name="GetDiagramLabel" documentation="Return the label of the corresponding diagram">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <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.internal.infra.gmfdiag.layers.ui.queries.GetDiagramLabel"/>
+ <override xsi:type="efacet:FacetOperation" href="platform:/plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/label"/>
+ </facetOperations>
+ <facetOperations name="GetDiagramIcon" documentation="Return the path to the icon of the corresponding diagram">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types#//Image"/>
+ <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.internal.infra.gmfdiag.layers.ui.queries.GetDiagramIcon"/>
+ <override xsi:type="efacet:FacetOperation" href="platform:/plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/image"/>
+ </facetOperations>
+ <facetOperations name="GetParent">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <eParameters name="eStructuralFeature">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//ETypedElement"/>
+ </eParameters>
+ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries.GetDiagramContainer"/>
+ <override xsi:type="efacet:FacetOperation" href="platform:/plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/parent"/>
+ </facetOperations>
+ </eClassifiers>
+ <eClassifiers xsi:type="efacet:Facet" name="DiagramContainer" documentation="this element represent a container of diagram" conformanceTypedElement="//DiagramContainer/isDiagramContainer">
+ <extendedMetaclass href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <facetOperations name="isDiagramContainer" documentation="test if the element references diagrams">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
+ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries.IsDiagramContainer"/>
+ </facetOperations>
+ </eClassifiers>
+ <eClassifiers xsi:type="custom:FacetCustomization" name="DiagramContainer" documentation="Representation of a diagram container">
+ <facetElements xsi:type="efacet:FacetReference" name="diagrams" upperBound="-1" defaultValueLiteral="" derived="true">
+ <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="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.internal.infra.gmfdiag.layers.ui.queries.GetContainedDiagrams"/>
+ </facetOperations>
+ <extendedFacets href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom#//DiagramContainer"/>
+ <customizedFacet href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom#//DiagramContainer"/>
+ </eClassifiers>
+</custom:Customization>
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DiagramsRefCollapseQuery.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DiagramsRefCollapseQuery.java
new file mode 100755
index 0000000..29db909
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DiagramsRefCollapseQuery.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ /*****************************************************************************/
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+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;
+
+public class DiagramsRefCollapseQuery implements IJavaQuery2<EObject, Boolean> {
+ public Boolean evaluate(final EObject context,
+ final IParameterValueList2 parameterValues,
+ final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature");
+ EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue();
+ if ((eStructuralFeature instanceof FacetReference) && ("diagrams".equals((eStructuralFeature).getName()))) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DisplayDiagramRef.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DisplayDiagramRef.java
new file mode 100755
index 0000000..aef71f5
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/DisplayDiagramRef.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2011 Atos, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Atos - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ */
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+
+public class DisplayDiagramRef implements IJavaQuery2<EObject, Boolean> {
+
+ /**
+ * Return true if the element is a Diagram Container and the Ereference is diagrams
+ */
+
+ public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature");
+ EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue();
+ if ((eStructuralFeature instanceof FacetReference) && ("diagrams".equals((eStructuralFeature).getName()))) {
+
+ ResourceSet resourceSet = EMFHelper.getResourceSet(source);
+
+ if (resourceSet != null) {
+ for (Diagram diagram : NotationUtils.getAllNotations(resourceSet, Diagram.class)) {
+ if (EcoreUtil.equals(DiagramUtils.getOwner(diagram), source)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyListQuery.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyListQuery.java
new file mode 100755
index 0000000..d9a6ff5
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyListQuery.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+
+/**
+ * @author Camille Letavernier
+ *
+ */
+public class EmptyListQuery implements IJavaQuery2<EObject, List<Object>> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public List<Object> evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyReferenceAndAttributeNotVisibleQuery.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyReferenceAndAttributeNotVisibleQuery.java
new file mode 100755
index 0000000..d111bf9
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/EmptyReferenceAndAttributeNotVisibleQuery.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ /*****************************************************************************/
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+
+public class EmptyReferenceAndAttributeNotVisibleQuery implements IJavaQuery2<EObject, Boolean> {
+ public Boolean evaluate(final EObject context,
+ final IParameterValueList2 parameterValues,
+ final IFacetManager facetManager)
+ throws DerivedTypedElementException {
+ // ParameterValue parameterValue= (ParameterValue)parameterValues.getParameterValueByName("eStructuralFeature");
+ // EStructuralFeature eStructuralFeature=(EStructuralFeature)parameterValue.getValue();
+ // if(!(eStructuralFeature instanceof FacetReference)){
+ // if( eStructuralFeature instanceof EAttribute){
+ // return false;
+ // }
+ // System.err.println(context.eGet(eStructuralFeature));
+ // if( eStructuralFeature instanceof EReference){
+ // if( context.eGet(eStructuralFeature)==null){
+ // return false;
+ // }
+ //
+ // if( context.eGet(eStructuralFeature) instanceof Collection){
+ // if(((Collection)context.eGet(eStructuralFeature)).size()==0){
+ // return false;
+ // }
+ // }
+ // }
+ // }
+ // return true;
+ return false;
+ }
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetAssociatedLayers.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetAssociatedLayers.java
new file mode 100755
index 0000000..adf40a6
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetAssociatedLayers.java
@@ -0,0 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.diagram.ui.DiagramUtil;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.AbstractLayer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Layer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayerExpression;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersStack;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.TopLayerOperator;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.runtime.model.LayersModelResource;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class GetAssociatedLayers implements IJavaQuery2<Diagram, Collection<AbstractLayer>> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public Collection<AbstractLayer> evaluate(Diagram source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ List<AbstractLayer> result = new ArrayList<AbstractLayer>();
+
+ try {
+ ModelSet modelSet = org.eclipse.papyrus.infra.ui.util.ServiceUtilsForHandlers.getInstance().getModelSet(null);
+ // DiagramEditPart diagEP = DiagramUtil.getOpenedDiagramEditor(source, PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getDiagramEditPart();
+ // diagEP.getDiagramView().getDiagram().eResource().getResourceSet()
+ // if (diagEP instanceof IMultiDiagramEditor) {
+ // ServicesRegistry registry = ((IMultiDiagramEditor) diagEP).getServicesRegistry();
+ // modelSet = registry.getService(ModelSet.class);
+ // }
+ ServicesRegistry registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(source);
+ IMultiDiagramEditor editor = registry.getService(IMultiDiagramEditor.class);
+ if (null != editor) {
+ modelSet = registry.getService(ModelSet.class);
+ }
+
+ LayersModelResource model = (LayersModelResource) modelSet.getModelChecked(LayersModelResource.MODEL_ID);
+
+ if (null == model) {
+ return result;
+ }
+ LayersStack layerStack = model.getLayerStackApplication().getLayersStackFor(source);
+
+ if (!(layerStack.getLayers() instanceof TopLayerOperator)) {
+ return result;
+ }
+ TopLayerOperator topLayerOperator = (TopLayerOperator) (layerStack.getLayers());
+
+ for (LayerExpression layerExpression : topLayerOperator.getLayers()) {
+ if (layerExpression instanceof AbstractLayer) {
+ result.add((AbstractLayer) layerExpression);
+ }
+ }
+
+ return result;
+
+ } catch (ServiceException e) {
+ org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.Activator.log.error("Unable to find the current ModelSet", e);
+ } catch (NotFoundException e) {
+ org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.Activator.log.error("Unable to retrieve the LayerResource associated to the modelSet", e);
+ }
+
+
+ return result;
+ }
+
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetContainedDiagrams.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetContainedDiagrams.java
new file mode 100755
index 0000000..dae204b
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetContainedDiagrams.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2011 Atos, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Atos - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ */
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+
+/** Get the collection of all contained diagrams */
+public class GetContainedDiagrams implements IJavaQuery2<EObject, Collection<org.eclipse.gmf.runtime.notation.Diagram>> {
+
+
+ public Collection<Diagram> evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ List<Diagram> result = new ArrayList<Diagram>();
+
+ Collection<Setting> settings = EMFHelper.getUsages(source);
+ if (settings != null) {
+ for (Setting setting : settings) {
+ Diagram diagram = NotationUtils.getOwnedDiagram(setting.getEObject(), source);
+ if (diagram != null) {
+ result.add(diagram);
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramContainer.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramContainer.java
new file mode 100755
index 0000000..2927f11
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramContainer.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+
+/**
+ * Query to retrieve the graphical container of a Diagram. If no such container
+ * exists, the semantic element of the Diagram is returned.
+ *
+ * @see {@link DiagramUtils#getOwner(Diagram)}
+ */
+public class GetDiagramContainer implements IJavaQuery2<Diagram, EObject> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public EObject evaluate(Diagram source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ return DiagramUtils.getOwner(source);
+ }
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramIcon.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramIcon.java
new file mode 100755
index 0000000..647dce2
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramIcon.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2011, 2016 Atos, CEA LIST, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Atos - Initial API and implementation
+ * Patrick Tessier (CEA LIST) - Modification
+ * Christian W. Damus - bug 485220
+ *
+ */
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
+import org.eclipse.papyrus.emf.facet.custom.ui.ImageUtils;
+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.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.infra.ui.editorsfactory.AbstractGetEditorIconQuery;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
+
+/** Return the path to the icon of the corresponding diagram */
+public class GetDiagramIcon extends AbstractGetEditorIconQuery implements IJavaQuery2<Diagram, IImage> {
+
+
+ public IImage evaluate(Diagram source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+
+ ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature");
+ EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue();
+ if ((eStructuralFeature !=null) ) {
+ return null;
+ }
+ ViewPrototype prototype = DiagramUtils.getPrototype(source);
+ return ImageUtils.wrap(prototype.getIconURI());
+ }
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramLabel.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramLabel.java
new file mode 100755
index 0000000..c352134
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetDiagramLabel.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2016 CEA LIST, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 516471
+ */
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationEditPlugin;
+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.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.ui.editorsfactory.AbstractGetEditorIconQuery;
+
+/**
+ * Return the label of the corresponding diagram.
+ */
+public class GetDiagramLabel extends AbstractGetEditorIconQuery implements IJavaQuery2<Diagram, String> {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ */
+ public String evaluate(final Diagram source, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException {
+ final String label = LabelInternationalization.getInstance().getDiagramLabel(source);
+ ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature");
+ EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue();
+ if ((eStructuralFeature !=null) ) {
+ return (eStructuralFeature).getName();
+ }
+
+ /*
+ bug 516471 : we must not display the EClass name
+ return label == null || label.length() == 0 ? NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) : //$NON-NLS-1$
+ NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ */
+ return label == null || label.length() == 0 ? NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) : label;//$NON-NLS-1$
+ }
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerContainer.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerContainer.java
new file mode 100755
index 0000000..5c1d459
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerContainer.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.AbstractLayer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Layer;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class GetLayerContainer implements IJavaQuery2<AbstractLayer, Diagram> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public Diagram evaluate(AbstractLayer source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ if (source instanceof AbstractLayer) {
+ return source.getOwningLayersStack().getDiagram();
+ }
+ return null;
+ }
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerIcon.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerIcon.java
new file mode 100755
index 0000000..1d5338e
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerIcon.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.infra.ui.editorsfactory.AbstractGetEditorIconQuery;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.AbstractLayer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Layer;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class GetLayerIcon extends AbstractGetEditorIconQuery implements IJavaQuery2<AbstractLayer, IImage> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public IImage evaluate(AbstractLayer source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+
+ return null;
+ }
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerLabel.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerLabel.java
new file mode 100755
index 0000000..97781f4
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/GetLayerLabel.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import org.eclipse.emf.ecore.EObject;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.AbstractLayer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Layer;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class GetLayerLabel implements IJavaQuery2<AbstractLayer, String> {
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
+ *
+ * @param source
+ * @param parameterValues
+ * @param facetManager
+ * @return
+ * @throws DerivedTypedElementException
+ */
+ @Override
+ public String evaluate(AbstractLayer source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+
+ final String label = "";
+ if (source instanceof AbstractLayer) {
+ source.getName();
+ }
+
+ return null == label || label.length() == 0 ? "Layer_" : label; //$NON-NLS-1$
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/IsDiagramContainer.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/IsDiagramContainer.java
new file mode 100755
index 0000000..057e9b6
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/queries/IsDiagramContainer.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2011 Atos, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Atos - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ */
+package org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.queries;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+
+public class IsDiagramContainer implements IJavaQuery2<EObject, Boolean> {
+
+ /**
+ * Return true if the element is a Diagram Container
+ */
+ public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
+ Collection<Setting> settings = EMFHelper.getUsages(source);
+ if (settings != null) {
+ for (Setting setting : settings) {
+ Diagram diagram = NotationUtils.getOwnedDiagram(setting.getEObject(), source);
+ if (diagram != null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}