Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Copy & Paste within CompartmentEditParts
Copy & Paste within CompartmentEditParts [message #708866] Wed, 03 August 2011 08:32 Go to next message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 71
Registered: July 2011
Member
Hi all,

I wonder if there is a solution to get copy & paste working within ShapeCompartmentEditParts. The default behaviour on a DiagramEditPart works as expected - the semantic element is copied with all EContainment references as well as the notation model element. (styles, bounds etc.) Even the compartments are copied the right way.
Unfortunatelly when I want to copy elements within a ShapeCompartmentEditPart, the notation model is copied correct. But the semantic elements are not copied, instead they refer to the original elements.

There is some documentation in the eclipse wiki about that topic:
http://wiki.eclipse.org/GMF_Newsgroup_Q_and_A#How_to_make_copy.2Fpaste_work_on_compartments.3F

Unfortunatelly, this does not solve the problem with the references to the original elements instead of a full copy.

Does anyone have any information on this topic?

Regards,

Andreas




Re: Copy & Paste within CompartmentEditParts [message #709011 is a reply to message #708866] Wed, 03 August 2011 11:59 Go to previous message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 71
Registered: July 2011
Member
After some debugging I found a solution for the problem.
The method NotationClipboardOperationHelper#getSemanticPasteTarget does not work as expected, it only returns the semantic element of the diagram. The solution in the wiki is not sufficient, too. One have to ensure, that the paste operation semantically makes sense. This also has to be done in the shouldAllowPaste() operation.

static EObject getSemanticPasteTarget(View view) {
		EObject semanticObjectToCopy = view.getElement();
		EObject semanticTarget = ((View)view.eContainer()).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;
	}


However, it is really a problem that this method is static. Because of that, I can not override it and have to copy & paste several classes from an internal package. I will file a bug for that.

Regards,

Andreas



Previous Topic:Get the ConnectionNodeEditPart from a CreateRelationshipRequest
Next Topic:Diagram is not present in resource
Goto Forum:
  


Current Time: Sat Nov 29 07:51:11 GMT 2014

Powered by FUDForum. Page generated in 0.04487 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software