Bug 2668 - ISelectionService should allow tracking of specific parts (1GHU8FN)
Summary: ISelectionService should allow tracking of specific parts (1GHU8FN)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P2 enhancement (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 7864 (view as bug list)
Depends on:
Blocks: 7864
  Show dependency tree
 
Reported: 2001-10-10 22:41 EDT by Darin Swanson CLA
Modified: 2002-03-28 13:18 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Swanson CLA 2001-10-10 22:41:06 EDT
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:
Comment 1 DJ Houghton CLA 2001-10-29 19:08:22 EST
PRODUCT VERSION:
0.9

Comment 2 Darin Wright CLA 2002-01-31 14:12:00 EST
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)
Comment 3 Darin Wright CLA 2002-01-31 14:12:44 EST
*** Bug 7864 has been marked as a duplicate of this bug. ***
Comment 4 Nick Edgar CLA 2002-01-31 23:00:52 EST
API should only allow a single part to be specified.
Comment 5 Nick Edgar CLA 2002-02-01 08:10:47 EST
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.
Comment 6 Darin Wright CLA 2002-02-01 08:15:31 EST
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.
Comment 7 Nick Edgar CLA 2002-02-01 15:08:56 EST
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.
Comment 8 Nick Edgar CLA 2002-03-01 10:08:53 EST
Code released in build > 20020228.
Need to write tests for this.
Comment 9 Nick Edgar CLA 2002-03-12 22:35:23 EST
Darin, have you tried using this?
Comment 10 Darin Swanson CLA 2002-03-12 22:45:16 EST
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.
Comment 11 Nick Edgar CLA 2002-03-12 23:52:42 EST
Wow, unexpectedly fast turnaround!  Have fun!
Comment 12 Darin Swanson CLA 2002-03-13 10:39:10 EST
The debugger has been ported and the code released to head.
Works as advertised so far.
Comment 13 Nick Edgar CLA 2002-03-28 13:18:22 EST
Closing PR.