Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Export diagram without workspace
Export diagram without workspace [message #1753667] Wed, 08 February 2017 16:19 Go to next message
Bastien BARET is currently offline Bastien BARETFriend
Messages: 12
Registered: February 2017
Junior Member

I'm currently trying to export my diagram as SVG without workspace (running on a server).
First of all, is it possible ? If so, how to create a Sirius Session in order to use an ExportAction for example ?

Thanks in advance !


Re: Export diagram without workspace [message #1753848 is a reply to message #1753667] Fri, 10 February 2017 16:49 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 270
Registered: July 2009
Senior Member

you can do something like
        // Get session from an absolute path (not in a workspace)
        URI sessionResourceURI = URI.createFileURI("D:/folder/representations.aird");
        Session session = SessionFactory.INSTANCE.createSession(sessionResourceURI, new NullProgressMonitor()); NullProgressMonitor());
        // 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 SVG image
        ExportFormat exportFormat = new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.SVG);
        DialectUIManager.INSTANCE.export(representation, session, new Path("D:/folder/image.svg"), exportFormat,
                new NullProgressMonitor());



Laurent Redor - Obeo

Need training or professional services for Sirius?
Re: Export diagram without workspace [message #1780505 is a reply to message #1753848] Tue, 23 January 2018 13:58 Go to previous messageGo to next message
Marianna DL is currently offline Marianna DLFriend
Messages: 1
Registered: January 2018
Junior Member

I answer on this topic near one year later because I found myself in the same situation that the topic author.
I want to export diagram representations from an acceleo script which can be launched in standalone.

For that, I want to use SessionFactory.INSTANCE.createSession.
However, for creating this session, an error in thrown because of the register factory. So, I added this line in my main acceleo java class.
 Resource.Factory.Registry.INSTANCE.getResourceFactoryRegistry().getExtensionToFactoryMap().put("aird",  new XMIResourceFactoryImpl());

But it's not enough, I have then this error :

Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri '' not found. 
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(
	... 7 more

Is there additional steps that I have to do to use the create session ?

Thanks in advance,

Re: Export diagram without workspace [message #1781778 is a reply to message #1780505] Tue, 13 February 2018 09:53 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 503
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Marianna,

It seems that you do not use the expected resource factory: aird resources needs the (it brings the automatic migration of Sirius resources).

Note that you could also try, progressmonitor) and then open the session or, IProgressMonitor, UICallBack) (with SiriusEditPlugin.getPlugin().getUiCallback() or a new regarding your context) instead of the use of the session factory.


Maxime Porhel - Obeo

Need training or professional services for Sirius?
Re: Export diagram without workspace [message #1790814 is a reply to message #1753667] Mon, 18 June 2018 12:49 Go to previous message
Stéphanie Piccin is currently offline Stéphanie PiccinFriend
Messages: 7
Registered: June 2018
Junior Member
Hi Maxime,

I try to export diagram from java application with Marianna.

When I use the following code :, new NullProgressMonitor(), SiriusEditPlugin.getPlugin().getUiCallback());

The application returns the following exception : "Workspace is closed ".

When I want to create a Session with the following code :
Session session = SessionFactory.INSTANCE.createSession(airdURI, new NullProgressMonitor()); NullProgressMonitor()); 

The application returns the following exception :
Exception in thread "main" java.lang.ExceptionInInitializerError
	at thales.thav.dsi.em.factory.gen.irsGenedocGeneration.IrsGenedocGenerate.<init>(
	at thales.thav.dsi.em.factory.gen.irsGenedocGeneration.IrsGenedocGenerate.main(
Caused by: java.lang.NullPointerException
	at org.eclipse.core.internal.runtime.ResourceTranslator.hasRuntime21(
	at org.eclipse.core.internal.runtime.ResourceTranslator.getResourceBundle(
	at org.eclipse.core.internal.runtime.ResourceTranslator.getResourceBundle(
	at org.eclipse.core.internal.runtime.InternalPlatform.getResourceBundle(
	at org.eclipse.core.runtime.Platform.getResourceBundle(
	at org.eclipse.emf.common.EMFPlugin$InternalHelper.getString(
	at org.eclipse.emf.common.EMFPlugin$EclipsePlugin.getString(
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(
	at org.eclipse.sirius.ext.base.I18N.initialize(
	at org.eclipse.sirius.ext.base.I18N.load(
	at org.eclipse.sirius.ext.base.I18N.initializeMessages(
	at org.eclipse.sirius.viewpoint.Messages.<clinit>(
	... 4 more

How can I export diagram from a java application by using Sirius API ?
Previous Topic:Creating edges between sub nodes present in different Conatiners.
Next Topic:Problems creating Session for Session (Error loading representation.aird)
Goto Forum:

Current Time: Wed Apr 14 09:22:46 GMT 2021

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

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

Back to the top