use of org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryExtension 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);
}
}
}
Aggregations