Examples of CMDocument


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

  /**
   * Returns the CMDocument that corresponds to the DOM Node. or null if no
   * CMDocument is appropriate for the DOM Node.
   */
  public CMDocument getCorrespondingCMDocument(Node node) {
    CMDocument tagdoc =null;
    if (node instanceof IDOMNode) {
      IDOMModel model = ((IDOMNode) node).getModel();
      String modelPath = model.getBaseLocation();
      if (modelPath != null && !IModelManager.UNMANAGED_MODEL.equals(modelPath)) {
        float version = DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(new Path(modelPath));
        tagdoc = TAGCMDocumentFactory.getCMDocument(version);
      }
    }

    CMDocument result = null;
    try {
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        String elementName = node.getNodeName();

        // test to see if this node belongs to JSP's CMDocument (case
View Full Code Here

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

  }

  private static boolean isTagAvailable(Document document, String elementName) {
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
    if (modelQuery != null) {
      CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
      CMNamedNodeMap map = cmdoc.getElements();
      if ((CMElementDeclaration) map.getNamedItem(elementName) != null) {
        return true;
      }
    }
View Full Code Here

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

    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

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

      extraProcessor.addAttributeValueProposals(contentAssistRequest);
    }

    ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
    if (mq != null) {
      CMDocument doc = mq.getCorrespondingCMDocument(node);
      // this shouldn't have to have the prefix coded in
      if (doc instanceof JSPCMDocument || doc instanceof CMNodeWrapper || node.getNodeName().startsWith("jsp:")) //$NON-NLS-1$
        return;
    }

    // Find the attribute name for which this position should have a value
    IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
    ITextRegionList openRegions = open.getRegions();
    int i = openRegions.indexOf(contentAssistRequest.getRegion());
    if (i < 0)
      return;
    ITextRegion nameRegion = null;
    while (i >= 0) {
      nameRegion = openRegions.get(i--);
      if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
        break;
    }
   
    // on an empty value, add all the JSP and taglib tags
    CMElementDeclaration elementDecl = getCMElementDeclaration(node);
    if (nameRegion != null && elementDecl != null) {
      String attributeName = open.getText(nameRegion);
      if (attributeName != null) {
        String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
       
        if(currentValue == null || currentValue.length() == 0) { //$NON-NLS-1$
          List additionalElements = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
          for (i = 0; i < additionalElements.size(); i++) {
            Object additionalElement = additionalElements.get(i);
            if(additionalElement instanceof CMElementDeclaration) {
              CMElementDeclaration ed = (CMElementDeclaration) additionalElement;
 
              String tagname = getContentGenerator().getRequiredName(node, ed);
              StringBuffer contents = new StringBuffer("\""); //$NON-NLS-1$
              getContentGenerator().generateTag(node, ed, contents);
              contents.append('"'); //$NON-NLS-1$
              CustomCompletionProposal proposal = new CustomCompletionProposal(contents.toString(), contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), contents.length(), JSPEditorPluginImageHelper.getInstance().getImage(JSPEditorPluginImages.IMG_OBJ_TAG_GENERIC), tagname, null, null, XMLRelevanceConstants.R_JSP_ATTRIBUTE_VALUE);
              contentAssistRequest.addProposal(proposal);
            }
          }
       
        }
      }
    }
    else if (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
      try {
        // Create a new model for Content Assist to operate on. This
        // will simulate
        // a full Document and then adjust the offset numbers in the
        // list of results.
        IStructuredModel internalModel = null;
        IModelManager mmanager = StructuredModelManager.getModelManager();
        internalModel = mmanager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
        IDOMNode xmlNode = null;
        IDOMModel xmlOuterModel = null;
        if (contentAssistRequest.getNode() instanceof IDOMNode) {
          xmlNode = (IDOMNode) contentAssistRequest.getNode();
          xmlOuterModel = xmlNode.getModel();
          internalModel.setResolver(xmlOuterModel.getResolver());
          internalModel.setBaseLocation(xmlOuterModel.getBaseLocation());
        }
        String contents = StringUtils.strip(contentAssistRequest.getText());
        if (xmlNode != null && contents != null) {
          int additionalShifts = 0;
          // Be sure that custom tags from taglibs also show up
          // by
          // adding taglib declarations to the internal model.
          TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(xmlOuterModel.getStructuredDocument());
          if (mgr != null) {
            List trackers = mgr.getCMDocumentTrackers(contentAssistRequest.getReplacementBeginPosition());
            if (trackers != null) {
              for (i = 0; i < trackers.size(); i++) {
                CMDocumentTracker tracker = (CMDocumentTracker) trackers.get(i);
                String declaration = tracker.getStructuredDocumentRegion().getText();
                if (declaration != null) {
                  contents = declaration + contents;
                  additionalShifts += declaration.length();
                }
              }
            }
          }
          // Also copy any jsp:useBean tags so that
          // jsp:[gs]etProperty will function
          Document doc = null;
          if (contentAssistRequest.getNode().getNodeType() == Node.DOCUMENT_NODE)
            doc = (Document) node;
          else
            doc = node.getOwnerDocument();
          NodeList useBeans = doc.getElementsByTagName(JSP12Namespace.ElementName.USEBEAN);
          for (int k = 0; k < useBeans.getLength(); k++) {
            IDOMNode useBean = (IDOMNode) useBeans.item(k);
            if (useBean.getStartOffset() < contentAssistRequest.getReplacementBeginPosition()) {
              StringBuffer useBeanText = new StringBuffer("<jsp:useBean"); //$NON-NLS-1$
              for (int j = 0; j < useBean.getAttributes().getLength(); j++) {
View Full Code Here

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

    // handle tag files here
    String contentType = node.getModel().getContentTypeIdentifier();
    if (ContentTypeIdForJSP.ContentTypeID_JSPTAG.equals(contentType))
      return JSPCMDocumentFactory.getCMDocument(CMDocType.TAG20_DOC_TYPE);

    CMDocument jcmdoc = null;
    String modelPath = node.getModel().getBaseLocation();
    if (modelPath != null && !IModelManager.UNMANAGED_MODEL.equals(modelPath)) {
      float version = DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(new Path(modelPath));
      jcmdoc = JSPCMDocumentFactory.getCMDocument(version);
    }
View Full Code Here

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

    if (decl instanceof CMNodeWrapper) {
      decl = (CMElementDeclaration) ((CMNodeWrapper) decl)
          .getOriginNode();
    }
    if (decl instanceof TLDElementDeclaration) {
      CMDocument doc = ((TLDElementDeclaration) decl).getOwnerDocument();
      if (doc instanceof TLDDocument) {
        TLDDocument tldDoc = (TLDDocument)doc;
        return getURIFromDoc(tldDoc , null);
      }
    }
View Full Code Here

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

            TaglibTracker tracker = (TaglibTracker) iter.next();
            if (namespace.equals(tracker.getURI())) {
                return tracker.getPrefix();
            }
           
            CMDocument cmdoc = tracker.getDocument();
            if (cmdoc instanceof TLDDocument
                    && namespace.equals(((TLDDocument) cmdoc).getUri())) {
                return tracker.getPrefix();
            }
        }
View Full Code Here

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

    if(!this.isXHTML) {
      IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
 
      ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
      if (mq != null) {
        CMDocument doc = mq.getCorrespondingCMDocument(node);
        // this shouldn't have to have the prefix coded in
        if (doc instanceof JSPCMDocument || doc instanceof CMNodeWrapper ||
            node.getNodeName().startsWith("jsp:")) { //$NON-NLS-1$
          return;
        }
View Full Code Here

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

      TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(((IDOMNode) node).getStructuredDocument());
      if (mgr != null) {
        List moreCMDocuments = mgr.getCMDocumentTrackers(textInsertionOffset);
        if (moreCMDocuments != null) {
          for (int i = 0; i < moreCMDocuments.size(); i++) {
            CMDocument doc = (CMDocument) moreCMDocuments.get(i);
            CMNamedNodeMap elements = doc.getElements();
            if (elements != null) {
              for (int j = 0; j < elements.getLength(); j++) {
                CMElementDeclaration ed = (CMElementDeclaration) elements.item(j);
                elementDecls.add(ed);
              }
            }
          }
        }
      }

      // get position dependent CMDocuments and insert their tags as
      // proposals

      ModelQueryAdapter mqAdapter = null;
      if (node.getNodeType() == Node.DOCUMENT_NODE)
        mqAdapter = (ModelQueryAdapter) ((IDOMNode) node).getAdapterFor(ModelQueryAdapter.class);
      else
        mqAdapter = (ModelQueryAdapter) ((IDOMNode) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);

      if (mqAdapter != null) {
        CMDocument doc = mqAdapter.getModelQuery().getCorrespondingCMDocument(node);
        if (doc != null) {
          CMDocument jcmdoc = getDefaultJSPCMDocument((IDOMNode) 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
View Full Code Here

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

    // handle tag files here
    String contentType = node.getModel().getContentTypeIdentifier();
    if (ContentTypeIdForJSP.ContentTypeID_JSPTAG.equals(contentType))
      return JSPCMDocumentFactory.getCMDocument(CMDocType.TAG20_DOC_TYPE);

    CMDocument jcmdoc = null;
    String modelPath = node.getModel().getBaseLocation();
    if (modelPath != null && !IModelManager.UNMANAGED_MODEL.equals(modelPath)) {
      float version = DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(new Path(modelPath));
      jcmdoc = JSPCMDocumentFactory.getCMDocument(version);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.