Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Constraint in ecore model(Constraint for flows in an activity diagram)
OCL Constraint in ecore model [message #1027762] Wed, 27 March 2013 11:39 Go to next message
Günther Fiedler is currently offline Günther Fiedler
Messages: 21
Registered: February 2013
Junior Member
Hello comunity,

The past few days i´ve been working on an activity diagram editor using Xtext to design the meta-model and GMF. It´s not like the usual UML diagram, because of domain specific requirements. The editor works fine, but still there are some issues which need to be fixed.

Here is my DSL:

ActivityDiagram:
{ActivityDiagram}
'ActivityDiagram: '
(nodes += Node*)
(pins += Pin*)
'AEND';

Flow:
(ControlFlow|ObjectFlow) //represents ControlFlow or ObjectFlow
;
ControlFlow:
('[' label=STRING ']')? '=>'(aim=[Node])
;
ObjectFlow:
('[' label=STRING ']')? '>>' target=[SourceNodes]
;

Pin:
'Pin' name=ID '{' type=STRING objectflows += ObjectFlow (',' objectflows += ObjectFlow)* '}';

Node:
( FinalNode|SourceNodes)
;

SourceNodes:
( InitialNode | ActionNode | ForkNode | JoinNode)
('{' flows+=ControlFlow (','flows+=ControlFlow )* '}')
;

InitialNode:
'Initial' name=ID ;

FinalNode:
'Final' name=ID
;

ActionNode:
'Action' name=ID
( 'Pin' pin = [Pin])? ;

ForkNode:
'Fork' name=ID;

JoinNode:
'Join' name=ID;

As you can see, i allow adding a Pin which (contains an ObjectFlow) to an ActionNode. Furthermore i also need ControlFlows. The Problem is, that the editor requests both flows after i added a Pin.

I was thinking that maybe an OCL Constraint could help to solve this Problem.

What do you think?


kind regards,
Günther
Re: OCL Constraint in ecore model [message #1027795 is a reply to message #1027762] Wed, 27 March 2013 12:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi

You can augment the behaviour of an Xtext editor by Loading a Complete
OCL Resource, so you could get diagnosis of an unwanted state.

However the OCL uis purely observational. It cannot repair your 'broken'
grammar.

In my experience such a grammar is not broken, because if the grammar
has insufficient precision, your user has insuiffocient understand too.

Therefpre the grammar should allow what seems sensible and give warnings
on the wing input.

Warnings can come from Java/CHECKS built-in to the editor, Complete OCL
added manually to the edit session, or OCLinEcore/Xcore built-in to the
model.

Regards

Ed Willink


On 27/03/2013 11:39, Günther Fiedler wrote:
> Hello comunity,
>
> The past few days i´ve been working on an activity diagram editor
> using Xtext to design the meta-model and GMF. It´s not like the usual
> UML diagram, because of domain specific requirements. The editor works
> fine, but still there are some issues which need to be fixed.
> Here is my DSL:
>
> ActivityDiagram:
> {ActivityDiagram}
> 'ActivityDiagram: '
> (nodes += Node*)
> (pins += Pin*)
> 'AEND';
>
> Flow:
> (ControlFlow|ObjectFlow) //represents ControlFlow or ObjectFlow
> ;
> ControlFlow:
> ('[' label=STRING ']')? '=>'(aim=[Node])
> ;
> ObjectFlow:
> ('[' label=STRING ']')? '>>' target=[SourceNodes]
> ;
>
> Pin:
> 'Pin' name=ID '{' type=STRING objectflows += ObjectFlow (','
> objectflows += ObjectFlow)* '}';
>
> Node:
> ( FinalNode|SourceNodes)
> ;
>
> SourceNodes:
> ( InitialNode | ActionNode | ForkNode | JoinNode)
> ('{' flows+=ControlFlow (','flows+=ControlFlow )* '}')
> ;
>
> InitialNode:
> 'Initial' name=ID ;
>
> FinalNode:
> 'Final' name=ID
> ;
>
> ActionNode:
> 'Action' name=ID
> ( 'Pin' pin = [Pin])? ;
>
> ForkNode:
> 'Fork' name=ID;
>
> JoinNode:
> 'Join' name=ID;
>
> As you can see, i allow adding a Pin which (contains an ObjectFlow) to
> an ActionNode. Furthermore i also need ControlFlows. The Problem is,
> that the editor requests both flows after i added a Pin.
>
> I was thinking that maybe an OCL Constraint could help to solve this
> Problem.
>
> What do you think?
>
>
> kind regards,
> Günther
Re: OCL Constraint in ecore model [message #1028042 is a reply to message #1027795] Wed, 27 March 2013 19:10 Go to previous message
Günther Fiedler is currently offline Günther Fiedler
Messages: 21
Registered: February 2013
Junior Member
Hi Ed,

Thank you for giving a broad hint with "broken". Wink

Now it works perfectly fine.
Previous Topic:[Complete OCL] Correct way of importing referred metamodels
Next Topic:Stereotype attributes and multiplicities
Goto Forum:
  


Current Time: Sat Oct 25 03:05:19 GMT 2014

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

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