Search in sources :

Example 66 with INodeNotifier

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

the class JSPDocumentLoader method preLoadAdapt.

protected void preLoadAdapt(IStructuredModel structuredModel) {
    IDOMModel domModel = (IDOMModel) structuredModel;
    // 
    // document must have already been set for this to
    // work.
    Document document = domModel.getDocument();
    Assert.isNotNull(document, JSPCoreMessages.JSPDocumentLoader_1);
    // 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());
    // 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) PropagatingAdapter(org.eclipse.wst.sse.core.internal.PropagatingAdapter) Document(org.w3c.dom.Document) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument) 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 67 with INodeNotifier

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

the class HTMLContentAssistProcessor method getXHTML.

/**
 * Determine if this Document is an XHTML Document. Oprates solely off of
 * the Document Type declaration
 */
protected boolean getXHTML(Node node) {
    if (node == null)
        return false;
    Document doc = null;
    if (node.getNodeType() != Node.DOCUMENT_NODE)
        doc = node.getOwnerDocument();
    else
        doc = ((Document) node);
    if (doc instanceof IDOMDocument)
        return ((IDOMDocument) doc).isXMLType();
    if (doc instanceof INodeNotifier) {
        ModelQueryAdapter adapter = (ModelQueryAdapter) ((INodeNotifier) doc).getAdapterFor(ModelQueryAdapter.class);
        CMDocument cmdoc = null;
        if (adapter != null && adapter.getModelQuery() != null)
            cmdoc = adapter.getModelQuery().getCorrespondingCMDocument(doc);
        if (cmdoc != null) {
            // model
            if (cmdoc instanceof HTMLCMDocument)
                return false;
            if (cmdoc.supports(HTMLCMProperties.IS_XHTML))
                return Boolean.TRUE.equals(cmdoc.getProperty(HTMLCMProperties.IS_XHTML));
        }
    }
    // this should never be reached
    DocumentType docType = doc.getDoctype();
    // $NON-NLS-1$
    return docType != null && docType.getPublicId() != null && docType.getPublicId().indexOf("-//W3C//DTD XHTML ") == 0;
}
Also used : HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) DocumentType(org.w3c.dom.DocumentType) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 68 with INodeNotifier

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

the class EmbeddedCSSFormatter method getCSSContent.

/**
 */
private String getCSSContent(IDOMNode text) {
    ICSSModel model = getCSSModel(text);
    if (model == null)
        return null;
    ICSSNode document = model.getDocument();
    if (document == null)
        return null;
    INodeNotifier notifier = (INodeNotifier) document;
    CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
    // try another way to get formatter
    if (formatter == null)
        formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(notifier);
    if (formatter == null)
        return null;
    StringBuffer buffer = formatter.format(document);
    if (buffer == null)
        return null;
    return buffer.toString();
}
Also used : CSSSourceFormatter(org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 69 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier 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)

Example 70 with INodeNotifier

use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project jbosstools-hibernate by jbosstools.

the class ObserverAdapterFactory method createAdapter.

protected INodeAdapter createAdapter(INodeNotifier target) {
    Node n = (Node) target;
    String nodeName = n.getNodeName();
    INodeAdapter result = null;
    Object key = DOMAdapter.class;
    if ("hibernate-reverse-engineering".equals(nodeName)) {
        // $NON-NLS-1$
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.hibernateMappingChanged();
            }
        };
    } else if ("table-filter".equals(nodeName)) {
        // $NON-NLS-1$
        result = new TableFilterAdapter((Node) target, revEngDefinition);
    } else if ("type-mapping".equals(nodeName)) {
        // $NON-NLS-1$
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.typeMappingChanged(notifier);
            }
        };
    } else if ("sql-type".equals(nodeName)) {
        // $NON-NLS-1$
        result = new TypeMappingAdapter((Node) target, revEngDefinition);
    } else if ("table".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngTableAdapter((Node) target, revEngDefinition);
    } else if ("column".equals(nodeName) || "key-column".equals(nodeName)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = new RevEngColumnAdapter((Node) target, revEngDefinition);
    } else if ("primary-key".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngPrimaryKeyAdapter((Node) target, revEngDefinition);
    } else if ("generator".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngGeneratorAdapter((Node) target, revEngDefinition);
    } else if ("param".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngParamAdapter((Node) target, revEngDefinition);
    } else if (// $NON-NLS-1$
    "foreign-key".equals(nodeName) || // $NON-NLS-1$
    "column-ref".equals(nodeName)) {
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.tablesChanged(notifier);
            }
        };
    }
    if (result == null) {
        result = new UnknownNodeAdapter(key, revEngDefinition);
    }
    if (result != null) {
        adaptChildren((Node) target);
    }
    return result;
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) RevEngPrimaryKeyAdapter(org.hibernate.eclipse.mapper.model.RevEngPrimaryKeyAdapter) Node(org.w3c.dom.Node) TableFilterAdapter(org.hibernate.eclipse.mapper.model.TableFilterAdapter) TypeMappingAdapter(org.hibernate.eclipse.mapper.model.TypeMappingAdapter) RevEngParamAdapter(org.hibernate.eclipse.mapper.model.RevEngParamAdapter) DOMAdapter(org.hibernate.eclipse.mapper.model.DOMAdapter) RevEngTableAdapter(org.hibernate.eclipse.mapper.model.RevEngTableAdapter) RevEngColumnAdapter(org.hibernate.eclipse.mapper.model.RevEngColumnAdapter) RevEngGeneratorAdapter(org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter) 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