Search in sources :

Example 1 with IJFaceNodeAdapter

use of org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter in project webtools.sourceediting by eclipse.

the class JFaceNodeLabelProviderCSS method getText.

/**
 * Returns the text for the label of the given element, for use in the
 * given viewer.
 *
 * @param viewer
 *            The viewer that displays the element.
 * @param element
 *            The element for which to provide the label text. Element can
 *            be <code>null</code> indicating no input object is set to
 *            the viewer.
 */
public String getText(Object element) {
    String text = null;
    IJFaceNodeAdapter adapter = getAdapter(element);
    if (adapter != null) {
        text = adapter.getLabelText(element);
    }
    return text;
}
Also used : IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)

Example 2 with IJFaceNodeAdapter

use of org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter in project webtools.sourceediting by eclipse.

the class JFaceNodeContentProvider method getElements.

public Object[] getElements(Object object) {
    // The root is usually an instance of an XMLStructuredModel in
    // which case we want to extract the document.
    Object topNode = object;
    if (object instanceof IDOMModel) {
        topNode = ((IDOMModel) object).getDocument();
    }
    IJFaceNodeAdapter adapter = getAdapter(topNode);
    if (adapter != null) {
        return adapter.getElements(topNode);
    }
    return new Object[0];
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)

Example 3 with IJFaceNodeAdapter

use of org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter in project webtools.sourceediting by eclipse.

the class JFaceNodeLabelProviderXPath method getText.

public String getText(Object element) {
    if (element instanceof EmptyNodeList) {
        return NO_MATCHES;
    }
    IJFaceNodeAdapter adapter = getAdapter(element);
    if (adapter == null) {
        // Could be our fake "AnyValue" Text node
        if (element instanceof Text) {
            return ((Text) element).getData();
        } else {
            return element.toString();
        }
    }
    StringBuffer sb = new StringBuffer(adapter.getLabelText(element));
    if (element instanceof Element) {
        Element impl = (Element) element;
        NamedNodeMap nnm = impl.getAttributes();
        if (nnm.getLength() > 0) {
            Attr a = (Attr) nnm.item(0);
            String val = a.getNodeValue();
            sb.append(" ").append(a.getName()).append("=").append(val);
        }
    }
    return sb.toString();
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) Attr(org.w3c.dom.Attr)

Example 4 with IJFaceNodeAdapter

use of org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter in project webtools.sourceediting by eclipse.

the class JFaceNodeContentProviderXPath method getElements.

public Object[] getElements(Object object) {
    if (object instanceof IDOMModel) {
        Object topNode = ((IDOMModel) object).getDocument();
        IJFaceNodeAdapter adapter = getAdapter(topNode);
        if (adapter != null) {
            return adapter.getElements(topNode);
        }
    } else if (object instanceof NodeList) {
        NodeList nodeList = (NodeList) object;
        if (nodeList.getLength() == 0) {
            return new Object[] { new EmptyNodeList() };
        } else {
            Node[] nodes = new Node[nodeList.getLength()];
            for (int i = 0; i < nodes.length; i++) {
                nodes[i] = nodeList.item(i);
            }
            return nodes;
        }
    }
    return new Object[0];
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) NodeList(org.w3c.dom.NodeList) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)

Example 5 with IJFaceNodeAdapter

use of org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter in project webtools.sourceediting by eclipse.

the class JFaceNodeLabelProviderCSS method getImage.

/**
 * Returns the image for the label of the given element, for use in the
 * given viewer.
 *
 * @param viewer
 *            The viewer that displays the element.
 * @param element
 *            The element for which to provide the label image. Element
 *            can be <code>null</code> indicating no input object is set
 *            to the viewer.
 */
public Image getImage(Object element) {
    Image image = null;
    IJFaceNodeAdapter adapter = getAdapter(element);
    if (adapter != null)
        image = adapter.getLabelImage(element);
    return image;
}
Also used : Image(org.eclipse.swt.graphics.Image) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)

Aggregations

IJFaceNodeAdapter (org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)7 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)3 Image (org.eclipse.swt.graphics.Image)1 IJSONModel (org.eclipse.wst.json.core.document.IJSONModel)1 Attr (org.w3c.dom.Attr)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 NodeList (org.w3c.dom.NodeList)1 Text (org.w3c.dom.Text)1