Search in sources :

Example 46 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector20.

public void testSelector20() {
    ICSSSelectorList list = createSelectorList("SPAN[hello=\"Cleveland\"][goodbye=\"Columbus\"]");
    checkSelectorList(list, "SPAN[hello=\"Cleveland\"][goodbye=\"Columbus\"]", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "SPAN[hello=\"Cleveland\"][goodbye=\"Columbus\"]", 1, 201, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "SPAN", false, 2, 0, 0, 0);
    checkSimpleSelectorAttributes(item, new String[] { "hello=\"Cleveland\"", "goodbye=\"Columbus\"" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 47 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector06.

public void testSelector06() {
    ICSSSelectorList list = createSelectorList(".warning");
    checkSelectorList(list, ".warning", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, ".warning", 1, 100, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "", true, 0, 1, 0, 0);
    checkSimpleSelectorClasses(item, new String[] { "warning" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 48 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector39.

public void testSelector39() {
    ICSSSelectorList list = createSelectorList(".123f567");
    checkSelectorList(list, ".123f567", 1, 1);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, ".123f567", 1, 100, 1);
    item = selector.getItem(0);
    checkSimpleSelector(item, "", true, 0, 1, 0, 0);
    checkSimpleSelectorClasses(item, new String[] { "123f567" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 49 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSStyleNotifyAdapter method addStyleListener.

/**
 */
public void addStyleListener(ICSSStyleListener listener) {
    if (listener == null)
        return;
    if (listeners == null)
        listeners = new Vector();
    if (!listeners.contains(listener)) {
        // send new selectors event to listener
        ImportedCollector trav = new ImportedCollector();
        trav.apply(model.getDocument());
        Iterator it = trav.getExternals().iterator();
        while (it.hasNext()) {
            ICSSStyleSheet sheet = (ICSSStyleSheet) it.next();
            // collect selectors
            SelectorsCollector selTrav = new SelectorsCollector();
            selTrav.apply(sheet);
            int nSel = selTrav.getSelectors().size();
            ICSSSelector[] added = new ICSSSelector[nSel];
            for (int i = 0; i < nSel; i++) added[i] = (ICSSSelector) selTrav.getSelectors().get(i);
            // fire event
            CSSStyleEventDeliverer deliverer = new CSSStyleEventDeliverer();
            deliverer.fireTo(listener, sheet.getModel(), null, added, null);
        }
        // add listener
        listeners.add(listener);
    }
}
Also used : ImportedCollector(org.eclipse.wst.css.core.internal.util.ImportedCollector) Iterator(java.util.Iterator) SelectorsCollector(org.eclipse.wst.css.core.internal.util.SelectorsCollector) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet) Vector(java.util.Vector)

Example 50 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSStyleNotifyAdapter method removeStyleListener.

/**
 */
public void removeStyleListener(ICSSStyleListener listener) {
    if (listener == null)
        return;
    if (listeners.contains(listener)) {
        listeners.remove(listener);
        // send old selectors event to listener
        ImportedCollector trav = new ImportedCollector();
        trav.apply(model.getDocument());
        Iterator it = trav.getExternals().iterator();
        while (it.hasNext()) {
            ICSSStyleSheet sheet = (ICSSStyleSheet) it.next();
            // collect selectors
            SelectorsCollector selTrav = new SelectorsCollector();
            selTrav.apply(sheet);
            int nSel = selTrav.getSelectors().size();
            ICSSSelector[] removed = new ICSSSelector[nSel];
            for (int i = 0; i < nSel; i++) removed[i] = (ICSSSelector) selTrav.getSelectors().get(i);
            // fire event
            CSSStyleEventDeliverer deliverer = new CSSStyleEventDeliverer();
            deliverer.fireTo(listener, sheet.getModel(), removed, null, null);
        }
    }
}
Also used : ImportedCollector(org.eclipse.wst.css.core.internal.util.ImportedCollector) Iterator(java.util.Iterator) SelectorsCollector(org.eclipse.wst.css.core.internal.util.SelectorsCollector) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)

Aggregations

ICSSSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector)52 ICSSSelectorList (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList)48 ICSSSelectorItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)42 Iterator (java.util.Iterator)7 ICSSStyleRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule)3 ImportedCollector (org.eclipse.wst.css.core.internal.util.ImportedCollector)3 SelectorsCollector (org.eclipse.wst.css.core.internal.util.SelectorsCollector)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)2 ICSSSimpleSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector)2 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)2 Vector (java.util.Vector)1 CSSTextParser (org.eclipse.wst.css.core.internal.parserz.CSSTextParser)1 CSSTextToken (org.eclipse.wst.css.core.internal.parserz.CSSTextToken)1 ICSSImportRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule)1 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)1 ImportRuleCollector (org.eclipse.wst.css.core.internal.util.ImportRuleCollector)1