Bug 186344 [CommonNavigator] Project Explorer duplicates Working Set actions
M7 The Project Explorer sometimes creates duplicate Working Set related view menu items. This seems to be triggered by "Link with Editor" on startup where two instances of WorkingSetActionProvider are created and initialized. The following is a stack trace at the point where the WorkingSetActionProvider adds its actions. Note the recursion starting in NavigatorActionService.getActionProviderInstance() Thread [main] (Suspended (breakpoint at line 277 in WorkingSetActionProvider)) owns: HashMap<K,V> (id=142) owns: RunnableLock (id=143) WorkingSetActionProvider.fillActionBars(IActionBars) line: 277 NavigatorActionService.initialize(String, CommonActionProvider) line: 353 NavigatorActionService.getActionProviderInstance(CommonActionProviderDescriptor) line: 332 NavigatorActionService.fillActionBars(IActionBars) line: 236 CommonNavigatorManager.selectionChanged(SelectionChangedEvent) line: 217 Viewer$2.run() line: 162 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 46 SafeRunnable.run(ISafeRunnable) line: 193 CommonViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 160 CommonViewer(StructuredViewer).updateSelection(ISelection) line: 2039 CommonViewer(StructuredViewer).handleInvalidSelection(ISelection, ISelection) line: 1102 CommonViewer(StructuredViewer).preservingSelection(Runnable, boolean) line: 1376 CommonViewer(TreeViewer).preservingSelection(Runnable, boolean) line: 377 CommonViewer(StructuredViewer).preservingSelection(Runnable) line: 1325 CommonViewer(AbstractTreeViewer).inputChanged(Object, Object) line: 1417 CommonViewer(ContentViewer).setInput(Object) line: 251 CommonViewer(StructuredViewer).setInput(Object) line: 1601 WorkingSetActionProvider.restoreState(IMemento) line: 237 NavigatorActionService.initialize(String, CommonActionProvider) line: 350 NavigatorActionService.getActionProviderInstance(CommonActionProviderDescriptor) line: 332 NavigatorActionService.fillActionBars(IActionBars) line: 236 CommonNavigatorManager.selectionChanged(SelectionChangedEvent) line: 217 Viewer$2.run() line: 162 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 46 SafeRunnable.run(ISafeRunnable) line: 193 CommonViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 160 CommonViewer(StructuredViewer).updateSelection(ISelection) line: 2039 CommonViewer(StructuredViewer).setSelection(ISelection, boolean) line: 1636 CommonViewer(TreeViewer).setSelection(ISelection, boolean) line: 1031 CommonViewer.setSelection(ISelection, boolean) line: 325 CommonNavigator.selectReveal(ISelection) line: 313 LinkEditorAction$2.runInUIThread(IProgressMonitor) line: 91 UIJob$1.run() line: 94 [...]
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/NavigatorActionService.java
* extension point.
 * </p>
 * <p>
 * A {@link CommonActionProvider} has opportunities to contribute to the context menu and
 * {@link org.eclipse.ui.IActionBars} whenever the selection in the viewer changes. Action Providers
 * are selected based on the enablement expressions of their associated content extension or their
 * own enablement expression if it is declared as a top-level &lt;actionProvider /&gt; element (of
 * the <b>org.eclipse.ui.navigator.navigatorContent</b> extension point). See the schema
 * documentation of <b>org.eclipse.ui.navigator.navigatorContent</b> for more information on how to
 * specify an Action Provider.
 * </p>
 * <p>
 * Clients that reuse this service outside of an instance of {@link CommonNavigator} must be sure
 * that {{@link #fillActionBars(IActionBars)} is called whenever the selection changes. The
 * retargetable actions for each selection could change, based on who contributed the items.
 * 
 * @since 3.2
 * 
 */
public final class NavigatorActionService extends ActionGroup implements IMementoAware {
	private static final IContributionItem[] DEFAULT_GROUPS = new IContributionItem[]{new Separator(ICommonMenuConstants.GROUP_NEW), new GroupMarker(ICommonMenuConstants.GROUP_GOTO), new GroupMarker(ICommonMenuConstants.GROUP_OPEN), new GroupMarker(ICommonMenuConstants.GROUP_OPEN_WITH), new Separator(ICommonMenuConstants.GROUP_EDIT), new GroupMarker(ICommonMenuConstants.GROUP_SHOW), new GroupMarker(ICommonMenuConstants.GROUP_REORGANIZE), new GroupMarker(ICommonMenuConstants.GROUP_PORT), new Separator(ICommonMenuConstants.GROUP_GENERATE), new Separator(ICommonMenuConstants.GROUP_SEARCH), new Separator(ICommonMenuConstants.GROUP_BUILD), new Separator(ICommonMenuConstants.GROUP_ADDITIONS), new Separator(ICommonMenuConstants.GROUP_PROPERTIES)};
	private final ICommonViewerSite commonViewerSite;
	private final StructuredViewer structuredViewer;
	private final NavigatorContentService contentService;
	private final INavigatorViewerDescriptor viewerDescriptor;
	private final Set actionProviderDescriptors = new HashSet();
	/*
	 * Map of CommonActionProviderDescriptors to CommonActionProviders
	 */
	private final Map actionProviderInstances = new HashMap();