Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338277

Summary: Unable to open editor
Product: [Eclipse Project] JDT Reporter: DJ Houghton <dj.houghton>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description DJ Houghton CLA 2011-02-25 15:58:03 EST
build i0224-2000

- I have "open on single click" selected
- close all editors
- select something in the Sync view to open a Compare editor
- note the editor does not have focus
- give the editor focus by clicking on the tab
- now click on that class in the Package Explorer
- no amount of single or double-clicking will open a real editor on the file, you must close the Compare editor first
- nothing in the error log
Comment 1 DJ Houghton CLA 2011-02-25 16:07:40 EST
Note you get similar behaviour if:
- close all editors
- open an editor on a file
- using the Sync view open a Compare editor on the same file
- give the Compare editor focus
- click in the Package Explorer (single, double, triple, whatever)
- note that the Compare editor gets focus and the real editor does not.
Comment 2 Remy Suen CLA 2011-02-28 08:56:50 EST
(In reply to comment #0)
> build i0224-2000
> 
> - I have "open on single click" selected
> - close all editors
> - select something in the Sync view to open a Compare editor
> - note the editor does not have focus

Just to be clear not having focus also happens on 3.x and seems to be the expected behaviour.
Comment 3 DJ Houghton CLA 2011-02-28 09:01:45 EST
Yep, that part is fine by me. I just wanted to call it out as something explicit in case it is related to the editor not opening.
Comment 4 Remy Suen CLA 2011-02-28 10:17:38 EST
After some investigations, I am inclined to believe that this is due to how JDT handles open requests for editors. If you perform the steps from comment 0 and comment 1 with non-Java files, another editor will be spawned correctly. You can also try to use the 'Navigator' view instead of the 'Package Explorer' view and you will see that a new editor is opened instead of leaving the active editor as the compare editor.

The trace below is the 3.x trace. You can see in EditorUtility's openInEditor(Object, boolean) that it will check if the editor shares the same ICompilationUnit as what's being opened before opening a new editor.

Thread [main] (Suspended (breakpoint at line 168 in EditorUtility))    
    EditorUtility.openInEditor(Object, boolean) line: 168    
    OpenAction.run(Object[]) line: 219    
    OpenAction.run(IStructuredSelection) line: 198    
    OpenAction(SelectionDispatchAction).dispatchRun(ISelection) line: 274    
    OpenAction(SelectionDispatchAction).run() line: 250    
    PackageExplorerActionGroup.handleOpen(ISelection, boolean) line: 373    
    PackageExplorerPart$4.open(ISelection, boolean) line: 526    
    OpenAndLinkWithEditorHelper$InternalListener.open(OpenEvent) line: 48    
    StructuredViewer$2.run() line: 845    
    SafeRunner.run(ISafeRunnable) line: 42    
    JFaceUtil$1.run(ISafeRunnable) line: 49    
    SafeRunnable.run(ISafeRunnable) line: 175    
   
PackageExplorerPart$PackageExplorerProblemTreeViewer(StructuredViewer).fireOpen(OpenEvent)
line: 843    
   
PackageExplorerPart$PackageExplorerProblemTreeViewer(StructuredViewer).handleOpen(SelectionEvent)
line: 1131    
    StructuredViewer$6.handleOpen(SelectionEvent) line: 1235    
    OpenStrategy.fireOpenEvent(SelectionEvent) line: 275    
    OpenStrategy.access$2(OpenStrategy, SelectionEvent) line: 269    
    OpenStrategy$1.handleEvent(Event) line: 309    
    EventTable.sendEvent(Event) line: 84    
    Tree(Widget).sendEvent(Event) line: 1053    
    Display.runDeferredEvents() line: 4126    
    Display.readAndDispatch() line: 3715    
    Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2696    
    Workbench.runUI() line: 2660    
    Workbench.access$4(Workbench) line: 2494    
    Workbench$7.run() line: 674    
    Realm.runWithDefault(Realm, Runnable) line: 332    
    Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 667    
    PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149    
    IDEApplication.start(IApplicationContext) line: 115
Comment 5 DJ Houghton CLA 2011-02-28 10:25:57 EST
Cool, thanks for the investigation. I hadn't noticed the difference in behaviour between Java and non-Java files. I'll move this to JDT. I still believe if I click on a file in the Package Explorer then I should be able to open an editor on it.
Comment 6 Dani Megert CLA 2011-02-28 10:31:44 EST
This was done on purpose after we beefed up the Java compare editor with most of the editor features. We also added 'Open' and 'Open With' to the context menu so that one can go easily to the Java editor if needed.

*** This bug has been marked as a duplicate of bug 277697 ***