How to add constraint? [message #55632] |
Tue, 26 September 2006 05:16  |
Eclipse User |
|
|
|
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 #56164 is a reply to message #55656] |
Wed, 27 September 2006 04:59   |
Eclipse User |
|
|
|
> 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 07:30  |
Eclipse User |
|
|
|
"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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03227 seconds