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
Member
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 TutorialUtils.java 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: java.io.FileNotFoundException: /egsc_test3/src/diagrams/Test47.diagram (No such file or directory)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at utils.FileUtil.getDiagramFromFile(FileUtil.java:88)
	at utils.FileUtil.getDiagrams(FileUtil.java:32)
	at features.EgsndiagramDrillDownGoalFeature.getDiagrams(EgsndiagramDrillDownGoalFeature.java:60)
	at org.eclipse.graphiti.ui.features.AbstractDrillDownFeature.getLinkedDiagrams(AbstractDrillDownFeature.java:183)
	at org.eclipse.graphiti.ui.features.AbstractDrillDownFeature.canExecute(AbstractDrillDownFeature.java:150)
	at features.EgsndiagramDrillDownGoalFeature.canExecute(EgsndiagramDrillDownGoalFeature.java:42)
	at org.eclipse.graphiti.ui.internal.action.CustomAction.isEnabled(CustomAction.java:51)
	at org.eclipse.jface.action.ActionContributionItem.update(ActionContributionItem.java:946)
	at org.eclipse.jface.action.ActionContributionItem.fill(ActionContributionItem.java:291)


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) {
            e.printStackTrace();
        }

        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.

Thanks,
Joe

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
Member
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.
Joe
Previous Topic:Make FigureCanvas Larger
Next Topic:Rotated text can not be saved?
Goto Forum:
  


Current Time: Fri Nov 28 18:37:27 GMT 2014

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

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