Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to enable a menuitem by default
how to enable a menuitem by default [message #505075] Sat, 26 December 2009 07:52 Go to next message
R.Afonso is currently offline R.Afonso
Messages: 10
Registered: December 2009
Junior Member
Hi,
I´m starting on Eclipse RCP and I try to create a simple menuitem to close the window:

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="fileMenu"
label="File">
<command
commandId="firstapp.Exit"
label="Exit"
style="push"
tooltip="Exit the app">
</command>
</menu>
</menuContribution>
</extension>

The menuitem Exit appears in the "File" menu but it´s disabled. Anything missing?
Re: how to enable a menuitem by default [message #505095 is a reply to message #505075] Sat, 26 December 2009 13:59 Go to previous messageGo to next message
Lars Vogel is currently offline Lars Vogel
Messages: 1049
Registered: July 2009
Senior Member

Hi,

how to add an Exit command (and lots of other stuff) is described here:
http://www.vogella.de/articles/EclipseCommands/article.html

In your case you most likely missing the handler.

Best regards, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter

On 26.12.2009 04:52, raff wrote:
> Hi, I´m starting on Eclipse RCP and I try to create a simple menuitem to
> close the window:
>
> <extension
> point="org.eclipse.ui.menus">
> <menuContribution
> locationURI="menu:org.eclipse.ui.main.menu">
> <menu
> id="fileMenu"
> label="File">
> <command
> commandId="firstapp.Exit"
> label="Exit"
> style="push"
> tooltip="Exit the app">
> </command>
> </menu>
> </menuContribution>
> </extension>
>
> The menuitem Exit appears in the "File" menu but it´s disabled. Anything
> missing?
Re: how to enable a menuitem by default [message #505285 is a reply to message #505095] Tue, 29 December 2009 00:17 Go to previous messageGo to next message
R.Afonso is currently offline R.Afonso
Messages: 10
Registered: December 2009
Junior Member
Hi,
in fact I was following one of your tutorials Smile. Nice work!

I found the problem, the code automatically generated by Eclipse for the handler returns false in isEnabled() and isHandled() functions.

Thanks
Re: how to enable a menuitem by default [message #505474 is a reply to message #505285] Wed, 30 December 2009 19:38 Go to previous messageGo to next message
Lars Vogel is currently offline Lars Vogel
Messages: 1049
Registered: July 2009
Senior Member

Hello,

good to hear that you solved the problem. In case my tutorial was
incorrect, please report it: http://groups.google.com/group/vogella

Best regards, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter

On 28.12.2009 21:17, R.Afonso wrote:
> Hi,
> in fact I was following one of your tutorials :). Nice work!
>
> I found the problem, the code automatically generated by Eclipse for the
> handler returns false in isEnabled() and isHandled() functions.
>
> Thanks
Re: how to enable a menuitem by default [message #505939 is a reply to message #505285] Tue, 05 January 2010 10:28 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

R.Afonso wrote:
> Hi,
> in fact I was following one of your tutorials :). Nice work!
>
> I found the problem, the code automatically generated by Eclipse for the
> handler returns false in isEnabled() and isHandled() functions.

Please make sure you subclass AbstractHandler (instead of implementing
IHandler directly)

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:How to close a view?
Next Topic:Website for book Eclipse Rich Client Platform: Designing, Coding, and Packaging Java Applications se
Goto Forum:
  


Current Time: Sat Aug 30 04:43:42 EDT 2014

Powered by FUDForum. Page generated in 0.02556 seconds