Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to prevent the directed connections becoming circle by configuring OCL in gmfmap?
How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199549] Wed, 30 July 2008 13:51 Go to next message
Eclipse UserFriend
Originally posted by: jiezi506.gmail.com

How to prevent the directed connections becoming circle by configuring
OCL in gmfmap?
Re: How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199584 is a reply to message #199549] Wed, 30 July 2008 20:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Jiezi,

I won't speak to the details of specifying link constraints in GMF, but
as far as OCL is concerned, I can help.

MDT OCL provides a non-standard "closure" iterator for just this kind of
situation. As an example, in UML Classifiers can be related by
Generalizations. Cycles in generalizations are not permitted. This is
expressed with a constraint like:

context Classifier
inv: self->closure(generalization.general)->excludes(self)

The closure iterator is proof against unbounded looping when cycles do
occur.

HTH,

Christian


jiezi wrote:
> How to prevent the directed connections becoming circle by configuring
> OCL in gmfmap?
Re: How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199588 is a reply to message #199584] Thu, 31 July 2008 00:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jiezi506.gmail.com

Christian W. Damus 写道:
> Hi, Jiezi,
>
> I won't speak to the details of specifying link constraints in GMF, but
> as far as OCL is concerned, I can help.
>
> MDT OCL provides a non-standard "closure" iterator for just this kind of
> situation. As an example, in UML Classifiers can be related by
> Generalizations. Cycles in generalizations are not permitted. This is
> expressed with a constraint like:
>
> context Classifier
> inv: self->closure(generalization.general)->excludes(self)
>
> The closure iterator is proof against unbounded looping when cycles do
> occur.
>
> HTH,
>
> Christian
>
>
> jiezi wrote:
>> How to prevent the directed connections becoming circle by configuring
>> OCL in gmfmap?
thx very much ,my English is bad.
Re: How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199594 is a reply to message #199588] Thu, 31 July 2008 18:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jiezi506.gmail.com

jiezi wrote:
> Christian W. Damus 写道:
>> Hi, Jiezi,
>>
>> I won't speak to the details of specifying link constraints in GMF,
>> but as far as OCL is concerned, I can help.
>>
>> MDT OCL provides a non-standard "closure" iterator for just this kind
>> of situation. As an example, in UML Classifiers can be related by
>> Generalizations. Cycles in generalizations are not permitted. This
>> is expressed with a constraint like:
>>
>> context Classifier
>> inv: self->closure(generalization.general)->excludes(self)
>>
>> The closure iterator is proof against unbounded looping when cycles do
>> occur.
>>
>> HTH,
>>
>> Christian
>>
>>
>> jiezi wrote:
>>> How to prevent the directed connections becoming circle by
>>> configuring OCL in gmfmap?
> thx very much ,my English is bad.

sorry,I don't understand much,I just make a try in GMF-mindmap
example,and add a Link Constraints on Link Mapping in mindmap.gmfmap :
Body=self->closure(generalization.general)->excludes(self)
Language=ocl


but after I generate diagram code again and run it,when I create the
connection,there is a Exception:

org.eclipse.ocl.SemanticException: Unrecognized variable: (generalization)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:309 )
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:279 )
at
org.eclipse.ocl.internal.helper.HelperUtil.checkForErrors(He lperUtil.java:519)
at
org.eclipse.ocl.internal.helper.HelperUtil.parseQuery(Helper Util.java:165)
at
org.eclipse.ocl.internal.helper.OCLHelperImpl.createQuery(OC LHelperImpl.java:175)
at org.eclipse.ocl.ecore.OCLHelperImpl.createQuery(OCLHelperImp l.java:90)
at org.eclipse.ocl.ecore.OCLHelperImpl.createQuery(OCLHelperImp l.java:1)
at
org.eclipse.gmf.examples.mindmap.diagram.expressions.Mindmap OCLFactory$Expression.getQuery(MindmapOCLFactory.java:98)
at
org.eclipse.gmf.examples.mindmap.diagram.expressions.Mindmap OCLFactory$Expression.doEvaluate(MindmapOCLFactory.java:113)
at
org.eclipse.gmf.examples.mindmap.diagram.expressions.Mindmap AbstractExpression.evaluate(MindmapAbstractExpression.java:8 4)
at
org.eclipse.gmf.examples.mindmap.diagram.edit.policies.Mindm apBaseItemSemanticEditPolicy$LinkConstraints.canExistRelatio nship_3002(MindmapBaseItemSemanticEditPolicy.java:463)
at
org.eclipse.gmf.examples.mindmap.diagram.edit.policies.Mindm apBaseItemSemanticEditPolicy$LinkConstraints.canCreateRelati onship_3002(MindmapBaseItemSemanticEditPolicy.java:394)
at
org.eclipse.gmf.examples.mindmap.diagram.edit.commands.Relat ionshipCreateCommand.canExecute(RelationshipCreateCommand.ja va:96)
Re: How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199662 is a reply to message #199594] Thu, 31 July 2008 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jiezi506.gmail.com

jiezi506@gmail.com 写道:

I want to prevent the connection like "PortA--->PortB---->PortC--->PortA".

I make a try in TaiPan example,but I don't know how to create the
expression,because in TaiPan,all the "parent and child" informations are
stored in Route,I can't make the expression like this
"self->closure(port.source-Port)->excludes(self)" follow
"self->closure(generalization.general)->excludes(self)",

furthermore,one port may have more than one source port,like
"PortD--->PorE<----PortF".



The test code in TaiPan LinkConstraint is below:
public static boolean canExistRoute_4002(Port source,
Port target) {
try {
if (target == null) {
return true;
}
if (Route_4002_TargetExpression == null) {
Map env = Collections.singletonMap(OPPOSITE_END_VAR,
TaiPanPackage.eINSTANCE.getPort());
Route_4002_TargetExpression = TaiPanOCLFactory
.getExpression(

"self->closure(route.source)->excludes(self)",
TaiPanPackage.eINSTANCE.getRoute(), env); //$NON-NLS-1$
}
Object targetVal =
Route_4002_TargetExpression.evaluate(target,
Collections.singletonMap(OPPOSITE_END_VAR, source));
if (false == targetVal instanceof Boolean
|| !((Boolean) targetVal).booleanValue()) {
return false;
} // else fall-through
return true;
} catch (Exception e) {
TaiPanDiagramEditorPlugin.getInstance().logError(
"Link constraint evaluation error", e);
//$NON-NLS-1$
return false;
}
}

How could I make the expression in TaiPan example?

thx.
Re: How to prevent the directed connections becoming circle by configuring OCL in gmfmap? [message #199918 is a reply to message #199662] Sat, 02 August 2008 01:19 Go to previous message
Eclipse UserFriend
Originally posted by: jiezi506.gmail.com

jiezi 写道:
I puzzled my brains to find the answer,Is there any anybody can help me?thx.
Previous Topic:Copy/Paste question - how can I change an attribute value on a paste?
Next Topic:GMF + swing
Goto Forum:
  


Current Time: Tue Apr 23 09:29:00 GMT 2024

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

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

Back to the top