Community
Participate
Working Groups
Build ID: M20080221-1800 Steps To Reproduce: This happen when we try to subclasses MultiPageEditorActionBarContributor, then extends MultiPageEditorActionBarContributor#setActiveEditor to hook actions in toolbar with our active editor 1. Open multiple editors (let say 4), each associated with a different files 2. Focus on one editor in the middle (let say editor 2) 3. Close eclipse, then re-opened it Result: race condition within setActiveEditor(). By printing the activeEditor title, I've got something like this: editor 2 editor 2 editor 1 editor 3 editor 4 As such, we incorrectly associated our action with editor 4, even though the focused and active editor is number 2. So when user invokes one of the actions, its effect is on editor 4 !!! More information: This probably happens because our setActive() runs quite long. But I tried to synchronized this method and it doesn't work. Our work around at the moment is to re-target the active editor to PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() when the above is not null and doesn't cause NPE.
Can you include a small MPEP sample plugin with an example that shows the failure? Is it that you are opening 4 MPEPs or you are opening one MPEP with 4 internal editors? PW
Sorry for the long delay. @Paul: I am not sure how to answer your question, so please let me know if I misunderstand your question. I start up 1 eclipse, then open 4 files in our editor (an extension of WST XML editor). Today, I use the wizard to create a simple text editor, then open 4 text files. Close eclipse, reopen it again, but the active editor is only invoke 1. Again, use wizard to create a simple XML editor, but I still can't reproduce the error. I am starting to think that this is either our plugin specific problem, or WST UI problem. I tested again with our editor and the problem is still there. I obtained the stack trace where setActiveEditor() is call, and will get back to you if anything interesting is in there.
(In reply to comment #2) > I start up 1 eclipse, then open 4 files in our editor (an extension of WST XML > editor). OK, I think I was just asking if it was 4 editors open or one MPEP open with 4 "inner" editors. It sounds like the 4 separate MPEP editors. If you get a stack trace from startup (and annotate it somehow) and attach it as a text file I can have a look at it as well. PW
ok, find the culprit in org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart.createPages(), which our editor subclasses. // set the active editor in the action bar contributor first // before setactivepage calls action bar contributor's // setactivepage (bug141013 - remove when bug151488 is fixed) IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); if (contributor instanceof MultiPageEditorActionBarContributor) { ((MultiPageEditorActionBarContributor) contributor).setActiveEditor(this); } Even though my code is using R2_0 maintenance release, this issue still persist with the latest code. I guess I'll make this a duplication of 151488 and closed *** This bug has been marked as a duplicate of bug 151488 ***