Community
Participate
Working Groups
Created attachment 114073 [details] RCP Application with the descriped behavior I tried to change the visibility of a menuContribution (menu and viewtoolbar) dynamically at runtime. Therefore I made a menuContribution which is visible when it is enabled (checkedEnabled on visibleWhen expression). But it seems to work only in one direction. When it is disabled (because the only handler is disabled) it disappears. Great! But when it is enabled it does not come back.
Created attachment 117527 [details] Patch v01 If there is no need to show the command item in the tool bar, the widget is disposed. Any further changes on the command are processed only after widget==null check is performed. In this case, even if the command is enabled again, since the widget will be null, its not processed. Fix: When processing the changes in command, when the widget == null && command is visible, recreate the widget. Patch attached.
(In reply to comment #1) > Created an attachment (id=117527) [details] > Patch v01 Given that we still have to protect ourselves from non-UI thread events, I would suggest: 1) let's get rid of the widget from the beginning of that call Use org.eclipse.ui.internal.services.IWorkbenchLocationService.getWorkbench() to get the workbench and org.eclipse.ui.IWorkbench.getDisplay() to get the display. You can do it in the constructor and cache it, I guess. 2) Then I guess in the Runnable we just swap the "if (commandEvent.isEnabledChanged() ..." block with the "if (commandEvent.getCommand().isDefined()) {..." block. Would that keep the current code working and also allow the new usecase to work? PW
Created attachment 118764 [details] Patch v02 (In reply to comment #2) > Would that keep the current code working and also allow the new usecase to > work? Yes. Esp 1) sounds like a much better option. All the tests ran fine with the modifications. Attached the patch
Released to HEAD >20081201 PW
*** Bug 249445 has been marked as a duplicate of this bug. ***
Verified in I20081208-1800
*** Bug 252597 has been marked as a duplicate of this bug. ***