use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class JSPModelLoader method createModel.
public IStructuredModel createModel(IStructuredModel oldModel) {
IStructuredModel model = super.createModel(oldModel);
// For JSPs, the ModelQueryAdapter must be "attached" to the document
// before content is set in the model, so taglib initialization can
// take place.
// In this "clone model" case, we create a ModelQuery adapter
// create a new instance from the old data. Note: I think this
// "forced fit" only works here since the implementation of
// ModelQueryAdapter does not
// have to be released.
ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(model);
if (modelQueryAdapter == null) {
modelQueryAdapter = getModelQueryAdapter(oldModel);
IDOMDocument document = ((IDOMModel) model).getDocument();
document.addAdapter(new JSPModelQueryAdapterImpl(modelQueryAdapter.getCMDocumentCache(), modelQueryAdapter.getModelQuery(), modelQueryAdapter.getIdResolver()));
}
return model;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class JSPModelLoader method getModelQueryAdapter.
private ModelQueryAdapter getModelQueryAdapter(IStructuredModel model) {
IDOMDocument document = ((IDOMModel) model).getDocument();
ModelQueryAdapter modelQueryAdapter = (ModelQueryAdapter) ((INodeNotifier) document).getAdapterFor(ModelQueryAdapter.class);
return modelQueryAdapter;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class JSPTranslationUtil method getTranslation.
public JSPTranslationExtension getTranslation() {
if (fTranslation == null) {
IDOMModel xmlModel = (IDOMModel) getModelManager().getExistingModelForRead(fDocument);
ModelHandlerForJSP.ensureTranslationAdapterFactory(xmlModel);
try {
IDOMDocument xmlDoc = xmlModel.getDocument();
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
if (translationAdapter != null)
fTranslation = translationAdapter.getJSPTranslation();
} finally {
if (xmlModel != null) {
xmlModel.releaseFromRead();
}
}
}
return fTranslation;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument 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.xml.core.internal.provisional.document.IDOMDocument 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);
}
}
Aggregations