blob: 057e9b6574295e93c0940f4e569f6b0ab0d5baf5 [file] [log] [blame]
/**
* 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;
}
}