[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: Problems with Duplicate action
|
I can actually duplicate elements contained in the canvas so I've got
something similar done in my editor, but my problem is that I can't
duplicate elements contained in comparments (the item "Duplicate" doesn't
even appear in the pop-up menu) and I don't see how that code can solve the
problem :-(
Thanks
Mario
"Thomas Beyer" <thomas.beyer81@xxxxxxxxxxx> escribió en el mensaje
news:gnk6l5$oea$1@xxxxxxxxxxxxxxxxxxxx
> Hi Mario,
>
>
> my solution below:
>
> 1. Create a new class called DuplicateAnythingCommand (see attached file).
>
> 2. In your generated XXXBaseItemSemanticEditPolicy, add the following
> lines to your generated <getCommand>-method as follows:
> public Command getCommand(Request request) {
> [...]
> Command result = super.getCommand(request);
> if (request instanceof EditCommandRequestWrapper) {
> IEditCommandRequest ier = ((EditCommandRequestWrapper)
> request).getEditCommandRequest();
> if (ier instanceof DuplicateElementsRequest && result == null) {
> //call your new DuplicateCommand
> return new ICommandProxy(new
> DuplicateAnythingCommand(getEditingDomain(), (DuplicateElementsRequest)
> ier));
> }
> }
> [...]
> return result;
> }
>
>
> Does the trick for me.
>
> HTH
> Regards, Thomas
>
>
> Mario Cervera schrieb:
>> Hello,
>>
>> I've noticed in my graphical editor that I can only duplicate elements
>> that
>> are contained in the canvas element but not in compartments. I'd like to
>> be
>> able to duplicate all elements. Does anyone know how to do this? I've
>> seen
>> that the Duplicate action is contributed in the plug-in
>> "org.eclipse.gmf.runtime.diagram.ui.providers" so I can't modify those
>> classes.
>>
>> Thanks in advance.
>>
>> Mario
>>
>>
>
>
--------------------------------------------------------------------------------
> package XXX.diagram.custom.command;
>
> import org.eclipse.emf.transaction.TransactionalEditingDomain;
> import
> org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
> import
> org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
>
> /**
> * Command that allows the duplication of any notational element with its
> * underlying domain model element.
> *
> */
> public class DuplicateAnythingCommand extends DuplicateEObjectsCommand {
>
> /**
> * Constructor
> *
> * @param editingDomain
> * @param req
> */
> public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain,
> DuplicateElementsRequest req) {
> super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(),
> req.getAllDuplicatedElementsMap());
> }
>
> }