|
|
|
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 14:23   |
Eclipse User |
|
|
|
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 09:09   |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02932 seconds