如何自动展开PreferenceManager的所有节点

时间:2014-11-20 17:06:34

标签: java swt jface

要管理我的swt / jface应用程序的首选项,我使用org.eclipse.jface.preference

我在首选项窗口中有3个节点:

    //Creation of the nodes
    PreferenceNode one = new PreferenceNode("one", new PreferencePage1());
    PreferenceNode two = new PreferenceNode("two", new PreferencePage2());
    PreferenceNode three = new PreferenceNode("three", new PreferencePage3());

    //Creation of the manager
    PreferenceManager mgr = new PreferenceManager();
    mgr.addToRoot(one);
    mgr.addToRoot(two);
    two.add(three);

    //Show the preference dialog
    PreferenceDialog myPreferenceDialog = new PreferenceDialog(null, mgr);

节点three是节点two的子节点。

如何在two

的树中展开节点PreferenceNode

1 个答案:

答案 0 :(得分:0)

如果您创建PreferenceDialog的子类,则可以覆盖createTreeViewer方法并设置自动扩展级别:

@Override
protected TreeViewer createTreeViewer(final Composite parent)
{
  TreeViewer viewer = super.createTreeViewer(parent);

  viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

  return viewer;
}