Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315328

Summary: HandledMenuItems should respond to enabled state
Product: [Eclipse Project] e4 Reporter: Paul Webster <pwebster>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact: Paul Webster <pwebster>
Severity: normal    
Priority: P3 CC: emoffatt, ob1.eclipse, remy.suen
Version: 1.0   
Target Milestone: 1.0 RC0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Enabled Menu Items v02
none
Enabled Menu Items v03 none

Description Paul Webster CLA 2010-06-01 20:45:43 EDT
Created attachment 170728 [details]
Enabled Menu Items v02

My HandledMenuItem should query the command to see if it is disabled or enabled.

The attachment only works on createGui(*), it won't respond to changes.

PW
Comment 1 Paul Webster CLA 2010-06-01 21:06:10 EDT
Created attachment 170731 [details]
Enabled Menu Items v03

This creates a run and track that keeps the widget up to date.

PW
Comment 2 Paul Webster CLA 2010-06-01 21:08:18 EDT
(In reply to comment #1)
> Created an attachment (id=170731) [details]
> Enabled Menu Items v03


Released to HEAD >20100601

The alternate to this would be if MenuItems were managed more in conjunction with their SWT Menu parent and SWT.Show and SWT.Hide.

no one is looking at this AFAIK.

PW
Comment 3 Paul Webster CLA 2010-06-02 08:05:57 EDT
Oleg, I've created a RunAndTrack that has code that looks like:

public boolean changed(IEclipseContext context) {
EHandlerService service = lclContext
		.get(EHandlerService.class);
ParameterizedCommand cmd = item.getWbCommand();
if (cmd == null) {
	cmd = generateParameterizedCommand(item, lclContext);
}
if (cmd == null) {
	return false;
}
item.setEnabled(service.canExecute(cmd));
}

The service.canExecute(*) will use lclContext to find the appropriate handler.  With the changes you made will this be updated when a context activeChild changes and a new handler is selected?

PW
Comment 4 Eric Moffatt CLA 2010-06-02 09:09:57 EDT
Committed in >20100602. Allied a clone of the patch to the ToolItemRenderer.
Comment 5 Paul Webster CLA 2010-06-21 13:32:02 EDT
Released to RC0