Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Embedding OCL editor in Sirius(Using OCL to allow users to create constraints)
Embedding OCL editor in Sirius [message #1835983] Thu, 17 December 2020 17:47 Go to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 49
Registered: March 2020
Member
Hi,

I have a Constraint class defined in my metamodel that is is to allow users to define constraints in the models that they create. I want the description of the constraint to be in OCL or some flavor of it. How do I allow a user to create a constraint and when writing it out, access an editor for it so that there is syntax highlighting and other nice to haves when it comes to writing formal constraints?

Essentially I want to embed an editor in my class so that it accessible to Sirius.. I think?
Re: Embedding OCL editor in Sirius [message #1835989 is a reply to message #1835983] Thu, 17 December 2020 19:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
Hi

You probably want to study the use of the EmbeddedXtextEditor which Papyrus uses for OCL and other purposes. In principle you just have to activate the CompleteOCLUiModule. In practice you need to be careful with your tool bar contributions to ensure that all the accelerators and decorators work.

The EmbeddedXtextEditor has a long history starting as an EclipseLabs project supervised by Obeo. From this I created the OCL variant in org.eclipse.ocl.examples.xtext.console.xtfo used by the Interactive OCL Xtext console and I think re-used by Papyrus. I suspect that an EmbeddedXtextEditor may now be available from Xtext itself.

Regards

Ws Willink
Re: Embedding OCL editor in Sirius [message #1835993 is a reply to message #1835989] Thu, 17 December 2020 20:07 Go to previous messageGo to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 49
Registered: March 2020
Member
Hi Ed,

Is it possible to import org.eclipse.ocl.examples.xtext.console.xtfo into Sirius then so that I can embed it in my editor? If so how do I do that? And what do I need from the Eclipse MarketPlace to do it?
Re: Embedding OCL editor in Sirius [message #1836004 is a reply to message #1835993] Fri, 18 December 2020 06:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
Hi

org.eclipse.ocl.examples.xtext.console.xtfo is part of the Eclipse OCL contribution to the Simultaneous Release that is available by using Install New Software... within Eclipse. No need for the MarketPlace which refuses to allow me to add the most recent two releases.

Select "OCL Examples and Editors SDK Developer Resources" from "2020-12 - http://download.eclipse.org/releases/2020-12".

Your comment makes me suspect that you expect everything to just work after a magic DND into Sirius. Not so, getting an EmbeddedXtextEditor to work is a programming activity, perhaps trivial if you do it right, but with plenty of opportunities for misunderstanding.

Regards

Ed Willink
Re: Embedding OCL editor in Sirius [message #1836030 is a reply to message #1836004] Fri, 18 December 2020 14:19 Go to previous messageGo to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 49
Registered: March 2020
Member
I was in fact quite optimistic that it would be a magic switch!

Thank you for pointing me to the repository. My biggest issue is just figuring out how to set up the dependencies in the first place to have everything connected. I'm hoping that as long as there is documentation about this topic then I should be able to figure out the programming part of it. Since it is an example that you are pointing to I'm hoping that I can find the documentation on it as well.
Re: Embedding OCL editor in Sirius [message #1836043 is a reply to message #1836030] Fri, 18 December 2020 18:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
Hi

I was very grateful to find the EclipseLabs prototype to show me the way, but IIRC it was far from easy and again IIRC Papyrus' usage seems to have experienced bit rot.

Regards

Ed Willink
Re: Embedding OCL editor in Sirius [message #1836046 is a reply to message #1836043] Fri, 18 December 2020 21:14 Go to previous messageGo to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 49
Registered: March 2020
Member
Do you have anywhere I can go to begin? I'm looking through that repo to get a starting point. I'm still relatively new to everything that is offered in EMF. So far the only experience I have is in the creation of Ecore models and deployment of an editor in Sirius. I haven't the faintest idea of where to start with setting this up beyond what you have just told me. I downloaded the software, I'm looking through the repos, but any extra documentation or steps that you can direct me to would be greatly appreciated.
Re: Embedding OCL editor in Sirius [message #1836061 is a reply to message #1836046] Sat, 19 December 2020 12:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
HI

I'm sorry. Open Source gives you the opportunities to do many things that you cannot with proprietary tools, but often the only documentation is the open source code / newsgroup discussions.

I can't just wave a magic wand and instantly transfer years of experience.

You just have to bear in mind the trade-offs; pay someone else to do it / invest your time in studying the Open Source code to enable re-use / write it yourself from scratch / don't do it all.

You begin by finding the existing functionality that most closely resembles what you want to do and study it. Reading code is pretty boring so I set breakpoints / instrument with 'printf's so that the debugger provides more instructive animation. Expect to spend 90% of your time 'studying' which gives very low productivity in terms of lines of new code per day, but hopefully high productivity in terms of achieved functionality per day.

If you try to write the re-use in one hit there will be some trivial catastrophic initialization you miss and nothing will happen; very depressing and hard to debug. Easier to migrate some working functionality to suit your purposes.

Regards

Ed Willink
Re: Embedding OCL editor in Sirius [message #1837141 is a reply to message #1836061] Fri, 22 January 2021 16:13 Go to previous message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 49
Registered: March 2020
Member
So while looking around I have come across this website which seems to talk about embedding a language in the "Providing a Custom Language" section: https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html

I have added the extension that is mentioned in this article however I do not know how to implement an interpreter. Is there anyone who can help?
Previous Topic:the following mapping semantic candidates expression could not be correctly evaluated
Next Topic:Understanding Etypes for attribute in Ecore
Goto Forum:
  


Current Time: Fri Apr 16 18:39:20 GMT 2021

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

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

Back to the top