[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.emf] Re: Use of Copy, Paste Command

Frank,
 
In a wrapper object for the copy which you put on the
clipboard?). What if the same thing is done using a copy and add command instead
of via the clipboard?
 
Yes. I was hoping to subclass the copy helper and add a variable to store the container of the source object. I don't want to store the container information of my objects in my model. Is there any other way to solve this problem?
 
I can't understand your second sentence. "What if the same thing is done using a copy and add command instead of via the clipboard" - Can you please elaborate on that.
 
Thanks
Balaji
"Frank Budinsky" <frankb@xxxxxxxxxx> wrote in message news:3F54DA28.616C71F1@xxxxxxxxxx...
> Balaji,
>
> It sounds kind of kludgy to enforce this kind of restriction by passing some
> information from a copy command to a paste command (where would you store the
> original's eContainer? In a wrapper object for the copy which you put on the
> clipboard?). What if the same thing is done using a copy and add command instead
> of via the clipboard?
>
> I think that ideally the model should be designed in such a way that the copied
> model object itself has all the necessary state information (maybe it's a
> specific subclass) that controls its suitability for adding at one place or
> another.
>
> Frank.
>
>
> Balaji wrote:
>
> > All,
> > I use my own copy and paste command to copy / paste objects using EMF
> > commands. I had to validate the owner on which the object is pasted.
> > for e.g. A contains a list of B objects.
> > If B's parent is a (instance of A), then B can be pasted only to a.
> >
> > To accomplish this, I need to know the eContainer of B. But the
> > PasteFromClipboardCommand does not provide me with the eContainer of the
> > object copied.
> >
> > command.append
> >
> > (new CommandWrapper()
> >
> > {
> >
> > protected Command createCommand()
> >
> > {
> >
> > // Command copyCommand = CopyCommand.create(domain, domain.getClipboard());
> >
> > CompoundCommand compoundCommand = new CompoundCommand();
> >
> > Collection objectsToBePasted = copyCommand.getResult();
> >
> > ...
> >
> > }
> >
> > The objectsToBePasted has information regarding the object but not the
> > container. What is the recommended approach in this case. Should I store the
> > eContainer of the owner when it is copied and use it when it is pasted ?.
> >
> > Thanks
> >
> > Balaji
>