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