Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Add all ecore Files in Workspace as Semantic Resource
Add all ecore Files in Workspace as Semantic Resource [message #1776156] Mon, 13 November 2017 09:54 Go to next message
Bo Liu is currently offline Bo LiuFriend
Messages: 32
Registered: July 2016
Member
Hello Community,

is there a way to add all the ecore files in workspace as semantic resource.
With Session.getSemanticResources(), I can only get the resources in the project.

How can I get all the resources in the workspace?

Thx!
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776161 is a reply to message #1776156] Mon, 13 November 2017 10:19 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

On your modeling project (in the Model Explorer view), on the "Project Dependencies" you have a contextual menu "Add model". This will open a dialog window to choose a model from the workspace or from the file system.

Also note that Session.getSemanticResources() will return all semantic resources used wherever they are in the project or not.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776164 is a reply to message #1776161] Mon, 13 November 2017 10:46 Go to previous messageGo to next message
Bo Liu is currently offline Bo LiuFriend
Messages: 32
Registered: July 2016
Member
Hi

thx for the reply.
I want to do this programmatically with Java Code.
I am able to get all the IProject in the workspace. But how can I get the resource URI to the ecore file in the projects?
Is there a method that does that? or do i have to manuelly search for the ecore files in the project path and build the resourceURI myself?
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776168 is a reply to message #1776164] Mon, 13 November 2017 11:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It's a bit opaque. In the OCL ProjectMap, I read plugin.xml to find the genmodel, then load the genmodel to locate the Ecore file. IIRC I raised a BUgzilla that the genmodel registration should optionally also regoster the ecore model.

Of course if you can count on naming conventions model/XXX.genmodel tells you where the *.ecore is.

Regards

Ed Willink
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776180 is a reply to message #1776168] Mon, 13 November 2017 13:46 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello again,

Ah ok you want to do it programatically. You can create the URI using URI.createPlatformResourceURI(path, true) where path is "/project-name/path-to-my-model" and then you execute the org.eclipse.sirius.tools.api.command.semantic.AddSemanticResourceCommand like this:
Command addSemanticResourceCmd = new AddSemanticResourceCommand(session, semanticResourceURI, new NullProgressMonitor());
session.getTransactionalEditingDomain().getCommandStack().execute(addSemanticResourceCmd);

You can find many test using this command if you need to have a look.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776255 is a reply to message #1776168] Tue, 14 November 2017 13:41 Go to previous messageGo to next message
Bo Liu is currently offline Bo LiuFriend
Messages: 32
Registered: July 2016
Member
Hi,
thx for the reply.
I have decided to use the name convention and search for ecore files in model folder of each project in the workspace.
Re: Add all ecore Files in Workspace as Semantic Resource [message #1776256 is a reply to message #1776180] Tue, 14 November 2017 13:42 Go to previous message
Bo Liu is currently offline Bo LiuFriend
Messages: 32
Registered: July 2016
Member
thx for the reply! This method has worked for me!
Previous Topic:[ANN] Sirius 4.1.7
Next Topic:Model reload in Sirius should be Irrevocable
Goto Forum:
  


Current Time: Thu Apr 25 12:51:42 GMT 2024

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

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

Back to the top