Search in sources :

Example 11 with INodeAdapterFactory

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

the class HTMLModelLoader method getAdapterFactories.

/**
 * This method must return those factories which must be attached to the
 * structuredModel before content is applied.
 */
public List getAdapterFactories() {
    List result = new ArrayList();
    INodeAdapterFactory factory = null;
    factory = StyleAdapterFactory.getInstance();
    result.add(factory);
    factory = HTMLStyleSelectorAdapterFactory.getInstance();
    result.add(factory);
    factory = HTMLDocumentTypeAdapterFactory.getInstance();
    result.add(factory);
    factory = HTMLModelParserAdapterFactory.getInstance();
    result.add(factory);
    // 
    factory = new ModelQueryAdapterFactoryForHTML();
    result.add(factory);
    factory = new PropagatingAdapterFactoryImpl();
    result.add(factory);
    return result;
}
Also used : PropagatingAdapterFactoryImpl(org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ModelQueryAdapterFactoryForHTML(org.eclipse.wst.html.core.internal.modelquery.ModelQueryAdapterFactoryForHTML) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 12 with INodeAdapterFactory

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

the class JSPContentSourceValidator method validate.

/**
 * This validate call is for the ISourceValidator partial document
 * validation approach
 *
 * @param dirtyRegion
 * @param helper
 * @param reporter
 * @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator
 */
public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) {
    if (helper == null || fDocument == null || !fEnableSourceValidation)
        return;
    if ((reporter != null) && (reporter.isCancelled() == true)) {
        throw new OperationCanceledException();
    }
    IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
    if (model == null)
        // error
        return;
    try {
        IDOMDocument document = null;
        if (model instanceof IDOMModel) {
            document = ((IDOMModel) model).getDocument();
        }
        if (document == null || !hasHTMLFeature(document))
            // ignore
            return;
        ITextFileBuffer fb = FileBufferModelManager.getInstance().getBuffer(fDocument);
        if (fb == null)
            return;
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(fb.getLocation());
        if (file == null || !file.exists())
            return;
        // this will be the wrong region if it's Text (instead of Element)
        // we don't know how to validate Text
        // model.getIndexedRegion(dirtyRegion.getOffset());
        IndexedRegion ir = getCoveringNode(dirtyRegion);
        if (ir instanceof Text) {
            while (ir != null && ir instanceof Text) {
                // it's assumed that this gets the IndexedRegion to
                // the right of the end offset
                ir = model.getIndexedRegion(ir.getEndOffset());
            }
        }
        if (ir instanceof INodeNotifier) {
            INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
            ValidationAdapter adapter = (ValidationAdapter) factory.adapt((INodeNotifier) ir);
            if (adapter == null)
                // error
                return;
            if (reporter != null) {
                HTMLValidationReporter rep = null;
                rep = getReporter(reporter, file, (IDOMModel) model);
                rep.clear();
                adapter.setReporter(rep);
                Message mess = new LocalizedMessage(IMessage.LOW_SEVERITY, file.getFullPath().toString().substring(1));
                reporter.displaySubtask(this, mess);
            }
            adapter.validate(ir);
        }
    } finally {
        if (model != null)
            model.releaseFromRead();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) Message(org.eclipse.wst.validation.internal.core.Message) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) Text(org.w3c.dom.Text) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) ValidationAdapter(org.eclipse.wst.sse.core.internal.validate.ValidationAdapter) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 13 with INodeAdapterFactory

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

the class PropagatingAdapterImpl method adaptOnCreate.

private void adaptOnCreate(IDOMNode node) {
    // chooses to
    if (adaptOnCreateFactories != null) {
        synchronized (adaptOnCreateFactories) {
            int length = adaptOnCreateFactories.size();
            for (int i = 0; i < length; i++) {
                INodeAdapterFactory factory = (INodeAdapterFactory) adaptOnCreateFactories.get(i);
                factory.adapt(node);
            }
        }
    }
}
Also used : INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 14 with INodeAdapterFactory

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

the class XMLModelLoader method getAdapterFactories.

public List getAdapterFactories() {
    List result = new ArrayList();
    INodeAdapterFactory factory = null;
    factory = new ModelQueryAdapterFactoryForXML();
    result.add(factory);
    // Does XML need propagating adapter? Or just JSP?
    factory = new PropagatingAdapterFactoryImpl();
    result.add(factory);
    return result;
}
Also used : ModelQueryAdapterFactoryForXML(org.eclipse.wst.xml.core.internal.modelquery.ModelQueryAdapterFactoryForXML) PropagatingAdapterFactoryImpl(org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 15 with INodeAdapterFactory

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

the class AdapterFactoryProviderForXML method addContentBasedFactories.

protected void addContentBasedFactories(IStructuredModel structuredModel) {
    FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
    // $NON-NLS-1$
    Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry");
    INodeAdapterFactory factory = null;
    factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
    if (factory == null) {
        factory = new JFaceNodeAdapterFactory();
        factoryRegistry.addFactory(factory);
    }
    // 
    if (structuredModel != null) {
        ModelQuery modelQuery = ModelQueryUtil.getModelQuery(structuredModel);
        if (modelQuery != null) {
            CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
            if (documentManager != null) {
                IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
                boolean useInferredGrammar = (store != null) ? store.getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR) : true;
                documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
                documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
                documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_USE_CACHED_RESOLVED_URI, true);
                DOMObserver domObserver = new DOMObserver(structuredModel);
                domObserver.setGrammarInferenceEnabled(useInferredGrammar);
                domObserver.init();
            }
        }
    }
}
Also used : CMDocumentManager(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager) FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) DOMObserver(org.eclipse.wst.xml.ui.internal.DOMObserver) JFaceNodeAdapterFactory(org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Aggregations

INodeAdapterFactory (org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)35 List (java.util.List)9 Iterator (java.util.Iterator)8 ArrayList (java.util.ArrayList)7 FactoryRegistry (org.eclipse.wst.sse.core.internal.model.FactoryRegistry)7 IJFaceNodeAdapter (org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)7 ValidationAdapter (org.eclipse.wst.sse.core.internal.validate.ValidationAdapter)4 PropagatingAdapterFactoryImpl (org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl)4 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 Vector (java.util.Vector)2 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IStyleSelectorAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSelectorAdapter)2 IStyleSheetAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)2