Skip to content

Commit 3464323

Browse files
authored
Handle Sirius forced resource set (#140)
* handle resourceSet created by Sirius session in some situations, the resourceSet we create is not used by Sirius for its session. In that case, we need to load the model from this resourceSet instead o the one we created. * warning if using both melange query and sirius returns a new resourceSet Signed-off-by: Didier Vojtisek <[email protected]>
1 parent d166607 commit 3464323

File tree

1 file changed

+19
-5
lines changed
  • framework/execution_framework/plugins/org.eclipse.gemoc.executionframework.extensions.sirius/src/org/eclipse/gemoc/executionframework/extensions/sirius/modelloader

1 file changed

+19
-5
lines changed

framework/execution_framework/plugins/org.eclipse.gemoc.executionframework.extensions.sirius/src/org/eclipse/gemoc/executionframework/extensions/sirius/modelloader/DefaultModelLoader.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,28 @@ private static Resource loadModel(IExecutionContext<?, ?, ?> context, boolean wi
165165
try {
166166
// Killing + restarting Sirius session for animation
167167
killPreviousSiriusSession(context.getRunConfiguration().getAnimatorURI());
168-
openNewSiriusSession(context, context.getRunConfiguration().getAnimatorURI(), resourceSet, modelURI,
168+
Session session = openNewSiriusSession(context, context.getRunConfiguration().getAnimatorURI(), resourceSet, modelURI,
169169
subMonitor,nsURIMapping);
170-
171170
// At this point Sirius has loaded the model, we just need to
172171
// find it
173-
for (Resource r : resourceSet.getResources()) {
174-
if (r.getURI().equals(modelURI)) {
175-
return r;
172+
if(session.getTransactionalEditingDomain().getResourceSet() != resourceSet) {
173+
// the session has created a different resourceSet than the one we provided
174+
//we need to use the resource from it instead of the one from our resourceSet
175+
// TODO check if this is still compatible with melange
176+
// TODO maybe some simplification is possible !
177+
if(useMelange) {
178+
Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Sirius Session returned a new ResourceSet and you are using a melange query, this scenario has not been validated yet", new Exception()));
179+
}
180+
for (Resource r : session.getTransactionalEditingDomain().getResourceSet().getResources()) {
181+
if (r.getURI().equals(modelURI)) {
182+
return r;
183+
}
184+
}
185+
} else {
186+
for (Resource r : resourceSet.getResources()) {
187+
if (r.getURI().equals(modelURI)) {
188+
return r;
189+
}
176190
}
177191
}
178192
} catch (CoreException e) {

0 commit comments

Comments
 (0)