Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Retargetable copy and paste action
Retargetable copy and paste action [message #233892] Fri, 04 May 2007 08:43 Go to next message
Dan Phifer is currently offline Dan PhiferFriend
Messages: 72
Registered: July 2009
Member
I have a functioning GEF Editor, and I wanted to add copy and paste
functionality (cloning, to be specific). But I have a couple questions.
I've implemented the copy and paste actions, I have added them to the
context menu and they work fine.

However, the enablement of the copy/paste actions in the menu behave
strangely and do not match the enablement of the actions in my context
menu. Here's how I add them to the context menu:

menu.appendToGroup(GEFActionConstants.GROUP_COPY,
getAction(ActionFactory.COPY.getId()));
menu.appendToGroup(GEFActionConstants.GROUP_COPY,
getAction(ActionFactory.PASTE.getId()));

I have registered the actions in the editor, and I am using the
ActionFactory.COPY.getId() and the ActionFactory.PASTE.getId().

addSelectionAction(registry, new CopyProcessesAction(this));
addSelectionAction(registry, new PasteProcessesAction(this));

private void addSelectionAction(ActionRegistry registry, IAction action)
{
registry.registerAction(action);
getSelectionActions().add(action.getId());
}


Is there something else I need to do in order to get the copy and paste
items in the menu (as well as the Ctrl+C, Ctrl+V commands) to enable
properly? Currently, when they are enabled, they work properly, so I know
that I have it set up at least partly in the right way. About half the
time, though, the copy command is disabled in the main menu, even when the
copy command in the context menu is enabled.
Re: Retargetable copy and paste action [message #233932 is a reply to message #233892] Fri, 04 May 2007 14:37 Go to previous messageGo to next message
Anthony Hunter is currently offline Anthony HunterFriend
Messages: 446
Registered: July 2009
Senior Member
Hi Dan,

You need to register these actions with the GlobalActionHandler. Look for
setGlobalActionHandler() for examples.

Cheers...
Anthony

"Dan Phifer" <dan.phifer@gmail.com> wrote in message
news:514188cbf1bad49e2b9eaf8897b0a455$1@www.eclipse.org...
>I have a functioning GEF Editor, and I wanted to add copy and paste
>functionality (cloning, to be specific). But I have a couple questions.
>I've implemented the copy and paste actions, I have added them to the
>context menu and they work fine.
> However, the enablement of the copy/paste actions in the menu behave
> strangely and do not match the enablement of the actions in my context
> menu. Here's how I add them to the context menu:
>
> menu.appendToGroup(GEFActionConstants.GROUP_COPY,
> getAction(ActionFactory.COPY.getId()));
> menu.appendToGroup(GEFActionConstants.GROUP_COPY,
> getAction(ActionFactory.PASTE.getId()));
>
> I have registered the actions in the editor, and I am using the
> ActionFactory.COPY.getId() and the ActionFactory.PASTE.getId().
> addSelectionAction(registry, new CopyProcessesAction(this));
> addSelectionAction(registry, new PasteProcessesAction(this));
>
> private void addSelectionAction(ActionRegistry registry, IAction action)
> {
> registry.registerAction(action);
> getSelectionActions().add(action.getId());
> }
>
>
> Is there something else I need to do in order to get the copy and paste
> items in the menu (as well as the Ctrl+C, Ctrl+V commands) to enable
> properly? Currently, when they are enabled, they work properly, so I know
> that I have it set up at least partly in the right way. About half the
> time, though, the copy command is disabled in the main menu, even when the
> copy command in the context menu is enabled.
>
>
Re: Retargetable copy and paste action [message #233939 is a reply to message #233932] Fri, 04 May 2007 15:59 Go to previous message
Dan Phifer is currently offline Dan PhiferFriend
Messages: 72
Registered: July 2009
Member
Great thanks. It works fine now. However, I have been working from the
Logic example, and now I am wondering about what the
handleActivationChange method does:

protected void handleActivationChanged(Event event)
{
IAction copy = null;
if (event.type == SWT.Deactivate)
copy = getActionRegistry().getAction(ActionFactory.COPY.getId());
if
(getEditorSite().getActionBars().getGlobalActionHandler(Acti onFactory.COPY.getId())
!= copy)
{

getEditorSite().getActionBars().setGlobalActionHandler(Actio nFactory.COPY.getId(),
copy);
getEditorSite().getActionBars().updateActionBars();
}
}

This seems to say, if the event is not SWT.Deativate, then set the global
handler to null and if it IS Deactivate, then set the handler to our copy
action. It seems like it should be the other way around... what am I
missing?
Previous Topic:Just a random Thank You!!! :-)
Next Topic:DirectedGraphLayout reassigns width and height
Goto Forum:
  


Current Time: Fri Mar 29 08:19:35 GMT 2024

Powered by FUDForum. Page generated in 0.02257 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top