Search in sources :

Example 21 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderForJSP 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 JFaceNodeAdapterFactoryForHTML(IJFaceNodeAdapter.class, true);
        factoryRegistry.addFactory(factory);
    }
    ModelHandlerForJSP.ensureTranslationAdapterFactory(structuredModel);
}
Also used : JFaceNodeAdapterFactoryForHTML(org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterFactoryForHTML) FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 22 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class HTMLSourceValidator method validate.

/**
 * This validate call is for the ISourceValidator partial document validation approach
 *
 * @param dirtyRegion
 * @param helper
 * @param reporter
 * @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator
 */
public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) {
    if (helper == null || fDocument == null)
        return;
    if ((reporter != null) && (reporter.isCancelled() == true)) {
        throw new OperationCanceledException();
    }
    IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
    if (model == null)
        // error
        return;
    try {
        IDOMDocument document = null;
        if (model instanceof IDOMModel) {
            document = ((IDOMModel) model).getDocument();
        }
        if (document == null || !hasHTMLFeature(document)) {
            // ignore
            return;
        }
        IPath filePath = null;
        IFile file = null;
        ITextFileBuffer fb = FileBufferModelManager.getInstance().getBuffer(fDocument);
        if (fb != null) {
            filePath = fb.getLocation();
            if (filePath.segmentCount() > 1) {
                file = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
                if (!file.isAccessible()) {
                    file = null;
                }
            }
        } else {
            filePath = new Path(model.getId());
        }
        // this will be the wrong region if it's Text (instead of Element)
        // we don't know how to validate Text
        // model.getIndexedRegion(dirtyRegion.getOffset());
        IndexedRegion ir = getCoveringNode(dirtyRegion);
        if (ir instanceof Text) {
            while (ir != null && ir instanceof Text) {
                // it's assumed that this gets the IndexedRegion to
                // the right of the end offset
                ir = model.getIndexedRegion(ir.getEndOffset());
            }
        }
        if (ir instanceof INodeNotifier) {
            INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
            ValidationAdapter adapter = (ValidationAdapter) factory.adapt((INodeNotifier) ir);
            if (adapter == null)
                // error
                return;
            if (reporter != null) {
                HTMLValidationReporter rep = null;
                rep = getReporter(reporter, file, (IDOMModel) model);
                rep.clear();
                adapter.setReporter(rep);
                Message mess = new LocalizedMessage(IMessage.LOW_SEVERITY, filePath.toString().substring(1));
                reporter.displaySubtask(this, mess);
            }
            adapter.validate(ir);
        }
    } finally {
        releaseModel(model);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) LocalizedMessage(org.eclipse.wst.html.core.internal.validation.LocalizedMessage) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) Message(org.eclipse.wst.validation.internal.core.Message) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) Text(org.w3c.dom.Text) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory) HTMLValidationReporter(org.eclipse.wst.html.core.internal.validation.HTMLValidationReporter) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) ValidationAdapter(org.eclipse.wst.sse.core.internal.validate.ValidationAdapter) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier) LocalizedMessage(org.eclipse.wst.html.core.internal.validation.LocalizedMessage)

Example 23 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class PropagatingAdapterFactoryImpl method copy.

public INodeAdapterFactory copy() {
    PropagatingAdapterFactory clonedInstance = new PropagatingAdapterFactoryImpl(getAdapterKey(), isShouldRegisterAdapter());
    // clone this adapters specific list of adapter factories too
    if (fContributedFactories != null) {
        Iterator iterator = fContributedFactories.iterator();
        clonedInstance.setContributedFactories(new ArrayList());
        while (iterator.hasNext()) {
            INodeAdapterFactory existingFactory = (INodeAdapterFactory) iterator.next();
            clonedInstance.addContributedFactories(existingFactory.copy());
        }
    }
    return clonedInstance;
}
Also used : PropagatingAdapterFactory(org.eclipse.wst.sse.core.internal.PropagatingAdapterFactory) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 24 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class PropagatingAdapterImpl method release.

/**
 * @see PropagatingAdapter#release()
 */
public void release() {
    if (adaptOnCreateFactories != null) {
        synchronized (adaptOnCreateFactories) {
            int length = adaptOnCreateFactories.size();
            for (int i = 0; i < length; i++) {
                INodeAdapterFactory factory = (INodeAdapterFactory) adaptOnCreateFactories.get(i);
                factory.release();
            }
        }
    }
}
Also used : INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 25 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class AbstractModelLoader method addFactories.

protected void addFactories(IStructuredModel model, List factoryList) {
    Assert.isNotNull(model);
    FactoryRegistry registry = model.getFactoryRegistry();
    // $NON-NLS-1$ //$NON-NLS-2$
    Assert.isNotNull(registry, "IStructuredModel " + model.getId() + " has a null FactoryRegistry");
    if (factoryList != null) {
        Iterator iterator = factoryList.iterator();
        while (iterator.hasNext()) {
            INodeAdapterFactory factory = (INodeAdapterFactory) iterator.next();
            registry.addFactory(factory);
        }
    }
}
Also used : Iterator(java.util.Iterator) 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