Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Show a particular PreferencePage?
Show a particular PreferencePage? [message #171042] Tue, 16 December 2003 16:28 Go to next message
Eclipse UserFriend
Originally posted by: jdf.pobox.com

Is there a cannonical way to cause the workbench preferences dialog to
open on a particular preference page?

There is a showPage(IPreferenceNode) method on the PreferenceDialog, but
it is protected.
--
Jonathan Feinberg jdf@us.ibm.com
http://domino.research.ibm.com/cambridge/research.nsf/pages/ cue.html
Re: Show a particular PreferencePage? [message #176399 is a reply to message #171042] Tue, 06 January 2004 22:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

The usual approach is to open a preference dialog that contains only
your preference page:

IPreferenceNode targetNode = new PreferenceNode(id, yourPrefPage);
PreferenceManager manager = new PreferenceManager();
manager.addToRoot(targetNode);
PreferenceDialog dialog = new PreferenceDialog(shell, manager);
dialog.create();
dialog.setMessage(targetNode.getLabelText());
dialog.open();
--

Jonathan Feinberg wrote:
> Is there a cannonical way to cause the workbench preferences dialog to
> open on a particular preference page?
>
> There is a showPage(IPreferenceNode) method on the PreferenceDialog, but
> it is protected.
Re: Show a particular PreferencePage? [message #734607 is a reply to message #171042] Sat, 08 October 2011 21:02 Go to previous messageGo to next message
Marco Lopes is currently offline Marco LopesFriend
Messages: 56
Registered: September 2010
Member
Eclipse User wrote on Tue, 16 December 2003 11:28
Originally posted by: jdf.pobox.com

Is there a cannonical way to cause the workbench preferences dialog to
open on a particular preference page?

There is a showPage(IPreferenceNode) method on the PreferenceDialog, but
it is protected.
--
Jonathan Feinberg jdf@us.ibm.com
http://domino.research.ibm.com/cambridge/research.nsf/pages/ cue.html


private void selectItem(PreferenceDialog dialog, String id) {

dialog.getTreeViewer().expandAll();

TreeItem item=findItem(dialog.getPreferenceManager().getRootSubNodes(),
dialog.getTreeViewer().getTree().getItems(), id);
if (item!=null)
dialog.getTreeViewer().setSelection(new StructuredSelection(item.getData()));
else
dialog.getTreeViewer().setSelection(new StructuredSelection(dialog.getTreeViewer().getTree().getItem(0).getData()));
}


private TreeItem findItem(IPreferenceNode[] nodes, TreeItem[] items, String id){

TreeItem item=null;

for(int i=0; i<nodes.length && item==null; i++){

if (nodes[i].getId().equals(id)){
item=items[i];
}else{
IPreferenceNode[] subNodes=nodes[i].getSubNodes();
TreeItem[] subItems=items[i].getItems();
if (subNodes.length>0)
item=findItem(subNodes,subItems,id);
}
}

return item;
}

[Updated on: Sat, 08 October 2011 21:03]

Report message to a moderator

Re: Show a particular PreferencePage? [message #734627 is a reply to message #734607] Sat, 08 October 2011 22:58 Go to previous messageGo to next message
Marco Lopes is currently offline Marco LopesFriend
Messages: 56
Registered: September 2010
Member
if you EXTEND PreferenceDialog here is a better solution:

/**
* Selects the NODE with the ID
*/
private void selectNode(String id) {

getTreeViewer().expandAll();

IPreferenceNode node=findNode(getPreferenceManager().getRootSubNodes(), id);
if (node!=null){
showPage(node);
getTreeViewer().setSelection(new StructuredSelection(node));
}else{
showPage(getPreferenceManager().getRootSubNodes()[0]);
}

}


/**
* Finds the NODE with the ID
*/
private IPreferenceNode findNode(IPreferenceNode[] nodes, String id){

IPreferenceNode node=null;
for(int i=0; i<nodes.length && node==null; i++){
if (nodes[i].getId().equals(id)){
return nodes[i];
}

IPreferenceNode[] subNodes=nodes[i].getSubNodes();
if (subNodes.length>0)
node=findNode(subNodes,id);
}
return node;
}
Re: Show a particular PreferencePage? [message #741551 is a reply to message #734627] Wed, 19 October 2011 16:32 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
We're using
org.eclipse.ui.dialogs.PreferenceUtil.createDialogOn(Shell, PREF_PAGE_ID, null, dataObjectInView)
Previous Topic:Hide menus thr' activities/perspectiveExtensions not working
Next Topic:Contributed toolbar not resizing
Goto Forum:
  


Current Time: Sat Nov 29 10:16:02 GMT 2014

Powered by FUDForum. Page generated in 0.03595 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software