Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Copy/Paste on the Toolbar
Copy/Paste on the Toolbar [message #179744] Fri, 29 April 2005 20:21 Go to next message
Sapna George is currently offline Sapna GeorgeFriend
Messages: 76
Registered: July 2009
Member
I want to add Copy/Paste Tool items onto my editor's toolbar. So, i tried
to add CopyRetargetAction and PasteRetargetAction to my
ActionBarContributor. But the documentation states that these are
deprecated and that we should use org.eclipse.ui.actions.ActionFactory
instead. How should we use this?

I tried the following:
1. in my ActionBarContributor's buildActions() method, i put the following
addAction(ActionFactory.COPY.create(editor.getEditorSite().g etWorkbenchWindow()));
addAction(ActionFactory.PASTE.create(editor.getEditorSite(). getWorkbenchWindow()));
where the variable 'editor' has been set to MY editor using the
setActiveEditor method.

2. In the method contributeToToolBar(IToolBarManager toolBarManager), i
added the following:
toolBarManager.add(getAction(ActionFactory.COPY.getId()));
toolBarManager.add(getAction(ActionFactory.PASTE.getId()));

BUT, upon execution, i get a NullPointerException at the call to create
the COPY action -
addAction(ActionFactory.COPY.create(editor.getEditorSite().g etWorkbenchWindow()));.

So, how else should i be doing this?

thanks
Sapna
Re: Copy/Paste on the Toolbar [message #179839 is a reply to message #179744] Sun, 01 May 2005 22:17 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Step 1 below is not required for step 2. That is, if you don't add the
retarget actions in buildActions(), the copy/paste will still show up on the
toolbar. Look at the getAction() code to see why that is.

However, you'd still want to add the retarget actions in buildActions() show
that the ones on the edit menu work properly, and so do the keybindings.
You can get to the WorkbenchWindow via PlatformUI.

"Sapna George" <sgeorge@vt.edu> wrote in message
news:0a8a2d930b1124ac939ffdb895c01e35$1@www.eclipse.org...
> I want to add Copy/Paste Tool items onto my editor's toolbar. So, i tried
> to add CopyRetargetAction and PasteRetargetAction to my
> ActionBarContributor. But the documentation states that these are
> deprecated and that we should use org.eclipse.ui.actions.ActionFactory
> instead. How should we use this?
>
> I tried the following:
> 1. in my ActionBarContributor's buildActions() method, i put the following
>
addAction(ActionFactory.COPY.create(editor.getEditorSite().g etWorkbenchWindo
w()));
>
addAction(ActionFactory.PASTE.create(editor.getEditorSite(). getWorkbenchWind
ow()));
> where the variable 'editor' has been set to MY editor using the
> setActiveEditor method.
>
> 2. In the method contributeToToolBar(IToolBarManager toolBarManager), i
> added the following:
> toolBarManager.add(getAction(ActionFactory.COPY.getId()));
> toolBarManager.add(getAction(ActionFactory.PASTE.getId()));
>
> BUT, upon execution, i get a NullPointerException at the call to create
> the COPY action -
>
addAction(ActionFactory.COPY.create(editor.getEditorSite().g etWorkbenchWindo
w()));.
>
> So, how else should i be doing this?
>
> thanks
> Sapna
>
>
>
Previous Topic:Grid/Rulers in editor (example or document)
Next Topic:Common command framework - is GEF moving this way?
Goto Forum:
  


Current Time: Sun Feb 05 15:21:17 GMT 2023

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

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

Back to the top