Bug 425965 - Request reevaluation of the @CanExecute method of the handlers in RCP applications
Summary: Request reevaluation of the @CanExecute method of the handlers in RCP applica...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 385394
Blocks:
  Show dependency tree
 
Reported: 2014-01-17 05:15 EST by Lars Vogel CLA
Modified: 2020-12-16 16:09 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2014-01-17 05:15:00 EST
The fix in Bug 385394 replaced the 400 ms TimerTask which evaluated the @CanExecute methods of the handlers with an event system based on IEclipseContext changes.

In RCP apps the handler state, may depend on a state outside the context, we should have a way to trigger the evaluation.

Quote from Bug 385394:
---------------
> E.g. button "Load server data" should be active if new data on the server is
> available?

You'll have to open a new bug for that.  For Eclipse4 in theory you can set the "org.eclipse.ui.internal.services.EvaluationService.evaluate" variable to Boolean.TRUE or FALSE on the MApplication IEclipseContext, but that's not been formalized and it probably should be.

In the Workbench, re-evaluation can be requested using the IEvaluationService. 

-------------

Maybe the IEvaluationService can be moved to be an IDE independend service?
Comment 1 Lars Vogel CLA 2016-12-06 15:33:27 EST
Possible via sending out an event.
Comment 2 Wim Jongman CLA 2020-12-16 15:38:15 EST
(In reply to Lars Vogel from comment #1)
> Possible via sending out an event.

Is there a special event that needs to be sent?
Comment 3 Wim Jongman CLA 2020-12-16 16:09:09 EST
(In reply to Wim Jongman from comment #2)
> (In reply to Lars Vogel from comment #1)
> > Possible via sending out an event.
> 
> Is there a special event that needs to be sent?

I did some debugging and this works like a charm:

/**
 * Update handlers enablement
 */
public static void updateHandlerEnablement() {
     IEventBroker broker = getContext().get(IEventBroker.class);
     broker.post("org/eclipse/e4/ui/renderer/requestEnablementUpdate", null);
}