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
Hi,

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 !

Cheers,

Bastien.
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: 238
Registered: July 2009
Senior Member
Hi,

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());
        session.open(new 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());


Regards,

Laurent


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/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
Hi,

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 'http://www.eclipse.org/sirius/1.1.0' not found. 
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2625)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2458)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1335)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1364)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 7 more


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

Thanks in advance,
Marianna





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: 429
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 org.eclipse.sirius.business.internal.resource.AirDResourceFactory (it brings the automatic migration of Sirius resources).

Note that you could also try org.eclipse.sirius.business.api.session.INSTANCE.getSession(uri, progressmonitor) and then open the session or org.eclipse.sirius.business.api.session.INSTANCE.openSession(URI, IProgressMonitor, UICallBack) (with SiriusEditPlugin.getPlugin().getUiCallback() or a new org.eclipse.sirius.tools.api.command.ui.NoUICallback regarding your context) instead of the use of the session factory.

Regards


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

Join the Sirius community at SiriusCon. Register for free: Nov. 9th Paris
http://www.siriuscon.org/
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: 1
Registered: June 2018
Junior Member
Hi Maxime,

I try to export diagram from java application with Marianna.

When I use the following code :

org.eclipse.sirius.business.api.session.SessionManager.INSTANCE.openSession(airdURI, 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());
session.open(new NullProgressMonitor()); 


The application returns the following exception :
Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.loadSessionModelResource(SessionFactoryImpl.java:116)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.createSession(SessionFactoryImpl.java:102)
	at thales.thav.dsi.em.factory.gen.irsGenedocGeneration.IrsGenedocGenerate.<init>(IrsGenedocGenerate.java:115)
	at thales.thav.dsi.em.factory.gen.irsGenedocGeneration.IrsGenedocGenerate.main(IrsGenedocGenerate.java:184)
Caused by: java.lang.NullPointerException
	at org.eclipse.core.internal.runtime.ResourceTranslator.hasRuntime21(ResourceTranslator.java:92)
	at org.eclipse.core.internal.runtime.ResourceTranslator.getResourceBundle(ResourceTranslator.java:66)
	at org.eclipse.core.internal.runtime.ResourceTranslator.getResourceBundle(ResourceTranslator.java:62)
	at org.eclipse.core.internal.runtime.InternalPlatform.getResourceBundle(InternalPlatform.java:487)
	at org.eclipse.core.runtime.Platform.getResourceBundle(Platform.java:999)
	at org.eclipse.emf.common.EMFPlugin$InternalHelper.getString(EMFPlugin.java:391)
	at org.eclipse.emf.common.EMFPlugin$EclipsePlugin.getString(EMFPlugin.java:304)
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:380)
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:359)
	at org.eclipse.sirius.ext.base.I18N.initialize(I18N.java:91)
	at org.eclipse.sirius.ext.base.I18N.load(I18N.java:78)
	at org.eclipse.sirius.ext.base.I18N.initializeMessages(I18N.java:64)
	at org.eclipse.sirius.viewpoint.Messages.<clinit>(Messages.java:25)
	... 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: Thu Sep 20 11:27:03 GMT 2018

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

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

Back to the top