Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Cannot Get Access to the Main ToolBar
Cannot Get Access to the Main ToolBar [message #1690389] Fri, 27 March 2015 05:35 Go to next message
Evelyn Guo is currently offline Evelyn GuoFriend
Messages: 1
Registered: March 2015
Junior Member
Hello,

I am trying to listen to user actions on the main toolbar. I thought I should attach a listener to the tool items in the tool bar, but I cannot get access to the main toolbar at all. I tried the following code but it does not seem to work:

WorkbenchWindow workbenchwindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
toolbarManager = (ToolBarManager) workbenchwindow.getToolBarManager();
ToolBar toolbar = toolbarManager.getControl(); //here toolbar is null
ToolItem [] items = toolbar.getItems(); // and here we have a null pointer exception

Could anyone help me with that? Thanks a lot Razz
Re: Cannot Get Access to the Main ToolBar [message #1690614 is a reply to message #1690389] Mon, 30 March 2015 04:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2526
Registered: July 2012
Senior Member
Where are you trying to add a listener. Sounds like you are too early.
Re: Cannot Get Access to the Main ToolBar [message #1690624 is a reply to message #1690614] Mon, 30 March 2015 07:23 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
Not to mention that he is relying on implementation details - if all the
tool-items are connected to a command (and not the old action-sets) the
far better option is to add yourself a command-listener!

Tom

On 30.03.15 06:09, Dirk Fauth wrote:
> Where are you trying to add a listener. Sounds like you are too early.
Previous Topic:Debugging Eclipse Welcome Page
Next Topic:How to use the attribute mnemonic for menus and menu items?
Goto Forum:
  


Current Time: Thu Nov 23 03:54:01 GMT 2017

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

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