在eclipse插件开发中,用到了ElementTreeSelectionDialog这个选择对话框,
现在想实现对话框弹出时能默认展开树的某个节点,跪求大神帮忙,本人已经
寻找多天实现方法。
在ElementTreeSelectionDialog类中有一个setInitialSelection()方法,不知道
和实现这个功能有什么关系没有....
以下是构建ElementTreeSelectionDialog的相关代码:
ElementTreeSelectionDialog treedialog = new ElementTreeSelectionDialog(shell, new ViewLabelProvider(), new ViewContentProvider());
if(treedialog != null){
treedialog.setTitle("选择响应路径");
treedialog.setEmptyListMessage("没有可选文件夹!");
LocalFileDir lfd=new LocalFileDir(path, name);
LocalFileDir[] root = {new LocalFileDir(path, name)};
List child=lfd.getChildren();
int flag = Window.CANCEL;
treedialog.setInput(root);
flag = treedialog.open();
treedialog.setInitialElementSelections(child);
flag = treedialog.open();
if(flag == Window.OK){
dir = (LocalFileDir)treedialog.getFirstResult();
//dir = (LocalFileDir)treedialog.getResult();
}
}