blob: a6e6d7933f0e01b25eee2ffe2421bcf57df558c8 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 Fundación Tecnalia Research & Innovation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Huascar Espinoza - initial API and implementation
* Alejandra Ruíz - initial API and implementation
* Idoya Del Río - initial API and implementation
* Mari Carmen Palacios - initial API and implementation
* Angel López - initial API and implementation
*******************************************************************************/
package org.eclipse.opencert.sam.arg.arg.diagram.edit.policies;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
import org.eclipse.gmf.runtime.notation.View;
import java.util.ArrayList;
import java.util.List;
public class DawnCaseCanonicalEditPolicy extends CaseCanonicalEditPolicy {
public DawnCaseCanonicalEditPolicy() {
super();
}
@Override
protected CreateViewRequest getCreateViewRequest(
List<ViewDescriptor> descriptors) {
List<View> viewChildren = getViewChildren();
List<ViewDescriptor> tbr = new ArrayList<CreateViewRequest.ViewDescriptor>();
for (ViewDescriptor desc : descriptors) {
EObject obj = (EObject) ((CanonicalElementAdapter) desc
.getElementAdapter()).getRealObject();
boolean found = false;
for (View view : viewChildren) {
if (view.getElement().equals(obj)) {
found = true;
break;
}
}
if (!found) {
tbr.add(desc);
}
}
descriptors.removeAll(tbr);
return new CreateViewRequest(descriptors);
}
}