|
|
@@ -14,13 +14,12 @@ import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import org.eclipse.emf.ecore.EObject;
|
|
|
import org.eclipse.emf.transaction.TransactionalEditingDomain;
|
|
|
import org.eclipse.emf.transaction.util.TransactionUtil;
|
|
|
-import org.eclipse.gef.EditPart;
|
|
|
import org.eclipse.gmf.runtime.common.core.command.ICommand;
|
|
|
import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
|
|
|
import org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext;
|
|
|
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
|
|
|
import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler;
|
|
|
import org.eclipse.jface.viewers.ISelection;
|
|
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
|
@@ -53,10 +52,10 @@ public class SemanticCopyPasteGlobalActionHandler extends
|
|
|
}
|
|
|
|
|
|
protected ICommand getCopyCommand(IGlobalActionContext cntxt) {
|
|
|
- List<EObject> objects = getSelectedElements(cntxt.getSelection());
|
|
|
+ List<IGraphicalEditPart> objects = getSelectedElements(cntxt.getSelection());
|
|
|
if (objects.size() > 0) {
|
|
|
TransactionalEditingDomain domain = TransactionUtil
|
|
|
- .getEditingDomain(objects.get(0));
|
|
|
+ .getEditingDomain(objects.get(0).getNotationView());
|
|
|
SemanticCopyCommand copyCmd = new SemanticCopyCommand(domain,
|
|
|
objects);
|
|
|
return copyCmd;
|
|
|
@@ -65,24 +64,22 @@ public class SemanticCopyPasteGlobalActionHandler extends
|
|
|
}
|
|
|
|
|
|
private ICommand getPasteCommand(IGlobalActionContext cntxt) {
|
|
|
- List<EObject> objects = getSelectedElements(cntxt.getSelection());
|
|
|
+ List<IGraphicalEditPart> objects = getSelectedElements(cntxt.getSelection());
|
|
|
if (objects.size() > 0) {
|
|
|
return new SemanticPasteCommand(objects);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- protected List<EObject> getSelectedElements(ISelection selection) {
|
|
|
- List<EObject> results = new ArrayList<EObject>();
|
|
|
+ protected List<IGraphicalEditPart> getSelectedElements(ISelection selection) {
|
|
|
+ List<IGraphicalEditPart> results = new ArrayList<IGraphicalEditPart>();
|
|
|
if (selection == null || selection.isEmpty())
|
|
|
return results;
|
|
|
Iterator<?> iterator = ((IStructuredSelection) selection).iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
Object selectedElement = iterator.next();
|
|
|
- if (selectedElement instanceof EditPart) {
|
|
|
- EObject element = (EObject) ((EditPart) selectedElement)
|
|
|
- .getAdapter(EObject.class);
|
|
|
- results.add(element);
|
|
|
+ if (selectedElement instanceof IGraphicalEditPart) {
|
|
|
+ results.add((IGraphicalEditPart)selectedElement);
|
|
|
}
|
|
|
}
|
|
|
return results;
|