Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to edit unknow feature.
How to edit unknow feature. [message #1118143] Fri, 27 September 2013 05:30 Go to next message
javen jia is currently offline javen jiaFriend
Messages: 7
Registered: December 2009
Junior Member
I use the iption "OPTION_RECORD_UNKNOWN_FEATUR" to record unknown featurs .I want to know how to change the value of such features on the editor.
                Resource resource=eobject.eResource();		 
		AnyType type=getEObjectExtension(eobject);
		FeatureMap featureMap= type.getAnyAttribute();
		EStructuralFeature feature= entry.getEStructuralFeature();
		if(property.equals("value")){
	             //EObject obj=feature.eContainer();
                     //SetCommand.create(domain, obj, feature, value);
		    featureMap.set(entry.getEStructuralFeature(), value);
		}

The code featureMap.set(entry.getEStructuralFeature(), value); can change the value,but the editor's status is not dirty.then i try to create a SetCommand but failed.
I want to add/remove unkown feature to a eobject dynamically ,too。

[Updated on: Fri, 27 September 2013 05:30]

Report message to a moderator

Re: How to edit unknow feature. [message #1118208 is a reply to message #1118143] Fri, 27 September 2013 07:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
Javen,

Comments below.

On 27/09/2013 7:30 AM, javen jia wrote:
> I use the iption "OPTION_RECORD_UNKNOWN_FEATUR" to record unknown
> featurs .I want to know how to change the value of such features on
> the editor.
>
> Resource resource=eobject.eResource(); AnyType
> type=getEObjectExtension(eobject);
> FeatureMap featureMap= type.getAnyAttribute();
> EStructuralFeature feature= entry.getEStructuralFeature();
How did you get entry?
> if(property.equals("value")){
What is property?
> //EObject obj=feature.eContainer();
Here obj is no doubt the EClass that contains the EStructuralFeature.
That's not what you want to be changing.
> //SetCommand.create(domain, obj, feature, value);
What's value?
> featureMap.set(entry.getEStructuralFeature(), value);
> }
>
> The code featureMap.set(entry.getEStructuralFeature(), value); can
> change the value,but thi editor's statud is not dirty.then i try to
> create a SetCommand but failed.
It's hard to comment on the incomplete code above, but clearly some
parts are wrong. To get it working, keep in mind that the feature map
is a list and that you can operate on it like any other list. So you can
determine the index of the feature map entry you want to replace, use
FeatureMapUtil to create a new replacement entry, and use a set command
to replace the current entry in the feature map with the new entry at
the index of the old entry.
> I want to add/remove unkown feature to a eobject dynamically ,too。
All such things operate on the feature map in the same way.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Now I need some advice for code generation
Next Topic:Teneo: Max length forced even when annotation set
Goto Forum:
  


Current Time: Mon May 13 15:22:26 GMT 2024

Powered by FUDForum. Page generated in 0.03527 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top