Search in sources :

Example 16 with ICatalogEntry

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

the class CatalogWriter method processCatalogEntries.

private void processCatalogEntries(ICatalog catalog, Element parent) {
    ICatalogEntry[] catalogEntries = catalog.getCatalogEntries();
    for (int i = 0; i < catalogEntries.length; i++) {
        ICatalogEntry entry = catalogEntries[i];
        String key = entry.getKey();
        String uri = entry.getURI();
        Element childElement = null;
        switch(entry.getEntryType()) {
            case ICatalogEntry.ENTRY_TYPE_PUBLIC:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_PUBLIC);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID, key);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
                }
                break;
            case ICatalogEntry.ENTRY_TYPE_SYSTEM:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_SYSTEM);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID, key);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
                }
                break;
            case ICatalogEntry.ENTRY_TYPE_URI:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_URI);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_NAME, key);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
                }
                break;
            default:
                break;
        }
        if (childElement != null) {
            setAttributes(entry, childElement);
            parent.appendChild(childElement);
        }
    }
}
Also used : Element(org.w3c.dom.Element) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)

Example 17 with ICatalogEntry

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

the class CatalogTest method testCatalog.

public void testCatalog() throws Exception {
    Catalog workingUserCatalog = new Catalog(null, "working", null);
    assertNotNull(userCatalog);
    workingUserCatalog.addEntriesFromCatalog(userCatalog);
    ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
    catalogEntry.setKey("testKey");
    catalogEntry.setURI("http://testuri");
    workingUserCatalog.addCatalogElement(catalogEntry);
    userCatalog.addEntriesFromCatalog(workingUserCatalog);
    String userCatalogLocation = userCatalog.getLocation();
    userCatalog.save();
    userCatalog.clear();
    userCatalog = getCatalog(XMLCorePlugin.USER_CATALOG_ID, userCatalogLocation);
    List entries = getCatalogEntries(userCatalog, ICatalogEntry.ENTRY_TYPE_PUBLIC);
    assertEquals(1, entries.size());
    ICatalogEntry entry = (ICatalogEntry) entries.get(0);
    assertEquals("http://testuri", entry.getURI());
    assertEquals("testKey", entry.getKey());
}
Also used : List(java.util.List) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) Catalog(org.eclipse.wst.xml.core.internal.catalog.Catalog)

Example 18 with ICatalogEntry

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

the class AbstractCatalogTest method getCatalogEntries.

protected static List getCatalogEntries(ICatalog catalog, int entryType) {
    List result = new ArrayList();
    ICatalogEntry[] entries = catalog.getCatalogEntries();
    for (int i = 0; i < entries.length; i++) {
        ICatalogEntry entry = entries[i];
        if (entry.getEntryType() == entryType) {
            result.add(entry);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)

Example 19 with ICatalogEntry

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

the class SelectFromCatalogDialog method createCatalogDetailsView.

protected void createCatalogDetailsView(Composite parent) {
    Group detailsGroup = new Group(parent, SWT.NONE);
    detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    detailsGroup.setLayout(new GridLayout());
    detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS);
    final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView(detailsGroup);
    ISelectionChangedListener listener = new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
            if (selectedObject instanceof ICatalogEntry) {
                ICatalogEntry entry = (ICatalogEntry) selectedObject;
                detailsView.setCatalogElement(entry);
                currentSelectionLocation = entry.getURI();
                currentSelectionNamespace = entry.getKey();
            } else {
                detailsView.setCatalogElement((ICatalogEntry) null);
                currentSelectionLocation = "";
                currentSelectionNamespace = "";
            }
        }
    };
    catalogEntriesView.getViewer().addSelectionChangedListener(listener);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) XMLCatalogEntryDetailsView(org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogEntryDetailsView) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)

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