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

Hi Marc,

unfortunately I ran into the same problems, recently. Copy/paste basically works - meaning I am able to copy compartments and components from one compartment to another (visually). If I modify properties of the copied component/compartment, the source-component/compartment is changed too. After reopening the diagram file, all copied elements disappeared, although they are still visible in the generated xmi-file. I am already using uuids.

Did you already manage to get copy/paste working? Any hints?

Thanks in advance,

Daniel

markitus wrote:
Hi Thomas,

I create a copy through the context menu (right-click on selected element
(s)), then copy/cut and paste. Easy, straightforward. Actually, it doesn't work at all if I try with shortcuts.


Weird weird weird. I guess it has something to do with the original creation of the ecore. The thing is that the development of this app started around 2 years ago, and perhaps it's a bit too late to start back again from scratch.

thanks for your help.

REGARDS, Marc.

El dia Mon, 23 Feb 2009 18:58:35 +0100, en/na Thomas Beyer va escriure:

Hello Markitus,

the behaviour you describe sounds to me like you are using shortcuts,
not real copies of elements.
How do you create your copy?
Select -> <Ctrl> + <C> -> <Ctrl> + <V> ?

Regards Thomas

markitus schrieb:
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:

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-
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!