Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 174684 - [Contributions] handler not activated using <activeWhen> clause
Summary: [Contributions] handler not activated using <activeWhen> clause
Status: VERIFIED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 150652
  Show dependency tree
 
Reported: 2007-02-19 15:24 EST by Darin Wright CLA
Modified: 2007-05-01 12:02 EDT (History)
2 users (show)

See Also:


Attachments
Active Handler project v01 (2.78 KB, application/octet-stream)
2007-02-19 20:13 EST, Paul Webster CLA
no flags Details
active handler example (4.23 KB, application/x-zip-compressed)
2007-04-24 15:20 EDT, Susan McCourt CLA
no flags Details
active handler example v03 (3.52 KB, application/octet-stream)
2007-04-24 19:22 EDT, Paul Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Wright CLA 2007-02-19 15:24:07 EST
Using I20070213-0907, and the fix to bug 171079, I have a handler with <activeWhen> and <enabledWhen> clauses that is not enabling when it should.

The handler should be enabled when the active part is NOT the snippet editor, and there is an available execution context (for a debugger evaluation). The contribution looks like the following:

<extension
       point="org.eclipse.ui.handlers">
    <handler
          class="org.eclipse.jdt.internal.debug.ui.evaluation.ForceReturnHandler"
          commandId="org.eclipse.jdt.debug.ui.commands.ForceReturn">
       <activeWhen>
 		  <with
                variable="activePartId">
                <not>
                <equals
                      value="org.eclipse.jdt.debug.ui.SnippetEditor">
                </equals>
                </not>
          </with>
       </activeWhen>
       <enabledWhen>
          <with
                variable="activeContexts">
             <test
                   property="org.eclipse.jdt.debug.ui.contains"
                   value="org.eclipse.jdt.debug.ui.evaluation">
             </test>
          </with>       
       </enabledWhen>
    </handler>
 </extension>

NOTES:
- when I remove the <not> clause for the SnippetEditor, and exchange it for an "equals specific part" clause, the active/enabled states work as expected. It seems that as soon as I insert the "not", the handler is never considered to be active.
- If I swap <active/enabledWhen> states (i.e. active when there is a context, and enabled when not in the snippet editor), it works (but that's not the behavior I want, since I want a different handler for the snippet editor).

I can attach a patch of the work in progress if needed.
Comment 1 Paul Webster CLA 2007-02-19 20:13:54 EST
Created attachment 59338 [details]
Active Handler project v01

First test project
PW
Comment 2 Susan McCourt CLA 2007-04-09 20:21:47 EDT
I'll see what I can do with this one...
Comment 3 Susan McCourt CLA 2007-04-24 15:20:19 EDT
Created attachment 64780 [details]
active handler example

Darin - I'm trying to come up with a simple case that will demonstrate the problem, and so far have had no luck.  Attached is a project with a sample handler that is active when the active part is NOT a java editor and enabled when the coolbar is visible.  

This works as expected, so I suppose it proves that <activeWhen> with a <not> clause on a specific part works as expected, and can work in conjunction with an enabledWhen expression.  

So I would guess the real problem is some subtlety in the enabledWhen expression.  Can you double check that your property tester is enabling correctly or otherwise comment on how your case might be different...
Comment 4 Susan McCourt CLA 2007-04-24 15:30:16 EDT
Darin, if you feel confident that your enabledWhen expression is reasonable, then just attach the code that demonstrates your specific problem and I'll dig further.
Comment 5 Paul Webster CLA 2007-04-24 19:22:26 EDT
Created attachment 64802 [details]
active handler example v03

I did a quick test with an expression that included a property tester.  It depends on having platform-ui-tests checked out into the workspace.  It works as one would expect.

I suspect that this problem was fixed end of Feb with bug 171079, prior to that it was not reliably updated.

PW
Comment 6 Darin Wright CLA 2007-04-24 22:10:26 EDT
I no longer have the work in progress - it was abandonned. If you think the problem is fixed, please mark it as such. It looks like we will not be migrating to the new action support until 3.4. If we find new problems we will open bugs then.

Thanks.
Comment 7 Susan McCourt CLA 2007-04-25 11:39:57 EDT
marking WORKSFORME
Comment 8 Susan McCourt CLA 2007-05-01 12:02:36 EDT
verified that it is working in Win XP, I20070430-0800