Search in sources :

Example 6 with NodeList

use of org.eclipse.wst.dtd.core.internal.NodeList in project webtools.sourceediting by eclipse.

the class DTDTreeContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    // otherwise
    if (parentElement instanceof DTDFile) {
        if (isShowLogicalOrder()) {
            // return the visible node lists
            if (logicalNodeLists == null) {
                Iterator nodeLists = ((DTDFile) parentElement).getNodeLists().iterator();
                List visibleLists = new ArrayList(7);
                while (nodeLists.hasNext()) {
                    NodeList list = (NodeList) nodeLists.next();
                    if (isVisibleNodeList(list)) {
                        visibleLists.add(list);
                    }
                }
                logicalNodeLists = visibleLists.toArray();
            }
            return logicalNodeLists;
        } else {
            // return the visible nodes
            List allNodes = ((DTDFile) parentElement).getNodes();
            List visibleNodes = new ArrayList(allNodes.size());
            for (int i = 0; i < allNodes.size(); i++) {
                Object o = allNodes.get(i);
                if (isVisibleNode(o)) {
                    visibleNodes.add(o);
                }
            }
            return visibleNodes.toArray();
        }
    } else if (parentElement instanceof NodeList) {
        return ((NodeList) parentElement).getNodes().toArray();
    } else if (parentElement instanceof Element) {
        // always group the attributes directly under the element
        Object[] children = ((DTDNode) parentElement).getChildren();
        List attributes = ((Element) parentElement).getElementAttributes();
        Object[] logicalChildren = new Object[children.length + attributes.size()];
        int index = 0;
        for (index = 0; index < children.length; index++) {
            logicalChildren[index] = children[index];
        }
        for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
            logicalChildren[index++] = iter.next();
        }
        return logicalChildren;
    } else if (parentElement instanceof DTDNode) {
        return ((DTDNode) parentElement).getChildren();
    }
    return Collections.EMPTY_LIST.toArray();
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) Element(org.eclipse.wst.dtd.core.internal.Element) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Aggregations

NodeList (org.eclipse.wst.dtd.core.internal.NodeList)6 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)4 DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)4 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)3 Element (org.eclipse.wst.dtd.core.internal.Element)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Entity (org.eclipse.wst.dtd.core.internal.Entity)2 LabelValuePair (org.eclipse.wst.dtd.core.internal.util.LabelValuePair)2 Vector (java.util.Vector)1 Separator (org.eclipse.jface.action.Separator)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1 Image (org.eclipse.swt.graphics.Image)1 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)1 CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)1 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)1 Comment (org.eclipse.wst.dtd.core.internal.Comment)1 Notation (org.eclipse.wst.dtd.core.internal.Notation)1 ParameterEntityReference (org.eclipse.wst.dtd.core.internal.ParameterEntityReference)1