Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Get Reference of ToolItems from the Main ToolBar
Get Reference of ToolItems from the Main ToolBar [message #661382] Thu, 24 March 2011 09:28 Go to next message
Eclipse UserFriend
Hey There

I Have this code :

Object data = shell.getData();
        ApplicationWindow app = (ApplicationWindow) data;



        MenuManager menuMng =  app.getMenuBarManager();
        IContributionItem[] items = menuMng.getItems();


        CoolBarManager coolBar = app.getCoolBarManager();
        ICoolBarManager icoolBar = app.getCoolBarManager2();
        IContributionItem citem = items[1];
        MenuManager submenu = (MenuManager) citem;
        String subId = submenu.getId();


        IContributionItem[]  icool = icoolBar.getItems();
        IContributionItem icot = icool[1];
        ToolBarContributionItem item = (ToolBarContributionItem) icot;
        IToolBarManager toolMng = item.getToolBarManager();
        ToolBarManager toolBarManager = (ToolBarManager)toolMng;
        ToolBar control = toolBarManager.getControl();

        ToolItem[] Toolitems = control.getItems();
        ToolItem toolitem = Toolitems[0];


        toolitem.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if(e.detail == SWT.ARROW);
                {



                }


            }




I need to get reference of the toolItems like this one "Class":
http://img546.imageshack.us/i/recommend002.jpg

I tried many classes with no luck, all i get is the first tooltem "New" , but couldnot get the dropdown menu of the toolitem. glad to hear your tips how to do that.

Thanks for help
Amir
p.s iam writing a plug-in .

[Updated on: Thu, 24 March 2011 10:15] by Moderator

Re: Get Reference of ToolItems from the Main ToolBar [message #661522 is a reply to message #661382] Fri, 25 March 2011 01:02 Go to previous messageGo to next message
Eclipse UserFriend
On 24/03/11 6:58 PM, amir wrote:
> I need to get reference of the toolItems like this one "Class":
> http://img546.imageshack.us/i/recommend002.jpg/
>
> I tried many classes with no luck, all i get is the first tooltem "New"
> , but couldnot get the dropdown menu of the toolitem. glad to hear your
> tips how to do that.

Most probably your solution for the requirement is wrong. What is your
use case?

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Get Reference of ToolItems from the Main ToolBar [message #661576 is a reply to message #661522] Fri, 25 March 2011 09:21 Go to previous messageGo to next message
Eclipse UserFriend
what do you mean with "use case" ?
my purpose is to get noticed, print something, when i hover over menuItem from the drop down menu of the toolItem, for example New->Class, as picture before.
Re: Get Reference of ToolItems from the Main ToolBar [message #661823 is a reply to message #661576] Mon, 28 March 2011 02:43 Go to previous messageGo to next message
Eclipse UserFriend
On 25/03/11 6:51 PM, amir wrote:
> what do you mean with "use case" ? my purpose is to get noticed, print
> something, when i hover over menuItem from the drop down menu of the
> toolItem, for example New->Class, as picture before.
>

Did you try ArmListener?

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Get Reference of ToolItems from the Main ToolBar [message #661924 is a reply to message #661382] Mon, 28 March 2011 10:20 Go to previous messageGo to next message
Eclipse UserFriend
I'll also mention that this is using "internals" and won't work in
Eclipse SDK 4.x/Eclipse 4 at all.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Get Reference of ToolItems from the Main ToolBar [message #662032 is a reply to message #661924] Mon, 28 March 2011 19:46 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
Did you try ArmListener?

i will use that if i can get the reference to the toolitm.

Quote:
I'll also mention that this is using "internals" and won't work in
Eclipse SDK 4.x/Eclipse 4 at all.


what did you mean by internals?
for example to get menuItems i used this:
 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
		     if (window != null) {
		    	String command = "org.eclipse.ui.file.import"; 
		    //TODO menuBar
		    	shell = window.getShell();
		    	
		    	
		    	
		       Menu menuBar = window.getShell().getMenuBar();
 MenuItem File = menuBar.getItem(0);
		       
		       File.getMenu().addMenuListener(new MenuListener() {
..
..
..
}


i tried to use something similar to this with Toolitems, but with no luck....the menu = null; Sad

[Updated on: Mon, 28 March 2011 19:47] by Moderator

Re: Get Reference of ToolItems from the Main ToolBar [message #662115 is a reply to message #662032] Tue, 29 March 2011 08:06 Go to previous messageGo to next message
Eclipse UserFriend
On 03/28/2011 07:46 PM, amir wrote:
>
> Menu menuBar = window.getShell().getMenuBar();
> MenuItem File = menuBar.getItem(0);
> File.getMenu().addMenuListener(new MenuListener() {

We expose an IWorkbenchWindow for dealing with the workbench window.
That you can dig into the Shell and find a Menu is an implementation
detail, and we make no guarantees that it will work even within one
session (sometimes we dispose MenuItems and recreate them later).

It won't work reliably in 4.x because we take even more liberties with
the SWT widget lifecycles.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Get Reference of ToolItems from the Main ToolBar [message #663096 is a reply to message #662115] Sun, 03 April 2011 11:17 Go to previous messageGo to next message
Eclipse UserFriend
well....bad news for me. Confused
What about context menu (popup) of java editor/project explorer...?
do i have access to them for editing? or just allowed for contribution?

[Updated on: Sun, 03 April 2011 11:39] by Moderator

Re: Get Reference of ToolItems from the Main ToolBar [message #663245 is a reply to message #663096] Mon, 04 April 2011 08:38 Go to previous message
Eclipse UserFriend
On 04/03/2011 11:17 AM, amir wrote:
> well....bad new for me. :? What about context menu (popup) of java
> editor/project explorer...?
> do i have access to them for editing? or just allowed for contribution?

Just allowed for contribution. org.eclipse.ui.activities can be used to
hide some other contributions, but the SWT menu/menu items themselves
are not exposed (except to the implementing part itself).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Previous Topic:.epf file format
Next Topic:Helios 3.6.2 is slow and hangs often
Goto Forum:
  


Current Time: Tue Jul 01 18:45:00 EDT 2025

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

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

Back to the top