[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: copy paste issue

Hi Markitus,

I really struggled a long time with cut, copy & paste, especially pasting into compartments.

From what I can tell, GMF provides everything you need and implements a very powerful framework around copy-paste. If you see all the related classes, its a quiet complex job.
Marios approach might also work for your use-case, unfortunately I never got it working for my editors.


There is just two little hints, I'd like to give you:
1. Make sure to use uuids for your semantic model as described in this post: http://serdom.eu/ser/2008/07/02/eclipse-gmf-enabling-uuids-in-semantic-model-the-simplest-way
There are lots of others threats in this group, adressing exactly this issue as well.


2. Fork the class NotationClipboardOperationHelper(in plugin org.eclipse.gmf.runtime.notation.providers)
and modify the following methods:
a)
static EObject getSemanticPasteTarget(View view) {
View parent = (View) view.eContainer();
return parent.getElement();
}


b)
private boolean shouldAllowPaste(
PasteChildOperation overriddenChildPasteOperation) {
EObject eObject = overriddenChildPasteOperation.getEObject();
EObject parentEObject = overriddenChildPasteOperation
.getParentEObject();
//implement your logic here, that checks, if eObject is allowed zo be can be pasted in the parentEObject
}


I got the clue from this page:
http://wiki.eclipse.org/GMF_Newsgroup_Q_and_A#How_to_make_copy.2Fpaste_work_on_compartments.3F
, which contains so many useful solutions!!!

Forking basically means, you import the plugin above from the eclipse cvs base, modify the code and use your customized plugin for your application, rcp or whatever. (just in case you struggle with the term, like I used to)
Let me know, if you need any further help.



HTH Regards, Thomas



markitus schrieb:
Hi,

I'm trying to copy and paste single elements from a model into a new model. Apparently it looks like it's done, since I can see a graphical copy of that element, but if I try to save the diagram and open it back it just disappears.

any ideas?? this is starting to drive me crazy. I haven't been able to find any complete and clear example of a simple copy paste action on GMF. Many people has already asked this issue on this list before me but it seems like there aren't any convincing solution.

Please, help!

thank you!