最近遇到个需求,要在PreferencePage中通过文本链接到其他Page,如: Text Editors, HTML File, JSP File等。
常用的几个Page Id如下
1 text editor : org.eclipse.ui.preferencePages.GeneralTextEditor
2 structured text editor : org.eclipse.wst.sse.ui.preferences.editor
3 html file : org.eclipse.wst.html.ui.preferences.html
4 jsp file : org.eclipse.jst.jsp.ui.preferences.jsp
5 xml file : org.eclipse.wst.xml.ui.preferences.xml.xml
链接到其他Page的代码片段(以HTML File为例)
String htmlFile = "org.eclipse.wst.html.ui.preferences.html";
Link link = new Link(parent, style);
link.setText("<a>HTML File</a>");
link.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
((IWorkbenchPreferenceContainer)MyPreference.this.getContainer()).openPage(htmlFile, null);
}
});