Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » [MDT OCL] OCL and GMF interaction
[MDT OCL] OCL and GMF interaction [message #660921] Tue, 22 March 2011 07:20 Go to next message
Darie Moldovan is currently offline Darie Moldovan
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
Hello,

I am posting this message in both the GMF and MDT/OCL sections, because this topic might be interesting in both of them.

Do you happen to know any OCL editor which can interact with GMF elements?

Example: write a query in the OCL console view and, if the result contains an element from the GMF diagram, then automatically select (highlight) that resulted element in the diagram. This is what I am trying to do and do not have any ideas where to start. There should be a trick on how to manipulate the AST from OCL, maybe you can give me a clue.

Thanks in advance.

Later edit: please take a look at Figure 5 from this article. Let's say we want to write an OCL query which returnes all the "Skill" elements of the company. We would probably write <b>Skill.allInstances()</b> in the OCL console and would get as a result 2 Skill-objects, namely <i>modelling</i> and <i>hacking</i>. Is there a way to automatically highlight/select these returned objects in the generic editor? Or, just think you would make an OCL query on a GMF diagram - the question stands. Is it possible to manipulate the instances of the objects, which are returned by an OCL query in the OCL console? If yes, what kind of approach would you recommend?

[Updated on: Tue, 22 March 2011 08:01]

Report message to a moderator

Re: [MDT OCL] OCL and GMF interaction [message #660976 is a reply to message #660921] Tue, 22 March 2011 10:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4030
Registered: July 2009
Senior Member
Hi Darie

[You omitted the OCL newsgroup]

OCL does not support model mutation; that is a responsibility of the
embedding application.

So as you've discovered the OCL Colsole supports evaluation of an OCL
expression using GMF elements, but does not support a write back.

The OCL Console as an embedding application could be extended by, for
instance, menu actions to push results to some destination.

The most obvious non-custom extension might be a QVTo Console, but I'm
not sure that there is one.

I think a custom OCL Console in which you intercept the OCL Console
evaluation result may be your simplest option. Alternatively you could
add menu actions to cutomize your GMF diagram editor.

Regards

Ed Willink


On 22/03/2011 04:20, Darie wrote:
> Hello,
>
> I am posting this message in both the GMF and MDT/OCL sections,
> because this topic might be interesting in both of them.
>
> Do you happen to know any OCL editor which can interact with GMF
> elements?
>
> Example: write a query in the OCL console view and, if the result
> contains an element from the GMF diagram, then automatically select
> (highlight) that resulted element in the diagram. This is what I am
> trying to do and do not have any ideas where to start. There should be
> a trick on how to manipulate the AST from OCL, maybe you can give me a
> clue.
>
> Thanks in advance.
Re: [MDT OCL] OCL and GMF interaction [message #660990 is a reply to message #660976] Tue, 22 March 2011 11:24 Go to previous messageGo to next message
Darie Moldovan is currently offline Darie Moldovan
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
Edward Willink wrote on Tue, 22 March 2011 15:34
So as you've discovered the OCL Colsole supports evaluation of an OCL expression using GMF elements, but does not support a write back.

The OCL Console as an embedding application could be extended by, for instance, menu actions to push results to some destination.

I think a custom OCL Console in which you intercept the OCL Console evaluation result may be your simplest option. Alternatively you could add menu actions to cutomize your GMF diagram editor.


Hi Ed,

thank you for your reply.

The write-back, as you called it, is exactly what I want to implement for the OCL console. Maybe this is not the purpose of the console, I know, but I need this feature for my editor. It would be nice to click on a button and have all the elements returned by the OCL console automatically highlighted in the editor, wouldn't it? Smile

I do agree with you, maybe I must somehow try to intercept the result from the OCL console and then do with it whatever I want to do. I think the OCL console does nothing more than checking which editor is active at the moment of the query, get the model and do an OCL query on it - nothing more.

What do you mean by "Alternatively you could add menu actions to cutomize your GMF diagram editor"? Why is this an alternative and what should the actions do?

Thank you.
Re: [MDT OCL] OCL and GMF interaction [message #661079 is a reply to message #660990] Tue, 22 March 2011 21:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4030
Registered: July 2009
Senior Member
Hi
> The write-back, as you called it, is exactly what I want to implement
> for the OCL console. Maybe this is not the purpose of the console, I
> know, but I need this feature for my editor. It would be nice to click
> on a button and have all the elements returned by the OCL console
> automatically highlighted in the editor, wouldn't it? :)

I'm at EclipseCon at present which has presented opportunities for wider
discussion. 'Expressive OCL' has been mentioned, but Google provides no
clues. I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=340717
as a possible enhancement to support model mutation from the console,
but that doesn't help you today, and I'm not sure that it would support
a derived algorithm such as highlighting in an editor.
>
> I do agree with you, maybe I must somehow try to intercept the result
> from the OCL console and then do with it whatever I want to do. I
> think the OCL console does nothing more than checking which editor is
> active at the moment of the query, get the model and do an OCL query
> on it - nothing more.
> What do you mean by "Alternatively you could add menu actions to
> cutomize your GMF diagram editor"? Why is this an alternative and what
> should the actions do?
You can either improve the OCL Console to control the editor, or improve
the editor to support the functionality that you want directly.

In your GMF editor you could imagine an editor menu action that pops up
a dialog box with an OCL Console like embedded editor so that you enter
your query, and on dialog box acceptance you evaluate and react with
appropriate highlights.

Regards

Ed Willink
Re: [MDT OCL] OCL and GMF interaction [message #661320 is a reply to message #661079] Thu, 24 March 2011 04:54 Go to previous messageGo to next message
Darie Moldovan is currently offline Darie Moldovan
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
Hi Ed,

thank you for the reply.

I think I will follow your advice and create an editor menu action, which pops up an OCL console. From there I can access my diagram elements and do whatever I want with them.

If I have any useful information, I'll post it here, maybe it will help other users.

Regards,

Darie
Re: [MDT OCL] OCL and GMF interaction [message #661409 is a reply to message #661320] Thu, 24 March 2011 10:50 Go to previous message
Darie Moldovan is currently offline Darie Moldovan
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
So, now I implemented what I wanted (the "write-back") and it workes properly.

I extended the capabilities of the standard OCL console, so that I can acces the elements within the GMF diagram, based on the result of an OCL query in the console.

I added an entry in the context menu of the GMF diagram, which calls an Action, the OCLConsoleAction, which I defined. I needed to edit the classes OCLConsole and OCLConsolePage from the org.eclipse.ocl.examples.interpreter.console package - the method evaluate() from the OCLConsolePage does the whole trick. At the end of this method, before the return statement, you have the result of the OCL evaluation, which is a collection of objects. A textual representation of these objects is shown in the console, as a result of the query. Having all the EditParts in the diagram, you can then easely get their corresponding EObjects and compare these with the EObjects the OCL query returns.

Just as a hint, for those who are interested in implementing the same thing as I did (automatic selection), take a look at the following classes:

- EditPartViewer
- SelectionManager

The appendSelection() Method from the SelectionManager did the trick in my case. This is the only way to be able to select multiple elements automatically.

I hope my post will help others trying to access the objects in the diagram, based on the result of an OCL query.

The above information only intends to give you a hint on where to look. Feel free to ask any questions.

Thanks again Ed, for your help!
Previous Topic:In memory Ecore model to XSD
Next Topic:Topcased interface custumitation
Goto Forum:
  


Current Time: Sat Aug 23 11:34:06 EDT 2014

Powered by FUDForum. Page generated in 0.01657 seconds