Esempio n. 1
0
  private String saveICMAssembly(AssemblyInstance assembly) {

    // configure this RF with the configuration file
    try {
      URL url =
          FileLocator.find(Platform.getBundle("SEI.ArchE.Performance"), new Path("/temp"), null);
      String tempPathName = FileLocator.resolve(url).getPath();

      ResourceSet resourceSet = new ResourceSetImpl();

      IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
      IPath path = new Path(tempPathName + assembly.getName() + ".icm");

      IFile xmlFile = workspaceRoot.getFile(path);

      // Get the URI of the model file
      URI fileURI = URI.createFileURI(path.toString());

      // Create a resource for this file.
      Resource resource = resourceSet.createResource(fileURI);

      // Add the assembly to the resource contents
      resource.getContents().add(assembly);

      // Save the contents of the resource to the file system.
      String xmlAssemblyFile = null;
      try {
        resource.save(Collections.EMPTY_MAP);
      } catch (IOException e) {
      }

      xmlAssemblyFile = fileURI.toFileString();

      return (path.toPortableString());

    } catch (MalformedURLException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    return null; // for error
  }