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

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


                  TLDCMDocumentManager documentManager = TaglibController.getTLDCMDocumentManager(doc);
                  if (documentManager != null) {
                    List documentTrackers = documentManager.getCMDocumentTrackers(currentNode.getPrefix(), region.getOffset());
                    for (int i = 0; i < documentTrackers.size(); i++) {
                      TaglibTracker tracker = (TaglibTracker) documentTrackers.get(i);
                      CMElementDeclaration decl = (CMElementDeclaration) tracker.getElements().getNamedItem(currentNode.getNodeName());
                      if (decl != null) {
                        decl = (CMElementDeclaration) ((CMNodeWrapper) decl).getOriginNode();
                        if (decl instanceof CMElementDeclarationImpl) {
                          String base = ((CMElementDeclarationImpl) decl).getLocationString();
                          IRegion hyperlinkRegion = getHyperlinkRegion(currentNode, region);
View Full Code Here


      public Elements() {
        CMNamedNodeMap elems = hcm.getElements();
        for (int i = 0; i < names.length; i++) {
          String name = names[i];
          CMElementDeclaration dec = (CMElementDeclaration) elems.getNamedItem(name);
          if (dec != null)
            map.put(name, dec);
        }
      }
View Full Code Here

          break;
        }
      }
     
      // on an empty value, add all the JSP and taglib tags
      CMElementDeclaration elementDecl =
        AbstractXMLModelQueryCompletionProposalComputer.getCMElementDeclaration(node);
      if (nameRegion != null && elementDecl != null) {
        String attributeName = open.getText(nameRegion);
        if (attributeName != null) {
          Node parent = contentAssistRequest.getParent();
         
          //ignore start quote in match string
          String matchString = contentAssistRequest.getMatchString().trim();
          if(matchString.startsWith("'") || matchString.startsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
            matchString = matchString.substring(1);
          }
         
          //get all the proposals
          List additionalElements = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(
              (Element) node, elementDecl, ModelQuery.INCLUDE_ALL);
          Iterator nodeIterator = additionalElements.iterator();
         
          //check each suggestion
          while (nodeIterator.hasNext()) {
            CMNode additionalElementDecl = (CMNode) nodeIterator.next();
            if (additionalElementDecl != null && additionalElementDecl instanceof CMElementDeclaration &&
                validModelQueryNode(additionalElementDecl)) {
              CMElementDeclaration ed = (CMElementDeclaration) additionalElementDecl;
              // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
              StringBuffer sb = new StringBuffer();
              getContentGenerator().generateTag(parent, ed, sb);
 
              String proposedText = sb.toString();
View Full Code Here

    if (!isXMLFormat(document)) {
      List additionalElements = forciblyGetTagLibAndJSPElements(new ArrayList(), document, childPosition);
     
      //convert CMElementDeclartions to proposals
      for (int i = 0; i < additionalElements.size(); i++) {
        CMElementDeclaration ed = (CMElementDeclaration) additionalElements.get(i);
        if (ed != null) {
          Image image = CMImageUtil.getImage(ed);
          if (image == null) {
            image = this.getGenericTagImage();
          }
View Full Code Here

          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
           */
          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("jsp:root")) || ((((IDOMNode) docElement).getStartStructuredDocumentRegion() != null || ((IDOMNode) docElement).getEndStructuredDocumentRegion() != null)))) //$NON-NLS-1$
              rejectElements.add(JSP12Namespace.ElementName.ROOT);

            for (int j = 0; j < jspelements.getLength(); j++) {
              CMElementDeclaration ed = (CMElementDeclaration) jspelements.item(j);
              if (rejectElements.contains(ed.getNodeName()))
                continue;
              elementDecls.add(ed);
            }

          }
View Full Code Here

      if (node.getNodeType() == Node.ELEMENT_NODE) {
        String elementName = node.getNodeName();

        // test to see if this node belongs to JSP's CMDocument (case
        // sensitive)
        CMElementDeclaration dec = (CMElementDeclaration) tagdoc.getElements().getNamedItem(elementName);
        if (dec != null) {
          result = tagdoc;
        }
      }
View Full Code Here

  }

  private static boolean isAttributeAvailable(Element element, String attrName) {
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
    if (modelQuery != null) {
      CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
      if (decl != null) {
        CMNamedNodeMap map = decl.getAttributes();
        if ((CMAttributeDeclaration) map.getNamedItem(attrName) != null) {
          return true;
        }
      }
    }
View Full Code Here

    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
    if (modelQuery == null)
      // undefined tag, return default
      return false;

    CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
    if (decl == null)
      // undefined tag, return default
      return false;

    return (decl.getContentType() == CMElementDeclaration.EMPTY);
  }
View Full Code Here

  protected List getRequiredAttrs(Node node) {
    List result = new ArrayList();

    ModelQuery modelQuery = getModelQuery(node);
    if (modelQuery != null) {
      CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
      if (elementDecl != null) {
        CMNamedNodeMap attrMap = elementDecl.getAttributes();
        Iterator it = attrMap.iterator();
        CMAttributeDeclaration attr = null;
        while (it.hasNext()) {
          attr = (CMAttributeDeclaration) it.next();
          if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
View Full Code Here

  }

  private boolean checkUnknownAttributes(IDOMElement element, CMElementDeclaration elementDecl, CMNamedNodeMap cmAttrs, IReporter reporter, IFile file, IStructuredDocument document, IStructuredDocumentRegion documentRegion) {
    boolean foundjspattribute = false;
    boolean dynamicAttributesAllowed = false;
    CMElementDeclaration decl = elementDecl;
    if (decl instanceof CMNodeWrapper)
      decl = (CMElementDeclaration) ((CMNodeWrapper) decl).getOriginNode();
    if (decl instanceof TLDElementDeclaration) {
      String dynamicAttributes = ((TLDElementDeclaration) decl).getDynamicAttributes();
      dynamicAttributesAllowed = dynamicAttributes != null ? Boolean.valueOf(dynamicAttributes).booleanValue() : false;
View Full Code Here

TOP

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

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.