Monday, October 26, 2020

Re: GWT + EMF + JSON

I know nothing about EMF,  or emf-json, but it seems to me that you need to do it this way:

https://emfjson.github.io/projects/gwt/latest/

(using emfjson-gwt)

On Friday, October 23, 2020 at 7:10:31 AM UTC-6 tonio....@gmail.com wrote:
Hi all,
I am using GWT with EMF and I want write files on client side containing description of some EMF object with the JSON format. For this purpose I use EMFJson tool  (https://emfjson.github.io/) with the following code but I can't write the file,. Have you an idea?

Here is the code:

        // As of here we preparing to save the model content
        ResourceSet resSet = new ResourceSetImpl();
        // Register the XMI resource factory for the * extension
        resSet.getPackageRegistry()
        .put(EcorePackage.eNS_URI,EcorePackage.eINSTANCE);

        resSet.getResourceFactoryRegistry()
        .getExtensionToFactoryMap()
        .put("*", new JsonResourceFactory());

        // Obtain a new resource set
       
        resSet.getURIConverter().getURIHandlers().add(new LocalStorageHandler());

        // create a resource
        URI uri = URI.createURI("file:///" + "D:/Spottest.json");
        GWT.log(uri.toString());
        Resource resource = resSet.createResource(uri);
        // Get the first model element and cast it to the right type,
        // everything is hierarchical included in this first node
        resource.getContents().add(custom);

        // now save the content.
        // resource.save(Collections.EMPTY_MAP);
        try {
            resource.save(Collections.EMPTY_MAP);
        } catch (Exception e) {
            GWT.log("Pb saved " + e.getMessage());
        }

Thanks a lot for your help.

Antonio

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/14617e6b-2d62-4650-ad02-020f1e899643n%40googlegroups.com.

No comments:

Post a Comment