Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: 1. Open two editors - one must be an ITextEditor (any java file) and the other must not be (extend EditorPart directly and only implement ISelectionProvider) 2. Place a break point in JavaBrowsingPart.selectionChanged(IWorkbenchPart, ISelection) 2. Switch between the two editors in the java browsing perspective (so you can see the packages). 3. When you select the ITextEditor it shows the editor's package, when you select the non-ITextEditor it checks line 718 and determines that the same part last fired the selection event because when the ITextEditor's selection event is processed it doesn't set fPreviousSelectionProvider. More information: A simple fix would seem to be to set the fPreviousSelectionProvider in a finally block with the contents of selectionChanged inside the try portion. It would be nice if this could make it into the next release as it really makes custom displays a pain to integrate.
Moving to JDT/UI
Just to clarify: you would like that the browsing views get cleared, right? What kind of selection does your editor have?
My editor edits a non-java file that exists in a package. I would like the package to be selected when the file is the active editor. I had to work around the problem by making my editor implement ITextEditor even though it isn't a text editor, because the JavaBrowsingPart base class for the packages view handles ITextEditor instances differently than other editor types. Looking at the code for JavaBrowsingPart.selectionChanged(..), you notice that in some cases it sets the fPreviousSelectionProvider attribute, and in some cases it does not. The problem with my editor not being an ITextEditor is that when you change the selected editor between an ITextEditor and a non-ITextEditor, the selectionChanged(..) method sets fPreviousSelectionProvider for the non-ITextEditor and not for the ITextEditor. The attribute fPreviousSelectionProvider is used by the selectionChanged(..) method on line 718 to determine whether the selection has really changed if the firing part is not an ITextEditor. So every time my editor is activated when alternating between my editor and an ITextEditor, the package view doesn't change its selection. Simply placing all the code inside the selectionChanged(..) method inside a try block and adding an finally to set fPreviousSelectionProvider = part should solve the problem.
Can you please tell me what kind of selection your editor sends out? Is it ITextSelection?
Ah.. sorry.. I am currently using a StructuredSelection.
setSelection(new StructuredSelection(((IFileEditorInput) getEditorInput()).getFile()));
Fixed in HEAD. Available in builds >= I20081021-0800. Please try it out in I20081021-0800 or next milestone (3.5 M3) which due in less than two weeks.