Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF Parsley » Adding an operation to a Form(How to add an operation on an EObject to a Form)
Adding an operation to a Form [message #1706213] Tue, 25 August 2015 02:42 Go to next message
John Conlon is currently offline John ConlonFriend
Messages: 35
Registered: July 2009
Member
Is it possible to call an operation on an EObject and show the results in a text field in a form? (Or to add a computed attribute in the form?)


I have a EObject that has an operation defined on it called localDateTime.
Have tried:

1. Use a custom FeaturesProvider to identify the features:
stringMap.mapTo("com.verticon.im.Event", "utc", "localDateTime", "type", "target","comments");


2. In a FeaturesCaptionProvider:
public String text_Event_localDateTime(final EStructuralFeature it) {
		return "Local Time and Date:";
}


3. In the DSL
Event : utc -> {createText(if(utc==null)"" else utc.toString(), SWT::BORDER,SWT::READ_ONLY)}
				
Event : localDateTime -> {createText(if(utc==null)"" else it.localDateTime.toString(), SWT::BORDER,SWT::READ_ONLY)}


But the localDateTime field does not show in my Form and I get the following error message:

!ENTRY org.eclipse.emf.parsley 4 0 2015-08-24 21:24:01.457
!MESSAGE cannot find feature 'localDateTime' in EClass 'Event'

thanks for any help,
John
Re: Adding an operation to a Form [message #1706240 is a reply to message #1706213] Tue, 25 August 2015 08:30 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1750
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 25/08/2015 04:43, John Conlon wrote:
> Is it possible to call an operation on an EObject and show the results
> in a text field in a form? (Or to add a computed attribute in the form?)
>
>
> I have a EObject that has an operation defined on it called
> localDateTime. Have tried:
>
> 1. Use a custom FeaturesProvider to identify the features:
> stringMap.mapTo("com.verticon.im.Event", "utc", "localDateTime", "type",
> "target","comments");
>
>
> 2. In a FeaturesCaptionProvider:
> public String text_Event_localDateTime(final EStructuralFeature it) {
> return "Local Time and Date:";
> }
>
> 3. In the DSL
> Event : utc -> {createText(if(utc==null)"" else utc.toString(),
> SWT::BORDER,SWT::READ_ONLY)}
>
> Event : localDateTime -> {createText(if(utc==null)"" else
> it.localDateTime.toString(), SWT::BORDER,SWT::READ_ONLY)}
>
>
> But the localDateTime field does not show in my Form and I get the
> following error message:
>
> !ENTRY org.eclipse.emf.parsley 4 0 2015-08-24 21:24:01.457
> !MESSAGE cannot find feature 'localDateTime' in EClass 'Event'
>
> thanks for any help,
> John

Hi John

is localDateTime an attribute or an operation (e.g., getLocalDateTime)?
Operations are currently not supported, but computed attributes should
work... however, the error message says that the feature localDateTime
is not present in the EClass... could it be that the operation is
called getLocalDateTime? Xbase (used in the DSL) has a syntactic sugar
for getter/setter and the DSL might have guessed that you refer to
getLocalDateTime using the shorter form (localDateTime)... but then it
is interpreted as a field which does not exist...

could you please provide some more context?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: Adding an operation to a Form [message #1706324 is a reply to message #1706240] Tue, 25 August 2015 18:06 Go to previous messageGo to next message
John Conlon is currently offline John ConlonFriend
Messages: 35
Registered: July 2009
Member
Hi Lorenzo,

Yes, localDateTime is indeed an operation:

/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @model kind="operation" dataType="com.verticon.im.LocalDateTime"
	 * @generated
	 */
	LocalDateTime getLocalDateTime();


The error message is generated if I include:

stringMap.mapTo("com.verticon.im.Event", "utc", "localDateTime", "type", "target", "comments");


in the FeaturesProvider. If I leave the whole statement out, or the localDateTime string, it goes away, but I still can't generate the computed attribute.

Any tips to do it?

thanks,
John
Re: Adding an operation to a Form [message #1706614 is a reply to message #1706324] Fri, 28 August 2015 07:36 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1750
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 25/08/2015 20:06, John Conlon wrote:
> Hi Lorenzo,
>
> Yes, localDateTime is indeed an operation:
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @model kind="operation" dataType="com.verticon.im.LocalDateTime"
> * @generated
> */
> LocalDateTime getLocalDateTime();
>
> The error message is generated if I include:
>
> stringMap.mapTo("com.verticon.im.Event", "utc", "localDateTime", "type",
> "target", "comments");
>
> in the FeaturesProvider. If I leave the whole statement out, or the
> localDateTime string, it goes away, but I still can't generate the
> computed attribute.
> Any tips to do it?

Hi John

if it's an operation, I'm afraid it's not directly supported, since we
only use EStructuralFeatures and IIRC EOperation is not an
EStructuralFeature... would it be feasible for you to add a feature
localDateTime (as derived, transient, etc.) and leave getLocalDateTime
as it is? I think that this way it will work (I'll test it personally
in our test suite ASAP).

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: Adding an operation to a Form [message #1706770 is a reply to message #1706614] Mon, 31 August 2015 01:16 Go to previous message
John Conlon is currently offline John ConlonFriend
Messages: 35
Registered: July 2009
Member
Hi Lorenzo,

Adding as a derived feature should work. I will do so when I refactor the model again.

thanks,
John
Previous Topic:Show or hide logic in FeatureCaptionProvider
Next Topic:How to Customize Context Menu to create child that is not a containment *list*?
Goto Forum:
  


Current Time: Sun May 20 13:39:12 GMT 2018

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

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

Back to the top