Search in sources :

Example 1 with ObjectInfo

use of org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo in project statecharts by Yakindu.

the class PositionalGeneralViewPasteOperation method getPostPasteOperation.

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);
        }
    };
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) EObject(org.eclipse.emf.ecore.EObject) PostPasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation) PasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation) OverridePasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation) List(java.util.List) PostPasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation) ObjectInfo(org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo)

Example 2 with ObjectInfo

use of org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo in project statecharts by Yakindu.

the class ConnectorViewPostPasteChildOperation method getSemanticElementPasteOperations.

/**
 * @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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) PostPasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation) PasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ObjectInfo(org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 ObjectInfo (org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo)2 PasteChildOperation (org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation)2 PostPasteChildOperation (org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 OverridePasteChildOperation (org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation)1 Node (org.eclipse.gmf.runtime.notation.Node)1