Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Menu extensions
Menu extensions [message #331395] Thu, 04 September 2008 16:57 Go to next message
Richard Craddock is currently offline Richard CraddockFriend
Messages: 31
Registered: July 2009
Member
I'm having some trouble with menus/commands..

What I want to do is have some menu items (commands) "disabled" - ie
greyed out - when the current selection is not a suitable object for those
actions.

I have created a simple expression:
<extension
point="org.eclipse.core.expressions.definitions">
<definition

id="org.eclipse.tigerstripe.workbench.ui.base.TSProjectSelected ">
<iterate>
<adapt
type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.projectNature"

value="org.eclipse.tigerstripe.workbench.base.tigerstripeProject ">
</test>
</adapt>
</iterate>
</definition>
</extension>

I know this works because I can use to make a menu entry disappear
(although that's not really what I want to do...):

<menu id="org.eclipse.tigerstripe.ui.main.menu.import"
label="Import...">
<visibleWhen
checkEnabled="false">
<reference
definitionId="org.eclipse.tigerstripe.workbench.ui.base.TSProjectSelected ">
</reference>
</visibleWhen>
</menu>

But if I try to use it to disable my commands then they get greyed out and
never come back..

<extension point="org.eclipse.ui.handlers">
<handler

class=" org.eclipse.tigerstripe.workbench.ui.internal.handlers.Tiger stripeCommandHandler "
commandId="org.eclipse.tigerstripe.workbench.ui.base.generate ">
<enabledWhen>
<reference

definitionId="org.eclipse.tigerstripe.workbench.ui.base.TSProjectSelected ">
</reference>
</enabledWhen>
</handler>
</extension>


I guess I am missing a step somewhere but can't quite work out what it
is...
My Handler is very basic at the moment - it only implements the
execute(..) command.

Can anyone point me in the right direction?

Thanks in advance,

Richard
Re: Menu extensions [message #331398 is a reply to message #331395] Thu, 04 September 2008 17:58 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Using org.eclipse.ui.handlers seems to be heading the right direction.

Some things I can think of: Make sure your command doesn't declare a
default handler. Are your menu contributions in the main menu or in a
popup?

What if you put your core expression definition directly in the enabledWhen?


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: Menu extensions [message #331402 is a reply to message #331398] Thu, 04 September 2008 18:51 Go to previous message
Richard Craddock is currently offline Richard CraddockFriend
Messages: 31
Registered: July 2009
Member
Hi Paul,

I did have a defaultHandler, and removing it made this work correctly!

The defaultHandler was actually the same class as my handler, so I'm a
little confused but at least I seem to abe to make things work correctly
now!

Many thanks

Richard

Paul Webster wrote:

> Using org.eclipse.ui.handlers seems to be heading the right direction.

> Some things I can think of: Make sure your command doesn't declare a
> default handler. Are your menu contributions in the main menu or in a
> popup?

> What if you put your core expression definition directly in the enabledWhen?


> PW
Previous Topic:Value returned by IConfigurationElement.getAttribute() was not translated
Next Topic:uitest throws ClassCastException
Goto Forum:
  


Current Time: Fri Oct 18 10:50:55 GMT 2024

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

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

Back to the top