Community
Participate
Working Groups
Currently the selection service allows you to track the selection from the active part. Some views need to track a specific part, which is not necessarily active. For example, the debug perspective's variables, console and other views typically track the selection in the debug/launches view. Currently, they have to write their own selection-service-like support for doing this: - tracking creation/disposal of the target view (not activation) - hooking a listener when created (and removing it when disposed) An API like the following would allow a part to simply track the selection in a specific other part: /** * Adds a selection listener which is notified when selection changes in any workbench part * whose id is in the given array. This is independent of part activation: the part need not * be active for notification to be sent. The listener is also notified when the part is created * and disposed. When the part is created, the listener is passed the part's initial selection. * When the part is disposed, the listener is passed an empty selection. * * @param partIds an array of workbench part identifiers * @param listener the listener to be notified */ public void addSelectionListener(String[] partIds, ISelectionListener listener); Need to consider whether this can be added to ISelectionService or whether a new interface needs to be introduced. NOTES:
PRODUCT VERSION: 0.9
The API we have in the 2.0 debugger can be found in org.eclipse.debug.internal.ui.views.DebugSelectionManager. It looks like: /** * Add the given listener to the selection provider for the specified * page and view. * * @param listener selection listener * @param page workbench page * @param viewId view identifier */ public void addSelectionChangedListener(ISelectionChangedListener listener, IWorkbenchPage page, String viewId); /** * Adds the given listener to the selection provider for * the specified window and view (i.e. all pages in the window) * * @param listener selection listener * @param window workbench window * @param viewId view identifier */ public void addSelectionChangedListener(ISelectionChangedListener listener, IWorkbenchWindow window, String viewId)
*** Bug 7864 has been marked as a duplicate of this bug. ***
API should only allow a single part to be specified.
Should also add getSelecion(String partId) to simplify getting the initial selection. The listeners are not notified immediately when added. This would parallel the service having getSelection() for the non-directed case.
Clarification of: "API should allow a single part to be specified". Does that mean that the part must exist? If a part is specified, then clients are responsible for tracking when that part comes into/out of existence. If a part Id is specified, it is up to the selection service to track the part.
I meant a single part ID. The service will track part open/close. The initial proposed API allowed an array of part IDs. It's preferable to require the API to be called multiple times.
Code released in build > 20020228. Need to write tests for this.
Darin, have you tried using this?
Nick, I started porting our code to it tonight. So far it looks like it replaces all of our custom implementation. I will let you know more tomorrow morning.
Wow, unexpectedly fast turnaround! Have fun!
The debugger has been ported and the code released to head. Works as advertised so far.
Closing PR.