Search in sources :

Example 26 with INodeAdapterFactory

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

the class FactoryRegistry method contains.

/*
	 * @see FactoryRegistry#contains(Object)
	 */
public boolean contains(Object type) {
    boolean result = false;
    // note: we're not using cloned list, so strictly speaking
    // is not thread safe.
    List internalList = _getFactories();
    for (int i = 0; i < internalList.size(); i++) {
        INodeAdapterFactory factory = (INodeAdapterFactory) internalList.get(i);
        if (factory.isFactoryForType(type)) {
            result = true;
            break;
        }
    }
    return result;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 27 with INodeAdapterFactory

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

the class FactoryRegistry method getFactoryFor.

/**
 * This method is a not a pure resistry. Factories retrieved based on
 * their response to "isFactoryForType(type)". Note that if there is more
 * than one factory that can answer 'true' that the most recently added
 * factory is used.
 */
public INodeAdapterFactory getFactoryFor(Object type) {
    INodeAdapterFactory result = null;
    if (factories == null)
        return null;
    int listSize = factories.size();
    for (int i = listSize - 1; i >= 0; i--) {
        // It is the adapter factories responsibility to answer
        // isFactoryForType so it gets choosen.
        // Notice we are going through the list backwards to get the
        // factory added last.
        INodeAdapterFactory a = (INodeAdapterFactory) factories.get(i);
        if (a.isFactoryForType(type)) {
            result = a;
            break;
        }
    }
    return result;
}
Also used : INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 28 with INodeAdapterFactory

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

the class JSPModelLoader 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 = new ModelQueryAdapterFactoryForJSP();
    result.add(factory);
    factory = new PropagatingAdapterFactoryImpl();
    result.add(factory);
    factory = new PageDirectiveAdapterFactory();
    result.add(factory);
    return result;
}
Also used : ModelQueryAdapterFactoryForJSP(org.eclipse.jst.jsp.core.internal.modelquery.ModelQueryAdapterFactoryForJSP) PropagatingAdapterFactoryImpl(org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl) PageDirectiveAdapterFactory(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapterFactory) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 29 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory 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 30 with INodeAdapterFactory

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

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