Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Programmatically Create Modeling Project Issues
Programmatically Create Modeling Project Issues [message #1849421] Wed, 19 January 2022 13:25 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I've spent several days now trying to programmatically create a Modeling Project through a New Project Wizard for my users. I want to reduce a nearly 20 step process to maybe 5 steps.

The only documentation I can find is in this forum. I'm trying to replicate it, but I'm getting random behavior that I just can't track down or understand. It's frustrating.

Here's most of my code - executed in the doFinish() method of a Project wizard:

		Session session = SessionManager.INSTANCE.getSession(URI.createPlatformResourceURI(prjName+"/representations.aird"), new NullProgressMonitor());
		session.open(new NullProgressMonitor());		
		
		TransactionalEditingDomain ted = session.getTransactionalEditingDomain();
		ResourceSet resSet = ted.getResourceSet();
		
		ted.getCommandStack().execute(new RecordingCommand(ted) {
			
			@Override
			protected void doExecute() {
				ComponentType pcrComp = createPcrComp(file, resSet, vlnvLib, vlnvName);

//                            This next step seems to do nothing to avoid this beahvior.
//				session.addSemanticResource(pcrComp.eResource().getURI(), new NullProgressMonitor());
				
			}
		});
		
		session.save(new NullProgressMonitor());
		
		Display.getDefault().asyncExec(new Runnable() {
		    @Override
		    public void run() {
		    	UserSession.from(session).selectOnlyViewpoint("MyViews");
		    }
		});
		
		session.save(new NullProgressMonitor());



When I run this code, frustratingly, the representations.aird file loads EVERY METAMODEL and metamodel plugin in my dev environment. Something like:

    <semanticResources>the file I actually want and that was created and saved in the resourceSet of the  transaction edit domain</semanticResources>
    <semanticResources>platform:/plugin/<plugpath>/designer.odesign</semanticResources>
    <semanticResources>environment:/viewpoint</semanticResources>
    <semanticResources>platform:/plugin/<plugpath>my.ecore</semanticResources>
    <semanticResources>platform:/plugin/<plugpath>another.ecore</semanticResources>
    <semanticResources>platform:/plugin/<plugpath>yetAnother.ecore</semanticResources>
    <semanticResources>platform:/plugin/org.eclipse.sirius.properties.defaultrules/model/properties.odesign</semanticResources>


Creating a New Modeling Project, adding a resource, then enabling my Viewpoint works great if I drive it manually in the GUI, but it's nearly 20 steps for the end user which is not great.

Why in the world would doing this programmatically load the "entire world" of metamodels as semantic resources? The result is that the respresentations.aird file is cluttered and the Right Click -> Viewpoint Selection menu has all of these unrelated Viewpoints listed (although they are unselected). This does not happen if I do it all manually in the GUI.

I've tried several methods of creating a new session and all of them suffer from this:

		Session session = SessionFactory.INSTANCE.createDefaultSession(URI.createPlatformResourceURI(prjName+"/representations.aird"));
vs
		Session session = SessionFactory.INSTANCE.createSession(URI.createPlatformResourceURI(prjName+"/representations.aird"), new NullProgressMonitor());
vs
		Session session = SessionManager.INSTANCE.getSession(URI.createPlatformResourceURI(prjName+"/representations.aird"), new NullProgressMonitor());


This behavior happens in a runtime instance while I'm developing. Is that a hint as to what is going wrong?

Another random aspect is that if I create consecutive projects, the behavior is slightly more random in that in the Model Explorer view, sometimes the semantic resources are listed under Project Dependencies, and then sometimes they are not. I've been unable to track down why.

[Updated on: Wed, 19 January 2022 13:33]

Report message to a moderator

Re: Programmatically Create Modeling Project Issues [message #1849422 is a reply to message #1849421] Wed, 19 January 2022 13:31 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Sirius 6.3.0 running on Photon in this case (an older app)
Re: Programmatically Create Modeling Project Issues [message #1849424 is a reply to message #1849422] Wed, 19 January 2022 14:00 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
In a deployed version of the app, I get fewer unrequested semantic resources added, but I still get these added without me asking for them:

    <semanticResources>the file I actually want and that was created and saved in the resourceSet of the  transaction edit domain</semanticResources>
    <semanticResources>platform:/plugin/<plugpath>/designer.odesign</semanticResources>
    <semanticResources>environment:/viewpoint</semanticResources>
    <semanticResources>platform:/plugin/org.eclipse.sirius.properties.defaultrules/model/properties.odesign</semanticResources>


So my ecore metamodels don't get included, but the odesign and several Sirius related models do.
Previous Topic:Extend a Sequence Diagram
Next Topic:How to draw edges between list items?
Goto Forum:
  


Current Time: Fri Apr 19 19:18:40 GMT 2024

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

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

Back to the top