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

Bug 320283

Summary: Menu "Build Automatically" missing checkmark
Product: [Eclipse Project] e4 Reporter: Oleg Besedin <ob1.eclipse>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: deepakazad, john.arthorne, pinnamur, pwebster, remy.suen
Version: 1.0   
Target Milestone: 4.1 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed Patch none

Description Oleg Besedin CLA 2010-07-19 11:33:01 EDT
The Project -> Build Automatically menu item is missing a checkmark. 

When the menu item selected, the auto-build appears to properly switch to "off" state, but the menu now shows the checkmark.
Comment 1 Remy Suen CLA 2010-07-23 19:46:53 EDT
For this particular case, we need to get the action's check state and set it into the model when creating menu items out of MenuHelper.
Comment 2 Paul Webster CLA 2010-07-23 19:51:55 EDT
How do we keep it up to date? For commands?  For pure actions?

PW
Comment 3 Remy Suen CLA 2010-07-23 20:27:40 EDT
(In reply to comment #2)
> How do we keep it up to date? For commands?

Do we have an MCommand for every regular Command? Since we have execution listeners in 3.x, maybe we could use the event bus for MCommand executions. Or maybe not since even the ECommandService itself deals with Commands instead of MCommands.

> For pure actions?

Probably have to resort to good ol' IPropertyChangeListeners for this one.
Comment 4 Deepak Azad CLA 2010-09-20 11:21:09 EDT
I also noticed a similar problem in 'Edit > Smart Insert Mode' where the checkmark is never present!
Comment 5 John Arthorne CLA 2010-10-26 16:58:45 EDT
Note the checkmark can appear in 4.1 (I20101026-0203), but it is inverted:

Checked = build is disabled
Unchecked = build is enabled

Is the problem just with initializing the checkmark to be correct at startup, but the toggling behaviour works?
Comment 6 Praveen CLA 2011-02-07 07:44:00 EST
(In reply to comment #5)
> Is the problem just with initializing the checkmark to be correct at startup,
> but the toggling behaviour works?

The problem is with initializing the checkmark at start-up. Otherwise, toggling works :)
Comment 7 Praveen CLA 2011-02-07 09:21:11 EST
I had a quick look into the source code to investigate this problem. I could verify that workspace preferences are set correctly.

However, when MenuHelper creates the HandledMenuItemImpl of type ItemType.CHECK (for 'Build Automatically' action, or may be for any action), it does *not* fetch the selection state from Action and does not set it to that item. So when ever the menu items are created, the menu manager returns the default selection state (ie., false) initially.

I guess the fix would be to change the code of MenuHelper.createItem(..,ActionContributionItem) to invoke setSelected(action.isChecked()) at the time MenuHelper creates the HandledMenuItemImpl for the type ItemType.CHECK or ItemType.RADIO
Comment 8 Praveen CLA 2011-03-03 04:00:38 EST
Created attachment 190247 [details]
Proposed Patch

The attached patch contain code changes that would fix the missing checkmark either with Build Automatically, or Smart Insert Mode, or any menu item that has to be selected during start-up.
Comment 9 Paul Webster CLA 2011-03-03 07:55:02 EST
Thanx Praveen, committed.
PW