use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class HTMLModelLoader method getAdapterFactories.
/**
* This method must return those factories which must be attached to the
* structuredModel before content is applied.
*/
public List getAdapterFactories() {
List result = new ArrayList();
INodeAdapterFactory factory = null;
factory = StyleAdapterFactory.getInstance();
result.add(factory);
factory = HTMLStyleSelectorAdapterFactory.getInstance();
result.add(factory);
factory = HTMLDocumentTypeAdapterFactory.getInstance();
result.add(factory);
factory = HTMLModelParserAdapterFactory.getInstance();
result.add(factory);
//
factory = new ModelQueryAdapterFactoryForHTML();
result.add(factory);
factory = new PropagatingAdapterFactoryImpl();
result.add(factory);
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class JSPContentSourceValidator 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 || !fEnableSourceValidation)
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;
ITextFileBuffer fb = FileBufferModelManager.getInstance().getBuffer(fDocument);
if (fb == null)
return;
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(fb.getLocation());
if (file == null || !file.exists())
return;
// 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, file.getFullPath().toString().substring(1));
reporter.displaySubtask(this, mess);
}
adapter.validate(ir);
}
} finally {
if (model != null)
model.releaseFromRead();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class PropagatingAdapterImpl method adaptOnCreate.
private void adaptOnCreate(IDOMNode node) {
// chooses to
if (adaptOnCreateFactories != null) {
synchronized (adaptOnCreateFactories) {
int length = adaptOnCreateFactories.size();
for (int i = 0; i < length; i++) {
INodeAdapterFactory factory = (INodeAdapterFactory) adaptOnCreateFactories.get(i);
factory.adapt(node);
}
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class XMLModelLoader method getAdapterFactories.
public List getAdapterFactories() {
List result = new ArrayList();
INodeAdapterFactory factory = null;
factory = new ModelQueryAdapterFactoryForXML();
result.add(factory);
// Does XML need propagating adapter? Or just JSP?
factory = new PropagatingAdapterFactoryImpl();
result.add(factory);
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.
the class AdapterFactoryProviderForXML 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);
}
//
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();
}
}
}
}
Aggregations