Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Using getDiagramFromFiles Error
Using getDiagramFromFiles Error [message #868383] Tue, 01 May 2012 21:32 Go to next message
Josef Pohl is currently offline Josef PohlFriend
Messages: 82
Registered: January 2012
Hey there,
I posted a similar question over on the EMF forum as I thought it might be more applicable but I was wondering if anyone here has had any luck using the code from the file in the Drill-Down example.

I am getting a FileNotFoundException on trying to load a resource from a file.
This is being derived from the Drill-Down Feature which I have implemented in a very similar fashion as the tutorial. The one big difference between my system and the tutorial is that I separate my diagram from my model file.

The stack trace I am getting is:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: /egsc_test3/src/diagrams/Test47.diagram (No such file or directory)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(
	at utils.FileUtil.getDiagramFromFile(
	at utils.FileUtil.getDiagrams(
	at features.EgsndiagramDrillDownGoalFeature.getDiagrams(
	at org.eclipse.graphiti.ui.features.AbstractDrillDownFeature.getLinkedDiagrams(
	at org.eclipse.graphiti.ui.features.AbstractDrillDownFeature.canExecute(
	at features.EgsndiagramDrillDownGoalFeature.canExecute(
	at org.eclipse.graphiti.ui.internal.action.CustomAction.isEnabled(
	at org.eclipse.jface.action.ActionContributionItem.update(
	at org.eclipse.jface.action.ActionContributionItem.fill(

Above, /egsc_test3 is the project. Test47.diagram is the diagram file I am trying to load.

The error is derived from the getDiagramFromFile method, which is essentially unchanged. Actually almost all of the TutorialUtil code that I have used is unchanged for the most part.

private static Diagram getDiagramFromFile(IFile file, ResourceSet resourceSet) {
        // Get the URI of the model file.
        final URI resourceURI = getFileURI(file, resourceSet);

        // Demand load the resource for this file.
        Resource resource;
        try {
            resource = resourceSet.getResource(resourceURI, true); // ERROR FROM HERE
            if (resource != null) {
                // does resource contain a diagram as root object?
                final EList<EObject> contents = resource.getContents();
                for (final EObject object : contents) {
                    if (object instanceof Diagram) {
                        return (Diagram) object;
        } catch (final WrappedException e) {

        return null;

I have tried both loading the model file (which has an extension ".egsn") and the diagram file (extension ".diagram"). Both derive the same result.

Anyhow, I was just wondering if anyone had run into the same problem.


Re: Using getDiagramFromFiles Error [message #868407 is a reply to message #868383] Tue, 01 May 2012 22:35 Go to previous message
Josef Pohl is currently offline Josef PohlFriend
Messages: 82
Registered: January 2012
Problem solved...
in the function getFileURI I needed to use
URI resourceURI = URI.createPlatformResourceURI(pathName, true); 

instead of
... URI.createFileURI(pathName);

I did not test it without the decode option, so I am not certain if that is necessary.
Previous Topic:Make FigureCanvas Larger
Next Topic:Rotated text can not be saved?
Goto Forum:

Current Time: Tue Dec 01 20:15:42 GMT 2015

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

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