Copy & Paste within CompartmentEditParts [message #708866] |
Wed, 03 August 2011 04:32  |
Eclipse User |
|
|
|
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 07:59  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04878 seconds