use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class PluginContributedFactoryReader 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 (!requesterType.equals(contentType))
return null;
String className = element.getAttribute(ATTR_CLASS);
// for adapter factories
if (className != null) {
try {
factory = (INodeAdapterFactory) element.createExecutableExtension(ATTR_CLASS);
} catch (CoreException e) {
// if an error occurs here, its probably that the plugin
// could not be found/loaded
// $NON-NLS-1$
org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e);
} catch (Exception e) {
// if an error occurs here, its probably that the plugin
// could not be found/loaded -- but in any case we just
// want
// to log the error and continue running and best we can.
// $NON-NLS-1$
org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e);
}
// if (plugin != null) {
// factory = oldAttributesCode(element, factory, className,
// plugin);
//
}
}
return factory;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class AbstractModelLoader method duplicateFactoryRegistry.
private void duplicateFactoryRegistry(IStructuredModel newModel, IStructuredModel oldModel) {
List oldAdapterFactories = oldModel.getFactoryRegistry().getFactories();
List newAdapterFactories = new ArrayList();
Iterator oldListIterator = oldAdapterFactories.iterator();
while (oldListIterator.hasNext()) {
INodeAdapterFactory oldAdapterFactory = (INodeAdapterFactory) oldListIterator.next();
// now "clone" the adapterfactory
newAdapterFactories.add(oldAdapterFactory.copy());
}
// now that we have the "cloned" list, add to new model
addFactories(newModel, newAdapterFactories);
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class JSPContentValidator method validate.
/*
* Mostly copied from HTMLValidator
*/
private void validate(IReporter reporter, IFile file, IDOMModel model) {
if (file == null || model == null)
// error
return;
IDOMDocument document = model.getDocument();
if (document == null)
// error
return;
// This validator currently only handles validating HTML content in
// JSP
boolean hasXMLFeature = isXMLJSP(document);
boolean hasHTMLFeature = hasHTMLFeature(document);
if (hasHTMLFeature && !hasXMLFeature) {
INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
ValidationAdapter adapter = (ValidationAdapter) factory.adapt(document);
if (adapter == null)
// error
return;
HTMLValidationReporter rep = getReporter(reporter, file, model);
rep.clear();
adapter.setReporter(rep);
adapter.validate(document);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class JSPContentValidator method validate.
private void validate(IFile file, int kind, ValidationState state, IProgressMonitor monitor, IDOMModel model, IReporter reporter) {
IDOMDocument document = model.getDocument();
if (document == null)
// error
return;
boolean isXMLJSP = isXMLJSP(document);
boolean hasHTMLFeature = hasHTMLFeature(document);
if (hasHTMLFeature && !isXMLJSP) {
INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
ValidationAdapter adapter = (ValidationAdapter) factory.adapt(document);
if (adapter != null) {
HTMLValidationReporter rep = getReporter(reporter, file, model);
rep.clear();
adapter.setReporter(rep);
adapter.validate(document);
}
}
if (!hasHTMLFeature && isXMLJSP) {
Validator xmlValidator = new Validator();
xmlValidator.validate(file, kind, state, monitor);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class ModelHandlerForJSP method ensureTranslationAdapterFactory.
public static void ensureTranslationAdapterFactory(IStructuredModel sm) {
if (sm.getFactoryRegistry().getFactoryFor(IJSPTranslation.class) == null) {
/*
* Check for tag/tagx files, otherwise add the JSP translation
* factory for better compatibility with other possible subtypes
* of JSP.
*/
IContentType thisContentType = Platform.getContentTypeManager().getContentType(sm.getContentTypeIdentifier());
IContentType tagContentType = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSPTAG);
if (thisContentType.isKindOf(tagContentType)) {
INodeAdapterFactory factory = new TagTranslationAdapterFactory();
sm.getFactoryRegistry().addFactory(factory);
} else {
INodeAdapterFactory factory = null;
// }
if (factory == null) {
factory = new JSPTranslationAdapterFactory();
}
sm.getFactoryRegistry().addFactory(factory);
}
}
}
Aggregations