Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Get XMI file for a given diagram
Get XMI file for a given diagram [message #1455847] Wed, 29 October 2014 20:35 Go to next message
Simone Di Cola is currently offline Simone Di ColaFriend
Messages: 60
Registered: February 2014
Member
Hi all,
is it possible to get the XMI file associated with a given .diagram file?
If yes, how?

Thanks
Simone
Re: Get XMI file for a given diagram [message #1456441 is a reply to message #1455847] Thu, 30 October 2014 11:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Simone,

that depends on the type of URIs that describes the location of the EMF resource. There is an internal implementation in Graphiti you might find helpful. See method getFile(URI) in http://git.eclipse.org/c/graphiti/org.eclipse.graphiti.git/tree/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/EmfService.java

Michael
Re: Get XMI file for a given diagram [message #1456503 is a reply to message #1456441] Thu, 30 October 2014 12:33 Go to previous message
Simone Di Cola is currently offline Simone Di ColaFriend
Messages: 60
Registered: February 2014
Member
Thanks. This is my final solution:

	private void removeFiles(Diagram linkedDiagram) {
	
 			ResourceSet resourceSet =  linkedDiagram.eResource().getResourceSet();
			List<Resource> resourcesToDelete = new ArrayList<Resource>();
 			for (Resource resource : resourceSet.getResources()) {
				if(resource.getURI().toString().contains(linkedDiagram.getName())){
					resourcesToDelete.add(resource);
				}
			}
 			
			for (Resource resource : resourcesToDelete) {
				try {
					resource.delete(null);
				} catch (IOException e) {
					 LOGGER.error("Error while deleting file:" +resource.getURI().toString(), e);
				}
			}
	}
Previous Topic:Switch programmatically to move mode
Next Topic:delete confirmation dialog
Goto Forum:
  


Current Time: Tue Mar 19 09:18:53 GMT 2024

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

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

Back to the top