Community
Participate
Working Groups
The CommandContributionItem does not set the command state object of ToggleState nor provide a mechanism to notify change of "checkedState" if menu and toolbutton style is TOGGLE. I think before the line "handlerService.executeCommand(command, event);" called, all the state objects with type of ToggleState and matching the id which has been defined in the extensionpoint "org.eclipse.ui.commands" should be updated with the state of "checkedState" or the menu and toolbar item provide the an extension point field for the toggle state id for the associated command. See: org.eclipse.ui.menus.CommandContributionItem Method: private void handleWidgetSelection(Event event) Code: if (openDropDownMenu(event)) return; if ((style & (SWT.TOGGLE | SWT.CHECK)) != 0) { if (event.widget instanceof ToolItem) { checkedState = ((ToolItem) event.widget).getSelection(); } else if (event.widget instanceof MenuItem) { checkedState = ((MenuItem) event.widget).getSelection(); } } try { >>>>> LEAKS checkedState to commands state objects <<<<<< handlerService.executeCommand(command, event); ....
I'm not sure what you mean by leak. There is only one command, and so only one checked state per command. PW
Create a Plugin and than add in the plugin following extensions: 1) a new command with a new ID and a state object of type ToggleState 2) a menu item which have style TOGGLE and associate it with the new command ID 3) a command handler which associate the new command ID. 4) in the command handler obtain the associated State object and query the state value. Run the plugin in Eclipse, put a break point in the command handlers execution method and click the new menu item. The check mark will be shown at the new menu item, but the state object which associated with the command, is still 'FALSE' (not checked). I mean the "checkedState" have not been updated in the commands state object. The second is there is one command - right - but it can be more than one state objects defined in the command extension. So you must associate the right state object with the menu- or toolbar item -or- all existing state objects wich have type ToggleState will be set to the state value of "checkedState". The other solution is to have an callback event so the user can update the state object by it self.
(In reply to comment #2) > > Run the plugin in Eclipse, put a break point in the command handlers execution > method and > click the new menu item. The check mark will be shown at the new menu item, but > the state object > which associated with the command, is still 'FALSE' (not checked). I mean the > "checkedState" > have not been updated in the commands state object. In the past it was the responsibility of the handler to update the model (which is the toggle state in this case), and keep it up to date unless Prakash has changed that behaviour with his improvements to checked and radio commands. > The second is there is one command - right - but it can be more than one state > objects > defined in the command extension. So you must associate the right state object > with > the menu- or toolbar item -or- all existing state objects wich have type > ToggleState > will be set to the state value of "checkedState". If you mean 2 different commands are sharing the same state object, that's bad, and needs to be fixed. But a menu item and tool item for the same command have the same state object. > The other solution is to have an callback event so the user can update the > state object > by it self. The handler is given opportunities to update information on UIElements (menu items and tool items) by implementing org.eclipse.ui.commands.IElementUpdater. That includes the checked state. PW
(In reply to comment #3) > (In reply to comment #2) > > > > Run the plugin in Eclipse, put a break point in the command handlers execution > > method and > > click the new menu item. The check mark will be shown at the new menu item, but > > the state object > > which associated with the command, is still 'FALSE' (not checked). I mean the > > "checkedState" > > have not been updated in the commands state object. > > In the past it was the responsibility of the handler to update the model (which > is the toggle state in this case), and keep it up to date unless Prakash has > changed that behaviour with his improvements to checked and radio commands. That still holds good. When the change is done in the UI (menu/tool item clicked), the propagation of the change to the model (updating the command state) should be done by the handler. http://wiki.eclipse.org/Menu_Contributions/Toggle_Button_Command http://wiki.eclipse.org/Menu_Contributions/Radio_Button_Command
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.