use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testGetTarget.
public void testGetTarget() {
IDOMModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
INodeNotifier notifier = pageDirectiveAdapter.getTarget();
assertNotNull("target is null", notifier);
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testBasicPD.
public void testBasicPD() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
assertTrue("model could not be created!", model != null);
// Now, assigning use a page directive, but leaving embedded type the same as default
model.getStructuredDocument().setText(this, "<%@ page contentType=\"text/html\" language=\"java\" %>");
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class);
String contentType = pageDirectiveAdapter.getContentType();
String language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertTrue("language should be java", "java".equals(language));
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testSetLanguage.
public void testSetLanguage() {
IDOMModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
pageDirectiveAdapter.setLanguage("text/xml");
assertTrue("set language failed", pageDirectiveAdapter.getLanguage().equals("text/xml"));
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class JSPModelQueryImpl method getEmbeddedModelQuery.
// ISSUE: shouldn't this be private?
protected ModelQuery getEmbeddedModelQuery(Node node) {
ModelQuery embeddedModelQuery = null;
if (node instanceof INodeNotifier) {
Node ownerNode = node.getOwnerDocument();
if (ownerNode == null) {
// then must be the document itself
ownerNode = node;
}
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
if (pageDirectiveAdapter != null) {
String effectiveContentType = null;
ModelQuery potentialModelQueryObject = null;
String familyId = pageDirectiveAdapter.getEmbeddedType().getFamilyId();
if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(familyId)) {
effectiveContentType = "text/html";
} else {
effectiveContentType = pageDirectiveAdapter.getContentType();
}
potentialModelQueryObject = (ModelQuery) embeddedModelQueries.get(effectiveContentType);
if (potentialModelQueryObject == null) {
ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
if (embeddedAdapter != null) {
// we will cache one model query per content type
embeddedModelQuery = embeddedAdapter.getModelQuery();
embeddedModelQueries.put(effectiveContentType, embeddedModelQuery);
}
} else {
embeddedModelQuery = potentialModelQueryObject;
}
}
}
return embeddedModelQuery;
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter 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