use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class TagModelLoader method getAdapterFactories.
public List getAdapterFactories() {
List factories = super.getAdapterFactories();
/*
* Replace the default JSP model query by using our own factory
*/
Iterator i = factories.iterator();
while (i.hasNext()) {
if (((INodeAdapterFactory) i.next()).isFactoryForType(ModelQueryAdapter.class)) {
i.remove();
}
}
factories.add(new ModelQueryAdapterFactoryForTag());
return factories;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class ModelManagerPluginRegistryReader method loadFactoryFromConfigurationElement.
protected INodeAdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
INodeAdapterFactory factory = null;
if (element.getName().equals(TAG_NAME)) {
String contentType = element.getAttribute(ATTR_CONTENTTYPE);
if (!contentType.equals(requesterType))
return null;
String className = element.getAttribute(ATTR_CLASS);
String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
String registerAdapters = element.getAttribute(ATTR_REGISTERADAPTER);
// for adapter factories
if (className != null) {
String name = element.getDeclaringExtension().getNamespace();
Bundle bundle = null;
try {
bundle = Platform.getBundle(name);
} catch (Exception e) {
// if an error occurs here, its probably that the plugin
// could not be found/loaded
// $NON-NLS-1$
Logger.logException("Could not find bundle: " + name, e);
}
if (bundle != null) {
boolean useExtendedConstructor = false;
boolean doRegisterAdapters = false;
Object adapterKey = null;
if (registerAdapters != null && registerAdapters.length() > 0 && Boolean.valueOf(registerAdapters).booleanValue()) {
doRegisterAdapters = true;
}
if (adapterKeyClass != null) {
try {
Class aClass = null;
// Class.forName(adapterKeyClass);
if (bundle.getState() != Bundle.UNINSTALLED) {
aClass = bundle.loadClass(adapterKeyClass);
} else {
aClass = Class.forName(adapterKeyClass);
}
if (aClass != null) {
useExtendedConstructor = true;
adapterKey = aClass;
} else {
adapterKey = adapterKeyClass;
}
} catch (Exception anyErrors) {
adapterKey = adapterKeyClass;
}
}
try {
Class theClass = null;
// Class.forName(className);
if (bundle.getState() != Bundle.UNINSTALLED) {
theClass = bundle.loadClass(className);
} else {
theClass = Class.forName(className);
}
if (useExtendedConstructor) {
java.lang.reflect.Constructor[] ctors = theClass.getConstructors();
for (int i = 0; i < ctors.length; i++) {
Class[] paramTypes = ctors[i].getParameterTypes();
if (ctors[i].isAccessible() && paramTypes.length == 2 && paramTypes[0].equals(Object.class) && paramTypes[1].equals(boolean.class)) {
try {
factory = (INodeAdapterFactory) ctors[i].newInstance(new Object[] { adapterKey, new Boolean(doRegisterAdapters) });
} catch (IllegalAccessException e) {
// log for now, unless we find reason
// not to
Logger.log(Logger.INFO, e.getMessage());
} catch (IllegalArgumentException e) {
// log for now, unless we find reason
// not to
Logger.log(Logger.INFO, e.getMessage());
} catch (InstantiationException e) {
// log for now, unless we find reason
// not to
Logger.log(Logger.INFO, e.getMessage());
} catch (InvocationTargetException e) {
// log for now, unless we find reason
// not to
Logger.log(Logger.INFO, e.getMessage());
} catch (ExceptionInInitializerError e) {
// log or now, unless we find reason
// not to
Logger.log(Logger.INFO, e.getMessage());
}
}
}
}
if (factory == null) {
factory = (INodeAdapterFactory) element.createExecutableExtension(ATTR_CLASS);
}
} catch (ClassNotFoundException e) {
// log or now, unless we find reason not to
Logger.log(Logger.INFO, e.getMessage());
} catch (CoreException e) {
// log or now, unless we find reason not to
Logger.log(Logger.INFO, e.getMessage());
}
}
}
}
return factory;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class ModelManagerPluginRegistryReader method loadRegistry.
protected List loadRegistry(Object contentType) {
List factoryList = new Vector();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
if (point != null) {
IConfigurationElement[] elements = point.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
INodeAdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
if (factory != null)
factoryList.add(factory);
}
}
return factoryList;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class AdapterFactoryProviderForJSON 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);
}
// cs... added for inferred grammar support
//
// 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();
// }
// }
// }
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class AdapterFactoryProviderCSS 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 JFaceNodeAdapterFactoryCSS(IJFaceNodeAdapter.class, true);
factoryRegistry.addFactory(factory);
}
}
Aggregations