use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel 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.IDOMModel 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.IDOMModel in project webtools.sourceediting by eclipse.
the class JSPTranslationAdapterFactory method createAdapter.
protected INodeAdapter createAdapter(INodeNotifier target) {
if (target instanceof IDOMNode && fAdapter == null) {
/* attempt to load externalized translator and create adapter from it
* else create new adapter */
IDOMModel model = ((IDOMNode) target).getModel();
JSPTranslator translator = JSPTranslatorPersister.getPersistedTranslator(model);
if (translator != null) {
fAdapter = new JSPTranslationAdapter(model, translator);
} else {
fAdapter = new JSPTranslationAdapter(model);
}
if (DEBUG) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("(+) JSPTranslationAdapterFactory [" + this + "] created adapter: " + fAdapter);
}
}
return fAdapter;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel 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.IDOMModel in project webtools.sourceediting by eclipse.
the class JSPActionValidator method isElIgnored.
/**
* Determines if EL should be ignored. Checks
* <ol>
* <li>JSP version</li>
* <li>Page directive isELIgnored</li>
* <li>Deployment descriptor's el-ignored</li>
* </ol>
* @return true if EL should be ignored, false otherwise. If the JSP version is < 2.0, EL is ignored by default
*/
private boolean isElIgnored(IPath path, IStructuredModel model) {
if (DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(path) < 2.0f)
return true;
PageDirectiveAdapter pdAdapter = ((PageDirectiveAdapter) (((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class)));
if (pdAdapter == null) {
// double-check the factory (although there just might not be a page directive in the file)
if (model.getFactoryRegistry().getFactoryFor(PageDirectiveAdapter.class) == null) {
model.getFactoryRegistry().addFactory(new PageDirectiveAdapterFactory());
pdAdapter = ((PageDirectiveAdapter) (((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class)));
}
}
if (pdAdapter != null) {
String directiveIsELIgnored = pdAdapter.getElIgnored();
// isELIgnored directive found
if (directiveIsELIgnored != null)
return Boolean.valueOf(directiveIsELIgnored).booleanValue();
}
// Check the deployment descriptor for el-ignored
PropertyGroup[] groups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(path);
if (groups.length > 0)
return groups[0].isELignored();
// JSP version >= 2.0 defaults to evaluating EL
return false;
}
Aggregations