Search in sources :

Example 1 with DOMObserver

use of org.eclipse.wst.xml.ui.internal.DOMObserver 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)

Example 2 with DOMObserver

use of org.eclipse.wst.xml.ui.internal.DOMObserver in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderForXSL method addContentBasedFactories.

@Override
protected void addContentBasedFactories(IStructuredModel structuredModel) {
    FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
    Assert.isNotNull(factoryRegistry, // $NON-NLS-1$
    "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);
    }
    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.xsl.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

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 FactoryRegistry (org.eclipse.wst.sse.core.internal.model.FactoryRegistry)2 INodeAdapterFactory (org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)2 IJFaceNodeAdapter (org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)2 CMDocumentManager (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager)2 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)2 DOMObserver (org.eclipse.wst.xml.ui.internal.DOMObserver)2 JFaceNodeAdapterFactory (org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory)1 JFaceNodeAdapterFactory (org.eclipse.wst.xsl.ui.internal.contentoutline.JFaceNodeAdapterFactory)1