|
Re: Copy/Paste on the Toolbar [message #179839 is a reply to message #179744] |
Sun, 01 May 2005 22:17 |
Pratik Shah 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
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02710 seconds