Search in sources :

Example 6 with IStyleSheetAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.

the class CSSTextNodeCleanupHandler method getCSSModel.

/**
 */
private ICSSModel getCSSModel(Node text) {
    if (text == null)
        return null;
    INodeNotifier notifier = (INodeNotifier) text.getParentNode();
    if (notifier == null)
        return null;
    INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class);
    if (adapter == null)
        return null;
    if (!(adapter instanceof IStyleSheetAdapter))
        return null;
    IStyleSheetAdapter styleAdapter = (IStyleSheetAdapter) adapter;
    return styleAdapter.getModel();
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 7 with IStyleSheetAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.

the class CSSStyleSheetImpl method getOwnerNodes.

/**
 * @return org.w3c.dom.NodeList
 */
public org.w3c.dom.NodeList getOwnerNodes() {
    List list = (getModel().getStyleListeners() != null) ? new Vector(getModel().getStyleListeners()) : null;
    if (list == null)
        return null;
    InternalNodeList nodes = new InternalNodeList();
    Iterator it = list.iterator();
    while (it.hasNext()) {
        Object obj = it.next();
        if (obj instanceof IStyleSheetAdapter) {
            nodes.nodes.add(((IStyleSheetAdapter) obj).getElement());
        }
    }
    if (nodes.getLength() > 0)
        return nodes;
    else
        return null;
}
Also used : Iterator(java.util.Iterator) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList) CSSRuleList(org.w3c.dom.css.CSSRuleList) MediaList(org.w3c.dom.stylesheets.MediaList) NodeList(org.w3c.dom.NodeList) List(java.util.List) Vector(java.util.Vector) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)

Example 8 with IStyleSheetAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.

the class HTMLDocumentAdapter method removeOldStyleSheets.

/**
 */
private void removeOldStyleSheets() {
    if (this.oldStyleAdapters == null)
        return;
    Iterator it = this.oldStyleAdapters.iterator();
    while (it.hasNext()) {
        IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next();
        if (adapter == null)
            continue;
        // do not release
        if (this.styleAdapters != null && this.styleAdapters.contains(adapter))
            continue;
        adapter.removed();
    }
    this.oldStyleAdapters = null;
}
Also used : Iterator(java.util.Iterator) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)

Example 9 with IStyleSheetAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.

the class EmbeddedCSSFormatter method getCSSModel.

/**
 */
private ICSSModel getCSSModel(IDOMNode text) {
    if (text == null)
        return null;
    INodeNotifier notifier = (INodeNotifier) text.getParentNode();
    if (notifier == null)
        return null;
    INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class);
    if (adapter == null)
        return null;
    if (!(adapter instanceof IStyleSheetAdapter))
        return null;
    IStyleSheetAdapter styleAdapter = (IStyleSheetAdapter) adapter;
    return styleAdapter.getModel();
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Aggregations

IStyleSheetAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)9 Iterator (java.util.Iterator)5 List (java.util.List)3 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)3 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)3 StyleSheetList (org.w3c.dom.stylesheets.StyleSheetList)3 Vector (java.util.Vector)2 NodeList (org.w3c.dom.NodeList)2 CSSRuleList (org.w3c.dom.css.CSSRuleList)2 MediaList (org.w3c.dom.stylesheets.MediaList)2 ArrayList (java.util.ArrayList)1 IStyleSheetListAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetListAdapter)1 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)1 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)1 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 StyleSheet (org.w3c.dom.stylesheets.StyleSheet)1