Bug 133378 - [FilteredTree] provide API to control expansion-state of FilteredTree on PreferencePage
Summary: [FilteredTree] provide API to control expansion-state of FilteredTree on Pref...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M5   Edit
Assignee: Karice McIntyre CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2006-03-27 10:52 EST by Paul E. Keyser CLA
Modified: 2007-01-31 10:49 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 Paul E. Keyser CLA 2006-03-27 10:52:54 EST
In my RCP app I have created a small set of prefs-pages, which are neatly displayed in the little "FilteredTree" to the left. 

But a user-request is to have that tree expanded by default on opening the Prefs-page; this is reasonable, as there are notvery many elements in the tree. 

As far as I can tell from the extension-point, the interface of FieldEditorPreferencePage, and the interface of IPreferencePageContainer, there is no way to do this. 

For example, the API to FilteredTree could have methods like the following, with some forwarding methods from PreferencePage to the implementation of IPreferencePageContainer, or the connection could be made in other ways: 

	public void expandAll() {
		treeViewer.expandAll(); 
		final ISelection sel = treeViewer.getSelection(); 
		if (!sel.isEmpty()) { 
			final IStructuredSelection iss = 
				(IStructuredSelection) sel; 
			treeViewer.reveal(iss.getFirstElement()); 
		}
	}

	public void setExpandedElements(Object[] elements) { 
		treeViewer.setExpandedElements(elements); 
	}
Comment 1 Karice McIntyre CLA 2006-04-05 11:59:00 EDT
This won't be possible for 3.2 as we are well past the API freeze.  The FilteredTree class was not promoted to API until 3.2.  Also note that the FilteredTree is not tied to IPreferencePageContainer at all, since it can be used in a general way in places other than just the preferences dialog, so adding API to that will not solve the problem.  It would have to be added to FilteredTree.
Comment 2 Karice McIntyre CLA 2006-09-22 10:20:19 EDT
Dani, what API do you need on FilteredTree to unblock bug 139798?  Just what is suggested below?
Comment 3 Dani Megert CLA 2006-09-22 10:50:38 EDT
Hi Karice,

on a second thought we don't need it at all since we have access to the tree viewer (getViewer()) and our code already uses this API on the viewer directly.

Blocking us from doing so is bug 158279.
Comment 4 Karice McIntyre CLA 2007-01-29 11:45:24 EST
The API needed is available via the tree widget itself, which is exposed via the viewer, which is exposed on the filtered tree class.  The convention is not to provide convenience API when access to the viewer/widget itself is provided.
Comment 5 Paul E. Keyser CLA 2007-01-30 08:42:09 EST
(In reply to comment #4)
> The API needed is available via the tree widget itself, which is exposed via
> the viewer, which is exposed on the filtered tree class.  The convention is not
> to provide convenience API when access to the viewer/widget itself is provided.
> 
Perfectly reasonable convention, but how is it relevant here? There is no API on the *Preference Page* to control the filtered tree's expansion-state. Another missed opportunity. 
Comment 6 Karice McIntyre CLA 2007-01-30 16:50:04 EST
Ok, so I didn't re-read the original description saying that you wanted a preference page to provide the API.  Adding API to an interface is not feasible as it will break binary compatibility.  However, it can be provided by making PreferenceDialog.getTreeViewer() public, rather than protected.  Then, in your open preferences dialog action you can create the preference dialog, call expandAll() on the tree viewer, then open the dialog.  e.g. 
		PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, null, null, null);
		dialog.getTreeViewer().expandAll();
		dialog.open();

Will this suit your needs?  If so, re-open this bug. 
Comment 7 Paul E. Keyser CLA 2007-01-30 17:48:46 EST
Yes, thanks, that solution should work for me -- I'm in an RCP, so could create my own open-prefs action rather than using the action-factory item. (Not clear to me if this would help folks working on plug-ins for the JDT ...) 
Comment 8 Karice McIntyre CLA 2007-01-31 10:49:01 EST
This functionality is probably most useful in an RCP setting anyway.  
Released in 3.3 for build > 20070131