[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.technology.higgins] Re: Problem Running Demo App and Saving Context

Hey Paul,
On a second thought, I was looking through the javadoc of 
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(URI), and 
the description states that this function "delegates to the resource factory 
registry to determine the correct factory, and then uses the factory to 
create the resource and add it to the contents.  If there is no registered 
factory, null will be returned; when running within Eclipse, a default XMI 
factory will be registered, and this will never return null"

In your function ProjectFolder.preSave(), when the resource set is created 
using "new ResourceSetImpl(), its resourceFactoryRegistry is null.  I'm not 
sure when would Eclipse add the default XMI factory, so I made the following 
modification to the preSave() function:
    ...
   rs = new ResourceSetImpl();
   rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
     "xml",new XMLResourceFactoryImpl());
    ...

I don't get a null from  "resource=rs.createResource(fileURI);" in the 
associateResource() function as before, but I still cannot resolve the uri 
to a valid window's filepath.  The value of "fileURI" in my case is 
"platform:/resource/simon/Simon/context.xml".

Please help.
Regards,
Sion



"Simon Chen" <jiaychen@xxxxxxxxx> wrote in message 
news:e1r87b$l5f$1@xxxxxxxxxxxxxxxxxxxx
> Hi Paul,
> thanks for the response.  I still cannot save my context information, and 
> I think this is because I'm trying to run the demo app under Windows.
>
> Bascially, in org.eclipse.higgins.context.store.ProjectFolder.java, the 
> following function always returns null:
>
> private static Resource associateResource(Object root, IFile ifile,
>   ResourceSet rs) throws IOException {
>  if (root == null)
>   throw new IllegalArgumentException();
>  if (debug)
>   System.out.println("[debug]AssociateResource "
>     + ifile.getFullPath().toString());
>  // Get the URI of the model file.
>  URI fileURI = URI.createPlatformResourceURI(ifile.getFullPath()
>    .toString());
>  // Create a resource for this file.
>  Resource resource = rs.createResource(fileURI);
>  // Add the initial model object to the contents.
>  resource.getContents().add(root);
>  return resource;
> }
>
> The line "Resource resource=rs.createResource(fileURI);" always returns 
> null, and fileURI has the value, for example, "/simon/Simon.context.xml". 
> I haven't tried on Linux, but I assume this fileURI works under Linux 
> since it's a valid file path.  However, under Windows, how do I resolve 
> the fileURI to the proper format such as "C:\\simon\\Simon\\context.xml"? 
> What's the proper way of doing this conversion?
>
> Thanks,
> Simon
>