Home » Modeling » OCL » OCL expression subset editor
|
Re: OCL expression subset editor [message #705741 is a reply to message #705715] |
Sat, 30 July 2011 08:49 |
Ed Willink Messages: 7670 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 #708981 is a reply to message #708274] |
Wed, 03 August 2011 11:14 |
A Vernotte 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 #713942 is a reply to message #709215] |
Tue, 09 August 2011 12:56 |
A Vernotte 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 |
Ed Willink Messages: 7670 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 |
A Vernotte 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 |
Ed Willink Messages: 7670 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
|
|
|
Goto Forum:
Current Time: Tue Sep 24 22:06:20 GMT 2024
Powered by FUDForum. Page generated in 0.04476 seconds
|