Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Getting the main Menu bar in Eclipse 3.3
Getting the main Menu bar in Eclipse 3.3 [message #332524] Sun, 26 October 2008 12:52 Go to next message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
I need to get the main menu bar from inside a custom view (not an
editor) to initialize an ActionBarContributor class. I know that inside
an editor I can use the ActionBarContributor in the plugin.xml and the
workbench will initialize it. I can also use the
getSite().getAcionBar() to get top menu and use that to initialize the
ActionBarContributor.
How can I get the same value and initialize a contributor in a View?
(the main reason it to get to the REDO/UNDO, File Save and etc).

Thanks
Yigal.
Re: Getting the main Menu bar in Eclipse 3.3 [message #332534 is a reply to message #332524] Mon, 27 October 2008 14:23 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What are you trying to do, exactly? The view actionbars don't have
access to the main menu, at least no commonly.

Are you trying to add some view actions to the main menu? You have a
couple of options, either using actionSets with an
actionSetPartAssociation or using org.eclipse.ui.menus and placing
commands that specifically deal with your view.

There is no API available to get the main menu or main coolbar.

--
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: Getting the main Menu bar in Eclipse 3.3 [message #332541 is a reply to message #332534] Mon, 27 October 2008 20:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yigal.spinner.comcast.net

Paul,
I want to use the basic "Edit" menu and plug in the REDO, UNDO, Cut and
etc actions.
In the EMF world they have EditingDomainActionBarContributor that switch
this values based on the editor. I want to duplicate the functionality
but for views.
In the EditingDomainActionBarContributor it gets initialized with the
top menu bar from the editor. Then each time the editor switches the
class uses the EditingDomian class to get the command stack and use it
in the menu.
I want to use the same command stack from EditingDoain, but in a view.
To implement that I need to top menu ActionBar reference.
I could not find any examples that show how to assign new action to the
Edit menu from a view. It is always using a popup menu or the view
action bar.

Yigal

Paul Webster wrote:
> What are you trying to do, exactly? The view actionbars don't have
> access to the main menu, at least no commonly.
>
> Are you trying to add some view actions to the main menu? You have a
> couple of options, either using actionSets with an
> actionSetPartAssociation or using org.eclipse.ui.menus and placing
> commands that specifically deal with your view.
>
> There is no API available to get the main menu or main coolbar.
>
Re: Getting the main Menu bar in Eclipse 3.3 [message #332543 is a reply to message #332541] Mon, 27 October 2008 22:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Yigal,

In the EMF newsgroup, there was some advice about how to do this in a
view; unfortunately I have no experience with views, other than views
like the outline which is a satellite to the editor.


Yigal Spinner wrote:
> Paul,
> I want to use the basic "Edit" menu and plug in the REDO, UNDO, Cut
> and etc actions.
> In the EMF world they have EditingDomainActionBarContributor that
> switch this values based on the editor. I want to duplicate the
> functionality but for views.
> In the EditingDomainActionBarContributor it gets initialized with the
> top menu bar from the editor. Then each time the editor switches the
> class uses the EditingDomian class to get the command stack and use it
> in the menu.
> I want to use the same command stack from EditingDoain, but in a view.
> To implement that I need to top menu ActionBar reference.
> I could not find any examples that show how to assign new action to
> the Edit menu from a view. It is always using a popup menu or the
> view action bar.
>
> Yigal
>
> Paul Webster wrote:
>> What are you trying to do, exactly? The view actionbars don't have
>> access to the main menu, at least no commonly.
>>
>> Are you trying to add some view actions to the main menu? You have a
>> couple of options, either using actionSets with an
>> actionSetPartAssociation or using org.eclipse.ui.menus and placing
>> commands that specifically deal with your view.
>>
>> There is no API available to get the main menu or main coolbar.
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting the main Menu bar in Eclipse 3.3 [message #332550 is a reply to message #332541] Tue, 28 October 2008 13:03 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Yigal Spinner wrote:
> Paul,
> I want to use the basic "Edit" menu and plug in the REDO, UNDO, Cut and
> etc actions.

In views you can activate handlers for the commands CUT/COPY/PASTE, etc:

IHandlerService handlerService
= (IHandlerService) getSite().getService(IHandlerService.class);
CopyHandler copyHandler = new CopyHandler(this);
handlerService.activateHandler(COPY_ID, copyHandler);

or use the view action bars to contribute an IAction:

IActionBars actionBar = getViewSite().getActionBars();
actionBar.setGlobalActionHandler(ActionFactory.COPY.getId(),
textCopyAction);

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:Automatically return from Debug Perspective
Next Topic:Re: Menu item accel key works only after menu item has been shown
Goto Forum:
  


Current Time: Tue Apr 23 13:57:34 GMT 2024

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

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

Back to the top