Search in sources :

Example 6 with ICatalogElement

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

the class XMLCatalogEntriesView method updateWidgetEnabledState.

protected void updateWidgetEnabledState() {
    boolean isEditable = false;
    ISelection selection = tableViewer.getSelection();
    boolean multipleSelection = false;
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        if (structuredSelection.size() > 1) {
            multipleSelection = true;
        }
        Object selectedObject = structuredSelection.getFirstElement();
        if (selectedObject instanceof ICatalogElement) {
            ICatalogElement[] elements = ((Catalog) workingUserCatalog).getCatalogElements();
            // dw List entriesList = new ArrayList(elements.length);
            for (int i = 0; i < elements.length; i++) {
                ICatalogElement element = elements[i];
                isEditable = selectedObject.equals(element);
                if (isEditable) {
                    break;
                }
            }
        }
    }
    // if (isPageEnabled)
    {
        editButton.setEnabled(isEditable & !multipleSelection);
        deleteButton.setEnabled(isEditable);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog) Catalog(org.eclipse.wst.xml.core.internal.catalog.Catalog) Point(org.eclipse.swt.graphics.Point)

Example 7 with ICatalogElement

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

the class XMLCatalogPreferencePage 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).size() == 1 ? ((IStructuredSelection) selection).getFirstElement() : null;
            if (selectedObject instanceof ICatalogElement) {
                detailsView.setCatalogElement((ICatalogElement) selectedObject);
            } else {
                detailsView.setCatalogElement(null);
            }
        }
    };
    catalogEntriesView.getViewer().addSelectionChangedListener(listener);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with ICatalogElement

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

the class Catalog method addEntriesFromCatalog.

public void addEntriesFromCatalog(ICatalog catalog) {
    try {
        setNotificationEnabled(false);
        if (catalog != null) {
            ICatalogElement[] entries = ((Catalog) catalog).getCatalogElements();
            for (int i = 0; i < entries.length; i++) {
                CatalogElement clone = (CatalogElement) ((CatalogElement) entries[i]).clone();
                addCatalogElement(clone);
            }
        } else {
            // $NON-NLS-1$
            Logger.log(Logger.ERROR, "argument was null in Catalog.addEntriesFromCatalog");
        }
    } finally {
        setNotificationEnabled(true);
    }
    internalResolver = null;
    notifyChanged();
}
Also used : ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog) IDelegateCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)

Example 9 with ICatalogElement

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement 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

ICatalogElement (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 ISelection (org.eclipse.jface.viewers.ISelection)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Group (org.eclipse.swt.widgets.Group)1 Catalog (org.eclipse.wst.xml.core.internal.catalog.Catalog)1 ICatalogEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)1 IDelegateCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog)1