Click propertyies in custom eclipse to bring up the preference dialog box

Source: Internet
Author: User
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 ();}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.