Exemple #1
0
 public static Resource loadResource(String filename) {
   URI uri = URI.createPlatformResourceURI(filename, true);
   Factory factory = ResourceFactoryRegistryImpl.INSTANCE.getFactory(uri);
   Resource resource = factory.createResource(uri);
   ResourceSet resourceSet = new ResourceSetImpl();
   resourceSet.getResources().add(resource);
   try {
     resource.load(Collections.EMPTY_MAP);
     return resource;
   } catch (IOException e) {
     throw new IllegalStateException("Error loading resource", e);
   }
 }
 public static Resource loadResource(URI uri) {
   Factory factory = ResourceFactoryRegistryImpl.INSTANCE.getFactory(uri);
   ResourceSet resourceSet = new ResourceSetImpl();
   Resource resource = factory.createResource(uri);
   resourceSet.getResources().add(resource);
   try {
     resource.load(Collections.emptyMap());
   } catch (IOException e) {
     e.printStackTrace();
     return null;
   }
   return resource;
 }
  protected MApplication createApplication() {
    resource = factory.createResource(temporaryURI);
    if (resource instanceof XMLResource) {
      xmlResource = (XMLResource) resource;
    }

    if (temporaryFile.exists()) {
      try {
        resource.load(null);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }

      return (MApplication) resource.getContents().get(0);
    }

    MApplication application = ApplicationFactoryImpl.eINSTANCE.createApplication();
    resource.getContents().add((EObject) application);
    return application;
  }