Project: Eclipse_Platform_UI
Bug 280799 [Commands] ActivateEditorHandler unnecessarily calls setFocus()
Reported: 2009-06-18 12:25:03 | Status: verified fixed

Build id: I20090603-2000 According to setFocus()'s javadoc... Clients should not call this method (the workbench calls this method at appropriate times). To have the workbench activate a part, use IWorkbenchPage.activate(IWorkbenchPart) instead. In ActivateEditorHandler, activate(IWorkbenchPart) is invoked quickly followed by a setFocus() invocation on lines 57 and 58. From the stack trace below, setFocus() is already called when activate(IWorkbenchPart) is invoked, so the explicit call to setFocus() appears to serve no purpose. Thread [main] (Suspended (breakpoint at line 6077 in AbstractTextEditor)) CompilationUnitEditor(AbstractTextEditor).setFocus() line: 6077 CompilationUnitEditor(JavaEditor).setFocus() line: 2362 EditorPane(PartPane).setFocus() line: 332 EditorPane.setFocus() line: 127 WorkbenchPage$3.run() line: 626 SafeRunner.run(ISafeRunnable) line: 42 Platform.run(ISafeRunnable) line: 888 WorkbenchPage.activatePart(IWorkbenchPart) line: 621 WorkbenchPage.setActivePart(IWorkbenchPart) line: 3527 WorkbenchPage.activate(IWorkbenchPart) line: 614 ActivateEditorHandler.execute(ExecutionEvent) line: 57 Thread [main] (Suspended (breakpoint at line 6077 in AbstractTextEditor)) CompilationUnitEditor(AbstractTextEditor).setFocus() line: 6077 CompilationUnitEditor(JavaEditor).setFocus() line: 2362 ActivateEditorHandler.execute(ExecutionEvent) line: 58

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActivateEditorHandler.java