Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Toolbar and command doesn't appear on custom view.
Toolbar and command doesn't appear on custom view. [message #490321] Thu, 08 October 2009 11:31 Go to next message
Prasanna K is currently offline Prasanna K
Messages: 78
Registered: July 2009
Member
In my plug-in, I intend to add a toolbar to my view and a couple of commands (push-buttons) to that toolbar.
I add a command and a handler to plugin.xml as :
        <command
            id="myorg.plugin.bottomView.filter.command"
            name="Filter">
     	</command>

         <handler
               commandId="myorg.plugin.bottomView.filter.command"
               class="com.myorg.eclipse.filterCommandHandler">
         </handler>        

To add this command to a toolbar and that (toolbar) to my view I add this menucontribution to plugin.xml as :
<menuContribution locationURI="toolbar:myorg.plugin.bottomView">
	<toolbar id="myorg.plugin.bottomView.toolbar?after=additions">
            		<command
	                  commandId="myorg.plugin.bottomView.filter.command"
	                  icon="icons/filter.gif"
	                  tooltip="Filter results"
	                  style="push">
		</command>
            </toolbar>
</menuContribution>

My command and the expected toolbar doesn't appear on my view.
If I change my locationURI to following the command with it's icon shows up properly in main toolbar next to run command.
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">

I believe there is something wrong in the locationURI. myorg.plugin.bottomView is the id of my view.
I didn't find a document that describes correct syntax of the same.
So, what is wrong in here?
It'll be a great help if any expert tells me what it is.

Thanks.
Re: Toolbar and command doesn't appear on custom view. [message #490451 is a reply to message #490321] Thu, 08 October 2009 17:01 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
kaprasi wrote:
> <menuContribution locationURI="toolbar:myorg.plugin.bottomView">
> <toolbar id="myorg.plugin.bottomView.toolbar?after=additions">
> <command
> commandId="myorg.plugin.bottomView.filter.command"

Adding the command directly to the menuContribution (without the
toolbar) should work.

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: Toolbar and command doesn't appear on custom view. [message #490551 is a reply to message #490451] Fri, 09 October 2009 06:46 Go to previous messageGo to next message
Prasanna K is currently offline Prasanna K
Messages: 78
Registered: July 2009
Member
Adding the command directly to the menuContribution (without the
toolbar) should work.

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com[/quote]


Hi Prakash,

Believe me I had tried that y'day but a typo - view name spelled wrong -caused all this exercise. Fresh day fresh outlook solved this in minutes.

Thanks anyways.
Re: Toolbar and command doesn't appear on custom view. [message #511580 is a reply to message #490321] Tue, 02 February 2010 07:12 Go to previous message
eliza sahoos is currently offline eliza sahoos
Messages: 3
Registered: February 2010
Junior Member

Sometimes it's necessary to customize the behavior of the existing i.e. the eclipse provided commands according to the business logic of the rcp application.

Example:

Let's say in general "Paste" command pastes the text from the clipboard. Now I want the paste command should paste text from clipboard with a prefix of "Hello".

Answer
The solution is to override the default handler with a custom one. But the problem with that is you can not declare a custom handler for existing command directly. It will raise a conflict.

So what we will do is we will activate the custom handler by activating a context.

Now, declare the custom handler like shown below:

<handler

class="<custom handler>"

commandId="<standard / existing command id>">

<activeWhen>

<with

variable="activeContexts">

<iterate

ifEmpty="false"

operator="or">

<equals

value="<custom context name>">

</equals>

</iterate>

</with>

</activeWhen>

</handler>

The above declaration will activate the custom handler when the declared context will be activated.

Now at the start up of the application you can activate the context by using following code.
Hope it did add some value.Any suggestions are welcomed.

Thanks
Eliza
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);

contextService.activateContext( <custom context name> );

So now the above declared command will use the custom handler.
Previous Topic:Getting handle to a file outside eclipse workspace
Next Topic:Eclipse crashes when cutting text in arbitrary editor
Goto Forum:
  


Current Time: Wed Sep 17 11:33:16 GMT 2014

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

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