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;
}
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;
}
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;
}
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);
}
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();
}
}
}
Aggregations