Procházet zdrojové kódy

Added copy & paste

Andreas Mülder před 14 roky
rodič
revize
6a9d31cbad
13 změnil soubory, kde provedl 817 přidání a 558 odebrání
  1. 10 0
      plugins/org.yakindu.sct.ui.editor/plugin.xml
  2. 0 45
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/SCTClipboardUtil.java
  3. 0 35
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/StatechartClipboardSupport.java
  4. 0 34
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/StatechartClipboardSupportFactory.java
  5. 35 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ClipboardSupportFactory.java
  6. 135 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ConnectorViewPasteOperation.java
  7. 213 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ConnectorViewPostPasteChildOperation.java
  8. 311 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/NotationClipboardOperationHelper.java
  9. 113 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/PositionalGeneralViewPasteOperation.java
  10. 0 111
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SemanticCopyCommand.java
  11. 0 126
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SemanticPasteCommand.java
  12. 0 119
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/SemanticCopyGlobalActionHandlerProvider.java
  13. 0 88
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/SemanticCopyPasteGlobalActionHandler.java

+ 10 - 0
plugins/org.yakindu.sct.ui.editor/plugin.xml

@@ -591,4 +591,14 @@
       </objectContribution>           
 </extension>
 
+<!-- Patched Clipboard support -->
+ <extension
+         point="org.eclipse.gmf.runtime.emf.clipboard.core.clipboardSupport">
+      <factory
+            class="org.yakindu.sct.ui.editor.clipboardsupport.ClipboardSupportFactory"
+            nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation"
+            priority="medium">
+      </factory>
+   </extension>
+
 </plugin>

+ 0 - 45
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/SCTClipboardUtil.java

@@ -1,45 +0,0 @@
-package org.yakindu.sct.ui.editor.clipboard;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-public final class SCTClipboardUtil {
-	
-	private static final int KILOBYTE = 1024;
-	private static final int BUFFER_SIZE = 128 * KILOBYTE;
-	
-	private SCTClipboardUtil(){
-		//This class shouldn't be instantiated.
-	}
-	
-	public static byte[] getByteArrayFromObject(Object object) {
-		
-		ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
-		try {
-			ObjectOutputStream o = new ObjectOutputStream( out );
-			o.writeObject(object);
-			return out.toByteArray();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return new byte[0];
-	}
-	
-	public static Object getObjectFromByteArray(byte[] array) {
-		
-		ByteArrayInputStream out = new ByteArrayInputStream(array);
-		
-		try {
-			ObjectInputStream o = new ObjectInputStream(out);
-			return o.readObject();
-		} catch (IOException e) {
-			e.printStackTrace();
-		} catch (ClassNotFoundException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-}

+ 0 - 35
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/StatechartClipboardSupport.java

@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.clipboard;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.gmf.runtime.emf.clipboard.core.AbstractClipboardSupport;
-import org.eclipse.gmf.runtime.emf.clipboard.core.PasteAction;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class StatechartClipboardSupport extends AbstractClipboardSupport {
-
-	protected EAttribute getNameAttribute(EClass eClass) {
-		return SGraphPackage.Literals.NAMED_ELEMENT__NAME;
-	}
-
-	@Override
-	public PasteAction getPasteCollisionAction(EClass eClass) {
-		return PasteAction.CLONE;
-	}
-
-}

+ 0 - 34
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboard/StatechartClipboardSupportFactory.java

@@ -1,34 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.clipboard;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.gmf.runtime.emf.clipboard.core.IClipboardSupport;
-import org.eclipse.gmf.runtime.emf.clipboard.core.IClipboardSupportFactory;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class StatechartClipboardSupportFactory implements
-		IClipboardSupportFactory {
-
-	private final IClipboardSupport support = new StatechartClipboardSupport();
-
-	public StatechartClipboardSupportFactory() {
-		super();
-	}
-
-	public IClipboardSupport newClipboardSupport(EPackage ePackage) {
-		return support;
-	}
-}

+ 35 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ClipboardSupportFactory.java

@@ -0,0 +1,35 @@
+package org.yakindu.sct.ui.editor.clipboardsupport;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.gmf.runtime.emf.clipboard.core.IClipboardSupport;
+import org.eclipse.gmf.runtime.emf.clipboard.core.IClipboardSupportFactory;
+
+
+/**
+ * Implementation of the extension point for creating clipboard support
+ * utilities.
+ *
+ * @author Christian W. Damus (cdamus)
+ */
+public class ClipboardSupportFactory
+	implements IClipboardSupportFactory {
+
+	private final IClipboardSupport clipHelper =
+		new NotationClipboardOperationHelper();
+
+	/**
+	 * Initializes me.
+	 */
+	public ClipboardSupportFactory() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * Implements the interface method.
+	 */
+	public IClipboardSupport newClipboardSupport(EPackage ePackage) {
+		return clipHelper;
+	}
+
+}

+ 135 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ConnectorViewPasteOperation.java

@@ -0,0 +1,135 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation 
+ ****************************************************************************/
+
+package org.yakindu.sct.ui.editor.clipboardsupport;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardSupportUtil;
+import org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo;
+import org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @author Yasser Lulu 
+ */
+@SuppressWarnings("all")
+public class ConnectorViewPasteOperation
+	extends OverridePasteChildOperation {
+
+	private boolean pasteSemanticElement;
+
+	private Edge connectorView;
+
+	private View sourceView;
+
+	private View targetView;
+
+	/**
+	 * @param overriddenChildPasteOperation
+	 */
+	public ConnectorViewPasteOperation(
+		PasteChildOperation overriddenChildPasteOperation) {
+		super(overriddenChildPasteOperation);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation#paste()
+	 */
+	public void paste() throws Exception {
+		//basically delay...
+		connectorView = (Edge) getEObject();
+		sourceView = connectorView.getSource();
+		targetView = connectorView.getTarget();
+		EObject element = connectorView.getElement();
+		if (element != null) {
+			if (element.eIsProxy()) {
+				element = ClipboardSupportUtil.resolve(element,
+					getParentPasteProcess().getLoadedIDToEObjectMapCopy());
+			}
+			if (element.eIsProxy() == false) {
+				pasteSemanticElement = true;
+			}
+		}
+	}
+
+	protected boolean shouldPasteAlwaysCopyObject(
+		ObjectInfo alwaysCopyObjectInfo) {
+		return false;
+	}
+
+	protected PasteChildOperation makeAuxiliaryChildPasteProcess(
+		ObjectInfo auxiliaryChildEObjectInfo) {
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation#getPostPasteOperation()
+	 */
+	public PasteChildOperation getPostPasteOperation() {
+		return new PostPasteChildOperation(this, EMPTY_ARRAY) {
+
+			public void paste() throws Exception {
+				//delay
+			}
+
+			public PasteChildOperation getPostPasteOperation() {
+				return new PostPasteChildOperation(this, EMPTY_ARRAY) {
+
+					public void paste() throws Exception {
+						//delay
+					}
+
+					public PasteChildOperation getPostPasteOperation() {
+						return new ConnectorViewPostPasteChildOperation(
+							ConnectorViewPasteOperation.this,
+							ConnectorViewPasteOperation.this.pasteSemanticElement);
+					}
+				};
+			}
+		};
+	}
+
+	protected ObjectInfo getChildObjectInfo() {
+		return super.getChildObjectInfo();
+	}
+
+	protected List getAlwaysCopyObjectPasteOperations() {
+		return Collections.EMPTY_LIST;
+	}
+
+	/**
+	 * @return Returns the sourceView.
+	 */
+	protected View getSourceView() {
+		return sourceView;
+	}
+
+	/**
+	 * @return Returns the targetView.
+	 */
+	protected View getTargetView() {
+		return targetView;
+	}
+
+	/**
+	 * @return Returns the connectorView.
+	 */
+	protected Edge getConnectorView() {
+		return connectorView;
+	}
+}

+ 213 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/ConnectorViewPostPasteChildOperation.java

@@ -0,0 +1,213 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation 
+ ****************************************************************************/
+
+package org.yakindu.sct.ui.editor.clipboardsupport;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardSupportUtil;
+import org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @author Yasser Lulu
+ */
+@SuppressWarnings("all")
+class ConnectorViewPostPasteChildOperation
+	extends PostPasteChildOperation {
+
+	private boolean pasteSemanticElement;
+
+	private List semanticElementPasteOperations;
+
+	ConnectorViewPostPasteChildOperation(
+			ConnectorViewPasteOperation connectorViewPasteOperation,
+			boolean pasteSemanticElement) {
+		super(connectorViewPasteOperation, EMPTY_ARRAY);
+		this.pasteSemanticElement = pasteSemanticElement;
+	}
+
+	private ConnectorViewPasteOperation getConnectorViewPasteOperation() {
+		return (ConnectorViewPasteOperation) getPasteChildOperation();
+	}
+
+	public void paste()
+		throws Exception {
+
+		EObject pastedElement = doPaste();
+		//did we succeed?
+		if (pastedElement != null) {
+			setPastedElement(pastedElement);
+			addPastedElement(pastedElement);
+		} else {
+			addPasteFailuresObject(getEObject());
+		}
+
+	}
+
+
+	/**
+	 * @return
+	 * @throws Exception
+	 */
+	private EObject doPaste()
+		throws Exception {
+
+		View sourceView = getConnectorViewPasteOperation().getSourceView();
+		View targetView = getConnectorViewPasteOperation().getTargetView();
+
+		if ((sourceView == null) || (targetView == null)) {
+			return null;
+		}
+
+		EObject sourceViewContainer = sourceView.eContainer();
+		EObject targetViewContainer = targetView.eContainer();
+
+		if ((sourceViewContainer == null) || (targetViewContainer == null)) {
+			return null;
+		}
+
+		if (sourceViewContainer.equals(targetViewContainer) == false) {
+			//not in the same container, let's try to see if they are in the
+			// same diagram at least
+			Diagram sourceViewDiagram = NotationClipboardOperationHelper
+				.getContainingDiagram((View) sourceViewContainer);
+			Diagram targetViewDiagram = NotationClipboardOperationHelper
+				.getContainingDiagram((View) targetViewContainer);
+			if ((sourceViewDiagram == null) || (targetViewDiagram == null)
+				|| (sourceViewDiagram.equals(targetViewDiagram) == false)) {
+				return null;
+			}
+		}
+		
+		Edge connectorView = getConnectorViewPasteOperation()
+			.getConnectorView();
+
+		if (pasteSemanticElement) {			
+			EObject semanticElement = connectorView.getElement();
+			if (semanticElement != null) {
+				if (semanticElement.eIsProxy()) {
+					semanticElement = ClipboardSupportUtil.resolve(semanticElement,
+						getParentPasteProcess().getLoadedIDToEObjectMapCopy());
+				}
+				String loadedId = getLoadedEObjectID(semanticElement);
+				if (loadedId != null) {
+					//even if we failed to paste the semantic element, we'll
+					// proceed to paste the edge view
+					doPasteSemanticElement();
+					//should have been pasted by now, if not then return
+					String newId = getEObjectID(semanticElement);
+					if (newId == null) {
+						return null;
+					}
+				}
+			}
+		}
+		EObject pastedElement = null;
+		Diagram pasteTargetDiagram = NotationClipboardOperationHelper
+			.getContainingDiagram((View) sourceViewContainer);
+		if (pasteTargetDiagram != null) {
+			//if we reached here then we should paste the connector and set
+			// refs to it accordingly
+			pastedElement = ClipboardSupportUtil.appendEObjectAt(
+				pasteTargetDiagram, getContainmentFeature(), connectorView);
+			if (pastedElement != null) {
+				ClipboardSupportUtil.appendEObjectAt(sourceView,
+					NotationPackage.eINSTANCE.getView_SourceEdges(),
+					connectorView);
+				ClipboardSupportUtil.appendEObjectAt(targetView,
+					NotationPackage.eINSTANCE.getView_TargetEdges(),
+					connectorView);
+			}
+		}
+
+		return pastedElement;
+	}
+
+	private void doPasteSemanticElement()
+		throws Exception {
+		List list = new ArrayList();
+		Iterator it = getSemanticElementPasteOperations().iterator();
+		while (it.hasNext()) {
+			PasteChildOperation operation = (PasteChildOperation) it.next();
+			operation.paste();
+			PasteChildOperation postPasteOperation = operation
+				.getPostPasteOperation();
+			if (postPasteOperation != null) {
+				list.add(postPasteOperation);
+			}
+		}
+		performSemanticElementPostPasteOperations(list);
+	}
+
+	private void performSemanticElementPostPasteOperations(List operations)
+		throws Exception {
+		if (operations.isEmpty() == false) {
+			List postPasteOperations = new ArrayList();
+			Iterator it = operations.iterator();
+			while (it.hasNext()) {
+				PasteChildOperation pasteOperation = (PasteChildOperation) it
+					.next();
+				pasteOperation.paste();
+				PasteChildOperation postPasteOperation = pasteOperation
+					.getPostPasteOperation();
+				if (postPasteOperation != null) {
+					postPasteOperations.add(postPasteOperation);
+				}
+			}
+			//perform those newly added post paste operations
+			performSemanticElementPostPasteOperations(postPasteOperations);
+		}
+	}
+
+	protected List getPostPasteOperations()
+		throws Exception {
+		return Collections.EMPTY_LIST;
+	}
+
+	/**
+	 * @return
+	 */
+	private List getSemanticElementPasteOperations() {
+		if (semanticElementPasteOperations == null) {
+			semanticElementPasteOperations = new ArrayList();
+			//use either source or target views since by now they should have
+			// been pasted already
+			EObject semanticPasteTarget = NotationClipboardOperationHelper
+				.getSemanticPasteTarget(getConnectorViewPasteOperation()
+					.getSourceView());
+			if (semanticPasteTarget != null) {
+				Iterator alwaysCopyEObjectInfoIt = getChildObjectInfo()
+					.getCopyAlwaysObjectInfoList().iterator();
+				while (alwaysCopyEObjectInfoIt.hasNext()) {
+					ObjectInfo alwaysCopyObjectInfo = (ObjectInfo) alwaysCopyEObjectInfoIt
+						.next();
+					PasteChildOperation pasteOperation = new PasteChildOperation(
+						getParentPasteProcess().clone(semanticPasteTarget),
+						alwaysCopyObjectInfo);
+					semanticElementPasteOperations.add(pasteOperation);
+				} //while always-copy
+			}
+		}
+		return semanticElementPasteOperations;
+	}
+
+}

+ 311 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/NotationClipboardOperationHelper.java

@@ -0,0 +1,311 @@
+/******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation 
+ ****************************************************************************/
+
+package org.yakindu.sct.ui.editor.clipboardsupport;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardSupportUtil;
+import org.eclipse.gmf.runtime.emf.clipboard.core.CopyOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.OverrideCopyOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteAction;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteOption;
+import org.eclipse.gmf.runtime.emf.core.clipboard.AbstractClipboardSupport;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * A minimal clipboard operation helper for the notation metamodel. Extenders of
+ * the notation metamodel should probably provide their own implementation of
+ * this via their own
+ * {@link org.eclipse.gmf.runtime.emf.core.internal.services.metamodel.IMetamodelSupport}
+ * implementation.
+ * 
+ * @author Christian W. Damus
+ * @author Yasser Lulu
+ */
+@SuppressWarnings("all")
+public class NotationClipboardOperationHelper extends AbstractClipboardSupport {
+
+	public void destroy(EObject eObject) {
+		DestroyElementCommand.destroy(eObject);
+	}
+
+	/**
+	 * By default, there are no collisions in pasting.
+	 * 
+	 * @return the {@link PasteAction#ADD}action, always
+	 */
+	public PasteAction getPasteCollisionAction(EClass eClass) {
+		return PasteAction.ADD;
+	}
+
+	/**
+	 * By default, the following paste options are supported:
+	 * <ul>
+	 * <li>{@link PasteOption#NORMAL}: always</li>
+	 * <li>{@link PasteOption#PARENT}: never</li>
+	 * <li>{@link PasteOption#DISTANT}: if and only only if the
+	 * <code>eStructuralFeature</code> is a
+	 * {@link org.eclipse.gmf.runtime.notation.View}'s reference to its semantic
+	 * {@linkplain org.eclipse.gmf.runtime.notation.View#getElement() element}</li>
+	 * </ul>
+	 */
+	public boolean hasPasteOption(EObject contextEObject,
+			EStructuralFeature eStructuralFeature, PasteOption pasteOption) {
+		if (pasteOption.equals(PasteOption.NORMAL)) {
+			return true;
+		} else if (pasteOption.equals(PasteOption.PARENT)) {
+			// disable the copy-parent functionality completely.
+			return false;
+		} else if (pasteOption.equals(PasteOption.DISTANT)) {
+			if (eStructuralFeature == null) {
+				return false;
+			} else {
+				return NotationPackage.eINSTANCE.getView_Element().equals(
+						eStructuralFeature);
+			}
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * By default, transient and derived references are never copied, and
+	 * containment references and the
+	 * {@linkplain org.eclipse.gmf.runtime.notation.View#getElement() element}
+	 * reference always are copied.
+	 */
+	public boolean isCopyAlways(EObject context, EReference eReference,
+			Object value) {
+		if ((eReference.isTransient()) || (eReference.isDerived())) {
+			return false;
+		} else if (eReference.equals(NotationPackage.eINSTANCE
+				.getView_Element())) {
+			return true;
+		} else {
+			return eReference.isContainment();
+		}
+	}
+
+	/**
+	 * By default, don't provide any child paste override behaviour.
+	 */
+	public boolean shouldOverrideChildPasteOperation(EObject parentElement,
+			EObject childEObject) {
+		return (childEObject.eClass().getEPackage() == NotationPackage.eINSTANCE);
+	}
+
+	/**
+	 * By default, don't provide any copy override behaviour.
+	 */
+	public boolean shouldOverrideCopyOperation(Collection eObjects, Map hintMap) {
+		return false;
+	}
+
+	protected boolean shouldAllowPaste(
+			PasteChildOperation overriddenChildPasteOperation) {
+		EObject eObject = overriddenChildPasteOperation.getEObject();
+		EObject parentEObject = overriddenChildPasteOperation
+				.getParentEObject();
+		// RATLC01137919 removed the condition that parentEObject is a diagram
+		// to allow paste into diagram elements
+		if ((parentEObject instanceof View) && (eObject instanceof View)) {
+			EObject semanticChildElement = ((View) eObject).getElement();
+			if (semanticChildElement == null) {
+				return true;
+			}
+
+			// PATCH START
+			EObject target = getSemanticPasteTarget((View) eObject,
+					(View) overriddenChildPasteOperation.getParentEObject());
+			if (target == null) {
+				return false;
+			}
+			// PATCH END
+
+			if (semanticChildElement.eIsProxy()) {
+				semanticChildElement = ClipboardSupportUtil.resolve(
+						semanticChildElement, overriddenChildPasteOperation
+								.getParentPasteProcess()
+								.getLoadedIDToEObjectMapCopy());
+				if (semanticChildElement.eIsProxy()) {
+					semanticChildElement = EcoreUtil.resolve(
+							semanticChildElement, getResource(parentEObject));
+				}
+			}
+
+			EPackage semanticChildEpackage = semanticChildElement.eClass()
+					.getEPackage();
+			EPackage parentRootContainerEpackage = EcoreUtil
+					.getRootContainer(parentEObject).eClass().getEPackage();
+			EPackage sematicParentRootContainerEpackage = null;
+			EObject sematicParentElement = ((View) parentEObject).getElement();
+			if (sematicParentElement != null) {
+				sematicParentRootContainerEpackage = EcoreUtil
+						.getRootContainer(sematicParentElement).eClass()
+						.getEPackage();
+			}
+
+			if (parentRootContainerEpackage != NotationPackage.eINSTANCE) {
+				if (semanticChildEpackage != parentRootContainerEpackage) {
+					return false;
+				}
+			}
+
+			if ((sematicParentRootContainerEpackage != null)
+					&& (sematicParentRootContainerEpackage != NotationPackage.eINSTANCE)) {
+				if (semanticChildEpackage != sematicParentRootContainerEpackage) {
+					return false;
+				}
+			}
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * By default, don't provide any child paste override behaviour.
+	 * 
+	 * @return <code>null</code>, always
+	 */
+	public OverridePasteChildOperation getOverrideChildPasteOperation(
+			PasteChildOperation overriddenChildPasteOperation) {
+		if (shouldAllowPaste(overriddenChildPasteOperation)) {
+			EObject eObject = overriddenChildPasteOperation.getEObject();
+			if (eObject instanceof org.eclipse.gmf.runtime.notation.Node) {
+				org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) eObject;
+				EObject element = node.getElement();
+				if ((element != null)) {
+					return new PositionalGeneralViewPasteOperation(
+							overriddenChildPasteOperation, true);
+				} else {
+					return new PositionalGeneralViewPasteOperation(
+							overriddenChildPasteOperation, false);
+				}
+			} else if (eObject instanceof Edge) {
+				return new ConnectorViewPasteOperation(
+						overriddenChildPasteOperation);
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * By default, don't provide any copy override behaviour.
+	 * 
+	 * @return <code>null</code>, always
+	 */
+	public OverrideCopyOperation getOverrideCopyOperation(
+			CopyOperation overriddenCopyOperation) {
+		return null;
+	}
+
+	/**
+	 * By default, don't exclude any objects from the copy operation.
+	 * 
+	 * @return an empty collection
+	 */
+	public Collection getExcludedCopyObjects(Set eObjects) {
+		return Collections.EMPTY_SET;
+	}
+
+	/**
+	 * By default, just get the resource that contains the object.
+	 */
+	public XMLResource getResource(EObject eObject) {
+		XMLResource eResource = (XMLResource) eObject.eResource();
+		if (eResource == null) {
+			if (eObject instanceof View) {
+				EObject element = ((View) eObject).getElement();
+				if ((element != null)) {
+					return (XMLResource) element.eResource();
+				}
+			}
+		}
+		return eResource;
+	}
+
+	/**
+	 * By default, we always copy all contents of an object.
+	 * 
+	 * @return <code>true</code>
+	 */
+	public boolean shouldSaveContainmentFeature(EObject eObj) {
+		if (EcorePackage.eINSTANCE.getEClassifiers().contains(eObj.eClass())) {
+			return false;
+		}
+		try {
+			eObj.eResource().getURIFragment(eObj);
+		} catch (Exception ex) {
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * By default, there is no post processing to be done.
+	 */
+	public void performPostPasteProcessing(Set pastedEObjects) {
+		// nothing to do
+	}
+
+	static Diagram getContainingDiagram(View view) {
+		EObject current = view;
+		while (current != null) {
+			if (current instanceof Diagram) {
+				return (Diagram) current;
+			}
+			current = current.eContainer();
+		}
+		return null;
+	}
+	// PATCH START
+	static EObject getSemanticPasteTarget(View view, View container) {
+		EObject semanticObjectToCopy = view.getElement();
+		View parent = (View) view.eContainer();
+		EObject semanticTarget = parent.getElement();
+		EList<EReference> eAllReferences = semanticTarget.eClass()
+				.getEAllReferences();
+		for (EReference eReference : eAllReferences) {
+			EClass eReferenceType = eReference.getEReferenceType();
+			if (eReference.isContainment()
+					&& (eReference.isContainment() && eReferenceType
+							.isSuperTypeOf(semanticObjectToCopy.eClass()))) {
+				return semanticTarget;
+			}
+		}
+		return null;
+	}
+
+	static EObject getSemanticPasteTarget(View view) {
+		return getSemanticPasteTarget(view, (View) view.eContainer());
+	}
+	// PATCH END
+
+}

+ 113 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/clipboardsupport/PositionalGeneralViewPasteOperation.java

@@ -0,0 +1,113 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation 
+ ****************************************************************************/
+
+package org.yakindu.sct.ui.editor.clipboardsupport;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo;
+import org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation;
+import org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @author Yasser Lulu
+ */
+@SuppressWarnings("all")
+public class PositionalGeneralViewPasteOperation
+	extends OverridePasteChildOperation {
+
+	private boolean shouldPasteAlwaysCopyObject;
+
+	/**
+	 * @param overriddenChildPasteOperation
+	 */
+	public PositionalGeneralViewPasteOperation(
+			PasteChildOperation overriddenChildPasteOperation,
+			boolean shouldPasteAlwaysCopyObject) {
+		super(overriddenChildPasteOperation);
+		this.shouldPasteAlwaysCopyObject = shouldPasteAlwaysCopyObject;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation#paste()
+	 */
+	public void paste()
+		throws Exception {
+		//		delay unsetting of connector refs
+	}
+
+	protected boolean shouldPasteAlwaysCopyObject(
+			ObjectInfo alwaysCopyObjectInfo) {
+		return shouldPasteAlwaysCopyObject;
+	}
+
+	public PasteChildOperation getPostPasteOperation() {
+
+		return new PostPasteChildOperation(this, EMPTY_ARRAY) {
+
+			public void paste()
+				throws Exception {
+				//unset connectors before pasting so that it won't affect
+				//real connectors especially if they happen to belong to the
+				// same
+				//target diagram
+				Node view = (Node) getEObject();
+				view.eUnset(NotationPackage.eINSTANCE.getView_SourceEdges());
+				view.eUnset(NotationPackage.eINSTANCE.getView_TargetEdges());
+
+				//now paste view
+				EObject pastedElement = doPasteInto(getParentEObject());
+				//did we succeed?
+				if (pastedElement != null) {
+					setPastedElement(pastedElement);
+					addPastedElement(pastedElement);
+				} else {
+					addPasteFailuresObject(getEObject());
+				}
+			}
+
+			protected boolean shouldPasteAlwaysCopyObject(
+					ObjectInfo alwaysCopyObjectInfo) {
+				return PositionalGeneralViewPasteOperation.this
+					.shouldPasteAlwaysCopyObject(alwaysCopyObjectInfo);
+			}
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see org.eclipse.gmf.runtime.emf.core.internal.copypaste.PasteChildOperation#makeAuxiliaryChildPasteProcess(org.eclipse.gmf.runtime.emf.core.internal.copypaste.ObjectInfo)
+			 */
+			@SuppressWarnings("restriction")
+			protected PasteChildOperation makeAuxiliaryChildPasteProcess(
+					ObjectInfo auxiliaryChildEObjectInfo) {				
+				EObject semanticPasteTarget = NotationClipboardOperationHelper
+					.getSemanticPasteTarget((View) getPastedElement());
+				if (semanticPasteTarget == null) {
+					return null;
+				}
+				return new PasteChildOperation(getParentPasteProcess().clone(
+					semanticPasteTarget), auxiliaryChildEObjectInfo);
+			}
+
+			public PasteChildOperation getPostPasteOperation() {
+				List operations = getAlwaysCopyObjectPasteOperations();
+				return new PostPasteChildOperation(this, operations);
+			}
+		};
+	}
+
+}

+ 0 - 111
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SemanticCopyCommand.java

@@ -1,111 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.commands;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.ui.action.actions.global.ClipboardManager;
-import org.eclipse.gmf.runtime.common.ui.util.CustomData;
-import org.eclipse.gmf.runtime.common.ui.util.CustomDataTransfer;
-import org.eclipse.gmf.runtime.common.ui.util.ICustomData;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardUtil;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.View;
-import org.yakindu.sct.ui.editor.clipboard.SCTClipboardUtil;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class SemanticCopyCommand extends AbstractTransactionalCommand {
-
-	private static final String COPY = "Copy";
-
-	// TODO
-	public static final String DRAWING_SURFACE = "Drawing Surface";
-
-	private final List<IGraphicalEditPart> selectedObjects;
-
-	public SemanticCopyCommand(TransactionalEditingDomain domain,
-			List<IGraphicalEditPart> selectedObjects) {
-		super(domain, COPY, null);
-		this.selectedObjects = selectedObjects;
-	}
-
-	@Override
-	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
-			IAdaptable info) throws ExecutionException {
-		
-		byte[] a = SCTClipboardUtil.getByteArrayFromObject(buildMap());
-		CustomData data = new CustomData (DRAWING_SURFACE,a);
-		
-		ClipboardManager.getInstance().addToCache(
-				new ICustomData[] {data},
-				CustomDataTransfer.getInstance());
-		
-		ClipboardManager.getInstance().flushCacheToClipboard();
-		
-		return CommandResult.newOKCommandResult();
-	}
-
-	protected List<EObject> getSemanticElements() {
-		List<EObject> result = new ArrayList<EObject>();
-		for (IGraphicalEditPart editPart : selectedObjects) {
-			EObject resolveSemanticElement = editPart.resolveSemanticElement();
-			result.add(resolveSemanticElement);
-		}
-		return result;
-	}
-
-	protected List<View> getNotationElements() {
-		List<View> result = new ArrayList<View>();
-		for (IGraphicalEditPart editPart : selectedObjects) {
-			View view = editPart.getNotationView();
-			result.add(view);
-		}
-		return result;
-	}
-	
-	private Map<byte[], String> buildMap() {
-		Map<byte[], String> map = new HashMap<byte[], String>();
-		for (IGraphicalEditPart editPart : selectedObjects) {
-			
-			// Collections.SingletonList(...) returns an immutable list and
-			// ClipboardUtil.copyElementsToString want to remove elements from
-			// the list...
-			List<EObject> list = new ArrayList<EObject>(
-					Collections.singletonList(editPart.resolveSemanticElement()));
-			
-			String semanticElementString = ClipboardUtil.copyElementsToString(
-					list, null, new NullProgressMonitor());
-			
-			View view = editPart.getNotationView();
-			
-			map.put(semanticElementString.getBytes(),
-					view.eResource().getURIFragment(view));
-		}
-
-		return map;
-	}
-}

+ 0 - 126
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SemanticPasteCommand.java

@@ -1,126 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.commands;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.ui.action.actions.global.ClipboardContentsHelper;
-import org.eclipse.gmf.runtime.common.ui.action.actions.global.ClipboardManager;
-import org.eclipse.gmf.runtime.common.ui.util.ICustomData;
-import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardUtil;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.yakindu.sct.ui.editor.clipboard.SCTClipboardUtil;
-import org.yakindu.sct.ui.editor.providers.SemanticHints;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class SemanticPasteCommand extends AbstractTransactionalCommand {
-
-	private static final String PASTE = "Paste";
-	private final List<IGraphicalEditPart> targets;
-
-	public SemanticPasteCommand(List<IGraphicalEditPart> target) {
-		super(
-				TransactionUtil.getEditingDomain(target.get(0)
-						.getNotationView()), PASTE, null);
-		this.targets = target;
-	}
-
-	@SuppressWarnings("unchecked")
-	@Override
-	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
-			IAdaptable info) throws ExecutionException {
-		
-		ICustomData[] clipboardData = ClipboardManager.getInstance()
-				.getClipboardData(SemanticCopyCommand.DRAWING_SURFACE,
-						ClipboardContentsHelper.getInstance());
-		
-		Object object = SCTClipboardUtil.getObjectFromByteArray(clipboardData[0].getData());
-		
-		if (object instanceof Map<?, ?>) {
-			copyElementsAndNotationViewAttributes((Map<byte[], String>) object);
-		}
-		
-		else {
-			String dataString = new String(clipboardData[0].getData());
-			for (IGraphicalEditPart target : targets) {
-				
-				Collection semanticElements = ClipboardUtil.pasteElementsFromString(dataString,
-						target.resolveSemanticElement(), null,
-						new NullProgressMonitor());
-			}
-		}
-		return CommandResult.newOKCommandResult();
-	}
-	
-	@SuppressWarnings("unchecked")
-	private void copyElementsAndNotationViewAttributes(Map<byte[], String> map) {
-		for (IGraphicalEditPart target : targets) {
-			Resource resource = target.resolveSemanticElement().eResource();
-			for (byte[] semanticKeySet : map.keySet()) {
-
-				EObject eObject = resource.getEObject(map.get(semanticKeySet));
-
-				if (eObject instanceof Node) {
-					Node view = (Node) eObject;
-
-					Collection<EObject> semanticElements = (Collection<EObject>) ClipboardUtil
-							.pasteElementsFromString(
-									new String(semanticKeySet),
-									target.resolveSemanticElement(), null,
-									new NullProgressMonitor());
-
-					EObject semanticElement = semanticElements.iterator()
-							.next();
-
-					View compartmentView = getStateCompartmentView(target.getNotationView());
-					if (compartmentView!=null) {
-						Node newNode = ViewService.createNode(
-								compartmentView, semanticElement,
-								view.getType(), target.getDiagramPreferencesHint());
-						
-						newNode.setLayoutConstraint(EcoreUtil.copy(view
-								.getLayoutConstraint()));
-					}
-				}
-			}
-		}
-	}
-	
-	private View getStateCompartmentView(View stateView) {
-		for (Object object : stateView.getChildren()) {
-			if (object instanceof View
-					&& ((View) object).getType() == SemanticHints.REGION_COMPARTMENT) {
-				return (View) object;
-			}
-		}
-		return null;
-	}
-	
-}

+ 0 - 119
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/SemanticCopyGlobalActionHandlerProvider.java

@@ -1,119 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    IBM Corporation - initial API and implementation 
- ****************************************************************************/
-
-package org.yakindu.sct.ui.editor.providers;
-
-import java.util.Hashtable;
-
-import org.eclipse.gmf.runtime.common.ui.services.action.global.AbstractGlobalActionHandlerProvider;
-import org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandler;
-import org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandlerContext;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Concrete class that implements the <code>IGlobalActionHandlerProvider</code>.
- * 
- * @author Vishy Ramaswamy
- */
-@SuppressWarnings("rawtypes")
-public final class SemanticCopyGlobalActionHandlerProvider
-	extends AbstractGlobalActionHandlerProvider {
-
-	/**	 * List that contains all the IGlobalActionHandlers mapped to the
-	 * IWorkbenchParts
-	 */
-	private Hashtable handlerList = new Hashtable();
-
-	/**
-	 * Constructor for DiagramGlobalActionHandlerProvider.
-	 */
-	public SemanticCopyGlobalActionHandlerProvider() {
-		super();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandlerProvider#getGlobalActionHandler(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandlerContext)
-	 */
-	@SuppressWarnings("unchecked")
-	public IGlobalActionHandler getGlobalActionHandler(
-			final IGlobalActionHandlerContext context) {
-		/* create the handler */
-		if (!getHandlerList().containsKey(context.getActivePart())) {
-			getHandlerList().put(context.getActivePart(),
-				new SemanticCopyPasteGlobalActionHandler());
-			/*
-			 * register as a part listener so that the cache can be cleared when
-			 * the part is disposed
-			 */
-			context.getActivePart().getSite().getPage().addPartListener(
-				new IPartListener() {
-
-					private IWorkbenchPart localPart = context.getActivePart();
-
-					/**
-					 * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
-					 */
-					public void partActivated(IWorkbenchPart part) {
-						// NULL implementation
-					}
-
-					/**
-					 * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
-					 */
-					public void partBroughtToTop(IWorkbenchPart part) {
-						// NULL implementation
-					}
-
-					/**
-					 * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
-					 */
-					public void partClosed(IWorkbenchPart part) {
-						/* remove the cache associated with the part */
-						if (part != null && part == localPart
-							&& getHandlerList().containsKey(part)) {
-							getHandlerList().remove(part);
-							localPart.getSite().getPage().removePartListener(
-								this);
-							localPart = null;
-						}
-					}
-
-					/**
-					 * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
-					 */
-					public void partDeactivated(IWorkbenchPart part) {
-						// NULL implementation
-					}
-
-					/**
-					 * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
-					 */
-					public void partOpened(IWorkbenchPart part) {
-						// NULL implementation
-					}
-				});
-		}
-		return (SemanticCopyPasteGlobalActionHandler) getHandlerList().get(
-			context.getActivePart());
-	}
-
-	/**
-	 * Returns the handlerList.
-	 * 
-	 * @return Hashtable
-	 */
-	private Hashtable getHandlerList() {
-		return handlerList;
-	}
-}

+ 0 - 88
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/SemanticCopyPasteGlobalActionHandler.java

@@ -1,88 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.providers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-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;
-import org.yakindu.sct.ui.editor.commands.SemanticCopyCommand;
-import org.yakindu.sct.ui.editor.commands.SemanticPasteCommand;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class SemanticCopyPasteGlobalActionHandler extends
-		DiagramGlobalActionHandler {
-
-	public ICommand getCommand(IGlobalActionContext cntxt) {
-		String actionId = cntxt.getActionId();
-		if (actionId.equals(GlobalActionId.COPY)) {
-			return getCopyCommand(cntxt);
-		} else if (actionId.equals(GlobalActionId.CUT)) {
-			return getCutCommand(cntxt);
-		} else if (actionId.equals(GlobalActionId.PASTE)) {
-			return getPasteCommand(cntxt);
-		}
-		return super.getCommand(cntxt);
-	}
-
-	private ICommand getCutCommand(IGlobalActionContext cntxt) {
-		// TODO: Implement me
-		return null;
-	}
-
-	protected ICommand getCopyCommand(IGlobalActionContext cntxt) {
-		List<IGraphicalEditPart> objects = getSelectedElements(cntxt.getSelection());
-		if (objects.size() > 0) {
-			TransactionalEditingDomain domain = TransactionUtil
-					.getEditingDomain(objects.get(0).getNotationView());
-			SemanticCopyCommand copyCmd = new SemanticCopyCommand(domain,
-					objects);
-			return copyCmd;
-		}
-		return null;
-	}
-
-	private ICommand getPasteCommand(IGlobalActionContext cntxt) {
-		List<IGraphicalEditPart> objects = getSelectedElements(cntxt.getSelection());
-		if (objects.size() > 0) {
-			return new SemanticPasteCommand(objects);
-		}
-		return null;
-	}
-
-	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 IGraphicalEditPart) {
-				results.add((IGraphicalEditPart)selectedElement);
-			}
-		}
-		return results;
-	}
-
-}