| [news.eclipse.modeling.gmf] Re: copy paste issue |
Hello Markitus,
Regards Thomas
Hi Thomas,
I did exactly as you said (step 1). Actually it was already done before I started trying to copy paste. I'm getting the same errors as Tobias. If I change smth in the new copied element, whatever change I do on this new element, is reflected on the original too. So there must be some base errors that leads us to this behavior.
I can't understand why it's behaving like this, and for sure I don't want to give up ( I can't ), but it's really starting to be quite discouraging. It seems so obvious that it should SIMPLY work...
good to know, Tobias, that I'm not alone in this fight!
El dia Fri, 20 Feb 2009 17:12:12 +0100, en/na Thomas Beyer va escriure:
semantic-Never give up, guys ;-)
So first of all: Did you both make sure to use uuids for your semantic model as I described earlier in step 1?
If so, copy paste should at least work for elements placed directly on the canvas.
So you must add the following extension to your plugin-xml: <extension point="org.eclipse.emf.ecore.extension_parser"> <parser type="MY_SEMANTIC_MODEL_FILE_EXTENSION" class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory"> </parser> </extension>
Where MY_SEMANTIC_MODEL_FILE_EXTENSION seriously only is the file-extension of your editor-files.
Step 2 was the solution to make copy/paste work in compartments (container-elements).
Regards, Thomas
Am 20.02.2009 16:06, schrieb Tobias:Hello Marc,
it seems you have the same problem I had (and still have). The point is, that the elements do not disappear after they have been copied, but that only their views are copied, I guesss. To verify this, please copy-paste an element and then modify it. If I'm right, the original element will get changed, too.
However, this is not a solution to your problem (I wish it were, as then my problem would be solved as well), but maybe it gives you some idea of where to begin. For me, I tried a few days to solve it before I finally gave up... :-(
Regards, and good luck, Tobias
markitus schrieb:Hi Thomas,
Perhaps I misunderstood or I missed something. But wouldn't the result be the same (or similar) if we extend AbstractClipboardSupport (which implements IClipboardSupport) and rewrite these methods? Anyway, I'm clearly confused, as you see. My problem is not pasting into compartments , I didn't even get that far yet :( . I've enabled the copy/Paste option so it shows up in the contextual menu. I'm being able to copy or paste whatever elements I want to(graphically), but when I try to make these changes persistent these new copied elements simply disappear. Even if I add an original object from the palette after a copy/paste action, the previously copied elements disappear from the canvas. It is so weird!!
So I'm not sure if i have to rewrite anything since I'm not trying to do anything special, just a simple copy paste action with simple elements (not compartments). Should I expect this to work straight, or should I rewrite some code ?
Thanks for your help.
Marc.
El dia Thu, 19 Feb 2009 19:22:49 +0100, en/na Thomas Beyer va escriure:
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-model-the-simplest-wayparent.getElement();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(); returnzo be}
b) private boolean shouldAllowPaste( PasteChildOperation overriddenChildPasteOperation) { EObject eObject = overriddenChildPasteOperation.getEObject(); EObject parentEObject = overriddenChildPasteOperation .getParentEObject(); //implement your logic here, that checks, if eObject is allowedGMF_Newsgroup_Q_and_A#How_to_make_copy.2Fpaste_work_on_compartments.3Fcan be pasted in the parentEObject }
I got the clue from this page: http://wiki.eclipse.org/, 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!