Search in sources :

Example 31 with INodeAdapter

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

the class CSSEmbededStyleNotifyAdapter method styleUpdate.

/**
 */
public void styleUpdate(ICSSModel srcModel) {
    IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
    if (node != null)
        return;
    INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
    if (adapter instanceof ICSSStyleListener) {
        ((ICSSStyleListener) adapter).styleUpdate(srcModel);
    }
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ICSSStyleListener(org.eclipse.wst.css.core.internal.event.ICSSStyleListener)

Example 32 with INodeAdapter

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

the class CSSEmbededStyleNotifyAdapter method styleChanged.

/**
 */
public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
    IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
    if (node != null)
        return;
    INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
    if (adapter instanceof ICSSStyleListener) {
        ((ICSSStyleListener) adapter).styleChanged(srcModel, removed, added, media);
    }
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ICSSStyleListener(org.eclipse.wst.css.core.internal.event.ICSSStyleListener)

Example 33 with INodeAdapter

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

the class HTMLElementFormatter method getCSSModel.

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

Example 34 with INodeAdapter

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

the class JFaceNodeAdapterForJs method getJsNode.

private Object getJsNode(Node parent, IJavaScriptElement root, Position position) {
    JsJfaceNode instance = null;
    if (root.getElementType() == IJavaScriptElement.TYPE) {
        instance = new JsJfaceNode(parent, root, position, ((SourceRefElement) root).getElementName());
    } else if (root.getElementType() == IJavaScriptElement.FIELD) {
        /* Field refrence, possibly to a type may need to implement later */
        instance = new JsJfaceNode(parent, root, position);
    } else {
        instance = new JsJfaceNode(parent, root, position);
    }
    String name = getJavaElementLabelProvider().getText(root);
    instance.setName(name);
    // ((JsJfaceNode)instance).setAdapterRegistry(registry);
    INodeAdapter adapter = (instance).getAdapterFor(IJFaceNodeAdapter.class);
    if (!(adapter instanceof JFaceNodeAdapterForJs)) {
        (instance).removeAdapter(adapter);
        (instance).addAdapter(this);
    }
    return instance;
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) SourceRefElement(org.eclipse.wst.jsdt.internal.core.SourceRefElement)

Example 35 with INodeAdapter

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

the class RegionChangedAdapterNotificationTests method testAppendWhitespaceToAttributeValue.

public void testAppendWhitespaceToAttributeValue() throws IOException {
    IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
    try {
        Document document = model.getDocument();
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.setText(this, "<a b= c></a>");
        Node before = document.getFirstChild();
        final int[] changed = new int[] { -1 };
        INodeAdapter adapter = new INodeAdapter() {

            public boolean isAdapterForType(Object type) {
                return type.equals(RegionChangedAdapterNotificationTests.class);
            }

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                changed[0] = eventType;
            }
        };
        ((INodeNotifier) before).addAdapter(adapter);
        Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
        StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 7, 0, " ");
        assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
        assertTrue(fmEvent instanceof RegionChangedEvent);
        Node after = document.getFirstChild();
        assertEquals("Node replaced", before, after);
        assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
        assertEquals("unexpected document content", "<a b= c ></a>", structuredDocument.get());
    } finally {
        model.releaseFromEdit();
    }
}
Also used : StructuredDocumentEvent(org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent) INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) RegionChangedEvent(org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Node(org.w3c.dom.Node) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Document(org.w3c.dom.Document) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier) NullInputStream(org.eclipse.wst.sse.core.internal.encoding.util.NullInputStream)

Aggregations

INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)51 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)31 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)25 Node (org.w3c.dom.Node)22 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)20 Document (org.w3c.dom.Document)19 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 Iterator (java.util.Iterator)10 Collection (java.util.Collection)7 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)7 Element (org.w3c.dom.Element)5 List (java.util.List)4 ICSSStyleListener (org.eclipse.wst.css.core.internal.event.ICSSStyleListener)4 IStyleSheetAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)4 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)4 EObject (org.eclipse.emf.ecore.EObject)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 ISelection (org.eclipse.jface.viewers.ISelection)3