blob: 347a63911edd3dc0b1c7f99197e6fc040c3dd9de [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.pkm.refframework.refframework.diagram.edit.parts;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.tooling.runtime.edit.policies.reparent.CreationEditPolicyWithCustomReparent;
import org.eclipse.opencert.pkm.refframework.refframework.diagram.edit.commands.RefframeworkCreateShortcutDecorationsCommand;
import org.eclipse.opencert.pkm.refframework.refframework.diagram.edit.commands.RefreshMultiDiagramCommand;
import org.eclipse.opencert.pkm.refframework.refframework.diagram.edit.policies.RefFrameworkCanonicalEditPolicy;
import org.eclipse.opencert.pkm.refframework.refframework.diagram.edit.policies.RefFrameworkItemSemanticEditPolicy;
import org.eclipse.opencert.pkm.refframework.refframework.diagram.part.RefframeworkVisualIDRegistry;
/**
* @generated
*/
public class RefFrameworkEditPart extends DiagramEditPart {
// Start MCP
/**
* @generated NOT
*/
public final static String FILE_MODEL_ID = ".refframework";
/**
* @generated NOT
*/
public final static String FILE_DIAGRAM_ID = ".refframework_diagram";
// End MCP
/**
* @generated
*/
public final static String MODEL_ID = "Refframework"; //$NON-NLS-1$
/**
* @generated
*/
public static final int VISUAL_ID = 1000;
/**
* @generated
*/
public RefFrameworkEditPart(View view) {
super(view);
}
/**
* @generated NOT
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
new RefFrameworkItemSemanticEditPolicy());
// Start MCP
/*
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE,
new RefFrameworkCanonicalEditPolicy());
*/
//End MCP
installEditPolicy(EditPolicyRoles.CREATION_ROLE,
new CreationEditPolicyWithCustomReparent(
RefframeworkVisualIDRegistry.TYPED_INSTANCE));
// Start MCP
/*
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
new DiagramDragDropEditPolicy() {
public Command getDropObjectsCommand(
DropObjectsRequest dropRequest) {
ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>();
for (Iterator<?> it = dropRequest.getObjects()
.iterator(); it.hasNext();) {
Object nextObject = it.next();
if (false == nextObject instanceof EObject) {
continue;
}
viewDescriptors
.add(new CreateViewRequest.ViewDescriptor(
new EObjectAdapter(
(EObject) nextObject),
Node.class, null,
getDiagramPreferencesHint()));
}
return createShortcutsCommand(dropRequest,
viewDescriptors);
}
private Command createShortcutsCommand(
DropObjectsRequest dropRequest,
List<CreateViewRequest.ViewDescriptor> viewDescriptors) {
Command command = createViewsAndArrangeCommand(
dropRequest, viewDescriptors);
if (command != null) {
return command
.chain(new ICommandProxy(
new RefframeworkCreateShortcutDecorationsCommand(
getEditingDomain(),
(View) getModel(),
viewDescriptors)));
}
return null;
}
});
*/
/* MCP!!!
* several diagrams
*/
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
new DiagramDragDropEditPolicy() {
public Command getDropObjectsCommand(
DropObjectsRequest dropRequest) {
List<EObject> list = new ArrayList();
EObject rootObject=null;
for (Iterator<?> it = dropRequest.getObjects()
.iterator(); it.hasNext();) {
Object nextObject = it.next();
if (false == nextObject instanceof EObject) {
continue;
}
rootObject = (EObject)nextObject;
list.add(rootObject);
}
Command command = new ICommandProxy(
new RefreshMultiDiagramCommand(list,
getEditingDomain(),
(View) getModel(), getHost()));
return command;
}
});
//End MCP
// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
}
}