In custom eclipse, click the preference dialog box popped up by propertyies. We can use it in our own RCP. The procedure is as follows: 1. Define preferencedialog, for example:
Public class propertypreferencedialog extends preferencedialog
2. Complete the constructor. For example: Private itreeentry entry; // transmits a tree node type to public propertypreferencedialog (shell parentshell, itreeentry entry) {super (parentshell, new preferencemanager ()); // here, a new preferencemanager object is directly added to the constructor this. entry = entry; generalpage = new generalpage (entry); // getpreferencemanager (). addtoroot (New preferencenode ("General", generalpage); // note the preferencenodegetpreferencemanager (). addtoroot (New P Referencenode ("Editor", new editorpage (entry); preferencenode node = new preferencenode ("Feed", new preferencepage ("Comprehensive") {// node, preferencenode is an abstract class @ override protected control createcontents (composite parent) {nodefaandandapplybutton (); // This sentence can also be put here, as is the constructor, of course, there is no need to define another constructor here. Use the default value to return New Composite (parent, SWT. none) ;}}); node. add (New preferencenode ("General", generalpage); node. add (New pre Ferencenode ("Editor", new editorpage (entry); getpreferencemanager (). addtoroot (node);} 3. Define each preferencepage. For example, public class generalpage extends preferencepage implementsiworkbenchpreferencepage {private itreeentry entry; private text textid;/*** create the preference page */Public generalpage (itreeentry entry) {super ("general"); this. entry = entry; nodefaandandapplybutton (); // do not display the Restore Default and cancel button}/*** create contents of the preference page * @ Param parent */@ overridepublic control createcontents (composite parent) {comp Osite Container = new composite (parent, SWT. null); container. setlayout (New gridlayout (2, false); Final label idlabel = new label (container, SWT. none); idlabel. settext ("ID:"); textid = new text (container, SWT. border); Final griddata gd_textid = new griddata (SWT. fill, SWT. center, true, false); textid. setlayoutdata (gd_textid); If (entry! = NULL) {textid. settext (string. valueof (entry. GETID ()));}
Return container;}/*** initialize the preference page */Public void Init (iworkbench Workbench ){
} // Of course, iworkbenchpreferencepage cannot be implemented based on actual usage. 4. the public class propertyaction extends action {private treeviewer; Public propertyaction (treeviewer) {This. treeviewer = treeviewer; this. settext ("attribute") ;}@ override public void run () {istructuredselection selectnode = (istructuredselection) treeviewer. getselection (); If (selectnode. isempty () {return;} itreeentry entry = (itreeentry) selectnode. getfirstelement (); If (Ent Ry = NULL) {return;} propertypreferencedialog PPD = new propertypreferencedialog (treeviewer. getcontrol (). getshell (), entry); PPD. setselectednode ("Editor"); // This function is quite good. You can locate a page, which is user-friendly. PPD. open ();}}