Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Custom Save
Custom Save [message #1002287] Fri, 18 January 2013 05:17 Go to next message
Lars Schulte is currently offline Lars Schulte
Messages: 4
Registered: December 2012
Junior Member
Hi,

is it possible to change the save behavior of Graphiti? As far as I can tell Graphiti saves its diagram as an xmi file. Thats fine so far, but what im looking for is the possibility to save several diagrams into a single xmi file.
Any ideas?

Greetings
Lars
Re: Custom Save [message #1002329 is a reply to message #1002287] Fri, 18 January 2013 07:11 Go to previous message
Aljoscha Hark is currently offline Aljoscha Hark
Messages: 24
Registered: March 2012
Junior Member
Hi,

you can do it easily:

- when doing it from within an already opened diagram, just do it by
Diagram diagram1 = ...; // the already opened diagram
Diagram diagram2 = ...; // the additional diagram
diagram1.eResource().getContents().add(diagram2); // do it inside a feature/write transaction

- when doing it "on load", e.g. from a context menu handler on a file
Diagram diagram = ...; // the additional diagram

String path = "/project/file.diagrams";
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(URI.createPlatformResource(path, true));
resource.getContents().add(diagram);
try {
   resource.save(Collections.emptyMap());
} catch(IOException e) {
   e.printStackTrace();
   // e.g. log error
}

greetings,
aljoscha
Previous Topic:new Diagram
Next Topic:Adding Root Domain Object on Diagram Creation
Goto Forum:
  


Current Time: Mon Apr 21 11:43:11 EDT 2014

Powered by FUDForum. Page generated in 0.10059 seconds