Search in sources :

Example 1 with EcoreUtil

use of org.eclipse.emf.ecore.util.EcoreUtil in project Palladio-Editors-Sirius by PalladioSimulator.

the class RemoveDiagramAction method execute.

@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    EObject element = (EObject) parameters.get("element");
    String viewpointName = (String) parameters.get("Viewpoint");
    Session session = SessionManager.INSTANCE.getSession(element);
    Set<DRepresentationDescriptor> toDelete = session.getOwnedViews().stream().filter(v -> viewpointName.equals(v.getViewpoint().getName())).map(DView::getOwnedRepresentationDescriptors).flatMap(Collection::stream).filter(d -> d.getTarget() == element).collect(Collectors.toSet());
    toDelete.forEach(EcoreUtil::delete);
}
Also used : SessionManager(org.eclipse.sirius.business.api.session.SessionManager) Session(org.eclipse.sirius.business.api.session.Session) DRepresentationDescriptor(org.eclipse.sirius.viewpoint.DRepresentationDescriptor) Collection(java.util.Collection) Map(java.util.Map) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Set(java.util.Set) DView(org.eclipse.sirius.viewpoint.DView) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) IExternalJavaAction(org.eclipse.sirius.tools.api.ui.IExternalJavaAction) EObject(org.eclipse.emf.ecore.EObject) Collection(java.util.Collection) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) DRepresentationDescriptor(org.eclipse.sirius.viewpoint.DRepresentationDescriptor) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

Collection (java.util.Collection)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 Session (org.eclipse.sirius.business.api.session.Session)1 SessionManager (org.eclipse.sirius.business.api.session.SessionManager)1 IExternalJavaAction (org.eclipse.sirius.tools.api.ui.IExternalJavaAction)1 DRepresentationDescriptor (org.eclipse.sirius.viewpoint.DRepresentationDescriptor)1 DView (org.eclipse.sirius.viewpoint.DView)1