Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Modelling a variable set of properties using FeatureMap
Modelling a variable set of properties using FeatureMap [message #425012] Thu, 13 November 2008 11:48 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm trying to model the concept of styles/styling of GUI elements, and need to
handle the case of "unknown" style attributes. My Style class has a set of
features for the "known" style attributes, like Color, Font, etc. I now want to
model the "unknown" and wonder if FeatureMap can be used and what is required to
make it work.

The idea is add a properties feature to the Style class, of type FeatureMap.
Hence, the programmer may add EStructuralFeatures and the corresponding values
for extra style attributes. In the article about Binding XML to Java (with EMF),
it is described how this is done with XML documents, by using
BasicExtendedMetaData and extendedMetadata.demandFeature. Will something similar
work for my case, so that (de)serialization is handled for me?

Ed, in a recent posting you referred to FeatureMaps as something that sucks
because it is there to support a feature of XML that sucks. Does my design suck?

Hallvard
Re: Modelling a variable set of properties using FeatureMap [message #425015 is a reply to message #425012] Thu, 13 November 2008 12:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Why can't someone who want to extend your "Style" to add a feature not
simply really derive from it in his own .ecore? If all packages are
registered correctly then EMF serializes/deserializes everything.

Tom

Hallvard Trætteberg schrieb:
> Hi,
>
> I'm trying to model the concept of styles/styling of GUI elements, and
> need to handle the case of "unknown" style attributes. My Style class
> has a set of features for the "known" style attributes, like Color,
> Font, etc. I now want to model the "unknown" and wonder if FeatureMap
> can be used and what is required to make it work.
>
> The idea is add a properties feature to the Style class, of type
> FeatureMap. Hence, the programmer may add EStructuralFeatures and the
> corresponding values for extra style attributes. In the article about
> Binding XML to Java (with EMF), it is described how this is done with
> XML documents, by using BasicExtendedMetaData and
> extendedMetadata.demandFeature. Will something similar work for my case,
> so that (de)serialization is handled for me?
>
> Ed, in a recent posting you referred to FeatureMaps as something that
> sucks because it is there to support a feature of XML that sucks. Does
> my design suck?
>
> Hallvard


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Modelling a variable set of properties using FeatureMap [message #425017 is a reply to message #425012] Thu, 13 November 2008 12:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Hallvard,

Comments below.

Hallvard Trætteberg wrote:
> Hi,
>
> I'm trying to model the concept of styles/styling of GUI elements, and
> need to handle the case of "unknown" style attributes.
Perhaps like attribute/element wildcards...
> My Style class has a set of features for the "known" style attributes,
> like Color, Font, etc. I now want to model the "unknown" and wonder if
> FeatureMap can be used and what is required to make it work.
Definitely that's possible.
>
> The idea is add a properties feature to the Style class, of type
> FeatureMap. Hence, the programmer may add EStructuralFeatures and the
> corresponding values for extra style attributes. In the article about
> Binding XML to Java (with EMF), it is described how this is done with
> XML documents, by using BasicExtendedMetaData and
> extendedMetadata.demandFeature. Will something similar work for my
> case, so that (de)serialization is handled for me?
Yes, although from what you describe, it could be a more strongly typed
thing. I.e., another model (corresponding to a schema that defines
global elements or attributes) could provide the strongly typed properties.
>
> Ed, in a recent posting you referred to FeatureMaps as something that
> sucks
Oops. :-P
> because it is there to support a feature of XML that sucks. Does my
> design suck?
Slightly. It's really an "eye of the beholder" type of thing.
FeatureMaps just aren't the most natural looking API, but what do you
expect from an object that can hold arbitrary open-end properties.

Another type of approach would be to have contained "StyleHolder"
instances that effectively allow you to create small objects to hold
additional style-related properties. I.e, more of a decorator
approach. In a UI, the properties of these style decorators could be
kind of flattened to make them look directly like properties on the
objects. Just a thought...
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Modelling a variable set of properties using FeatureMap [message #425021 is a reply to message #425015] Thu, 13 November 2008 12:49 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Tom Schindl wrote:
>
> Why can't someone who want to extend your "Style" to add a feature not
> simply really derive from it in his own .ecore? If all packages are
> registered correctly then EMF serializes/deserializes everything.

I agree that is usually desirable. Sometimes I (or others) nevertheless may want
to be able to add data (and the metadata, if required) directly, without editing
a separate model.

Being able to add a feature with data (in the FeatureMap), sounds like a very
flexible feature, in the general case, don't you think so? Perhaps the metadata
(feature's data) could be stored as part of the resource, and the resource could
transparently use these features when handling the XML for the data in the
FeatureMap? I notice that FeatureMaps arent't serializable, but perhaps by
adding some logic to save and load, it could be handled?

save:
if (attributeType == EFeatureMap) {
add necessary features to a local class for this resource
serialize the data, by pretending the owner class had this feature
}

load:
load the special class local to this resource
if (element recognized as FeatureMap feature) {
update the featureMap accordingly
}

Hallvard
Previous Topic:Generate impl and interfaces in different projects
Next Topic:[CDO] Current head not working with config file
Goto Forum:
  


Current Time: Thu Apr 25 22:55:56 GMT 2024

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

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

Back to the top