Search in sources :

Example 1 with INextCatalog

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

the class CatalogContributorRegistryReader method processNextCatalogElements.

private void processNextCatalogElements(IConfigurationElement[] childElementList) {
    if (catalog == null)
        return;
    for (int i = 0; i < childElementList.length; i++) {
        IConfigurationElement childElement = childElementList[i];
        // mandatory
        String location = childElement.getAttribute(OASISCatalogConstants.ATTR_CATALOG);
        if (// $NON-NLS-1$
        location == null || location.equals("")) {
            Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_next_catalog_location_uri_not_set);
            continue;
        }
        INextCatalog nextCatalog = new NextCatalog();
        String resolvedPath = resolvePath(location);
        nextCatalog.setCatalogLocation(resolvedPath);
        String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID);
        if (// $NON-NLS-1$
        id != null && !id.equals("")) {
            nextCatalog.setId(id);
        }
        catalog.addCatalogElement(nextCatalog);
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 2 with INextCatalog

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

the class CatalogWriter method processNextCatalogs.

private void processNextCatalogs(ICatalog catalog, Element parent) {
    // handle catalog entries
    INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
    Element childElement = null;
    // dw String attrValue = null;
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog delegate = nextCatalogs[i];
        childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_NEXT_CATALOG);
        if (childElement != null) {
            parent.appendChild(childElement);
            String location = delegate.getCatalogLocation();
            if (location != null) {
                childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, location);
            }
            setAttributes(delegate, childElement);
        }
    }
}
Also used : Element(org.w3c.dom.Element) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)

Example 3 with INextCatalog

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

the class GlobalCMDocumentCache method getSystemCatalogEntries.

private static synchronized HashMap getSystemCatalogEntries() {
    HashMap systemCatalogURIs = new HashMap();
    ICatalog systemCatalog = null;
    ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog catalog = nextCatalogs[i];
        ICatalog referencedCatalog = catalog.getReferencedCatalog();
        if (referencedCatalog != null) {
            if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
                systemCatalog = referencedCatalog;
            }
        }
    }
    if (systemCatalog != null) {
        ICatalogEntry[] catalogEntries = systemCatalog.getCatalogEntries();
        for (int i = 0; i < catalogEntries.length; i++) {
            systemCatalogURIs.put(catalogEntries[i].getURI(), new SoftReference(null));
        }
    }
    return systemCatalogURIs;
}
Also used : SoftReference(java.lang.ref.SoftReference) HashMap(java.util.HashMap) 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 4 with INextCatalog

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

the class SelectXMLCatalogIdPanel method createTableViewer.

protected XMLCatalogTableViewer createTableViewer(Composite parent) {
    String[] headings = new String[2];
    headings[0] = XMLUIMessages._UI_LABEL_KEY;
    headings[1] = XMLUIMessages._UI_LABEL_URI;
    XMLCatalogTableViewer theTableViewer = new XMLCatalogTableViewer(parent, headings) {

        protected void addXMLCatalogEntries(List list, ICatalogEntry[] entries) {
            for (int i = 0; i < entries.length; i++) {
                ICatalogEntry entry = entries[i];
                if (catalogEntryType == 0) {
                    list.add(entry);
                } else if (catalogEntryType == entry.getEntryType()) {
                    list.add(entry);
                }
            }
        }

        public Collection getXMLCatalogEntries() {
            List result = null;
            if ((fXmlCatalog == null) || doTableSizeHack) {
                // this lets us create a table with an initial height of
                // 10 rows
                // otherwise we get stuck with 0 row heigh table... that's
                // too small
                doTableSizeHack = false;
                result = new Vector();
                for (int i = 0; i < 6; i++) {
                    // $NON-NLS-1$
                    result.add("");
                }
            } else {
                result = new Vector();
                processCatalog(result, fXmlCatalog);
            }
            return result;
        }

        private void processCatalog(List result, ICatalog catalog) {
            addXMLCatalogEntries(result, catalog.getCatalogEntries());
            INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
            for (int i = 0; i < nextCatalogs.length; i++) {
                ICatalog nextCatalog = nextCatalogs[i].getReferencedCatalog();
                if (nextCatalog != null) {
                    processCatalog(result, nextCatalog);
                }
            }
        }
    };
    return theTableViewer;
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) List(java.util.List) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) Vector(java.util.Vector) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 5 with INextCatalog

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

the class CatalogReaderTest method testReadComplexCatalog.

/*
	 * Class under test for void read(ICatalog, String)
	 */
public void testReadComplexCatalog() throws Exception {
    // read catalog
    String catalogFile = "/data/delegateAndRewrite/catalog11.xml";
    URL catalogUrl = TestPlugin.getDefault().getBundle().getEntry(catalogFile);
    assertNotNull(catalogUrl);
    URL base = FileLocator.resolve(catalogUrl);
    Catalog catalog = (Catalog) getCatalog("catalog11", base.toString());
    // CatalogReader.read(catalog, catalogFilePath);
    assertNotNull(catalog);
    // test main catalog - catalog1.xml
    // assertEquals("cat1", catalog.getId());
    assertEquals(13, catalog.getCatalogElements().length);
    // test public entries
    assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_PUBLIC).size());
    // test system entries
    assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_SYSTEM).size());
    // test uri entries
    assertEquals(1, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_URI).size());
    // test next catalog - catalog2.xml
    INextCatalog[] nextCatalogEntries = catalog.getNextCatalogs();
    assertEquals(1, nextCatalogEntries.length);
    INextCatalog nextCatalogEntry = (INextCatalog) nextCatalogEntries[0];
    assertNotNull(nextCatalogEntry);
    assertEquals("catalog.xml", nextCatalogEntry.getCatalogLocation());
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) URL(java.net.URL) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) Catalog(org.eclipse.wst.xml.core.internal.catalog.Catalog) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Aggregations

INextCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)17 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)13 ICatalogEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)9 List (java.util.List)6 URL (java.net.URL)4 Catalog (org.eclipse.wst.xml.core.internal.catalog.Catalog)4 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 SoftReference (java.lang.ref.SoftReference)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 Composite (org.eclipse.swt.widgets.Composite)1 ICatalogElement (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1