Package org.eclipse.wst.xml.core.internal.contentmodel

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument


   *
   * @param uri -
   *            the location of a valid taglib descriptor
   */
  public CMDocument createCMDocument(String uri) {
    CMDocument result = null;
    URL url = null;
    try {
      url = new URL(uri);
    }
    catch (MalformedURLException e) {
View Full Code Here


  /**
   * @param fileName
   * @return
   */
  private CMDocument createCMDocumentFromFile(String fileName) {
    CMDocument result = null;
    if (fileName.endsWith(".jar")) { //$NON-NLS-1$
      result = buildCMDocumentFromJar(fileName);
    }
    else {
      File file = new File(fileName);
View Full Code Here

    Object cacheKey = getCacheKey(reference);
    if (cacheKey == null)
      return null;
   
    long lastModified = getModificationStamp(reference);
    CMDocument doc = (CMDocument) getDocuments().get(cacheKey);
    if (doc == null) {
      /*
       * If hasn't been moved into the local table, do so and increment
       * the count. A local URI reference can be different depending on
       * the file from which it was referenced. Use a computed key to
       * keep them straight.
       */
      Object o = getSharedDocumentCache().get(cacheKey);
      if (o != null) {
        if (o instanceof TLDCacheEntry) {
          TLDCacheEntry entry = (TLDCacheEntry) o;
          if (_debugCache) {
            System.out.println("TLDCMDocument cache hit on " + cacheKey);
          }
          if (entry != null && entry.modificationStamp != IResource.NULL_STAMP && entry.modificationStamp >= lastModified) {
            doc = entry.document;
            entry.referenceCount++;
          }
          else {
            getSharedDocumentCache().remove(cacheKey);
          }
        }
        else if (o instanceof Reference) {
          TLDCacheEntry entry = (TLDCacheEntry) ((Reference) o).get();
          if (entry != null) {
            if (entry.modificationStamp != IResource.NULL_STAMP && entry.modificationStamp >= lastModified) {
              doc = entry.document;
              entry.referenceCount = 1;
              getSharedDocumentCache().put(cacheKey, entry);
            }
          }
          else {
            getSharedDocumentCache().remove(cacheKey);
          }
        }
      }
      /* No document was found cached, create a new one and share it */
      if (doc == null) {
        if (_debugCache) {
          System.out.println("TLDCMDocument cache miss on " + cacheKey);
        }
        CMDocument document = loadTaglib(reference);
        if (document != null) {
          TLDCacheEntry entry = new TLDCacheEntry();
          doc = entry.document = document;
          entry.referenceCount = 1;
          entry.modificationStamp = getModificationStamp(reference);
View Full Code Here

  /**
   * Loads the taglib from the specified URI. It must point to a valid
   * taglib descriptor to work.
   */
  protected CMDocument loadTaglib(String uri) {
    CMDocument document = null;
    IPath currentPath = getCurrentParserPath();
    if (currentPath != null) {
      ITaglibRecord record = TaglibIndex.resolve(currentPath.toString(), uri, false);
      if (record != null) {
        document = getCMDocumentBuilder().createCMDocument(record);
View Full Code Here

      if (mgr != null) {

        List trackers = mgr.getCMDocumentTrackers(-1);
        Iterator taglibs = trackers.iterator();
 
        CMDocument doc = null;
        CMNamedNodeMap elements = null;
        while (taglibs.hasNext()) {
          doc = (CMDocument) taglibs.next();
          CMNode node = null;
          if ((elements = doc.getElements()) != null && (node = elements.getNamedItem(tagToAdd)) != null && node.getNodeType() == CMNode.ELEMENT_DECLARATION) {
 
            if (node instanceof CMNodeWrapper) {
              node = ((CMNodeWrapper) node).getOriginNode();
            }
            TLDElementDeclaration tldElementDecl = (TLDElementDeclaration) node;
View Full Code Here

      // if (support == null)
      // return new TaglibVariable[0];
      //
      // Iterator taglibs =
      // support.getCMDocuments(customTag.getStartOffset()).iterator();
      CMDocument doc = null;
      CMNamedNodeMap elements = null;
      while (taglibs.hasNext()) {
        doc = (CMDocument) taglibs.next();
        CMNode node = null;
        if ((elements = doc.getElements()) != null && (node = elements.getNamedItem(tagToAdd)) != null && node.getNodeType() == CMNode.ELEMENT_DECLARATION) {

          if (node instanceof CMNodeWrapper) {
            node = ((CMNodeWrapper) node).getOriginNode();
          }
          TLDElementDeclaration tldElementDecl = (TLDElementDeclaration) node;
View Full Code Here

    private void enableTags(String prefix, String uri, IStructuredDocumentRegion anchorStructuredDocumentRegion) {
      if (prefix == null || uri == null || bannedPrefixes.contains(prefix))
        return;
      // Try to load the CMDocument for this URI
      CMDocument tld = getCMDocument(uri);
      if (tld == null || !(tld instanceof TLDDocument)) {
        if (_debug) {
          System.out.println("TLDCMDocumentManager failed to create a CMDocument for " + uri); //$NON-NLS-1$
        }
        return;
View Full Code Here

      } else {
        mqAdapter = (ModelQueryAdapter) ((IDOMNode) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
      }

      if (mqAdapter != null) {
        CMDocument doc = mqAdapter.getModelQuery().getCorrespondingCMDocument(node);
        if (doc != null) {
          CMDocument jcmdoc = getDefaultJSPCMDocument(node);
          CMNamedNodeMap jspelements = jcmdoc.getElements();

          /* For a built-in JSP action the content model is properly
           * set up, so don't just blindly add the rest--unless this
           * will be a direct child of the document
           */
          if (jspelements != null && (!(doc instanceof JSPCMDocument) || node.getNodeType() == Node.DOCUMENT_NODE)) {
            List rejectElements = new ArrayList();

            // determine if the document is in XML form
            Document domDoc = null;
            if (node.getNodeType() == Node.DOCUMENT_NODE) {
              domDoc = (Document) node;
            } else {
              domDoc = node.getOwnerDocument();
            }

            // Show XML tag forms of JSP markers if jsp:root is
            // the document element OR it's HTML but
            // isn't really in the text.
            // If the document isn't strictly XML, pull out the
            // XML tag forms it is xml format
            rejectElements.add(JSP12Namespace.ElementName.SCRIPTLET);
            rejectElements.add(JSP12Namespace.ElementName.EXPRESSION);
            rejectElements.add(JSP12Namespace.ElementName.DECLARATION);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_INCLUDE);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_PAGE);
            rejectElements.add(JSP12Namespace.ElementName.TEXT);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_TAGLIB);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_TAG);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_ATTRIBUTE);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_VARIABLE);
            if (isXMLFormat(domDoc)) {
              // jsp actions
              rejectElements.add(JSP12Namespace.ElementName.FALLBACK);
              rejectElements.add(JSP12Namespace.ElementName.USEBEAN);
              rejectElements.add(JSP12Namespace.ElementName.GETPROPERTY);
              rejectElements.add(JSP12Namespace.ElementName.SETPROPERTY);
              rejectElements.add(JSP12Namespace.ElementName.INCLUDE);
              rejectElements.add(JSP12Namespace.ElementName.FORWARD);
              rejectElements.add(JSP12Namespace.ElementName.PLUGIN);
              rejectElements.add(JSP12Namespace.ElementName.FALLBACK);
              rejectElements.add(JSP12Namespace.ElementName.PARAM);
              rejectElements.add(JSP12Namespace.ElementName.PARAMS);
            }


            // don't show jsp:root if a document element already
            // exists
            Element docElement = domDoc.getDocumentElement();
            if (docElement != null &&((docElement.getNodeName().equals(TAG_JSP_ROOT)) ||
                ((((IDOMNode) docElement).getStartStructuredDocumentRegion() != null ||
                    ((IDOMNode) docElement).getEndStructuredDocumentRegion() != null)))) {
             
              rejectElements.add(JSP12Namespace.ElementName.ROOT);
            }
            //Add JSP elements into autocomplete menu
            for (int j = 0; j < jspelements.getLength(); j++) {
              CMElementDeclaration ed = (CMElementDeclaration) jspelements.item(j);
              if (!rejectElements.contains(ed.getNodeName())) {
                nodeList.add(ed);
              }
            }
           
            //Add Tapestry components into autocomplete menu
            jcmdoc = getDefaultTapestryCMDocument();
            CMNamedNodeMap tapestryelements = jcmdoc.getElements();
            for (int j = 0; j < tapestryelements.getLength(); j++) {
              CMElementDeclaration ed = (CMElementDeclaration) tapestryelements.item(j);
              if (!rejectElements.contains(ed.getNodeName())) {
                nodeList.add(ed);
              }
View Full Code Here

        }

        @Override
        public String getUri()
        {
            final CMDocument owner = _tldDoc.getOwnerDocument();

            if (owner instanceof TLDDocument)
            {
                return ((TLDDocument)owner).getUri();
            }
View Full Code Here

   *
   * @return the default non-embedded CMDocument for the document being
   *         edited.
   */
  private CMDocument getDefaultJSPCMDocument(IDOMNode node) {
    CMDocument jcmdoc = null;
   
    // handle tag files here
    String contentType = node.getModel().getContentTypeIdentifier();
    if (ContentTypeIdForJSP.ContentTypeID_JSPTAG.equals(contentType)) {
      jcmdoc =  JSPCMDocumentFactory.getCMDocument(CMDocType.TAG20_DOC_TYPE);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.