Search in sources :

Example 1 with ICatalogElement

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

the class Catalog method getCatalogElements.

private List getCatalogElements(int type) {
    List result = new ArrayList();
    ICatalogElement[] elements = (ICatalogElement[]) catalogElements.toArray(new ICatalogElement[catalogElements.size()]);
    for (int i = 0; i < elements.length; i++) {
        ICatalogElement element = elements[i];
        if (element.getType() == type) {
            result.add(element);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 2 with ICatalogElement

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

the class CatalogElement method clone.

/*
	   * Since we don't have events notifications for entry properties, clone()
	   * could allow to copy and edit entry and then replace it in catalog. Entry
	   * replacement will signal ICatalogEvent @return
	   */
public Object clone() {
    ICatalogElement element = ownerCatalog.createCatalogElement(type);
    String[] attributes = getAttributes();
    for (int i = 0; i < attributes.length; i++) {
        String attrName = attributes[i];
        String attrValue = getAttributeValue(attrName);
        element.setAttributeValue(attrName, attrValue);
    }
    element.setOwnerCatalog(ownerCatalog);
    element.setId(id);
    element.setBase(base);
    return element;
}
Also used : ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)

Example 3 with ICatalogElement

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

the class XMLCatalogEntriesView method performNew.

protected void performNew() {
    // ICatalogEntry newEntry =
    // (ICatalogEntry)workingUserCatalog.createCatalogElement(ICatalogElement.TYPE_ENTRY);
    EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_NEW_DIALOG_TITLE, workingUserCatalog);
    ICatalogElement element = dialog.getCatalogElement();
    if (dialog.getReturnCode() == Window.OK) {
        workingUserCatalog.addCatalogElement(element);
        tableViewer.setSelection(new StructuredSelection(element), true);
        tableViewer.refresh();
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)

Example 4 with ICatalogElement

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

the class XMLCatalogEntriesView method performDelete.

protected void performDelete() {
    ISelection selection = tableViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        Iterator iterator = structuredSelection.iterator();
        while (iterator.hasNext()) {
            Object selectedObject = iterator.next();
            if (selectedObject instanceof ICatalogElement) {
                ICatalogElement catalogElement = (ICatalogElement) selectedObject;
                workingUserCatalog.removeCatalogElement(catalogElement);
            }
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with ICatalogElement

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

the class XMLCatalogEntriesView method performEdit.

protected void performEdit() {
    ISelection selection = tableViewer.getSelection();
    Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
    if (selectedObject instanceof ICatalogElement) {
        ICatalogElement oldEntry = (ICatalogElement) selectedObject;
        ICatalogElement newEntry = (ICatalogElement) ((CatalogElement) oldEntry).clone();
        EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_EDIT_DIALOG_TITLE, newEntry, workingUserCatalog);
        if (dialog.getReturnCode() == Window.OK) {
            // delete the old value if the 'mapFrom' has changed
            // 
            workingUserCatalog.removeCatalogElement(oldEntry);
            // update the new mapping
            // 
            workingUserCatalog.addCatalogElement(newEntry);
            tableViewer.setSelection(new StructuredSelection(newEntry));
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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