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  |
John Conlon 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   |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: Adding an operation to a Form [message #1706324 is a reply to message #1706240] |
Tue, 25 August 2015 18:06   |
John Conlon 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   |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| |
Goto Forum:
Current Time: Thu Oct 05 04:13:07 GMT 2023
Powered by FUDForum. Page generated in 0.02068 seconds
|