Search in sources :

Example 1 with SelectorList

use of org.w3c.css.sac.SelectorList in project eclipse.pde by eclipse-pde.

the class CssSpyPart method performCSSSearch.

private void performCSSSearch(IProgressMonitor monitor, String text, Collection<Widget> results) {
    if (text.trim().length() == 0) {
        return;
    }
    widgetTreeViewer.collapseAll();
    Object[] roots = widgetTreeProvider.getElements(widgetTreeViewer.getInput());
    SubMonitor subMonitor = SubMonitor.convert(monitor, MessageFormat.format(Messages.CssSpyPart_Searching_for, text), roots.length * 10);
    for (Object root : roots) {
        if (monitor.isCanceled()) {
            return;
        }
        CSSStylableElement element = getCSSElement(root);
        if (element == null) {
            continue;
        }
        CSSEngine engine = getCSSEngine(root);
        try {
            SelectorList selectors = engine.parseSelectors(text);
            subMonitor.split(2);
            processCSSSearch(subMonitor.split(8), engine, selectors, element, null, results);
        } catch (CSSParseException | IOException e) {
            System.out.println(e.toString());
        }
    }
    monitor.done();
}
Also used : CSSParseException(org.w3c.css.sac.CSSParseException) SelectorList(org.w3c.css.sac.SelectorList) SubMonitor(org.eclipse.core.runtime.SubMonitor) CSSEngine(org.eclipse.e4.ui.css.core.engine.CSSEngine) IOException(java.io.IOException) CSSStylableElement(org.eclipse.e4.ui.css.core.dom.CSSStylableElement)

Example 2 with SelectorList

use of org.w3c.css.sac.SelectorList in project org.eclipse.rap by eclipse-rap.

the class StyleSheet method toString.

@Override
public String toString() {
    StringBuilder buffer = new StringBuilder();
    StyleRule[] styleRules = getStyleRules();
    for (int i = 0; i < styleRules.length; i++) {
        StyleRule styleRule = styleRules[i];
        SelectorList selectors = styleRule.getSelectors();
        int length = selectors.getLength();
        for (int j = 0; j < length; j++) {
            if (j > 0) {
                buffer.append(",");
            }
            if (i > 0) {
                buffer.append("\n");
            }
            buffer.append(selectors.item(j));
        }
        buffer.append("\n");
        buffer.append(styleRule.getProperties());
        buffer.append("\n");
    }
    return buffer.toString();
}
Also used : SelectorList(org.w3c.css.sac.SelectorList)

Example 3 with SelectorList

use of org.w3c.css.sac.SelectorList in project org.eclipse.rap by eclipse-rap.

the class StyleSheet method createSelectorWrappers.

private void createSelectorWrappers() {
    List<SelectorWrapper> selectorWrappersList = new LinkedList<>();
    for (int pos = 0; pos < styleRules.length; pos++) {
        StyleRule styleRule = styleRules[pos];
        SelectorList selectors = styleRule.getSelectors();
        StylePropertyMap properties = styleRule.getProperties();
        int length = selectors.getLength();
        for (int i = 0; i < length; i++) {
            Selector selector = selectors.item(i);
            SelectorWrapper selectorWrapper = new SelectorWrapper(selector, properties, pos);
            selectorWrappersList.add(selectorWrapper);
        }
    }
    Collections.sort(selectorWrappersList, COMPARATOR);
    Collections.reverse(selectorWrappersList);
    selectorWrappers = new SelectorWrapper[selectorWrappersList.size()];
    selectorWrappersList.toArray(selectorWrappers);
}
Also used : SelectorList(org.w3c.css.sac.SelectorList) LinkedList(java.util.LinkedList) Selector(org.w3c.css.sac.Selector)

Example 4 with SelectorList

use of org.w3c.css.sac.SelectorList in project org.eclipse.rap by eclipse-rap.

the class Parser method parseSelectorsInternal.

/**
 * Parses selectors using the current scanner.
 */
protected SelectorList parseSelectorsInternal() throws CSSException, IOException {
    nextIgnoreSpaces();
    SelectorList ret = parseSelectorList();
    scanner = null;
    return ret;
}
Also used : SelectorList(org.w3c.css.sac.SelectorList)

Example 5 with SelectorList

use of org.w3c.css.sac.SelectorList in project org.eclipse.rap by eclipse-rap.

the class ThemeTestBase method processTestStyleRule.

private static void processTestStyleRule(StyleRule styleRule) {
    SelectorList selectors = styleRule.getSelectors();
    StylePropertyMap properties = styleRule.getProperties();
    int length = selectors.getLength();
    for (int i = 0; i < length; i++) {
        Selector selector = selectors.item(i);
        SelectorExt selectorExt = (SelectorExt) selector;
        checkProperties(selectorExt, properties);
    }
}
Also used : SelectorExt(org.eclipse.rap.rwt.internal.theme.css.SelectorExt) SelectorList(org.w3c.css.sac.SelectorList) StylePropertyMap(org.eclipse.rap.rwt.internal.theme.css.StylePropertyMap) SimpleSelector(org.eclipse.rap.rwt.internal.theme.SimpleSelector) Selector(org.w3c.css.sac.Selector)

Aggregations

SelectorList (org.w3c.css.sac.SelectorList)16 Selector (org.w3c.css.sac.Selector)7 Test (org.junit.jupiter.api.Test)5 CSSParseException (org.w3c.css.sac.CSSParseException)3 ConditionalSelector (org.w3c.css.sac.ConditionalSelector)3 ArrayList (java.util.ArrayList)2 ExtendedCSSRule (org.eclipse.e4.ui.css.core.dom.ExtendedCSSRule)2 ExtendedSelector (org.eclipse.e4.ui.css.core.impl.sac.ExtendedSelector)2 JSONParser (com.codename1.io.JSONParser)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 CharArrayReader (java.io.CharArrayReader)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1