Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to add constraint?
How to add constraint? [message #55632] Tue, 26 September 2006 09:16 Go to next message
Junyan is currently offline JunyanFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,

I encounter a problem about adding constraint to a node.
problem:
Class A has containment reference feature (bReferences)to B. B could add
to A's compartment. In the gmfmap file under the Node Mapping of Class A,
I add a constraint with ocl body of 'slef.bReferences->size()<=3'. Then I
generate the diagram editor code. But in the editor I can still add more
than 3 B in A's compartment. Is anything incorrect around here? Thanks a
lot.

best regards
Junyan
Re: How to add constraint? [message #55656 is a reply to message #55632] Tue, 26 September 2006 09:34 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Junyan,

If you have used an Audit Rule for your constraint you must set 'Live =

Mode' to
'true' in order to prohibit adding more B nodes during editing.
See http://wiki.eclipse.org/index.php/GMF_Tutorial_Part_2#Valida tion and=
=

EMFT Validation.
Otherwise, audits are evaluated on demand in 'Batch Mode' during =

'Validate' action execution.

Beware that the Constraint child element of Node Mapping is just a =

restriction to domain elements which
are to be mapped to the given node. This allows mapping of single EClass=
=

to multiple nodes based on the specified
condition.

Regards,
/Radek


On Tue, 26 Sep 2006 11:16:19 +0200, Junyan <alexmajy@gmail.com> wrote:

> Hi,
>
> I encounter a problem about adding constraint to a node.
> problem:
> Class A has containment reference feature (bReferences)to B. B could a=
dd =

> to A's compartment. In the gmfmap file under the Node Mapping of Class=
=

> A, I add a constraint with ocl body of 'slef.bReferences->size()<=3D3'=
.. =

> Then I generate the diagram editor code. But in the editor I can still=
=

> add more than 3 B in A's compartment. Is anything incorrect around her=
e? =

> Thanks a lot.
>
> best regards
> Junyan
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: How to add constraint? [message #56164 is a reply to message #55656] Wed, 27 September 2006 08:59 Go to previous messageGo to next message
Junyan is currently offline JunyanFriend
Messages: 10
Registered: July 2009
Junior Member
> Radek Dvorak wrote:

> Hi Junyan,

> If you have used an Audit Rule for your constraint you must set 'Live
> Mode' to
> 'true' in order to prohibit adding more B nodes during editing.
> See http://wiki.eclipse.org/index.php/GMF_Tutorial_Part_2#Valida tion and
> EMFT Validation.
> Otherwise, audits are evaluated on demand in 'Batch Mode' during
> 'Validate' action execution.

> Beware that the Constraint child element of Node Mapping is just a
> restriction to domain elements which
> are to be mapped to the given node. This allows mapping of single EClass
> to multiple nodes based on the specified
> condition.

> Regards,
> /Radek


> On Tue, 26 Sep 2006 11:16:19 +0200, Junyan <alexmajy@gmail.com> wrote:

>> Hi,
>>
>> I encounter a problem about adding constraint to a node.
>> problem:
>> Class A has containment reference feature (bReferences)to B. B could add
>> to A's compartment. In the gmfmap file under the Node Mapping of Class
>> A, I add a constraint with ocl body of 'slef.bReferences->size()<=3'..
>> Then I generate the diagram editor code. But in the editor I can still
>> add more than 3 B in A's compartment. Is anything incorrect around here?
>> Thanks a lot.
>>
>> best regards
>> Junyan


Hi Radek,

It works with the 'Live Mode' Audit Rule. Just as you said 'Audit Rule'
could be regarded as the hole constraint for a domain element target. But
I could not do the constraint successfully by adding child constraint to
node mapping, just like tutorial dose for link mapping. Are there any
additional special settings for the node mapping constraint? Thanks

Best regards
Junyan
Re: How to add constraint? [message #56255 is a reply to message #56164] Wed, 27 September 2006 11:30 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
"Junyan" <alexmajy@gmail.com> wrote in message
news:1b947b600f534c90d49ccde7dab4a30f$1@www.eclipse.org...
>> Radek Dvorak wrote:
>
>> Hi Junyan,
>
>> If you have used an Audit Rule for your constraint you must set 'Live
>> Mode' to
>> 'true' in order to prohibit adding more B nodes during editing.
>> See http://wiki.eclipse.org/index.php/GMF_Tutorial_Part_2#Valida tion and
>> EMFT Validation.
>> Otherwise, audits are evaluated on demand in 'Batch Mode' during
>> 'Validate' action execution.
>
>> Beware that the Constraint child element of Node Mapping is just a
>> restriction to domain elements which
>> are to be mapped to the given node. This allows mapping of single EClass
>> to multiple nodes based on the specified
>> condition.
>
>> Regards,
>> /Radek
>
>
>> On Tue, 26 Sep 2006 11:16:19 +0200, Junyan <alexmajy@gmail.com> wrote:
>
>>> Hi,
>>>
>>> I encounter a problem about adding constraint to a node.
>>> problem:
>>> Class A has containment reference feature (bReferences)to B. B could add
>>> to A's compartment. In the gmfmap file under the Node Mapping of Class
>>> A, I add a constraint with ocl body of 'slef.bReferences->size()<=3'..
>>> Then I generate the diagram editor code. But in the editor I can still
>>> add more than 3 B in A's compartment. Is anything incorrect around here?
>>> Thanks a lot.
>>>
>>> best regards
>>> Junyan
>
>
> Hi Radek,
>
> It works with the 'Live Mode' Audit Rule. Just as you said 'Audit Rule'
> could be regarded as the hole constraint for a domain element target. But
> I could not do the constraint successfully by adding child constraint to
> node mapping, just like tutorial dose for link mapping. Are there any
> additional special settings for the node mapping constraint? Thanks
>

I'm not sure I fully understand your problem. In the first post you have
described
a situation about constraint for editing the model (addition up to 3 Bs),
which is an AuditRule.
As for the Constraint element of NodeMapping, It just refines the mapping of
domain
meta-model EClass to visual Node (as I have stated in the end of my previous
answer).

In other words, 'slef.bReferences->size()<=3' constraint under the A
NodeMapping says that
only A instances containing up to 3 B instances are mapped to the given
node.

Or have I missed anything ?

PS: there is only one thing I can see as a source of the problem, a typing
error in 'slef'' .?
I would expect 'self'' instead, unless your A class defines a 'slef'
property.


> Best regards
> Junyan
>
Previous Topic:maintenance release for gmf 1.0?
Next Topic:ClassCastException 'Compartment Mapping' - ecore - "modelworkz.ecore" yEnc (1/1)
Goto Forum:
  


Current Time: Wed Jul 24 15:24:07 GMT 2024

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

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

Back to the top