Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » edit FeatureMap Text feature from text field in a form
edit FeatureMap Text feature from text field in a form [message #431549] Thu, 16 July 2009 02:55 Go to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 31
Registered: July 2009
Member
Sorry for bugging you on what is probably an easy one. I've been trying
to teach myself how to build a form with emf for too many hours now. I
read and re-read the EMF Second Edition on EMF.Edit, and click through
the source code and look at examples and I am still perplexed. Please
help. I'm new to swt, jface and emf.

I want to create a master-details form. The master side is ok for me,
the devil is in the details (sorry, could not resist.) I started with
the generated editor and turned it into a FormEditor. One of the pages
added is my master-details form.

My ecore is generated from xml schema with mixed content. In the details
form, I would like text form fields to be associated with the Text node
of the FeatureMap.

The ModifyEvent handler of my text fields has access to the editingDomain
and adapterFactory. It also has access to the parent of the FeatureMap's
container.

So my question is: how do I write the form's text field into the Text
feature of the feature map? The things I've tried don't work. I'd also
like to make sure the change event propagation is not suppressed.

[I don't think I need a AdapterFactoryContentProvider because, as I
understand, this is used for adapting the ItemProvider to jface Viewer
provider interfaces. My details form does not contain jface viewers.]



toolkit.createLabel(client, "description");
textDescription = toolkit.createText(client, "", SWT.SINGLE);
textDescription.setLayoutData(layoutData);
textDescription.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String changedText = textDescription.getText();

// description is the container of the 'mixed' FeatureMap
DescriptionType description =
eventDefinition.getDescription();

// how do I update the model?
}



Here is segment of the xml schema:


<xs:element name="event-definition">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="description"/>
.... other stuff elided....
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>

<xs:element name="description">
<xs:complexType mixed="true">
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>


Thanks.
Re: edit FeatureMap Text feature from text field in a form [message #431560 is a reply to message #431549] Thu, 16 July 2009 16:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
John,

Comments below.


John J. Franey wrote:
> Sorry for bugging you on what is probably an easy one. I've been trying
> to teach myself how to build a form with emf for too many hours now. I
> read and re-read the EMF Second Edition on EMF.Edit, and click through
> the source code and look at examples and I am still perplexed. Please
> help. I'm new to swt, jface and emf.
>
That's a lot to learn at once...
> I want to create a master-details form. The master side is ok for me,
> the devil is in the details (sorry, could not resist.) I started with
> the generated editor and turned it into a FormEditor. One of the pages
> added is my master-details form.
>
Not sure if the forms stuff in here helps:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=108470
> My ecore is generated from xml schema with mixed content. In the details
> form, I would like text form fields to be associated with the Text node
> of the FeatureMap.
>
There can be many...
> The ModifyEvent handler of my text fields has access to the editingDomain
> and adapterFactory. It also has access to the parent of the FeatureMap's
> container.
>
> So my question is: how do I write the form's text field into the Text
> feature of the feature map? The things I've tried don't work. I'd also
> like to make sure the change event propagation is not suppressed.
>
Things like FeatureMapUtil.addText help, but I assume you want to change
the existing text entry.

Methods like FeatureMapUtil.createTextEntry are useful, and then you can
use a SetCommand to replace the current feature map entry.
> [I don't think I need a AdapterFactoryContentProvider because, as I
> understand, this is used for adapting the ItemProvider to jface Viewer
> provider interfaces. My details form does not contain jface viewers.]
>
>
>
> toolkit.createLabel(client, "description");
> textDescription = toolkit.createText(client, "", SWT.SINGLE);
> textDescription.setLayoutData(layoutData);
> textDescription.addModifyListener(new ModifyListener() {
> public void modifyText(ModifyEvent e) {
> String changedText = textDescription.getText();
>
> // description is the container of the 'mixed' FeatureMap
> DescriptionType description =
> eventDefinition.getDescription();
>
> // how do I update the model?
> }
>
>
>
I'm not sure how you will deal with the fact that the getMixed() feature
map can have multiple entries for which FeatureMapUtil.isText is true...
> Here is segment of the xml schema:
>
>
> <xs:element name="event-definition">
> <xs:complexType>
> <xs:sequence>
> <xs:element minOccurs="0" ref="description"/>
> .... other stuff elided....
> </xs:sequence>
> <xs:attribute name="id" type="xs:ID"/>
> </xs:complexType>
> </xs:element>
>
> <xs:element name="description">
> <xs:complexType mixed="true">
> <xs:attribute name="id" type="xs:ID"/>
> </xs:complexType>
> </xs:element>
>
I don't understand why this complex type wasn't just given simple
content of type xsd:string. That would certainly make the EMF model for
it nicer and validates the same XML...
>
> Thanks.
>
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: edit FeatureMap Text feature from text field in a form [message #431569 is a reply to message #431560] Fri, 17 July 2009 02:45 Go to previous message
John J. Franey is currently offline John J. FraneyFriend
Messages: 31
Registered: July 2009
Member
On Thu, 16 Jul 2009 12:39:34 -0400, Ed Merks wrote:

> John,
>
> Comments below.
>
>
> John J. Franey wrote:
>> Here is segment of the xml schema:
>>
>>
>> <xs:element name="event-definition">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element minOccurs="0" ref="description"/>
>> .... other stuff elided....
>> </xs:sequence>
>> <xs:attribute name="id" type="xs:ID"/>
>> </xs:complexType>
>> </xs:element>
>>
>> <xs:element name="description">
>> <xs:complexType mixed="true">
>> <xs:attribute name="id" type="xs:ID"/>
>> </xs:complexType>
>> </xs:element>
>>
> I don't understand why this complex type wasn't just given simple
> content of type xsd:string. That would certainly make the EMF model for
> it nicer and validates the same XML...

That rang the bell. I made that change. Thanks.


>>
>> Thanks.
>>
>>
>>
>>
>>
Previous Topic:[Databinding API] Path over multi-valued features
Next Topic:[CDO] query server for existing repository
Goto Forum:
  


Current Time: Fri Apr 26 22:05:40 GMT 2024

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

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

Back to the top