Cell editor for customizing EMF program attribute View

Source: Internet
Author: User

Overwrite the getpropertysheetpage () method of xxxeditor. Java generated by EMF. For the remaining steps, see the followingCodeThis example uses a custom dialog box for a specific type of eattribute (etype is "com. Your. etype") to set the attribute value.

 /**  * This accesses a cached version of the property sheet. * <! -- Begin-user-doc --> * <! -- End-user-doc --> * @ generated not  */  Public  Ipropertysheetpage getpropertysheetpage (){  If (Propertysheetpage = Null  ) {Propertysheetpage = New Extendedpropertysheetpage (editingdomain ){  Public   Void  Setselectiontoviewer (list selection) {bmeditor.  This  . Setselectiontoviewer (selection); bmeditor.  This  . Setfocus ();}  Public   Void  Setactionbars (iactionbars actionbars ){  Super . Setactionbars (actionbars); getactionbarcontributor (). shareglobalactions (  This  , Actionbars );}};  //  Use custom content provider here Propertysheetpage. setpropertysourceprovider ( New  Bmadapterfactorycontentprovider (adapterfactory ));}  Return  Propertysheetpage ;}  /**  * Apply customized cell editor for custom datatype * @ Author  Zhanghao *  */  Class Bmadapterfactorycontentprovider Extends  Adapterfactorycontentprovider {  Public  Bmadapterfactorycontentprovider (adapterfactory ){  Super  (Adapterfactory);} @ override  Protected  Ipropertysource createpropertysource (Object object, iitempropertysource itempropertysource ){ Return   New  Propertysource (object, itempropertysource) {@ override  Protected  Ipropertydescriptor createpropertydescriptor (iitempropertydescriptor itempropertydescriptor ){  Return   New  Propertydescriptor (object, itempropertydescriptor) {@ override  Public  Celleditor createpropertyeditor (composite) {object genericfeature =Itempropertydescriptor. getfeature (object );  If (Genericfeature Instanceof Estructuralfeature & (estructuralfeature) genericfeature). getetype () Instanceof  Edatatype) {edatatype etype = (Edatatype) (estructuralfeature) genericfeature). getetype ();  If ("Com. Your. datatype" . Equals (etype. getinstancetypename ())){  Return   New Dialogcelleditor (composite) {@ override  Protected  Object opendialogbox (control celleditorwindow ){  //  Open your dialog to read user input Expressiondialog dialog = New  Expressiondialog (celleditorwindow. getshell (); resource Resource = Bmeditor. This . Geteditingdomain (). getresourceset (). getresources (). Get (0); Businessmodel Model = (Businessmodel) resource. getcontents (). Get (0 ); Dialog. setmodel (model );  If (Window. OK = Dialog. open ()){  Return  Dialog. getdemand ();}  Else  {  Return Object ;}}};}}  Return   Super  . Createpropertyeditor (composite );}};}};}} 

Reference: http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg09433.html

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.