Package org.eclipse.wst.sse.core.internal.util

Examples of org.eclipse.wst.sse.core.internal.util.URIResolver


    }
    return null;
  }

  private String getResolvedURL(Element element_, String attrName) {
    URIResolver resolver = null;
    if (element_ instanceof IDOMNode) {
      resolver = ((IDOMNode) element_).getModel().getResolver();
    }
    if (null == resolver) {
      return null;
    }
    String src = URI;
    if (src != null && src.length() > 0) {
      return resolver.getLocationByURI(src);
    }
    return null;
  }
View Full Code Here


   *      java.lang.Class)
   */
  public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (URIResolver.class.equals(adapterType)) {
      IProject project = (IProject) adaptableObject;
      URIResolver fProjectResolver = new ProjectResolver(project);
      return fProjectResolver;
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  static String getResolvedURL(Element element, String attrName) {
    URIResolver resolver = null;
    if (element instanceof IDOMNode) {
            // TODO: the new URI resolver is not available on the IStructuredModel
      resolver = ((IDOMNode) element).getModel().getResolver();
    }
    if (null == resolver) {
      return null;
    }
    String src = element.getAttribute(attrName);
    if (src != null && src.length() > 0) {
      return resolver.getLocationByURI(src);
    }
    return null;
  }
View Full Code Here

   * @param element
   * @param attrName
   * @return
   */
  static String getResolvedURL(Element element, String attrName) {
    URIResolver resolver = null;
    if (element instanceof IDOMNode) {
      resolver = ((IDOMNode) element).getModel().getResolver();
    }
    if (null == resolver) {
      return null;
    }
    String src = DOMUtil.getAttributeIgnoreCase(element, attrName);
    if (src != null && src.length() > 0) {
      return resolver.getLocationByURI(src);
    }
    return null;
  }
View Full Code Here

    IStructuredModel baseModel = ((IDOMNode) getElement()).getModel();
    ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID);

    // calculate base location and set
    // get resolver in Model
    URIResolver resolver = baseModel.getResolver();

    // resolve to absolute url : this need not exact location of css file. It is important that absurl is not null.
    String ref = getElement().getAttribute(HTML40Namespace.ATTR_NAME_HREF);
    String absurl = (resolver != null && ref != null && ref.length() > 0) ? resolver.getLocationByURI(ref, true) : null;
    if ((absurl == null) || (absurl.length() == 0)) {
      IPath basePath = new Path(baseModel.getBaseLocation());
      URLHelper helper = new URLHelper(basePath.removeLastSegments(1).toString());
      absurl = helper.toAbsolute(ref == null ? "" : ref);//$NON-NLS-1$
    }
View Full Code Here

    }
    else {
      String id = null;
      InputStream inStream = null;
      // obtain resolver
      URIResolver resolver = (project != null) ? (URIResolver) project.getAdapter(URIResolver.class) : null;
      if (resolver == null) {
        // ProjectResolver can take care of the case if project is
        // null.
        resolver = new ProjectResolver(project);
      }
View Full Code Here

        }
      }
    }

    // get resolver in Model
    final URIResolver resolver = baseModel.getResolver();

    // resolve to absolute url
    final String absurl = (resolver != null) ? ((baseHref != null) ? resolver.getLocationByURI(ref, baseHref, resolveCrossProjectLinks) : resolver.getLocationByURI(ref, resolveCrossProjectLinks)) : null;
    if ((resolver != null) && (absurl == null) && (ref != null) && (ref.trim().length() > 0) && (ref.trim().charAt(0) == '/')) {
      // to reach here means :
      //    ref is a Docroot relative
      //    resolver can't resolve ref
      // so that href is a broken and should not create model
      return null;
    }
    if ((absurl != null) && (absurl.length() > 0)) {
      return absurl;
    }

    // maybe ref is at outside of the Project
    // obtain docroot;
    final IContainer container = (resolver != null) ? resolver.getRootLocation() : null;
    String docroot = null;
    if (container != null) {
      IPath containerLocation = container.getLocation();
      if (containerLocation != null) {
        docroot = containerLocation.toString();
View Full Code Here

      if (model != null) {
        // use the base location to obtain the in-workspace IFile
        IFile modelFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
        if (modelFile != null) {
          // find the referenced file's location on disk
          URIResolver resolver = model.getResolver();
          if (resolver != null) {
            String filesystemLocation = resolver.getLocationByURI(fileString);
            if (filesystemLocation != null) {
              IFile[] workspaceFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(filesystemLocation));
              // favor a workspace file in the same project
              for (int i = 0; i < workspaceFiles.length && file == null; i++) {
                if (workspaceFiles[i].getProject().equals(modelFile.getProject())) {
View Full Code Here

        // try to locate the file in the workspace
        try {
          sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
          if (sModel != null) {
            URIResolver resolver = sModel.getResolver();
            if (resolver != null) {
              String uriString = resolver.getFileBaseLocation();
              file = getFile(uriString);
            }
          }
        }
        finally {
View Full Code Here

        // try to locate the file in the workspace
        try {
          sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
          if (sModel != null) {
            URIResolver resolver = sModel.getResolver();
            if (resolver != null) {
              String uriString = resolver.getFileBaseLocation();
              file = getFile(uriString);
            }
          }
        }
        finally {
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.util.URIResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.