Home » Archived » EMF-IncQuery » Using Incquery as EVM for notifying UML papyrus changes(Using Incquery as EVM for notifying UML papyrus changes)
| |
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702591 is a reply to message #1702586] |
Thu, 23 July 2015 12:34   |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
Quote:This code snippets work and IncQuery notifies me the results but not does by IncQuery? Does Incquery re-evaluate models if they are changed in any manner?
I guess, one of the IncQuery occurences in the first version should be Papyrus; in the remainder I would go on that basis. If it is incorrect, feel free to ask for clarification.
The change notification in EMF-IncQuery works by registering an IncQueryEngine instance as change listener to EMF models (more specifically, Resource/ResourceSets), and then sends further notifications when match sets are changed. E.g., you can verify this in the Query Explorer view from the IncQuery SDK: load your queries and the instance model (from a Papyrus editor), and you can check that the display reacts to model changes automatically.
Behind the scenes, for EMF-IncQuery to work with the changes of the edited model, you have to make sure to initialize the IncQueryEngine on the ResourceSet used by Papyrus, instead of simply opening the model again programmatically (that would result in having a separate in-memory representation of the same model; but the two are not connected in any way). For this to work, you have to write some integration code, e.g. check the current selection of the editor, and find the corresponding resource, or (if I recall correctly), the Papyrus editor implements the IEditingDomainProvider interface, that can also be used to access the editors ResourceSet.
Cheers,
Zoltán
|
|
| |
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702630 is a reply to message #1702609] |
Thu, 23 July 2015 15:33   |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
the fact that you try to combine JUnit tests and Papyrus integration strongly suggests to me that you have two different models loaded (and I am not even sure they are in the same JVM! JUnit test execute in a different JVM than your Eclipse instance).
If you want EMF-IncQuery to listen to changes in an Eclipse editor, you have to
1. Write an Eclipse plug-in, that initializes the IncQuery Engine to the resourceset of Papyrus. This can be triggered by a menu command, or you could use internal Papyrus services.
2. The registered engine will receive notifications, and you can use it any way, you want; but you have to make sure to reuse this engine instance.
We don't have any example for accessing models from an editor, but maybe the model connector implementation we use in Query Explorer might help: http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/plugins/org.eclipse.incquery.tooling.ui/src/org/eclipse/incquery/tooling/ui/queryexplorer/adapters/EMFModelConnector.java#n99 This class is instantiated with a reference to an Eclipse editor; and at a later point, the getNotifier method is called that returns the Resource/ResourceSet of the editor that can be used to initialize the IncQueryEngine with.
Cheers,
Zoltán
|
|
| |
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702843 is a reply to message #1702842] |
Sat, 25 July 2015 17:21  |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
this behavior is related to the fact that the Papyrus editor uses EMF Transactions in the background, that (among other things) allows undo/redo for the model modifications, however, it requires that all model modification be wrapped into EMF Edit commands.
Basically, you could do one of the following things:
1. You can use RecordingCommands to wrap your custom code into commands.
2. You can write your model modifications using commands.
Finally, we have developed a model transformation API (including model modifications) in the VIATRA project, that allows changing from plain EMF operations to EMF.Edit commands without changing the transformation rules (see https://wiki.eclipse.org/VIATRA/Transformation_API#Model_Manipulation_Primitives for details).
I hope, this explanation is clear.
Cheers,
Zoltán
|
|
|
Goto Forum:
Current Time: Thu Mar 30 18:04:31 GMT 2023
Powered by FUDForum. Page generated in 0.01340 seconds
|