Get updated resource set from Java service [message #1799942] |
Mon, 17 December 2018 17:36 |
Edmundo López Bóbeda Messages: 27 Registered: October 2012 |
Junior Member |
|
|
Hello,
I'm using a Sirius service to get possible models for an import, the code looks more or less like this:
public EObject addImport(MappingInstance instance) {
EList<Resource> resources = instance.eResource().getResourceSet().getResources();
List<String> validExtensions = new ArrayList<>();
validExtensions.add("common");
validExtensions.add("model");
validExtensions.add("map");
List<Resource> models = resources.stream().filter(p -> validExtensions.contains(p.getURI().fileExtension()))
.collect(Collectors.toList());
// do my stuff to find the models I wan to import...
The problem I find is that if I add or remove a file, the resource set is not updated and I'm not able to find the resources (or on deletion, the resources are shown but are actually not there).
How can I make sure that the resource sets are updated?
Thanks in advance,
Best regards,
Edmundo López
PS: If I close and reopen the diagram, the resource set updates automagically.
[Updated on: Mon, 17 December 2018 19:17] Report message to a moderator
|
|
|
Re: Get updated resource set from Java service [message #1799971 is a reply to message #1799942] |
Tue, 18 December 2018 09:06 |
|
Hello,
I think that if you add the resource to the resourceSet but not the Sirius session, that would explain the need to close and reopen. Have you tried executing the command org.eclipse.sirius.tools.api.command.semantic.AddSemanticResourceCommand.AddSemanticResourceCommand(Session, URI, IProgressMonitor)? It should properly update the resourceSet and your session.
Regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.04052 seconds