Search in sources :

Example 6 with FactoryRegistry

use of org.eclipse.wst.sse.core.internal.model.FactoryRegistry in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderForJSP 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 JFaceNodeAdapterFactoryForHTML(IJFaceNodeAdapter.class, true);
        factoryRegistry.addFactory(factory);
    }
    ModelHandlerForJSP.ensureTranslationAdapterFactory(structuredModel);
}
Also used : JFaceNodeAdapterFactoryForHTML(org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterFactoryForHTML) FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 7 with FactoryRegistry

use of org.eclipse.wst.sse.core.internal.model.FactoryRegistry in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderForJSDT 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 instanceof JFaceNodeAdapterFactoryForJSDT)) {
        factoryRegistry.removeFactoriesFor(IJFaceNodeAdapter.class);
        factory = new JFaceNodeAdapterFactoryForJSDT(IJFaceNodeAdapter.class, true);
        factoryRegistry.addFactory(factory);
    }
    JsTranslationAdapterFactory.setupAdapterFactory(structuredModel);
}
Also used : FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) JFaceNodeAdapterFactoryForJSDT(org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterFactoryForJSDT) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 8 with FactoryRegistry

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

Example 9 with FactoryRegistry

use of org.eclipse.wst.sse.core.internal.model.FactoryRegistry in project webtools.sourceediting by eclipse.

the class EditorModelUtil method addFactoriesTo.

public static void addFactoriesTo(final IStructuredModel structuredModel) {
    if (structuredModel == null)
        return;
    AdapterFactoryRegistry adapterRegistry = SSEUIPlugin.getDefault().getAdapterFactoryRegistry();
    String contentTypeId = structuredModel.getContentTypeIdentifier();
    Iterator adapterFactoryProviders = null;
    if (adapterRegistry instanceof AdapterFactoryRegistryExtension) {
        adapterFactoryProviders = ((AdapterFactoryRegistryExtension) adapterRegistry).getAdapterFactories(contentTypeId);
    } else {
        adapterFactoryProviders = adapterRegistry.getAdapterFactories();
    }
    FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
    // $NON-NLS-1$
    Assert.isNotNull(factoryRegistry, SSEUIMessages.EditorModelUtil_0);
    // Add all those appropriate for this particular type of content
    while (adapterFactoryProviders.hasNext()) {
        try {
            final AdapterFactoryProvider provider = (AdapterFactoryProvider) adapterFactoryProviders.next();
            /*
				 * ContentType might have already been checked above, this
				 * check is here for backwards compatability for those that
				 * don't specify a content type
				 */
            if (provider.isFor(structuredModel.getModelHandler())) {
                SafeRunner.run(new // $NON-NLS-1$
                SafeRunnable(// $NON-NLS-1$
                SSEUIMessages.EditorModelUtil_1) {

                    public void run() {
                        provider.addAdapterFactories(structuredModel);
                    }
                });
            }
        } catch (Exception e) {
            Logger.logException(e);
        }
    }
}
Also used : AdapterFactoryProvider(org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider) Iterator(java.util.Iterator) AdapterFactoryRegistry(org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry) FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) AdapterFactoryRegistryExtension(org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryExtension) AdapterFactoryRegistry(org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry)

Aggregations

FactoryRegistry (org.eclipse.wst.sse.core.internal.model.FactoryRegistry)9 INodeAdapterFactory (org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)7 IJFaceNodeAdapter (org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)7 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 JFaceNodeAdapterFactoryForHTML (org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterFactoryForHTML)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 Iterator (java.util.Iterator)1 JFaceNodeAdapterFactoryCSS (org.eclipse.wst.css.ui.internal.contentoutline.JFaceNodeAdapterFactoryCSS)1 JFaceNodeAdapterFactoryForJSDT (org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterFactoryForJSDT)1 JFaceNodeAdapterFactory (org.eclipse.wst.json.ui.internal.contentoutline.JFaceNodeAdapterFactory)1 AdapterFactoryProvider (org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider)1 AdapterFactoryRegistry (org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry)1 AdapterFactoryRegistryExtension (org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryExtension)1 JFaceNodeAdapterFactory (org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory)1 JFaceNodeAdapterFactory (org.eclipse.wst.xsl.ui.internal.contentoutline.JFaceNodeAdapterFactory)1