diff options
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram.model/src/org/eclipse/sirius/diagram/model/business/internal/description/tool/spec/DeleteElementDescriptionSpec.java')
-rw-r--r-- | plugins/org.eclipse.sirius.diagram.model/src/org/eclipse/sirius/diagram/model/business/internal/description/tool/spec/DeleteElementDescriptionSpec.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.model/src/org/eclipse/sirius/diagram/model/business/internal/description/tool/spec/DeleteElementDescriptionSpec.java b/plugins/org.eclipse.sirius.diagram.model/src/org/eclipse/sirius/diagram/model/business/internal/description/tool/spec/DeleteElementDescriptionSpec.java new file mode 100644 index 0000000000..08826243e5 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.model/src/org/eclipse/sirius/diagram/model/business/internal/description/tool/spec/DeleteElementDescriptionSpec.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2010 THALES GLOBAL SERVICES. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.model.business.internal.description.tool.spec; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; +import org.eclipse.sirius.diagram.description.DescriptionPackage; +import org.eclipse.sirius.diagram.description.DiagramElementMapping; +import org.eclipse.sirius.diagram.description.tool.impl.DeleteElementDescriptionImpl; + +/** + * Implementation of DeleteElementDescription. + * + * @author nlepine + * + */ +public class DeleteElementDescriptionSpec extends DeleteElementDescriptionImpl { + + /** + * {@inheritDoc} + * + * @see org.eclipse.sirius.viewpoint.description.tool.impl.DeleteElementDescriptionImpl#getMappings() + */ + @Override + public EList<DiagramElementMapping> getMappings() { + Resource r = this.eResource(); + if (r == null) { + throw new UnsupportedOperationException(); + } + ECrossReferenceAdapter crossReferencer = ECrossReferenceAdapter.getCrossReferenceAdapter(r); + if (crossReferencer == null) { + throw new UnsupportedOperationException(); + } + final List<DiagramElementMapping> diagramElementsMappings = new LinkedList<DiagramElementMapping>(); + final Collection<Setting> settings = crossReferencer.getInverseReferences(this, true); + for (final Setting setting : settings) { + final EObject eReferencer = setting.getEObject(); + final EStructuralFeature eFeature = setting.getEStructuralFeature(); + if (eReferencer instanceof DiagramElementMapping && eFeature.equals(DescriptionPackage.eINSTANCE.getDiagramElementMapping_DeletionDescription())) { + diagramElementsMappings.add((DiagramElementMapping) eReferencer); + } + } + return new BasicEList<DiagramElementMapping>(diagramElementsMappings); + } + +} |