| Summary: | [Contributions] Visibility of menu items not correct after perspective change | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Dirk Wenke <wenke> |
| Component: | UI | Assignee: | Platform UI Triaged <platform-ui-triaged> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | prasad0612, pwebster, rsbecker |
| Version: | 3.5 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
Sorry, I forgot the Build ID Build Identifier: I20090611-1540 The issue here is if a part is already active so it doesnot fire partActivated event.If you see WorkbenchSourceProvider.java it has a partListner which calls checkActivePart() API.In order to get correct context menus this API needs to be called.It also has a perspectiveActivate listner which fails to get proper selection because it doesnot have information of ActivePart (Code error).
To work around this add PerspectiveActivated listner to your code and place following code in it.
Display.getDefault().asyncExec( new Runnable()
{
@Override
public void run()
{
final ISourceProviderService service = (ISourceProviderService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(
ISourceProviderService.class );
final ISourceProvider provider = service.getSourceProvider( ISources.SHOW_IN_SELECTION );
if( provider instanceof WorkbenchSourceProvider )
{
( (WorkbenchSourceProvider) provider ).checkActivePart();
}
}
} );
It is called in display to introduce a delay so that it is called after perspectiveActivated listener in WorkbenchSourceProvider.
:)
If you'd consider a patch we could get this in. See http://wiki.eclipse.org/Platform_UI/How_to_Contribute PW While this fix works in different circumstances, including our own views, the WorkbenchSourceProvider is part of org.eclipse.ui.internal.services, which is restricted. I would suggest abstracting this out to a new interface (say IWorkbenchSourceProvider) where checkActivePart() is visible. 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. |
User-Agent: Opera/9.80 (Windows NT 6.1; U; de) Presto/2.2.15 Version/10.10 Build Identifier: If you define a menu item for the context menu of a view and this view is used in more than one perspective, the visibility/enablement of the item is not working correctly after a perspective switch. Reproducible: Always Steps to Reproduce: 1.Create a small plugin with the following extension: <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="popup:org.eclipse.ui.views.ResourceNavigator?after=org.eclipse.ui.RefreshAction"> <command commandId="org.eclipse.ui.file.refresh" label="MyRefresh" style="push"> <visibleWhen checkEnabled="false"> <iterate ifEmpty="false" operator="and"> <instanceof value="org.eclipse.core.resources.IResource"> </instanceof> </iterate> </visibleWhen> </command> </menuContribution> </extension> 2. Start a runtime workbench 3. Open the resource navigator in two different perspectives 4. Select a file in the resource navigator and invoke the context menu => the "MyRefresh" entry should be visible 5. Switch to the other perspective, the resource navigator should already be the active part. 6. Invoke the context menu again (do not select another item). => The menu item is not shown. Seems like the selection gets lost internally when switching the perspective.