1

I have looked at this question Eclipse force handlers to to re-evaluate and the answer that Paul Webster provided. Why does this not work using the activeWhen element in the handler? It will only work if I change the following plug-in.xml to use the enabledWhen element. My particular command should no longer be enabled once the command has been run.

<handler
    commandId="org.eclipse.jpt.jpa.ui.xmlFileUpgradeToLatestVersion"
    class="org.eclipse.jpt.jpa.ui.internal.commands.UpgradeXmlFileVersionHandler">
        <activeWhen>
            <iterate ifEmpty="false">
                <or>
                    <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
                        <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
                    </adapt>
                    <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
                       <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
                    </adapt>
                </or>
            </iterate>
        </activeWhen>
</handler>

At the end of my handler execution I call:

IEvaluationService service = (IEvaluationService) activeWorkbenchWindow.getService(IEvaluationService.class);
service.requestEvaluation("org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion");

Update: I've done some more investigation and I see a regression in 4.2.1 as compared to 3.8.1. Even once I switch to use enabledWhen and use the call to requestEvaluation, I am still seeing the command in the quick access. I use the command via quick access, then immediately use the quick access again and I see the command still there and get a NotEnabledException if I click on it. This works fine with 3.8.1.

This particular command does not open a dialog, but I added a confirmation dialog and now my command is removed from the quick access! And this is without even using the IValuationService.requestEvaluation. Is the change in focus making the handler get re-evaluated?

Community
  • 1
  • 1
Karen Butzke
  • 1,442
  • 12
  • 18
  • So enabledWhen worked in 3.8.1 but not in 4.2.1? And activeWhen didn't work at all in either stream? – Paul Webster Nov 09 '12 at 14:04
  • That's right. I don't know about earlier streams, I'm just beginning to understand the command framework and we've only moved some of our old org.eclipse.ui.popupMenus extensions to it. – Karen Butzke Nov 09 '12 at 15:48

0 Answers0