|
Re: Specifying Save/Load options at runtime [message #1281745 is a reply to message #1281681] |
Tue, 01 April 2014 09:41 |
|
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 #1281837 is a reply to message #1281751] |
Tue, 01 April 2014 12:26 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03557 seconds