try { ResourceSet set = new ResourceSet(); Resource resource = set.createResource(URI .createPlatformResourceURI(diagramFile.getFullPath() .toString(), false)); if (!resource.isLoaded()) { resource.load(new HashMap(GMFResourceFactory .getDefaultLoadOptions())); } Iterator rootContents = resource.getContents().iterator(); while(rootContents.hasNext()) { EObject rootElement = (EObject)rootContents.next(); if(rootElement instanceof Diagram) this.diagram = (Diagram)rootElement; } System.out.println(diagram.getName()); } catch (IOException e) { e.printStackTrace(); }
<?xml version="1.0" encoding="ASCII"?> <di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmi:id="_JfTw8spTEd-Ly98anaGDeg"> <pageList xmi:id="_JfTw88pTEd-Ly98anaGDeg"> <availablePage xmi:id="_Jfc64cpTEd-Ly98anaGDeg"> <emfPageIdentifier href="model.notation#_JfTw8MpTEd-Ly98anaGDeg"/> </availablePage> <availablePage xmi:id="_A8rPVMpYEd-1LOFEodgUOQ"> <emfPageIdentifier href="model.notation#_A8iFUcpYEd-1LOFEodgUOQ"/> </availablePage> <availablePage xmi:id="_RYCsycyNEd-t0sqdTA50oA"/> </pageList> <sashModel xmi:id="_JfTw9MpTEd-Ly98anaGDeg" currentSelection="_Jfc64MpTEd-Ly98anaGDeg"> <windows xmi:id="_JfTw9cpTEd-Ly98anaGDeg"> <children xsi:type="di:TabFolder" xmi:id="_Jfc64MpTEd-Ly98anaGDeg"> <children xmi:id="_Jfc64spTEd-Ly98anaGDeg"> <emfPageIdentifier href="model.notation#_JfTw8MpTEd-Ly98anaGDeg"/> </children> <children xmi:id="_UW00UMvYEd-OpLwFnxoZew"> <emfPageIdentifier href="model.notation#_A8iFUcpYEd-1LOFEodgUOQ"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>