Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Programmatically exporting image from aird in stand-alone situation
Programmatically exporting image from aird in stand-alone situation [message #1805472] Mon, 15 April 2019 18:54 Go to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 11
Registered: January 2018
Junior Member
Hi all,

I'm trying to export a PNG image from my .aird file in a standalone situation where the following code is initiated by an MWE2 workflow in a Standalone setup.

Using this forum I got this far:
			Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("aird", new AirDResourceFactory());
log.info("Exporting image of " + getAirdFile() + " file to " + getImageFileName());
			IProgressMonitor progressMonitor = BasicMonitor.toIProgressMonitor(new LoggerMonitor(log));
			// Get session from an absolute path (not in a workspace)
			URI sessionResourceURI = URI.createFileURI(getAirdFile());
			Session session = SessionFactory.INSTANCE.createSession(sessionResourceURI, progressMonitor);
			//Session session = SessionManager.INSTANCE.openSession(sessionResourceURI, progressMonitor, noUICallback, false);
			session.open(progressMonitor);
			
			
			// Get the expected representation (here the first of the first DView)
			DViewQuery query = new DViewQuery(session.getOwnedViews().iterator().next());
			DRepresentation representation = query.getLoadedRepresentations().get(0);
			
			
			// Export it as PNG image
			ExportFormat exportFormat = new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG);
			DialectUIManager.INSTANCE.export(representation, session, new Path(getImageFileName()), exportFormat,
					progressMonitor);


But when I do this, I get an error:
java.lang.RuntimeException: Problems running workflow nl.tno.esdl.ReleaseESDL: null
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.NullPointerException
	at org.eclipse.sirius.business.api.session.danalysis.DAnalysisSelectorService.initializeProviders(DAnalysisSelectorService.java:106)
	at org.eclipse.sirius.business.api.session.danalysis.DAnalysisSelectorService.getCustomerProviders(DAnalysisSelectorService.java:94)
	at org.eclipse.sirius.business.api.session.danalysis.DAnalysisSelectorService.getSelector(DAnalysisSelectorService.java:66)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.<init>(DAnalysisSessionImpl.java:204)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.createSession(SessionFactoryImpl.java:303)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.loadSessionModelResource(SessionFactoryImpl.java:171)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.createSession(SessionFactoryImpl.java:87)
	at nl.tno.esdl.EcoreImageGenerator.invoke(EcoreImageGenerator.java:67)


In DAnalysisSelectorService the following code is executed:
if (defaults == null || defaults.isEmpty()) {
            SiriusPlugin.getDefault().warning(MessageFormat.format(Messages.DAnalysisSelectorService_noDefaultWarningMsg, ID), null);
            defaultSiriusProvider = new DefaultAnalysisSelectorProvider();
}


SiriusPlugin.getDefault() returns null here.

How can I run this code in a standalone way?

Re: Programmatically exporting image from aird in stand-alone situation [message #1805881 is a reply to message #1805472] Fri, 26 April 2019 12:05 Go to previous message
Laurent Fasani is currently offline Laurent FasaniFriend
Messages: 157
Registered: October 2014
Senior Member
Hello

SiriusPlugin.getDefault() is null because you code is executed out of eclipse context. Sirius is not supposed to work in standalone application. Perhaps some part of Sirius may work by chance in some cases but it has never been tested.

regards
Laurent


Laurent Fasani - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Getting java.lang.IllegalArgumentException: Argument not valid exception
Next Topic:Loading Resource file
Goto Forum:
  


Current Time: Wed Aug 21 06:01:26 GMT 2019

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

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

Back to the top