Exemplo n.º 1
0
 protected static void doRemoveProxy(InternalEObject p, Resource res) {
   String id = p.eProxyURI().fragment();
   if (res instanceof XMLResource) {
     ((XMLResource) res).setID(p, id);
   }
   p.eSetProxyURI(null);
 }
Exemplo n.º 2
0
 public EObject resolveJavaObjectURIProxy(InternalEObject proxy, JvmTypeReference sender) {
   if (indexedJvmTypeAccess != null) {
     EObject result = indexedJvmTypeAccess.getIndexedJvmType(proxy.eProxyURI(), getResourceSet());
     if (result != null) {
       return result;
     }
   }
   return EcoreUtil.resolve(proxy, sender);
 }
  /** Add the specified list any external resource for this EReference feature */
  protected void processReferenceValue(
      final Resource eResource,
      final EObject eObject,
      final EReference eReference,
      final EObject value,
      final List externalResources,
      final Set unresolvedResourceURIs) {
    if (value == null) {
      return;
    }

    // Check if the object is an EMF proxy ...
    if (value.eIsProxy()) {
      if (value instanceof InternalEObject) {
        final InternalEObject iObject = (InternalEObject) value;
        final URI proxyUri = iObject.eProxyURI();
        CoreArgCheck.isNotNull(proxyUri);

        // Get the URI of the resource ...
        URI resourceUri = proxyUri.trimFragment();

        // Make the relative URI absolute if necessary
        URI baseLocationUri = eResource.getURI();
        URI proxyLocationUri = UriHelper.makeAbsoluteUri(baseLocationUri, resourceUri);
        // URI proxyLocationUri = resourceUri;
        // if (baseLocationUri.isHierarchical() && !baseLocationUri.isRelative() &&
        // proxyUri.isRelative()) {
        // proxyLocationUri = proxyLocationUri.resolve(baseLocationUri);
        // }
        Resource rsrc = findByURI(proxyLocationUri, true);

        // If the resource URI is a workspace relative path (e.g. "/project/.../model.xmi")
        if (rsrc == null && baseLocationUri.isFile() && resourceUri.toString().charAt(0) == '/') {
          String baseLocation = URI.decode(baseLocationUri.toFileString());
          String projectName = resourceUri.segment(0);
          String proxyLocation = URI.decode(resourceUri.toString());
          int index = baseLocation.indexOf(projectName);
          if (index != -1) {
            proxyLocation = baseLocation.substring(0, index - 1) + proxyLocation;
            rsrc = findByURI(URI.createFileURI(proxyLocation), true);
          }
        }

        if (rsrc != null && eResource != rsrc && !externalResources.contains(rsrc)) {
          externalResources.add(rsrc);
        } else if (rsrc == null) {
          unresolvedResourceURIs.add(resourceUri);
        }
      }
    } else {
      Resource rsrc = value.eResource();
      if (eResource != rsrc && !externalResources.contains(rsrc)) {
        externalResources.add(rsrc);
      }
    }
  }