Search in sources :

Example 51 with IDOMModel

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;
}
Also used : ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) JSPModelQueryAdapterImpl(org.eclipse.jst.jsp.core.internal.modelquery.JSPModelQueryAdapterImpl) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 52 with IDOMModel

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;
}
Also used : ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 53 with IDOMModel

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;
}
Also used : IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)

Example 54 with IDOMModel

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;
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 55 with IDOMModel

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;
}
Also used : PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) PageDirectiveAdapterFactory(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapterFactory) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)

Aggregations

IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)433 Document (org.w3c.dom.Document)123 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)120 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)110 Element (org.w3c.dom.Element)109 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)103 Node (org.w3c.dom.Node)57 IFile (org.eclipse.core.resources.IFile)56 NodeList (org.w3c.dom.NodeList)47 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)45 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)44 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)41 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)41 Text (org.w3c.dom.Text)39 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)35 IJSPTranslation (org.eclipse.jst.jsp.core.internal.java.IJSPTranslation)28 IOException (java.io.IOException)26 CoreException (org.eclipse.core.runtime.CoreException)26 JSPTranslationAdapter (org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter)26 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)25