Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Specifying Save/Load options at runtime
Specifying Save/Load options at runtime [message #1281681] Tue, 01 April 2014 07:46 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
Hi,

with Sirius, how can I specify Load/Save options for semantic resources
at runtime? For example say there's a user preference to pretty print
xml or not.

Thanks,
Felix
Re: Specifying Save/Load options at runtime [message #1281745 is a reply to message #1281681] Tue, 01 April 2014 09:41 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 01/04/2014 09:46, Felix Dorner a écrit :
> Hi,

Hi.

> with Sirius, how can I specify Load/Save options for semantic resources
> at runtime? For example say there's a user preference to pretty print
> xml or not.

For loading, maybe something like this (completely untested):

rs = session.getTransactionalEditingDomain().getResourceSet();
rs.getLoadOptions().put(KEY, VALUE);
session.addSemanticResource(uri, pm);

The actual loading is performed using ResourceSet#getResource(uri,
true), which should honor the default load options set on the resource
set. You may want to revert your customizations afterwards if they can
have side-effects on other resources.

For saving, simply pass the options in the map argument of
Session.save(Map<?,?>, IProgressMonitor).


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Specifying Save/Load options at runtime [message #1281751 is a reply to message #1281745] Tue, 01 April 2014 09:51 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 01/04/2014 11:41, Pierre-Charles David wrote:

> For loading, maybe something like this (completely untested):
>
> rs = session.getTransactionalEditingDomain().getResourceSet();
> rs.getLoadOptions().put(KEY, VALUE);
> session.addSemanticResource(uri, pm);

I see.

> For saving, simply pass the options in the map argument of
> Session.save(Map<?,?>, IProgressMonitor).

But won't this apply the options to all resources (semantic and
sirius/diagrams?)
Re: Specifying Save/Load options at runtime [message #1281837 is a reply to message #1281751] Tue, 01 April 2014 12:26 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 01/04/2014 11:51, Felix Dorner a écrit :
> On 01/04/2014 11:41, Pierre-Charles David wrote:
>> For saving, simply pass the options in the map argument of
>> Session.save(Map<?,?>, IProgressMonitor).
>
> But won't this apply the options to all resources (semantic and
> sirius/diagrams?)

Yes. If you need further control, you can provide your own
implementation of org.eclipse.sirius.business.api.session.SavingPolicy,
and configure the session to use it using Session.setSavingPolicy().

When your policy is called, it gets the options which were passed to
Session.save(), but you can then interpret them as you want, or set
specific ones for some of the resources.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Multiple model files?
Next Topic:Semantic model based on XML schema generated ecore and handling of DocumentRoot class
Goto Forum:
  


Current Time: Thu Apr 18 13:27:49 GMT 2024

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

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

Back to the top