Search in sources :

Example 6 with INodeNotifier

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

the class CSSNodeAdapter method getElements.

/**
 * Returns an enumeration with the elements belonging to the passed
 * element. These elements can be presented as rows in a table, items in a
 * list etc.
 */
public Object[] getElements(Object object) {
    if (object instanceof ICSSModel) {
        ArrayList v = new ArrayList();
        // internalGetElements(object, v);
        addElements(object, v);
        Object[] elements = v.toArray();
        for (int i = 0; i < elements.length; i++) {
            /*
				 * Required to correctly connect the refreshing behavior to
				 * the tree
				 */
            if (elements[i] instanceof INodeNotifier) {
                ((INodeNotifier) elements[i]).getAdapterFor(IJFaceNodeAdapter.class);
            }
        }
        return elements;
    }
    return new Object[0];
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ArrayList(java.util.ArrayList) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 7 with INodeNotifier

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

the class TestPageDirective method testGetTarget.

public void testGetTarget() {
    IDOMModel model = createUnmanagedHTMLModel();
    PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
    INodeNotifier notifier = pageDirectiveAdapter.getTarget();
    assertNotNull("target is null", notifier);
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 8 with INodeNotifier

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

the class JSPModelLoader method preLoadAdapt.

protected void preLoadAdapt(IStructuredModel structuredModel) {
    super.preLoadAdapt(structuredModel);
    IDOMModel domModel = (IDOMModel) structuredModel;
    // 
    // document must have already been set for this to
    // work.
    Document document = domModel.getDocument();
    Assert.isNotNull(document);
    // 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.
    // This 'get' causes first to be be attached.
    PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) document).getAdapterFor(PropagatingAdapter.class);
    // may make this easier to use in futue
    propagatingAdapter.addAdaptOnCreateFactory(new PageDirectiveWatcherFactory());
    if (Debug.debugNotificationAndEvents) {
        propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory());
    }
    // For JSPs, the ModelQueryAdapter must be "attached" to the document
    // before content is set in the model, so taglib initization can
    // take place.
    ((INodeNotifier) document).getAdapterFor(ModelQueryAdapter.class);
// 
}
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) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IDocument(org.eclipse.jface.text.IDocument) BasicStructuredDocument(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) PageDirectiveWatcherFactory(org.eclipse.jst.jsp.core.internal.document.PageDirectiveWatcherFactory) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 9 with INodeNotifier

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

the class JSPModelQueryImpl method getEmbeddedModelQuery.

// ISSUE: shouldn't this be private?
protected ModelQuery getEmbeddedModelQuery(Node node) {
    ModelQuery embeddedModelQuery = null;
    if (node instanceof INodeNotifier) {
        Node ownerNode = node.getOwnerDocument();
        if (ownerNode == null) {
            // then must be the document itself
            ownerNode = node;
        }
        PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
        if (pageDirectiveAdapter != null) {
            String effectiveContentType = null;
            ModelQuery potentialModelQueryObject = null;
            String familyId = pageDirectiveAdapter.getEmbeddedType().getFamilyId();
            if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(familyId)) {
                effectiveContentType = "text/html";
            } else {
                effectiveContentType = pageDirectiveAdapter.getContentType();
            }
            potentialModelQueryObject = (ModelQuery) embeddedModelQueries.get(effectiveContentType);
            if (potentialModelQueryObject == null) {
                ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
                if (embeddedAdapter != null) {
                    // we will cache one model query per content type
                    embeddedModelQuery = embeddedAdapter.getModelQuery();
                    embeddedModelQueries.put(effectiveContentType, embeddedModelQuery);
                }
            } else {
                embeddedModelQuery = potentialModelQueryObject;
            }
        }
    }
    return embeddedModelQuery;
}
Also used : ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) Node(org.w3c.dom.Node) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 10 with INodeNotifier

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

the class JSPedCSSPropertySheetConfiguration method getInputSelection.

public ISelection getInputSelection(IWorkbenchPart selectingPart, ISelection selection) {
    // remove UI refresh adapters
    if (fSelectedNotifiers != null) {
        for (int i = 0; i < fSelectedNotifiers.length; i++) {
            fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
        }
        fSelectedNotifiers = null;
    }
    ISelection preferredSelection = super.getInputSelection(selectingPart, selection);
    if (preferredSelection instanceof IStructuredSelection) {
        Object[] selectedObjects = new Object[((IStructuredSelection) selection).size()];
        System.arraycopy(((IStructuredSelection) selection).toArray(), 0, selectedObjects, 0, selectedObjects.length);
        for (int i = 0; i < selectedObjects.length; i++) {
            if (selectedObjects[i] instanceof ICSSNode) {
                ICSSNode node = (ICSSNode) selectedObjects[i];
                while (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE || node.getNodeType() == ICSSNode.STYLEDECLITEM_NODE) {
                    node = node.getParentNode();
                    selectedObjects[i] = node;
                }
            }
        }
        /*
			 * Add UI refresh adapters and remember notifiers for later
			 * removal
			 */
        if (selectedObjects.length > 0) {
            List selectedNotifiers = new ArrayList(1);
            for (int i = 0; i < selectedObjects.length; i++) {
                if (selectedObjects[i] instanceof INodeNotifier) {
                    selectedNotifiers.add(selectedObjects[i]);
                    ((INodeNotifier) selectedObjects[i]).addAdapter(fRefreshAdapter);
                }
            }
            fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers.toArray(new INodeNotifier[selectedNotifiers.size()]);
        }
        preferredSelection = new StructuredSelection(selectedObjects);
    }
    return preferredSelection;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) 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