Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Definition and data editor
Definition and data editor [message #894222] Sat, 07 July 2012 20:59 Go to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Hello,

I am trying to develop a model, which can represent a definition and additional the data.

I want to have a list with definition entries, which contains a map with a string key and for example an integer value like following:

command definition:

  • start - 4
  • dc - 6
  • end - 10
  • c - 1


The integer represent the count of spells, which can be used in the data entry.

command entry:

  • start - 1010
  • dc - 111011
  • end - 1001011010
  • c - 1


I hope my idea is clear enough, otherwise please ask and I will try to provide more details.

The first part (definition) is very simple and I have done this yet.
But how can I add the data part?
Re: Definition and data editor [message #894319 is a reply to message #894222] Sun, 08 July 2012 06:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
With Xcore you'd do it like this<br>
<blockquote><small>class StringToInteger wraps Map$Entry<br>
{<br>
    String key<br>
    Integer value<br>
}<br>
<br>
class Entry<br>
{<br>
    contains StringToInteger[] data<br>
}<br>
</small></blockquote>
Or you'd read the FAQ:<br>
<body>
</body>
<blockquote><a
href="http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_Map_in_EMF.3F"><span
class="tocnumber">2.29</span> <span class="toctext">How do I
create a Map in EMF?</span></a></blockquote>
<body>
</body>
<br>
<div class="moz-cite-prefix">On 07/07/2012 10:59 PM, Missing name
Mising name wrote:<br>
</div>
<blockquote cite="mid:jta7uv$4tm$1@xxxxxxxxe.org" type="cite">Hello,
<br>
<br>
I am trying to develop a model, which can represent a definition
and additional the data.
<br>
<br>
I want to have a list with definition entries, which contains a
map with a string key and for example an integer value like
following:
<br>
<br>
command definition:
<br>
<br>
start - 4
<br>
dc - 6
<br>
end - 10
<br>
c - 1
<br>
<br>
<br>
The integer represent the count of spells, which can be used in
the data entry.
<br>
<br>
command entry:
<br>
<br>
start - 1010
<br>
dc - 111011
<br>
end - 1001011010
<br>
c - 1
<br>
<br>
<br>
I hope my idea is clear enough, otherwise please ask and I will
try to provide more details.
<br>
<br>
The first part (definition) is very simple and I have done this
yet.
<br>
But how can I add the data part?
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: Definition and data editor [message #894453 is a reply to message #894222] Mon, 09 July 2012 09:40 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Thanks so far, I have generated the base model with the help of the map.

My definition model looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="container"
    nsURI="com.test.container" nsPrefix="container">
  <eClassifiers xsi:type="ecore:EClass" name="StringToInteger" instanceClassName="java.util.Map$Entry">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="key" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="data">
    <eStructuralFeatures xsi:type="ecore:EReference" name="definition" upperBound="-1"
        eType="#//StringToInteger" containment="true"/>
  </eClassifiers>
</ecore:EPackage>


But how can I connect it with my data editor?
In that case the integer value tells the validator the length of the data input. Furthermore the definition model contains possible keys.

EDIT:
My first approach to connect the keys is to reference from the second Map on the first map, but using StringToInteger as EType and key:EString as EKeys doesn't work.

[Updated on: Mon, 09 July 2012 09:57]

Report message to a moderator

Re: Definition and data editor [message #894463 is a reply to message #894453] Mon, 09 July 2012 10:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
Comments below.

On 09/07/2012 11:40 AM, Missing name Mising name wrote:
> Thanks so far, I have generated the base model with the help of the map.
>
> My definition model looks like the following:
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="container"
> nsURI="com.test.container" nsPrefix="container">
> <eClassifiers xsi:type="ecore:EClass" name="StringToInteger"
> instanceClassName="java.util.Map$Entry">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="key"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="data">
> <eStructuralFeatures xsi:type="ecore:EReference" name="definition"
> upperBound="-1"
> eType="#//StringToInteger" containment="true"/>
> </eClassifiers>
> </ecore:EPackage>
>
> But how can I connect it with my data editor?
What is your data editor?
> In that case the integer value tells the validator the length of the
> data input.
Which validator? What kind of data input is this?
> Furthermore the definition model contains possible keys.
Keys?
Re: Definition and data editor [message #894473 is a reply to message #894463] Mon, 09 July 2012 11:05 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
>> But how can I connect it with my data editor?
> What is your data editor?
I want to create a model which contains on the one side a definition of possible data and on the other side the data itself.

>> In that case the integer value tells the validator the length of the
>> data input.
> Which validator? What kind of data input is this?
There is actually no validator. I was searching for a possibility to do that with EMF, if it is possible.
Perhaps I have to use something else.

>> Furthermore the definition model contains possible keys.
> Keys?
I tried to explain it in my first post. The definition map holds an entry with key (string) and value (integer). the used keys have to be in the second map, but the value is different. The value have to be validated for example on length with the given integer value from map one.

My first step is to connect both key sets from map two with the key set of map one.
Re: Definition and data editor [message #894479 is a reply to message #894473] Mon, 09 July 2012 11:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Clearly what you're trying to accomplish is highly specialized to
your particular use case.  EMF won't generate it for you.  You can
model all this definition data and write the rest of the UI by
hand.  Perhaps you can declare named constraints in your model and
them implement their logic by hand:<br>
<blockquote><a class="moz-txt-link-freetext" href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.Validation.html">http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.Validation.html</a><br>
</blockquote>
<br>
<br>
<div class="moz-cite-prefix">On 09/07/2012 1:05 PM, Missing name
Mising name wrote:<br>
</div>
<blockquote cite="mid:jtedu9$n7m$1@xxxxxxxxe.org" type="cite">
<blockquote type="cite">
<blockquote type="cite">But how can I connect it with my data
editor?
<br>
</blockquote>
What is your data editor?
<br>
</blockquote>
I want to create a model which contains on the one side a
definition of possible data and on the other side the data itself.
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">In that case the integer value tells the
validator the length of the data input.
<br>
</blockquote>
Which validator? What kind of data input is this?
<br>
</blockquote>
There is actually no validator. I was searching for a possibility
to do that with EMF, if it is possible.
<br>
Perhaps I have to use something else.
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">Furthermore the definition model
contains possible keys.
<br>
</blockquote>
Keys?
<br>
</blockquote>
I tried to explain it in my first post. The definition map holds
an entry with key (string) and value (integer). the used keys have
to be in the second map, but the value is different. The value
have to be validated for example on length with the given integer
value from map one.
<br>
<br>
My first step is to connect both key sets from map two with the
key set of map one.
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: Definition and data editor [message #894480 is a reply to message #894479] Mon, 09 July 2012 11:32 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Thanks so far.
What would be the best approachment to create an editor?
I was thinking about the ecore editor. Use it and provide somehow the needed UI dialogs and so on.
Re: Definition and data editor [message #894522 is a reply to message #894480] Mon, 09 July 2012 13:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
You'll definitely need to write some type of dialog.  Perhaps you'll
want to use it as a cell editor in from the properties view:<br>
<body>
<li class="toclevel-2"><a
href="http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_property_editor_in_a_generated_application"><span
class="tocnumber">3.1</span> <span class="toctext">Recipe:
Create your own property editor in a generated application</span></a></li>
</body>
<br>
<div class="moz-cite-prefix">On 09/07/2012 1:32 PM, Missing name
Mising name wrote:<br>
</div>
<blockquote cite="mid:jtefgf$q67$1@xxxxxxxxe.org" type="cite">Thanks
so far.
<br>
What would be the best approachment to create an editor?
<br>
I was thinking about the ecore editor. Use it and provide somehow
the needed UI dialogs and so on.
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: Definition and data editor [message #895052 is a reply to message #894522] Wed, 11 July 2012 14:36 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Thanks so much. I have got the constraints working.

Is there any possibility to use the same keys in a map?
Re: Definition and data editor [message #895056 is a reply to message #895052] Wed, 11 July 2012 14:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
A map is constrained to have unique keys.

On 11/07/2012 4:36 PM, Missing name Mising name wrote:
> Thanks so much. I have got the constraints working.
>
> Is there any possibility to use the same keys in a map?
Re: Definition and data editor [message #895057 is a reply to message #895056] Wed, 11 July 2012 14:53 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Yeah sure, I think I was too indistinct.
Is it possible to have two maps which share the keys?

>A map is constrained to have unique keys.

On 11/07/2012 4:36 PM, Missing name Mising name wrote:
>> Thanks so much. I have got the constraints working.
>>
>> Is there any possibility to use the same keys in a map?
Re: Definition and data editor [message #895067 is a reply to message #895057] Wed, 11 July 2012 15:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
Your keys are just Strings so what does it mean for maps to share keys.
Of course two different maps can have the same or different keys...

On 11/07/2012 4:53 PM, Missing name Mising name wrote:
> Yeah sure, I think I was too indistinct.
> Is it possible to have two maps which share the keys?
>
>> A map is constrained to have unique keys.
>
> On 11/07/2012 4:36 PM, Missing name Mising name wrote:
>>> Thanks so much. I have got the constraints working.
>>>
>>> Is there any possibility to use the same keys in a map?
>
Re: Definition and data editor [message #895068 is a reply to message #895067] Wed, 11 July 2012 15:13 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
My idea was to have one list with the keys and this one can be used from the keyset of both maps.


> Ed Merks wrote on Wed, 11 July 2012 11:03
> Your keys are just Strings so what does it mean for maps to share keys.
> Of course two different maps can have the same or different keys...
Re: Definition and data editor [message #895074 is a reply to message #895068] Wed, 11 July 2012 15:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
So if either map contained a key that wasn't in the list, you'd want
that validated as an error?  You could certainly define such a
constraint.  <br>
<br>
Also, you could specialize the cell  editor so it offers only the
valid choices:<br>
<body>
<li class="toclevel-2"><a
href="http://wiki.eclipse.org/index.php/EMF-FAQ#How_can_I_control_which_instances_are_available_as_choices_when_editing_a_property_in_the_properties_view.3F"><span
class="tocnumber">2.46</span> <span class="toctext">How can
I control which instances are available as choices when
editing a property in the properties view?</span></a></li>
</body>
But then, I assume you're using some type of dialog, so in that you
could provide a drop down with the valid choices.<br>
<br>
<br>
<div class="moz-cite-prefix">On 11/07/2012 5:13 PM, Missing name
Mising name wrote:<br>
</div>
<blockquote cite="mid:jtk57d$f16$1@xxxxxxxxe.org" type="cite">My
idea was to have one list with the keys and this one can be used
from the keyset of both maps.
<br>
<br>
<br>
<blockquote type="cite">Ed Merks wrote on Wed, 11 July 2012 11:03
<br>
Your keys are just Strings so what does it mean for maps to
share keys.  Of course two different maps can have the same or
different keys...
<br>
</blockquote>
</blockquote>
<br>
<br>
</body>
</html>
Re: Definition and data editor [message #895549 is a reply to message #895074] Fri, 13 July 2012 13:59 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
I have used the map entry in my model, but starting with the generated model doesn't give me any chance to create an entry.
Is there a need for an own implementation of a map editor?
Re: Definition and data editor [message #895567 is a reply to message #895549] Fri, 13 July 2012 15:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
As you noticed, there is no generated interface for a map entry EClass.
Doing a eMap.put creates the entry and one doesn't generally work
directly with entries, other than via the Map.Entry interface. You can
use XyzFactory.eINSTANCE.create(XyzPackage.Literals.YOUR_MAP_ENTRY) to
create a map entry explicitly.


On 13/07/2012 3:59 PM, Missing name Mising name wrote:
> I have used the map entry in my model, but starting with the generated
> model doesn't give me any chance to create an entry.
> Is there a need for an own implementation of a map editor?
Re: Definition and data editor [message #897330 is a reply to message #895567] Mon, 23 July 2012 15:38 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
So I finished my work with the definition editor.
What would be the best way to implement the data editor?

In the definition editor, I can give details about the constraint. The data editor shall validate against them.
My idea was to create a data model, which loads the definition model and I add to the data model some annotations for the validation.
Re: Definition and data editor [message #897368 is a reply to message #897330] Mon, 23 July 2012 19:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
I suggest you asking more focused questions.


On 23/07/2012 5:38 PM, Missing name Mising name wrote:
> So I finished my work with the definition editor.
> What would be the best way to implement the data editor?
>
> In the definition editor, I can give details about the constraint. The
> data editor shall validate against them.
> My idea was to create a data model, which loads the definition model
> and I add to the data model some annotations for the validation.
Re: Definition and data editor [message #897467 is a reply to message #897368] Tue, 24 July 2012 08:30 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
I tried to explain it in my first post (http://www.eclipse.org/forums/index.php/mv/msg/367048/894222/#msg_894222).
I am searching for a good way to model and implement a definition and data editor.

Definition editor shall give the possibility to create a structure of attributes with constraints values.
Data editor shall use the structure of attributes to store them and check them against the constraints values.

The definition model was realized very fast and with your hints, I know the way how to handle constraints and so on.
But I want to model and implement the data editor now.

The idea was to create a data model, which loads the definition model and I "copy" the structure of the definition.
After that I change the types (of the constraints values) to the needed one (of the data values) and add the needed constraints annotation.

Perhaps there is a better way.
Re: Definition and data editor [message #897475 is a reply to message #897467] Tue, 24 July 2012 09:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
Comments below.

On 24/07/2012 10:30 AM, Missing name Mising name wrote:
> I tried to explain it in my first post
> (http://www.eclipse.org/forums/index.php/mv/msg/367048/894222/#msg_894222).
> I am searching for a good way to model and implement a definition and
> data editor.
It's a very long thread...
>
> Definition editor shall give the possibility to create a structure of
> attributes with constraints values.
> Data editor shall use the structure of attributes to store them and
> check them against the constraints values.
>
> The definition model was realized very fast and with your hints, I
> know the way how to handle constraints and so on.
> But I want to model and implement the data editor now.
>
> The idea was to create a data model, which loads the definition model
> and I "copy" the structure of the definition.
> After that I change the types (of the constraints values) to the
> needed one (of the data values) and add the needed constraints
> annotation.
Try it.
>
> Perhaps there is a better way.
I don't have the time to fully understand your design.
Previous Topic:Transform exiting model and save to .uml
Next Topic:What is the best way to translate an EMF model instance to a standard XML model instance
Goto Forum:
  


Current Time: Wed Dec 11 20:38:40 GMT 2019

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

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

Back to the top