Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [commands] override a handler
[commands] override a handler [message #337100] Tue, 28 July 2009 01:43 Go to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
I'm writing a plugin (for RCP applications), and I need to launch two
different versions of a wizard, depending on whether the workspace
(org.eclipse.core.resources) bundle is available. Currently, my setup is:

com.example - defines view, a basic wizard, a command and a handler that
launches the basic wizard
com.example.resources - defines a more advanced resource-aware wizard, and a
handler that launches it

The goal is to be able to use the first plug-in stand alone, and drop in the
second if the RCP application uses the workspace and wants the added
functionality.

I have been investigating the activeWhen condition for handlers and have
succeeded by creating a dummy property tester and adding it to the
enablement condition in the com.example.resources handler. It seems that a
condition with "and(A, B)" gets higher priority than "A" by itself, even if
"B" is a dummy test.

I am wondering if this is a valid/supported approach or if there are better
ways to do this. Is there a way to add a simple true branch in a condition
that would avoid the property tester?

Thanks,
Will
Re: [commands] override a handler [message #369120 is a reply to message #337100] Tue, 28 July 2009 17:32 Go to previous messageGo to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
"Will Horn" <will.horn@gmail.com> wrote in message
news:h4ll4f$ujn$1@build.eclipse.org...
> I'm writing a plugin (for RCP applications), and I need to launch two
> different versions of a wizard, depending on whether the workspace
> (org.eclipse.core.resources) bundle is available. Currently, my setup is:
>
> com.example - defines view, a basic wizard, a command and a handler that
> launches the basic wizard
> com.example.resources - defines a more advanced resource-aware wizard, and
> a handler that launches it
>
> The goal is to be able to use the first plug-in stand alone, and drop in
> the second if the RCP application uses the workspace and wants the added
> functionality.
>
> I have been investigating the activeWhen condition for handlers and have
> succeeded by creating a dummy property tester and adding it to the
> enablement condition in the com.example.resources handler. It seems that
> a condition with "and(A, B)" gets higher priority than "A" by itself, even
> if "B" is a dummy test.
I spoke to soon - this does NOT work. I was looking at the wrong thing and
upon further investigation the two handlers do still conflict. So I do not
have a solution and would appreciate any suggestions.

Thanks,
Will
Re: [commands] override a handler [message #452802 is a reply to message #337100] Sat, 01 August 2009 14:15 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In activeWhen, conflicts are resolved using priorities based on the information in org.eclipse.ui.ISources (i.e. with variable="selection", with variable="activeEditorId")

You can test if org.eclipse.core.resources is available using the provide property tester:

<with variable="org.eclipse.core.runtime.Platform">
<or>
<test property="org.eclipse.core.runtime.bundleState" args......value.../>
<test property="org.eclipse.core.runtime.bundleState" args......value.../>
</or>
</with>

See http://wiki.eclipse.org/Command_Core_Expressions

You can either put the test in both handlers (so that one will be active if it is available and one will be active if it is *not* available) or add an extra variable check to the second handler. (something like activeShell instanceof Object) in an *and*.

PW


Previous Topic:show a view from a LaunchDelegate
Next Topic:Best way to listen to context activation/deactivation
Goto Forum:
  


Current Time: Fri Apr 19 03:24:25 GMT 2024

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

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

Back to the top