Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Implementing an IPreferenceStore working on an EObject
Implementing an IPreferenceStore working on an EObject [message #536981] Mon, 31 May 2010 19:10 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Hi.

I am trying to implement an IPreferenceStore that can take an EObject as "backend". So I would like to fetch some attribute value from the EObject by calling for example:
emfPreferenceStore.getBoolean(PubProjectStorePackage.Literal s.PUB_FORM_ELEMENT__FILLER_TYPE.getName())
or something like that.

But how do I implement that in the store. What is the way to translate the String name back again to EFeatureStructure, so that I can call:
eObject.eGet(PubProjectStorePackage.Literals.PUB_FORM_ELEMEN T__FILLER_TYPE)

Regards,
Kai
Re: Implementing an IPreferenceStore working on an EObject [message #536986 is a reply to message #536981] Mon, 31 May 2010 19:32 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Ok, a solution that may work ... are there better solutions?

@Override
public long getString(String name) {
for (EAttribute attr: eObj.eClass().getEAllAttributes()) {
if (attr.getName().equals(name) && attr.getEType() == EcorePackage.Literals.ESTRING) {
return (String) eObj.eGet(attr);
}
}
throw new IllegalArgumentException();
}
Re: Implementing an IPreferenceStore working on an EObject [message #536989 is a reply to message #536981] Mon, 31 May 2010 19:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Kai,

With eObject.eGet(eObject.eClass().getEStructuralFeature("foo")) you
could fetch the value of the feature named foo.


Kai Schlamp wrote:
> Hi.
>
> I am trying to implement an IPreferenceStore that can take an EObject
> as "backend". So I would like to fetch some attribute value from the
> EObject by calling for example:
> emfPreferenceStore.getBoolean(PubProjectStorePackage.Literal
> s.PUB_FORM_ELEMENT__FILLER_TYPE.getName())
> or something like that.
>
> But how do I implement that in the store. What is the way to translate
> the String name back again to EFeatureStructure, so that I can call:
> eObject.eGet(PubProjectStorePackage.Literals.PUB_FORM_ELEMEN
> T__FILLER_TYPE)
>
> Regards,
> Kai


Ed Merks
Professional Support: https://www.macromodeling.com/
icon1.gif  Re: Implementing an IPreferenceStore working on an EObject [message #537010 is a reply to message #536989] Mon, 31 May 2010 21:17 Go to previous message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Thanks Ed,

that implementation is much cleaner.
Previous Topic:[EMF Validation]Is the Validation Example from New and Noteworthy for Helios (EMF 2.6) somewhere dow
Next Topic:Model Backward migration
Goto Forum:
  


Current Time: Fri Apr 26 18:30:39 GMT 2024

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

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

Back to the top