Search in sources :

Example 1 with CSSClassTraverser

use of org.eclipse.wst.css.core.internal.util.CSSClassTraverser in project webtools.sourceediting by eclipse.

the class HTMLDocumentAdapter method getClasses.

/**
 */
public Enumeration getClasses() {
    StyleSheetList sheetList = getStyleSheets();
    int nSheets = sheetList.getLength();
    final ArrayList classes = new ArrayList();
    CSSClassTraverser traverser = new CSSClassTraverser();
    traverser.setTraverseImported(true);
    for (int i = 0; i < nSheets; i++) {
        org.w3c.dom.stylesheets.StyleSheet sheet = sheetList.item(i);
        if (sheet instanceof ICSSNode) {
            traverser.apply((ICSSNode) sheet);
        }
    }
    classes.addAll(traverser.getClassNames());
    return new Enumeration() {

        int i = 0;

        public boolean hasMoreElements() {
            return i < classes.size();
        }

        public Object nextElement() {
            return classes.get(i++);
        }
    };
}
Also used : StyleSheet(org.w3c.dom.stylesheets.StyleSheet) Enumeration(java.util.Enumeration) ArrayList(java.util.ArrayList) CSSClassTraverser(org.eclipse.wst.css.core.internal.util.CSSClassTraverser) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList)

Aggregations

ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)1 CSSClassTraverser (org.eclipse.wst.css.core.internal.util.CSSClassTraverser)1 StyleSheet (org.w3c.dom.stylesheets.StyleSheet)1 StyleSheetList (org.w3c.dom.stylesheets.StyleSheetList)1