| 
| [commands] override a handler [message #337100] | Mon, 27 July 2009 21:43  |  | 
| Eclipse User  |  |  |  |  | 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 13:32   |  | 
| Eclipse User  |  |  |  |  | "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 10:15  |  | 
| Eclipse User  |  |  |  |  | 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
 
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03962 seconds