Search in sources :

Example 11 with ICatalogEntry

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.

the class XMLHyperlinkDetector method createHyperlink.

/**
 * Create the appropriate hyperlink
 *
 * @param uriString
 * @param hyperlinkRegion
 * @return IHyperlink
 */
private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
    IHyperlink link = null;
    ICatalogEntry entry = getCatalogEntry(uriString);
    if (entry != null) {
        link = new CatalogEntryHyperlink(hyperlinkRegion, entry);
    } else {
        // try to locate the file in the workspace
        File systemFile = getFileFromUriString(uriString);
        if (systemFile != null) {
            String systemPath = systemFile.getPath();
            IFile file = getFile(systemPath);
            if (file != null) {
                // this is a WorkspaceFileHyperlink since file exists in
                // workspace
                link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
            } else {
                // this is an ExternalFileHyperlink since file does not
                // exist in workspace
                link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
            }
        }
    }
    return link;
}
Also used : IFile(org.eclipse.core.resources.IFile) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 12 with ICatalogEntry

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.

the class BugFixesTest method testInvalidSchemaWithNamespaceInCatalog.

/**
 * Test /BugFixes/XSDRegisteredWithCatalog/InvalidSchemaWithNamespaceInCatalog.xsd
 */
public void testInvalidSchemaWithNamespaceInCatalog() {
    String testname = "InvalidSchemaWithNamespaceInCatalog";
    String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd";
    String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
    String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
    createSimpleProject("Project", new String[] { testfile });
    ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog nextCatalog = nextCatalogs[i];
        if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
            ICatalog userCatalog = nextCatalog.getReferencedCatalog();
            if (userCatalog != null) {
                ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
                catalogEntry.setKey("http://www.eclipse.org/webtools/Catalogue");
                catalogEntry.setURI("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd");
                userCatalog.addCatalogElement(catalogEntry);
                runTest("platform:/resource/Project/InvalidSchemaWithNamespaceInCatalog.xsd", loglocation, idealloglocation);
                catalog.removeCatalogElement(catalogEntry);
            }
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 13 with ICatalogEntry

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.

the class BugFixesTest method testInvalidSchemaInXMLCatalog.

/**
 * Test /BugFixes/InvalidSchemaInXMLCatalog/InvalidSchemaInXMLCatalog.xsd
 */
public void testInvalidSchemaInXMLCatalog() {
    String testname = "InvalidSchemaInXMLCatalog";
    String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd";
    String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
    String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
    createSimpleProject("Project", new String[] { testfile });
    ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog nextCatalog = nextCatalogs[i];
        if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
            ICatalog userCatalog = nextCatalog.getReferencedCatalog();
            if (userCatalog != null) {
                ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
                catalogEntry.setKey("testKey");
                catalogEntry.setURI("http://testuri");
                userCatalog.addCatalogElement(catalogEntry);
                runTest("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd", /*FILE_PROTOCOL + file.getLocation().toString()*/
                loglocation, idealloglocation);
                catalog.removeCatalogElement(catalogEntry);
            }
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 14 with ICatalogEntry

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.

the class ProjectDescription method getCatalogRecords.

private Collection getCatalogRecords() {
    if (fCatalogRecords == null) {
        List records = new ArrayList();
        ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
        if (defaultCatalog != null) {
            // Process default catalog
            ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
            for (int entry = 0; entry < entries.length; entry++) {
                ITaglibRecord record = createCatalogRecord(entries[entry]);
                records.add(record);
            }
            // Process declared OASIS nextCatalogs catalog
            INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
            for (int nextCatalog = 0; nextCatalog < nextCatalogs.length; nextCatalog++) {
                ICatalog catalog = nextCatalogs[nextCatalog].getReferencedCatalog();
                ICatalogEntry[] entries2 = catalog.getCatalogEntries();
                for (int entry = 0; entry < entries2.length; entry++) {
                    String uri = entries2[entry].getURI();
                    if (uri != null) {
                        uri = uri.toLowerCase(Locale.US);
                        if (uri.endsWith((".jar")) || uri.endsWith((".tld"))) {
                            ITaglibRecord record = createCatalogRecord(entries2[entry]);
                            if (record != null) {
                                records.add(record);
                            }
                        }
                    }
                }
            }
        }
        fCatalogRecords = records;
    }
    return fCatalogRecords;
}
Also used : ArrayList(java.util.ArrayList) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 15 with ICatalogEntry

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.

the class CatalogContributorRegistryReader method processMappingInfoElements.

private void processMappingInfoElements(IConfigurationElement[] childElementList) {
    if (catalog == null)
        return;
    for (int i = 0; i < childElementList.length; i++) {
        IConfigurationElement childElement = childElementList[i];
        String name = childElement.getName();
        String key = null;
        int type = ICatalogEntry.ENTRY_TYPE_PUBLIC;
        if (OASISCatalogConstants.TAG_PUBLIC.equals(name)) {
            key = childElement.getAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID);
        } else if (OASISCatalogConstants.TAG_SYSTEM.equals(name)) {
            key = childElement.getAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID);
            type = ICatalogEntry.ENTRY_TYPE_SYSTEM;
        } else if (OASISCatalogConstants.TAG_URI.equals(name)) {
            key = childElement.getAttribute(OASISCatalogConstants.ATTR_NAME);
            type = ICatalogEntry.ENTRY_TYPE_URI;
        } else if (OASISCatalogConstants.TAG_NEXT_CATALOG.equals(name)) {
            processNextCatalogElements(new IConfigurationElement[] { childElement });
            continue;
        }
        if (// $NON-NLS-1$
        key == null || key.equals("")) {
            Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_key_not_set);
            continue;
        }
        // mandatory
        String entryURI = childElement.getAttribute(OASISCatalogConstants.ATTR_URI);
        if (// $NON-NLS-1$
        entryURI == null || entryURI.equals("")) {
            Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_uri_not_set);
            continue;
        }
        ICatalogElement catalogElement = catalog.createCatalogElement(type);
        if (catalogElement instanceof ICatalogEntry) {
            ICatalogEntry entry = (ICatalogEntry) catalogElement;
            entry.setKey(key);
            String resolvedPath = resolvePath(entryURI);
            entry.setURI(resolvedPath);
            // optional
            String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID);
            if (// $NON-NLS-1$
            id != null && !id.equals("")) {
                entry.setId(id);
            }
        }
        // process any other attributes
        for (int j = 0; j < childElement.getAttributeNames().length; j++) {
            String attrName = childElement.getAttributeNames()[j];
            if (!attrName.equals(OASISCatalogConstants.ATTR_URI) && !attrName.equals(OASISCatalogConstants.ATTR_NAME) && !attrName.equals(OASISCatalogConstants.ATTR_PUBLIC_ID) && !attrName.equals(OASISCatalogConstants.ATTR_SYSTEM_ID) && !attrName.equals(OASISCatalogConstants.ATTR_CATALOG) && !attrName.equals(OASISCatalogConstants.ATTR_ID) && !attrName.equals(OASISCatalogConstants.ATTR_BASE)) {
                String attrValue = childElement.getAttribute(attrName);
                if (// $NON-NLS-1$
                attrValue != null && !attrValue.equals("")) {
                    catalogElement.setAttributeValue(attrName, attrValue);
                }
            }
        }
        catalog.addCatalogElement(catalogElement);
    }
}
Also used : ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Aggregations

ICatalogEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)19 INextCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)10 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)9 List (java.util.List)8 Catalog (org.eclipse.wst.xml.core.internal.catalog.Catalog)4 URL (java.net.URL)3 ISelection (org.eclipse.jface.viewers.ISelection)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 ArrayList (java.util.ArrayList)2 ICatalogElement (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)2 File (java.io.File)1 SoftReference (java.lang.ref.SoftReference)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 IFile (org.eclipse.core.resources.IFile)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1