Community
Participate
Working Groups
I was working with the 4.0 SDK, I20100614-2011. I opened a second window to host my java files that are just resources, not in the classpath. I copied something out of one, but when I switched to the main window to paste in my editor, it was pasted in the second window editor. PW
When we switch between two editors in the same workbench window, the handlers from the "old" editor are deactivated and handlers for the "new" editor are activated. (See, for instance, HandlerServiceImpl#activateHandler()). When we switch between two workbench windows, there is no activation/deactivation of handlers. Technically, the first reason this happens because PageBookView#showPageRec() has the following line: if (activeRec == pageRec) { return; } However, it could be argued that that is corrrect behavior for the PageBookView. (There are likely other problems but this is that check is the first failure point where we do not deactivate/activate handlers on the window switch.) Seems like a design problem - when a window looses focus, should the part get deactivated? ====== By the way, to duplicate a specific sequence should be followed: - Create a project with two Java files - one.java and two.java - Open one.java - Open a new workbench window - Open two.java in the second window - Ctrl+C something from the two.java; place cursor in a different location to see the effects - Switch to the first window with one.java active - Press Ctrl+P -> paste is done in the two.java (If copy is done from the first window and paste done in the second, it works fine. Also if editors were activated in a different sequence, the problem might not show up.)
It seems that when the paste is performed in the first workbench window, the handler lookup is correct (that is, it walks down the chain correctly to the right editor), but getTextEditor() in ClipboardOperationAction is retrieving the old editor.
(In reply to comment #1) > Seems like a design problem - when a window looses focus, should the part get > deactivated? This doesn't happen on 3.x. Swapping workbench windows does not cause part events to be fired. How the handlers are working properly in 3.x, I do not yet know.
In 3.x, the handlers just update themselves based on the sources changing. There is not an implicit activation/deactivation request. Thread [main] (Suspended (breakpoint at line 951 in Command)) Command.setHandler(IHandler) line: 951 HandlerAuthority.updateCommand(String, IHandlerActivation) line: 458 HandlerAuthority.processChangedCommands() line: 637 HandlerAuthority.access$1(HandlerAuthority) line: 609 HandlerAuthority$1.propertyChange(PropertyChangeEvent) line: 174 EvaluationAuthority$1.run() line: 252 SafeRunner.run(ISafeRunnable) line: 42 EvaluationAuthority.fireServiceChange(String, Object, Object) line: 246 EvaluationAuthority.endSourceChange(String[]) line: 197 EvaluationAuthority.sourceChanged(String[]) line: 135 EvaluationAuthority(ExpressionAuthority).sourceChanged(int, String[]) line: 311 EvaluationAuthority(ExpressionAuthority).sourceChanged(int, Map) line: 290 WorkbenchSourceProvider(AbstractSourceProvider).fireSourceChanged(int, Map) line: 99 WorkbenchSourceProvider.access$10(WorkbenchSourceProvider, int, Map) line: 1 WorkbenchSourceProvider$6.handleEvent(Event) line: 775
Created attachment 174297 [details] Patch After quite a bit of debugging the problem turned out to be caching of action bars. When I looked in details at what happened, the handler evaluation service was selecting a handler from two candidates. The thing is, one of the candidates was for the wrong WrokbenchPage. I tracked the wrong handler back to the editor action bar - the EditorRefence for the editor opened in the 2nd Workbench window re-used the action bar from the 1st Workbench window. This is caused by the EditorReference.actionCache that keeps a cache of action bars (that are specific to the Workbench window) based only on the editor type, such as "org.eclipse.jdt.ui.CompilationUnitEditor". Opening a Java editor in the first window creates a cache entry which is then used for Java editors opened in the second workbench window. The patch changes action bar caching to take into account both editor type and workbench page. Paul, could you review the patch?
Patch applied to CVS Head.