Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Commands and Toolbar and Toggle style buttons?
Commands and Toolbar and Toggle style buttons? [message #336423] Wed, 10 June 2009 16:37 Go to next message
Eclipse UserFriend
Originally posted by: eclipse-newsgroups.scharf.gr

Hi,

I am trying to do a very simple thing: I want to add
a simple button to the windows menu and the tool bar
and it should be a toggle button. I used the "Hello world
Command" template.

I have the following problems:

1. if I add it to the toolbar as in the with
locationURI as:
toolbar:org.eclipse.ui.main.toolbar?after=additions
the button appears but in the "Customize perspective"
the tool bar has no group and I am too stupid to figure
out how to create a group :-(

2. How do I update the toggle state of the tool bar command
and the menu command? (they should somehow listen to the
state of my Handler). I am sure there is somewhere some
magic, but I was unable to figure it out...

So, I thought I'd better ask the experts:
http://michaelscharf.blogspot.com/2009/05/why-is-rcp-emf-p2- databinding-so-hard.html


Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: Commands and Toolbar and Toggle style buttons? [message #336427 is a reply to message #336423] Thu, 11 June 2009 02:16 Go to previous messageGo to next message
Eclipse UserFriend
Michael Scharf wrote:
> I am trying to do a very simple thing: I want to add
> a simple button to the windows menu and the tool bar
> and it should be a toggle button. I used the "Hello world
> Command" template.

The "Hello World" Command template, is what its meant to be - the
starting point to understand the commands. It adds a command, a handler,
a binding and two UI contributions (menu and toolbar).

If you really wanted to learn beyond a "Hello World" example, I would
suggest you to get into the following links:

http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Menu_Contributions
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm

http://blog.eclipse-tips.com/search/label/Commands

Is there something more can be done to simplfy the learning?

- Prakash

---
http://blog.eclipse-tips.com
Re: Commands and Toolbar and Toggle style buttons? [message #336435 is a reply to message #336427] Thu, 11 June 2009 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-newsgroups.scharf.gr

Prakash,

Great links! But I still cannot figure out how
the heck I create a group so it appears in the
customize perspective as something that I can select
(with a name).

Michael

> Michael Scharf wrote:
>> I am trying to do a very simple thing: I want to add
>> a simple button to the windows menu and the tool bar
>> and it should be a toggle button. I used the "Hello world
>> Command" template.
>
> The "Hello World" Command template, is what its meant to be - the
> starting point to understand the commands. It adds a command, a handler,
> a binding and two UI contributions (menu and toolbar).
>
> If you really wanted to learn beyond a "Hello World" example, I would
> suggest you to get into the following links:
>
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Menu_Contributions
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
>
> http://blog.eclipse-tips.com/search/label/Commands
>
> Is there something more can be done to simplfy the learning?
>
> - Prakash
>
> ---
> http://blog.eclipse-tips.com


--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: Commands and Toolbar and Toggle style buttons? [message #336439 is a reply to message #336423] Thu, 11 June 2009 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Those groups each represent one toolbar in the coolbar, but the labels
in the CustomizePerspectiveDialog are kinda hacked in. Basically, they
currently come from
org.eclipse.ui.internal.WorkbenchWindow.getToolbarLabel(Stri ng). File
and Navigate are hard code :-) and everything else is looked up from the
actionSet registry. sigh, I can't believe this stuff.


So for example, if you create a new toolbar using something like:
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
<toolbar id="com.example.myToolbar">
<command commandId="org.eclipse.ui.help.aboutAction"/>
</toolbar>
</menuContribution>

Then com.example.myToolbar will be sent to that method.

But it implies a workaround would be to create an empty actionSet with
an ID matching your toolbar and the appropriate label.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: Commands and Toolbar and Toggle style buttons? [message #336440 is a reply to message #336435] Thu, 11 June 2009 14:12 Go to previous message
Eclipse UserFriend
Michael Scharf wrote:
> Prakash,
>
> Great links! But I still cannot figure out how
> the heck I create a group so it appears in the
> customize perspective as something that I can select
> (with a name).

Were you able to find the toggle update part? There should have been an
example off of the http://wiki.eclipse.org/Menu_Contributions page, it
basically involves using IElementUpdater on the handler.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Previous Topic:Schedule UIJob in Activator.start()
Next Topic:How to use java syntax coloring for non java files
Goto Forum:
  


Current Time: Mon Mar 10 21:57:48 EDT 2025

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

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

Back to the top