Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » DSL showing attributes based on its content value
DSL showing attributes based on its content value [message #995615] Sun, 30 December 2012 17:19 Go to next message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

Backgroud:
I have following EMF model:

EClass - View
		uielements [list containing of type UIElement]
EClass - UIElement
		properties [list containing of type Property]
EClass - Property 
		name [String]
		value [String]


You can think of this View as any html page which contains many UI elements and each UI element has many properties.
There are existing xmi files each containing content of a View.
I am loadoing this xmi file using XMIResource and then moved the content to XTextResource (with different file extension). When i save the XTextResource, i can see the DSL format.

Problem:
The DSL shows all Properties for a UI Element.
I want to show only those properties which have value not equal to its non-default value.
In this way the size of DSL will be small.

Any hint on how i can achieve this will be really helpful.

Thanks and Regards,
Ashwani Kr Sharma

[Updated on: Sun, 30 December 2012 17:44]

Report message to a moderator

Re: DSL showing attributes based on its content value [message #995664 is a reply to message #995615] Sun, 30 December 2012 20:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Ashwani,

I wonder if in your model these features are marked as optional and in
your grammar you've also made them optional?

On 30/12/2012 6:20 PM, Ashwani Kr Sharma wrote:
> Hi,
>
> Backgroud:
> I have following model:
>
> EClass - View
> uielements [list containing of type UIElement]
> EClass - UIElement
> properties [list containing of type Property]
> EClass - Property name [String]
> value [String]
>
> You can think of this View as any html page which contains many UI
> elements and each UI element has many properties.
> There are existing xmi files each containing content of a View.
> I am loadoiing this xmi file using XMIResource and then moved the
> content to XTextResource (with different file extension). When i save
> the XTextResource, i can see the DSL format.
>
> Problem:
> The DSL shows all Properties for a UI Element. I want to show only
> those properties which have value not equal to it non-default value.
>
> Any hint on how i can acheive this will be really helpful.
>
> Thanks and Regards,
> Ashwani Kr Sharma
Re: DSL showing attributes based on its content value [message #995811 is a reply to message #995664] Mon, 31 December 2012 07:08 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi Ed,

Thanks for your reply.
These features are optional in both ECore model and xtext grammar.

Actually the xmi file have UIElement with all properties set to their values (even if they are default). Hence, when DSL is generated based on the model these values are part of the DSL.
I think i have to do something in the Serializer, to not serialize the property if the value is equal to default value. But i am not able to understand where to do this.

Any hints ?

Regards,
Ashwani Kr Sharma

[Updated on: Mon, 31 December 2012 07:09]

Report message to a moderator

Re: DSL showing attributes based on its content value [message #995818 is a reply to message #995811] Mon, 31 December 2012 07:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Ashwani,

Comments below.


On 31/12/2012 8:08 AM, Ashwani Kr Sharma wrote:
> Hi Ed,
>
> Thanks for you reply.
> These features are optional in both ECore model and xtext grammar.
>
> Actually the xmi file have UIElement with all properties set to their
> values (even if they are default).
The XML serializers checks EObject.eIsSet for each feature and generally
does not serialize features that aren't set.
> Hence, when DSL is generated based on the model these values are part
> of the DSL.
> I think i have to do something in the Serializer to not serialize the
> property if the value is equal to default value.
Probably (but I'm not sure), the Xtext serializer does the same checking.
> But i am not able to understand where to do this.
Do you know if eIsSet is true for these features that are being
serialized but you don't want to have serialized? Is
EStructuralFeature.isUnsettable true for these feature?
>
> Any hints ?
>
> Regards,
> Ashwani Kr Sharma
Re: DSL showing attributes based on its content value [message #999617 is a reply to message #995818] Sat, 12 January 2013 17:11 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

I am kinna stuck with this issue. Can you please give some hints.

Regards,
Ashwani Kr Sharma
Re: DSL showing attributes based on its content value [message #999623 is a reply to message #999617] Sat, 12 January 2013 17:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Ashwani,

You didn't answer my questions. My questions were the hints...

On 12/01/2013 6:11 PM, Ashwani Kr Sharma wrote:
> Hi,
>
> I am kinna stuck with this issue. Can you please give some hints.
>
> Regards,
> Ashwani Kr Sharma
Re: DSL showing attributes based on its content value [message #1006989 is a reply to message #999623] Sun, 03 February 2013 15:45 Go to previous message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi Ed,

Sorry to follow up late. Was stuck up in some parallel work.

I read my post and your replies. I think missed an important part of in problem description.

Actually there are two models:
ViewModel:
EClass - View
		uielements [list containing of type UIElement]
EClass - UIElement
		properties [list containing of type Property]
EClass - Property 
		name [String]
		value [String]


AND

UI Element Definitions
EClass - UIElementDef
		properties [list containing of type PropertyDef]
EClass - PropertyDef
		name [String]
		defaultvalue [String]


I want to create text modeling for xmi coming from View Model.
While doing so only those property has to be shown which has
(property.name = propertyDef.name and property.value != propertyDef.defaultvalue)


The logic of eIsSet would have worked if the value for EObject was not equal to its default Value in EMF Model.
In my use case, i guess i need to put code somewhere to skip the property.name to display in the DSL.

I should have specified the complete scenario but i missed somehow.
Where can i put the logic to skip property.name when property.value != propertyDef.defaultvalue

Regards,
Ashwani Kr Sharma

[Updated on: Sun, 03 February 2013 15:46]

Report message to a moderator

Previous Topic:How to turn an expression String into an Xtext object?
Next Topic:Standalone Java Application
Goto Forum:
  


Current Time: Mon Sep 22 00:18:48 GMT 2014

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

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