Bug 292427 [CommonNavigator] LinkEditorAction reacts to its own selection
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 (CK-IBM) Firefox/3.0.13 Build Identifier: M20090211-1700 1) when a user clicks on a tab in the editor area, LinkEditorAction selects the editor item in the CommonViewer 2) when a user selects an item in the CommonViewer, LinkEditorAction opens the editor in the editor are however LinkEditorAction does NOT ignore a selection change caused by itself--(1) also causes (2) this is not only a performance issue of reopening the editor, but it also causes a flaky situation because both 1 & 2 use UIJobs: 1)user clicks on an editor tab (editor A) and a UIJob is scheduled to select editor A in the CommonViewer 2)UIJob executes, causing selection to change which in turn causes a second UIJob to be scheduled to bring the editor to the top (the unnecessary UIJob) 3) but before this unnecessary UIJob executes (happens if loading A takes a while), the user clicks on editor B tab and a new UIJob is scheduled to change the selection in the CommonViewer to editor B 4) but it can't run until the unecessary UIJob runs (jobs are processed FIFO) 5) and when the unnecessary job does run, it sees that the current selection is still editor A so it brings A back to the top even the user had opened B the effect is if the user selects A before B has fully loaded, A will temporarily open, then flip back to B a suggested fix is to do this: 1) in LinkEditorAction#updateSelectionJob when LinkEditorAction changes the selection in the viewer (in reaction to a tab clicked in the editor area) it should save that selection: IStructuredSelection newSelection = linkService... ignoreSelection = newSelection; 2) and in LinkEditorAction#selectionChanged it should ignore that selection change public void selectionChanged(SelectionChangedEvent event) { if (commonNavigator.isLinkingEnabled() && event.getSelection() != ignoreSelection) { ignoreSelection = null; activateEditor(); } } Reproducible: Always Steps to Reproduce: 1. open two editors 2. turn on linking in common viewer 3. expand common viewer 4. click on the editor tab that isn't visible and before that editor fully loads (put a wait in it), click on the tab of the editor that was just open 5. Notice that the first editor opens temporarily, then flashes back to the second editor.
tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java
public static final String TEST_VIEW_NON_COMMONVIEWER = "org.eclipse.ui.tests.navigator.NonCommonViewerTestView";
	public static final String TEST_CONTENT = "org.eclipse.ui.tests.navigator.testContent";
	public static final String TEST_CONTENT2 = "org.eclipse.ui.tests.navigator.testContent2";
	public static final String TEST_CONTENT_OVERRIDDEN1 = "org.eclipse.ui.tests.navigator.testContentOverridden1";
	public static final String TEST_CONTENT_OVERRIDDEN2 = "org.eclipse.ui.tests.navigator.testContentOverridden2";
	public static final String TEST_CONTENT_OVERRIDE1 = "org.eclipse.ui.tests.navigator.testContentOverride1";
	public static final String TEST_CONTENT_OVERRIDE2 = "org.eclipse.ui.tests.navigator.testContentOverride2";
	public static final String TEST_CONTENT_OVERRIDE2_BLANK = "org.eclipse.ui.tests.navigator.testContentOverride2Blank";
	public static final String TEST_CONTENT_RESOURCE_OVERRIDE = "org.eclipse.ui.tests.navigator.testContentResourceOverride";
	public static final String TEST_CONTENT_PIPELINE = "org.eclipse.ui.tests.navigator.testPipeline";
	public static final String TEST_CONTENT_WITH = "org.eclipse.ui.tests.navigator.testContentWith";
	public static final String TEST_CONTENT_NO_CHILDREN = "org.eclipse.ui.tests.navigator.testContentNoChildren";
	public static final String TEST_CONTENT_EMPTY = "org.eclipse.ui.tests.navigator.testContentEmpty";
	public static final String TEST_CONTENT_RESOURCE_UNSORTED = "org.eclipse.ui.tests.navigator.resourceContent.unsorted";
	public static final String TEST_CONTENT_INITIAL_ACTIVATION_FALSE = "org.eclipse.ui.tests.navigator.testInitialActivationFalse";
	public static final String TEST_CONTENT_INITIAL_ACTIVATION_TRUE = "org.eclipse.ui.tests.navigator.testInitialActivationTrue";
	public static final String TEST_SIMPLE_CHILDREN1 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent1";
	public static final String TEST_SIMPLE_CHILDREN2 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent2";
	public static final String TEST_SIMPLE_CHILDREN3 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent3";
	
	public static final String TEST_CONTENT_M12_VIEW = "org.eclipse.ui.tests.navigator.M12View";
	public static final String TEST_CONTENT_M12_M1_CONTENT = "org.eclipse.ui.tests.navigator.m12.M1";
	public static final String TEST_CONTENT_M12_M1_CONTENT_FIRST_CLASS = "org.eclipse.ui.tests.navigator.m12.M1FirstClass";
	public static final String TEST_CONTENT_M12_M2_CONTENT = "org.eclipse.ui.tests.navigator.m12.M2";
	public static final String TEST_CONTENT_LABEL1 = "org.eclipse.ui.tests.navigator.testContentLabel1";
	public static final String TEST_CONTENT_LABEL2 = "org.eclipse.ui.tests.navigator.testContentLabel2";
	public static final String TEST_CONTENT_SORTER_MODEL = "org.eclipse.ui.tests.navigator.testContentSorterModel";
	public static final String TEST_CONTENT_SORTER_MODEL_OVERRIDE = "org.eclipse.ui.tests.navigator.testContentSorterModel.override";
	public static final String TEST_CONTENT_SORTER_MODEL_OVERRIDE_NOSORT = "org.eclipse.ui.tests.navigator.testContentSorterModel.override.nosort";
	public static final String TEST_CONTENT_SORTER_RESOURCE = "org.eclipse.ui.tests.navigator.testContentSorterResource";