Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF Parsley » Nested features in TableViewer, any updates ?
Nested features in TableViewer, any updates ? [message #1827292] Tue, 12 May 2020 10:53 Go to next message
Samuel BADION is currently offline Samuel BADIONFriend
Messages: 2
Registered: May 2020
Junior Member
Hello Parlsey team,

First, thank you for your awesome work.

Related topics

I have read a few topics related to my interest but they are 4 or 5 years old. Maybe things have evolved.

Related topics :
- https://www.eclipse.org/forums/index.php/t/1075375/
- https://www.eclipse.org/forums/index.php/t/1065425/

Issue

I would like to show a nested feature using a TableView, however I do not want to declare a derived feature in my metamodel for this sole purpose.

Here is an example :
,--------------.
|   Child      |
|--------------|
|+name : String|
|--------------|
`--------------'
        |       
        |
        V  parent     
,--------------.
|   Adult      |
|--------------|
|+name : String|
|--------------|
`--------------'

Let each row of my TableView respresent a child instance, I would like to display a column containing parent's name (child.parent.name). No containment here.

Using your DSL, the usage of a '.' is invalid :
featuresProvider{
	features{
		Child -> name, parent.name
	}
}


Is there any way of doing this using your DSL ?

Should I provide my own Java class extending your FeaturesProvider ?

If so, what should my implementation put in the provided stringMap ?
public void buildStringMap(final EClassToEStructuralFeatureAsStringsMap stringMap);


Re: Nested features in TableViewer, any updates ? [message #1827314 is a reply to message #1827292] Tue, 12 May 2020 23:26 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 235
Registered: January 2012
Senior Member

Hi Samuel,
if your goal is to show an additional column showing parent.name and you have a specific Parsley plugin for handling the table, then you could simply specify via DSL (with tableLabelProvider) how to represent Child.parent, like this:
	tableLabelProvider {
		text {
			Child:parent -> {  it.parent.name }
		}
	}
Re: Nested features in TableViewer, any updates ? [message #1827358 is a reply to message #1827314] Wed, 13 May 2020 17:23 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 235
Registered: January 2012
Senior Member

Sorry,
in my previous comment I missed a little detail ;) that is adding just parent in the featureProvider

featuresProvider {
	features{
		Child -> name, parent
	}
}
Re: Nested features in TableViewer, any updates ? [message #1827418 is a reply to message #1827358] Thu, 14 May 2020 09:15 Go to previous messageGo to next message
Samuel BADION is currently offline Samuel BADIONFriend
Messages: 2
Registered: May 2020
Junior Member
It seems like your solution only supports one column by direct feature, right ? Your TableLabelProvider provides a representation of Child:parent using the Adult:name feature, it does not create a specific column for Child:parent:name.

,--------------.
|   Adult      |
|--------------|
|+name : String|
|+age : String |
|--------------|
`--------------'


To display a third column for parent.age the following snippet would not work as it creates a duplication in the map :

featuresProvider {
	features{
		Child -> name, parent
	}
}

tableLabelProvider {
	text {
                Child:name   -> name
		Child:parent -> parent.name
                Child:parent -> parent.age
	}
}


My first example was too minimalist to illustrate my issue.
Re: Nested features in TableViewer, any updates ? [message #1827515 is a reply to message #1827418] Sat, 16 May 2020 13:06 Go to previous message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 235
Registered: January 2012
Senior Member

Hi Samuel,
you're right: my previous suggestion only works if you have just one attribute to show in the referenced object.

Indeed the idea behind Parsley is that the EMF Model should be strongly tied to the UI, rather than to the domain model (even at the cost of having two different models).

Usually your goal is obtained by adding to the main model class a set of 'calculated' EAttributes (e.g. parentName, parentAge) with:

  • Changeable = false (no setter will be generated)
  • Volatile = true (no attribute will be generated)

then, after re-generating the model source you will see tha *Impl classes contains methods like
getParentName()
getParentAge()
whose body is throwing an exception.
Notice that no new attributes are being generated and that no correspondent setter method is present.

At this point you can implement their body as you wish, e.g.:
	public String getParentName() {
		return parent.getName();
	}

Note: remember to delete or change the * @generated annotation in comment, otherwise at next re-generation your code will be overwritten.

In case you are not allowed to change the original EMF model you can create a derived model that depends and extends the original one.

HTH
Vincenzo
Previous Topic:Any API for Parsley RAP?
Next Topic:Case sensitivity problem in parsley proposals
Goto Forum:
  


Current Time: Fri Apr 19 22:22:25 GMT 2024

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

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

Back to the top