Search in sources :

Example 6 with URIResolver

use of org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver in project webtools.sourceediting by eclipse.

the class BaseTestCase method locateFileUsingCatalog.

protected String locateFileUsingCatalog(String namespaceURI) {
    URIResolver resolver = URIResolverPlugin.createResolver();
    String result = resolver.resolve("", namespaceURI, "");
    String resolvedURI = resolver.resolvePhysicalLocation("", namespaceURI, result);
    if (resolvedURI == null || resolvedURI.length() == 0) {
        return namespaceURI;
    }
    return resolvedURI;
}
Also used : URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver)

Example 7 with URIResolver

use of org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver in project webtools.sourceediting by eclipse.

the class ModelQueryAdapterFactoryForXML method createAdapter.

/**
 * createAdapter method comment.
 */
protected INodeAdapter createAdapter(INodeNotifier target) {
    if (org.eclipse.wst.sse.core.internal.util.Debug.displayInfo)
        // $NON-NLS-1$
        System.out.println("-----------------------ModelQueryAdapterFactoryForXML.createAdapter" + target);
    if (modelQueryAdapterImpl == null) {
        if (target instanceof IDOMNode) {
            IDOMNode xmlNode = (IDOMNode) target;
            IStructuredModel model = xmlNode.getModel();
            stateNotifier = xmlNode.getModel();
            stateNotifier.addModelStateListener(getInternalModelStateListener());
            org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
            if (Debug.displayInfo)
                // $NON-NLS-1$
                System.out.println("----------------ModelQueryAdapterFactoryForXML... baseLocation : " + resolver.getFileBaseLocation());
            /**
             * XMLCatalogIdResolver currently requires a filesystem
             * location string. Customarily this will be what is in the
             * deprecated SSE URIResolver and required by the Common URI
             * Resolver.
             */
            URIResolver idResolver = null;
            if (resolver != null) {
                idResolver = new XMLCatalogIdResolver(resolver.getFileBaseLocation(), resolver);
            } else {
                /*
					 * 203649 - this block may be necessary due to ordering of
					 * setting the resolver into the model
					 */
                String baseLocation = null;
                String modelsBaseLocation = model.getBaseLocation();
                if (modelsBaseLocation != null) {
                    File file = new Path(modelsBaseLocation).toFile();
                    if (file.exists()) {
                        baseLocation = file.getAbsolutePath();
                    } else {
                        IPath basePath = new Path(model.getBaseLocation());
                        IResource derivedResource = null;
                        if (basePath.segmentCount() > 1)
                            derivedResource = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
                        else
                            derivedResource = ResourcesPlugin.getWorkspace().getRoot().getProject(basePath.segment(0));
                        IPath derivedPath = derivedResource.getLocation();
                        if (derivedPath != null) {
                            baseLocation = derivedPath.toString();
                        } else {
                            URI uri = derivedResource.getLocationURI();
                            if (uri != null) {
                                baseLocation = uri.toString();
                            }
                        }
                    }
                    if (baseLocation == null) {
                        baseLocation = modelsBaseLocation;
                    }
                }
                idResolver = new XMLCatalogIdResolver(baseLocation, null);
            }
            CMDocumentCache cmDocumentCache = new CMDocumentCache();
            ModelQuery modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);
            // cs todo...
            // for now we create a CMDocumentCache on a 'per editor' basis
            // in the future we need to support a CMDocumentCache that is
            // shared between editors
            // nsd comment: may not be appropriate depending on
            CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
            if (documentManager != null) {
                configureDocumentManager(documentManager);
            }
            modelQueryAdapterImpl = new ModelQueryAdapterImpl(cmDocumentCache, modelQuery, idResolver);
        }
    }
    return modelQueryAdapterImpl;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CMDocumentManager(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager) URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver) ModelQueryAdapterImpl(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapterImpl) URI(java.net.URI) CMDocumentCache(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IResource(org.eclipse.core.resources.IResource)

Example 8 with URIResolver

use of org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver in project webtools.sourceediting by eclipse.

the class ExtensionsSchemasRegistry method locateFileUsingCatalog.

/**
 * Returns the String location for the schema with the given namespaceURI by
 * looking at the XML catalog. We look only in the plugin specified entries of
 * the catalog.
 *
 * @param namespaceURI
 * @return String representing the location of the schema.
 */
private String locateFileUsingCatalog(String namespaceURI) {
    URIResolver resolver = URIResolverPlugin.createResolver();
    String result = resolver.resolve("", namespaceURI, "");
    return resolver.resolvePhysicalLocation("", namespaceURI, result);
}
Also used : URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver)

Example 9 with URIResolver

use of org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver in project webtools.sourceediting by eclipse.

the class ModelQueryAdapterFactoryForHTML method createAdapter.

/**
 * createAdapter method comment.
 *
 * XXX: we must make this method more independent of 'location' (at least
 * provide some fall-back method).
 */
protected INodeAdapter createAdapter(INodeNotifier target) {
    if (Debug.displayInfo) {
        // $NON-NLS-1$
        Logger.log(Logger.INFO_DEBUG, "-----------------------ModelQueryAdapterFactoryForHTML.createAdapter" + target);
    }
    if (modelQueryAdapter == null) {
        if (target instanceof IDOMNode) {
            IDOMNode xmlNode = (IDOMNode) target;
            modelStateNotifier = xmlNode.getModel();
            modelStateNotifier.addModelStateListener(getInternalModelStateListener());
            IStructuredModel model = xmlNode.getModel();
            org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
            if (Debug.displayInfo)
                // $NON-NLS-1$
                System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + resolver.getFileBaseLocation());
            /**
             * XMLCatalogIdResolver currently requires a filesystem
             * location string. Customarily this will be what is in the
             * deprecated SSE URIResolver and required by the Common URI
             * Resolver.
             */
            URIResolver idResolver = null;
            if (resolver != null) {
                idResolver = new XMLCatalogIdResolver(resolver.getFileBaseLocation(), resolver);
            } else {
                /*
					 * 203649 - this block may be necessary due to ordering of
					 * setting the resolver into the model
					 */
                String baseLocation = null;
                String modelsBaseLocation = model.getBaseLocation();
                if (modelsBaseLocation != null) {
                    File file = new Path(modelsBaseLocation).toFile();
                    if (file.exists()) {
                        baseLocation = file.getAbsolutePath();
                    } else {
                        IPath basePath = new Path(model.getBaseLocation());
                        IResource derivedResource = null;
                        if (basePath.segmentCount() > 1)
                            derivedResource = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
                        else
                            derivedResource = ResourcesPlugin.getWorkspace().getRoot().getProject(basePath.segment(0));
                        IPath derivedPath = derivedResource.getLocation();
                        if (derivedPath != null) {
                            baseLocation = derivedPath.toString();
                        } else {
                            URI uri = derivedResource.getLocationURI();
                            if (uri != null) {
                                baseLocation = uri.toString();
                            }
                        }
                    }
                    if (baseLocation == null) {
                        baseLocation = modelsBaseLocation;
                    }
                }
                idResolver = new XMLCatalogIdResolver(baseLocation, null);
            }
            CMDocumentCache documentCache = new CMDocumentCache();
            ModelQuery modelQuery = new HTMLModelQueryImpl(documentCache, idResolver);
            modelQuery.setEditMode(ModelQuery.EDIT_MODE_UNCONSTRAINED);
            modelQueryAdapter = new ModelQueryAdapterImpl(documentCache, modelQuery, idResolver);
        }
    }
    return modelQueryAdapter;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) XMLCatalogIdResolver(org.eclipse.wst.xml.core.internal.modelquery.XMLCatalogIdResolver) IPath(org.eclipse.core.runtime.IPath) URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver) ModelQueryAdapterImpl(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapterImpl) URI(java.net.URI) CMDocumentCache(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IResource(org.eclipse.core.resources.IResource)

Aggregations

URIResolver (org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver)9 IFile (org.eclipse.core.resources.IFile)4 IResource (org.eclipse.core.resources.IResource)4 IPath (org.eclipse.core.runtime.IPath)4 File (java.io.File)3 URI (java.net.URI)3 Path (org.eclipse.core.runtime.Path)3 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)3 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)3 CMDocumentCache (org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache)3 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)3 XMLCatalogIdResolver (org.eclipse.wst.xml.core.internal.modelquery.XMLCatalogIdResolver)2 ModelQueryAdapterImpl (org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapterImpl)2 List (java.util.List)1 ComponentDeclarationEntry (org.eclipse.wst.common.core.search.document.ComponentDeclarationEntry)1 Entry (org.eclipse.wst.common.core.search.document.Entry)1 FileReferenceEntry (org.eclipse.wst.common.core.search.document.FileReferenceEntry)1 SearchDocument (org.eclipse.wst.common.core.search.document.SearchDocument)1 DTDFile (org.eclipse.wst.dtd.core.internal.emf.DTDFile)1 ErrorMessage (org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage)1