Search in sources :

Example 11 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.

the class AbstractCSSModelAdapter method notifyStyleChanged.

/**
 */
protected void notifyStyleChanged(Element target) {
    INodeNotifier notifier = (INodeNotifier) target;
    if (notifier == null)
        return;
    Collection adapters = notifier.getAdapters();
    if (adapters == null)
        return;
    Iterator it = adapters.iterator();
    if (it == null)
        return;
    while (it.hasNext()) {
        INodeAdapter adapter = (INodeAdapter) it.next();
        if (adapter instanceof StyleListener) {
            StyleListener listener = (StyleListener) adapter;
            listener.styleChanged();
        }
    }
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) Iterator(java.util.Iterator) Collection(java.util.Collection) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 12 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.

the class HTMLDocumentAdapter method notifyStyleSheetsChanged.

/**
 */
private void notifyStyleSheetsChanged(Document target) {
    INodeNotifier notifier = (INodeNotifier) target;
    if (notifier == null)
        return;
    Collection adapters = notifier.getAdapters();
    if (adapters == null)
        return;
    Iterator it = adapters.iterator();
    if (it == null)
        return;
    while (it.hasNext()) {
        INodeAdapter adapter = (INodeAdapter) it.next();
        if (adapter instanceof StyleListener) {
            StyleListener listener = (StyleListener) adapter;
            listener.styleChanged();
        }
    }
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) Iterator(java.util.Iterator) Collection(java.util.Collection) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 13 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.

the class HTMLDocumentAdapter method addStyleSheet.

/**
 */
private void addStyleSheet(Element node) {
    IDOMElement element = (IDOMElement) node;
    String tagName = element.getTagName();
    if (tagName == null)
        return;
    boolean isContainer = false;
    if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.NOSCRIPT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE) || tagName.equalsIgnoreCase(JSP11Namespace.ElementName.ROOT) || (!element.isGlobalTag() && element.isContainer())) {
        isContainer = true;
    } else if (element.isCommentTag()) {
        Node parent = element.getParentNode();
        if (parent == element.getOwnerDocument()) {
            // This condition is too severe, actually do not work for JSF template.
            // But above (! globalTag() && isContainer()) cover JSF template + tpl template
            isContainer = true;
        } else if (parent.getNodeType() == Node.ELEMENT_NODE) {
            tagName = ((Element) parent).getTagName();
            if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) {
                isContainer = true;
            }
        }
    } else {
        String localName = element.getLocalName();
        if (localName != null && localName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML)) {
            // taglib html tag
            isContainer = true;
        } else {
            INodeNotifier notifier = element;
            INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class);
            if (adapter != null && adapter instanceof IStyleSheetAdapter) {
                this.styleAdapters.addElement(adapter);
            }
        }
    }
    if (isContainer) {
        INodeNotifier notifier = element;
        if (notifier.getExistingAdapter(IStyleSheetListAdapter.class) == null) {
            notifier.addAdapter(this);
        }
        for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
            if (child.getNodeType() != Node.ELEMENT_NODE)
                continue;
            addStyleSheet((Element) child);
        }
    }
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) Node(org.w3c.dom.Node) IStyleSheetListAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetListAdapter) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 14 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.

the class HTMLDocumentLoader method preLoadAdapt.

protected void preLoadAdapt(IStructuredModel structuredModel) {
    // DMW: just added this preload on 8/16/2002
    // I noticed the ProagatingAdapterFactory was being added,
    // that that the ProagatingAdapterAdapter was not being
    // preload adapted -- I'm assuing it ALWAYS has to be.
    IDOMModel domModel = (IDOMModel) structuredModel;
    // if there is a model in the adapter, this will adapt it to
    // first node. After that the PropagatingAdater spreads over the
    // children being
    // created. Each time that happends, a side effect is to
    // also "spread" sprecific registered adapters,
    // they two can propigate is needed.
    ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 15 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.

the class HTMLModelLoader method preLoadAdapt.

protected void preLoadAdapt(IStructuredModel structuredModel) {
    super.preLoadAdapt(structuredModel);
    // DMW: just added this preload on 8/16/2002
    // I noticed the ProagatingAdapterFactory was being added,
    // that that the ProagatingAdapterAdapter was not being
    // preload adapted -- I'm assuing it ALWAYS has to be.
    IDOMModel domModel = (IDOMModel) structuredModel;
    // if there is a model in the adapter, this will adapt it to
    // first node. After that the PropagatingAdater spreads over the
    // children being
    // created. Each time that happends, a side effect is to
    // also "spread" sprecific registered adapters,
    // they two can propigate is needed.
    ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
    if (Debug.debugNotificationAndEvents) {
        PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
        propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory());
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) DebugAdapterFactory(org.eclipse.wst.xml.core.internal.DebugAdapterFactory) PropagatingAdapter(org.eclipse.wst.sse.core.internal.PropagatingAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Aggregations

INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)71 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)35 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)31 Node (org.w3c.dom.Node)29 Document (org.w3c.dom.Document)26 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)24 NullInputStream (org.eclipse.wst.sse.core.internal.encoding.util.NullInputStream)18 RegionChangedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent)18 StructuredDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent)18 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)14 Iterator (java.util.Iterator)9 List (java.util.List)8 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)8 ModelQueryAdapter (org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter)8 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)7 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)7 Element (org.w3c.dom.Element)7 CSSSourceFormatter (org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter)6