Search in sources :

Example 6 with INodeAdapterFactory

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 7 with INodeAdapterFactory

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);
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 8 with INodeAdapterFactory

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);
    }
}
Also used : ValidationAdapter(org.eclipse.wst.sse.core.internal.validate.ValidationAdapter) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 9 with INodeAdapterFactory

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);
    }
}
Also used : ValidationAdapter(org.eclipse.wst.sse.core.internal.validate.ValidationAdapter) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) Validator(org.eclipse.wst.xml.core.internal.validation.eclipse.Validator) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 10 with INodeAdapterFactory

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);
        }
    }
}
Also used : TagTranslationAdapterFactory(org.eclipse.jst.jsp.core.internal.java.TagTranslationAdapterFactory) JSPTranslationAdapterFactory(org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapterFactory) IContentType(org.eclipse.core.runtime.content.IContentType) IJSPTranslation(org.eclipse.jst.jsp.core.internal.java.IJSPTranslation) 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