Trigger evaluation of PropertyTester

The code from two years back had to be upgraded to E4, and now a bunch of stuff does not work anymore. One of these is the IEvaluationService if used like this:

<handler class="org.acme.PrintHandler" commandId="org.eclipse.ui.file.print">
  <activeWhen>
    <with variable="activePart">
      <test property="org.acme.printable" />
    </with>
  </activeWhen>
</handler>
IEvaluationService service = (IEvaluationService) PlatformUI.getWorkbench().getService(IEvaluationService.class);
service.requestEvaluation("org.acme.printable");

How do I (re)trigger the evaluation of a PropertyTester? Since E4 is really not even close to being production ready, I need a workaround for E3 (compatibility layer).

Related question - but this user was searching for the equivalent in E4, while I need one that works in E3.

Funnily enough, if I replace the <activeWhen> tags with <enabledWhen> it works. In that case IEventBroker#post and IEventBroker#send work, too.

This is a similar question. That user used Eclipse 4.2 - I tested the problem with 4.5, 4.6 and 4.7.

The EvaluationService is API compatible in the E3 Compatibility Layer. But the implementation in E4 is completely different, causing the behaviour of requestEvaluation to be fundamentally different.

The best solution to this problem I could find is to manually deactivate and activate all contexts of currently active parts. This causes internally to re-evaluate and, when required, re-render all UI elements of the respective parts.

One could argue this is less efficient than requesting the evaluation of a very specific property, as the EvaluationService is supposed to do. But since the evaluation is limited to active parts only, it should not create too much overhead. And it does work globally, as no specific property string is required anymore.

The only usecase not covered by this yet may be the main toolbar of your RCP application.

/**
 * Triggers evaluation of all UI elements (buttons, etc.) of the active part.
 * Also causes test of all property testers of all opened parts implicitly.
 * Workaround of the broken <code>IEvaluationService.requestEvaluation</code>.
 */
public static void triggerUIElementsEvaluation() {
    try {
        final EPartService partService = PlatformUI.getWorkbench().getService(EPartService.class);
        final MPart activePart = partService.getActivePart();

        /* Toggle context of active part to trigger re-evaluation of its UI elements. */
        if (activePart != null) {
            activePart.getContext().deactivate();
            activePart.getContext().activateBranch();
        }
    } catch (IllegalStateException e) {
        /* Ignore "Application does not have an active window" exception to allow program to continue. */
    }
}

eclipse plugin - Trigger evaluation of PropertyTester, The EvaluationService is API compatible in the E3 Compatibility Layer. But the implementation in E4 is completely different, causing the behaviour of  One could argue this is less efficient than requesting the evaluation of a very specific property, as the EvaluationService is supposed to do. But since the evaluation is limited to active parts only, it should not create too much overhead. And it does work globally, as no specific property string is required anymore.

I'm going to share my workaround, which is not good, and does not work in alles cases. And only really works because in my use case I have a IWorkbenchPart with an ISelectionProvider... but maybe it will help the next person:

IWorkbenchPart activePart = // get active view or editor
ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider();
ISelection selection = selectionProvider.getSelection();
selectionProvider.setSelection(new StructuredSelection());
selectionProvider.setSelection(selection);

This code just resets the selection, which normally triggers the PropertyTester. I don't think it'll work if nothing was selected.

Rich Client Platform (RCP , getWorkbench().getService(IEvaluationService.class); service.requestEvaluation(​"org.acme.printable");. How do I (re)trigger the evaluation of a PropertyTester ? Evaluate a tester's understanding of the various testing techniques available and knowledge of which technique is the most effective for the task at hand. An evaluation of tester effectiveness can be based on a review of the test artifacts.

eventBroker.post(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, UIEvents.ALL_ELEMENT_ID);

See also Eclipse bug 436755 and Eclipse Wiki: Eclipse 4 - RCP - Event Model

Uses of Class org.eclipse.core.expressions.PropertyTester, I first thought that the problem might be that my property tester is produces a String which is evaluated via <equals> in the plugin.xml. Reevaluation is now triggered in the Source Providers as well via fireSourceChanged(). Trigger evaluation of PropertyTester. The code from two years back had to be upgraded to E4, and now a bunch of stuff does not work anymore.

Triggers and Trigger Tools, Trigger evaluation of PropertyTester. The code from two years back had to be upgraded to E4, and now a bunch of stuff does not work anymore. One of these is​  Your appraiser will look at the front and back of your home and will evaluate whether there are any visual signs of damage or other red flags that could decrease it’s value. Determine the visual desirability of your location: Your appraiser will make note of your home’s immediate surroundings.

28. Metaprogramming with proxies, Uses of PropertyTester in org.eclipse.debug.internal.ui.actions ResourceExtender provides property testers for the XML expression language evaluation. If any assumptions change or there is a further impairment trigger at the year end, the calculation is required to be updated. Example 2 Entity B, a nightclub operator, has a year end of 28 February 2009 and has goodwill relating to a number of acquisitions on its balance sheet. Management normally prepares the impairment test as at the year

Overview (Eclipse Platform API Specification), Triggers alert patient safety personnel to possible adverse events so they can and their familiarity with the clinical setting being evaluated. Working with Test Triggers gives us the peace of mind that our site is always being put to the test to increase conversions.” Terrence Brown Director of Marketing, Mossy Oak Graphics Featured Offerings

Comments
  • This does only work for the tag <enabledWhen>, not <activeWhen>. But the IEvaluationService works for <enabledWhen> as well.