Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL expression subset editor
OCL expression subset editor [message #705715] Sat, 30 July 2011 08:13 Go to next message
A Vernotte is currently offline A VernotteFriend
Messages: 21
Registered: June 2011
Junior Member
Hi,

I'm creating a plugin that will contribute to Papyrus. One of its perks is to allow users to specify pre and postcondition to operation classes. So what I need is an OCL Editor, but not a completeOCL editor, its scope should only be OCL expressions (as it is required in the UML metamodel).
Is there any existing editor that would do the job ? I started creating a dedicated one with EMFText, but it's going to take days before having a workable solution.
Also, I need the editor to know the context it is in, even if it's not given in the OCL code. For example, if I'm giving a precondition to method "world()" of class "hello", "self" would correspond to the class hello and the auto-completion should show its attributes and associations.

Thank you !

A
Re: OCL expression subset editor [message #705741 is a reply to message #705715] Sat, 30 July 2011 08:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi A

This functionality is already 'part of' Papyrus.

A just before Indigo change for the Eclipse OCL examples was to support
UML models via an automated translation to Ecore.

A just before Indigo change for Papyrus was to add integration for the
EssentialOCL editor.

You can use this functionality for direct editing of constraints in
Class Diagrams.

Since these were very late contributions, the ergonomics can be
improved, and the Eclipse OCL APIs will be improving to make the editors
more extensible when they are promoted to non-example status in Juno.
The Xtext editors underlying the OCL editors are very extensible,
however the mapping from Concrete Syntax to Abstract Syntax is not yet
model defined and so may require considerable manual customisation for
significantly different Concrete Syntaxes.

Regards

Ed Willink

On 30/07/2011 09:13, A Vernotte wrote:
> Hi,
>
> I'm creating a plugin that will contribute to Papyrus. One of its
> perks is to allow users to specify pre and postcondition to operation
> classes. So what I need is an OCL Editor, but not a completeOCL
> editor, its scope should only be OCL expressions (as it is required in
> the UML metamodel). Is there any existing editor that would do the job
> ? I started creating a dedicated one with EMFText, but it's going to
> take days before having a workable solution. Also, I need the editor
> to know the context it is in, even if it's not given in the OCL code.
> For example, if I'm giving a precondition to method "world()" of class
> "hello", "self" would correspond to the class hello and the
> auto-completion should show its attributes and associations.
>
> Thank you !
>
> A
Re: OCL expression subset editor [message #708093 is a reply to message #705741] Tue, 02 August 2011 13:05 Go to previous messageGo to next message
A Vernotte is currently offline A VernotteFriend
Messages: 21
Registered: June 2011
Junior Member
Hi Edward,

thank you for your reply ! I will look into it harder, it's weird though because I tried to add constraints to an Operation, and an OpaqueExpression to each of these constraints. I indeed found an editor to write OCL, but I don't think it's the one you mentioned.

http://img11.hostingpics.net/pics/538754opaqueexpression.jpg

I'm not sure then what you exactly ment, as there is no such editor as EssentialOCL in my version of Eclipse. I Hope you can provide me a little more explanation on the subject.
FYI I work with Indigo and Papyrus 0.8.

Anyway, thank you for helping !

[Updated on: Tue, 02 August 2011 13:26]

Report message to a moderator

Re: OCL expression subset editor [message #708274 is a reply to message #708093] Tue, 02 August 2011 16:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi A

The OCL editors are not part of the basic Core OCL that is part of
modeling. You need to install the OCL Examples and Editors.

Look for org.eclipse.ocl.examples.xtext.* plugins.

Regards

Ed Willink

On 02/08/2011 14:06, A Vernotte wrote:
> Hi Edward,
>
> thank you for your reply ! I will look into it harder, it's weird
> though because I tried to add constraints to an Operation, and an
> OpaqueExpression to each of these constraints. I indeed found an
> editor to write OCL, but I don't think it's the one you mentioned.
>
>
> I'm not sure then what you exactly ment, as there is no such editor as
> EssentialOCL in my version of Eclipse. I Hope you can provide me a
> little more explanation on the subject.
> Anyway, thank you for helping !
>
>
Re: OCL expression subset editor [message #708981 is a reply to message #708274] Wed, 03 August 2011 11:14 Go to previous messageGo to next message
A Vernotte is currently offline A VernotteFriend
Messages: 21
Registered: June 2011
Junior Member
Hi Ed,

yeah I've already installed the OCL Examples and Editors, and as a matter of fact I can open an EssentialOCL editor instance to edit a .essentialocl file. But what I can't do is edit OpaqueExpressions, I looked everywhere (well, I hope not) and I could not get it. Have I forgotten to do something necessary ?

Thanks again..

[Updated on: Wed, 03 August 2011 13:13]

Report message to a moderator

Re: OCL expression subset editor [message #709215 is a reply to message #708981] Wed, 03 August 2011 16:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The EssentialOCL editor maintains a text string and an OclExpression
tree, which may be wrapped in an ExpressionInOcl which derives
fromOpaqueExpression to provide OCL's integration with UML.

If you use ExpressionInOcl you will run into problems because the OMG
specification doesn't provide a useable interchange specification, so
you can use org.eclipse.ocl.uml.ExpressionInOcl that aligns with the
UML2 project or org.eclipse.ocl.examples.pivot.ExpressionInOcl that is a
prototype for a resolution
of the specification problems.

Given the problems with ExpressionInOcl, I would recommend that you
construct an OpaqueExpression instead so that OCL is interchanged textually.

Regards

Ed Willink

On 03/08/2011 12:14, A Vernotte wrote:
> Hi Ed,
>
> yeah I've already installed the OCL Examples and Editors, and as a
> matter of fact I can open an EssentialOCL editor instance to edit a
> file. But what I can't do is edit OpaqueExpressions, I looked
> everywhere (well, I hope not) and I could not get it. Have I forgotten
> to do something necessary ?
>
> Thanks again..
>
Re: OCL expression subset editor [message #713942 is a reply to message #709215] Tue, 09 August 2011 12:56 Go to previous messageGo to next message
A Vernotte is currently offline A VernotteFriend
Messages: 21
Registered: June 2011
Junior Member
Hi Ed,

I followed your precious advices, well I hope I did, and what I'm trying to do now is to create a .essentialOCL file, in order to open it with its associated Editor, to eventually load its content into an OpaqueExpression. I'm actually struggling with the last step.
Maybe I should post in the GMF or Xtext Section, but I'll try here as it's a consequence to my previous problem and you could have an answer for me. I have in fact two problems :

First, I don't know how to "load the file content" into an OpaqueExpression instance at saving. I'l try to find out int the Xtext doc, but if you (or anyone else !) have an instant solution it would be great.
Second, I can't "link" a constraint containing the freshly created OpaqueExpression to the selected Operation anymore, it says "Cannot modify resource set without a write transaction". I tried a method I found in the GMF Q_and_A (http://wiki.eclipse.org/GMF_Archived_Newsgroup_Q_and_A#How_can_I_change_a_property_programmatically.3F and http://wiki.eclipse.org/GMF_Archived_Newsgroup_Q_and_A#How_can_I_modify_a_resource_set_without_a_write_transaction.3F), but it does not seem to work.

Again, thank you a lot.

A

[Updated on: Wed, 10 August 2011 07:50]

Report message to a moderator

Re: OCL expression subset editor [message #714054 is a reply to message #713942] Tue, 09 August 2011 17:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This is the right newsgroup. Nothing to do with GMF at all; just
possibly Papyrus.

The extension should be .essentialocl

You should just be able to ResourceSet.loadResource and get an
XtextResource which is a CST.

If you want an AST use CS2Pivot and populate an ExpressionInOcl.

If you want text, as you do for an OpaqueExpression, save the
XtextResource to a StringWriter and then save the text

StringWriter xmlWriter = new StringWriter();
xmlResource.save(writer, null);

Putting all this in an OpaqueExpression seems like useful utility
routine. If you feel like contributing a draft please do.

Regards

Ed Willink

On 09/08/2011 13:56, A Vernotte wrote:
> Hi Ed,
>
> I followed your precious advices, well I hope I did, and what I'm
> trying to do now is to create a .essentialOCL file, in order to open
> it with its associated Editor, to eventually load its content into an
> OpaqueExpression. I'm actually struggling with the last step.
> Maybe I should post in the GMF or Xtext Section, but I'll try here as
> it's a consequence to my previous problem and you could have an answer
> for me. I have in fact two problems :
>
> First, I don't know how to "load the file content" into an
> OpaqueExpression instance at saving. I'l try to find out int the Xtext
> doc, but if you (or anyone else !) have an instance solution it would
> be great.
> Second, I can't "link" a constraint containing the freshly created
> OpaqueExpression to the selected Operation anymore, it says "Cannot
> modify resource set without a write transaction". I tried a method I
> found in the GMF Q_and_A
> (http://wiki.eclipse.org/GMF_Archived_Newsgroup_Q_and_A#How_can_I_change_a_property_programmatically.3F
> and
> http://wiki.eclipse.org/GMF_Archived_Newsgroup_Q_and_A#How_can_I_modify_a_resource_set_without_a_write_transaction.3F),
> but it does not seem to work.
>
> Again, thank you a lot.
>
> A
Re: OCL expression subset editor [message #714786 is a reply to message #714054] Thu, 11 August 2011 13:50 Go to previous messageGo to next message
A Vernotte is currently offline A VernotteFriend
Messages: 21
Registered: June 2011
Junior Member
Hi Ed,

Thanks you again, but there are still some things that are just not clear to me.

I'll try to explain what I did :
When should I get the essentialocl file content ? At saving I guess, and as it's a resource, I tried to add a ResourceChangeListener, to get modified resources and pick the one I need. First problem, with the essentialocl editor, the resource corresponding to the essentialocl file isn't retrieved by the listener, only its project. With any other text editor, when saving an edited file, the listener behaves as expected and retrieve the file resource.

I didn't really understand what I should do with an Xtext resource, well I guess it's the editor content, which I would "transform" into a String with a StringWriter, but I don't know how to retrieve it at the right time.

On the bright side, I finally found how to create an OpaqueExpression programmatically, with a write transaction : a SetValueCommand executed by a commandStack. Well, I still should create it at saving and not when opening the editor, but it's a start.

I would love to contribute a draft, but only when I'll feel competent enough. This is not for today.

A

[Updated on: Thu, 11 August 2011 13:50]

Report message to a moderator

Re: OCL expression subset editor [message #714906 is a reply to message #714786] Thu, 11 August 2011 17:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi
> When should I get the essentialocl file content ? At saving I guess,
> and as it's a resource, I tried to add a ResourceChangeListener, to
> get modified resources and pick the one I need. First problem, with
> the essentialocl editor, the resource corresponding to the
> essentialocl file isn't retrieved by the listener, only its project.
> With any other text editor, when saving an edited file, the listener
> behaves as expected and retrieve the file resource.
>
This doesn't sound right. The EssentialOCL editor is a very ordinary
Xtext editor; only the OCLinEcore editor has significantly adjusted
Resource-level behaviour.
> I didn't really understand what I should do with an Xtext resource,
> well I guess it's the editor content, which I would "transform" into a
> String with a StringWriter, but I don't know how to retrieve it at the
> right time.
I suggest trying to repeat your experiments with either a *.xtext
(directly) or a *.dmodel (the Xtext Domain Model example). This will
enable you to tell whether your problem is with Xtext Resources in
general or EssentialOCL Resources in particular.

Regards

Ed Willink
Previous Topic:Definion of variables inOclInEcore
Next Topic:check OCL constraints as program constraints
Goto Forum:
  


Current Time: Thu Apr 18 16:50:52 GMT 2024

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

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

Back to the top