Package org.eclipse.wst.xml.core.internal.provisional.document

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode


   * This methods validate nodes other than HTML elements.
   */
  private void validateContent(Iterator children, boolean isFragment) {
    boolean foundDoctype = false;
    while (children.hasNext()) {
      IDOMNode child = (IDOMNode) children.next();

      int error = ErrorState.NONE_ERROR;
      int segType = FMUtil.SEG_WHOLE_TAG;

      switch (child.getNodeType()) {
        case Node.ELEMENT_NODE :
          if (!isFragment) {
            Element childElem = (Element) child;
            CMElementDeclaration ced = CMUtil.getDeclaration(childElem);
            // Undefined element is valid.
View Full Code Here


  public void refreshSheet() {
    if (!replaceModel) {
      removed();
      replaceModel = true;

      IDOMNode node = (IDOMNode) getElement();
      if (node != null) {
        node.notify(INodeNotifier.CHANGE, getElement().getAttributeNode(org.eclipse.wst.html.core.internal.provisional.HTML40Namespace.ATTR_NAME_HREF), null, null, node.getStartOffset());
      }
    }
  }
View Full Code Here

    CMNode[] nodes = EMPTY_CMNODE_ARRAY;
    ArrayList nodeList = new ArrayList();
   
    //only returns anything if looking for child nodes
    if(((includeOptions & ModelQuery.INCLUDE_CHILD_NODES) != 0) && parentElement instanceof IDOMNode) {
      IDOMNode node = (IDOMNode)parentElement;
      // get position dependent CMDocuments and insert their tags as
      // proposals
      ModelQueryAdapter mqAdapter = null;
      if (node.getNodeType() == Node.DOCUMENT_NODE) {
        mqAdapter = (ModelQueryAdapter) 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(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.
View Full Code Here

  /**
   * @param srcModel com.ibm.sed.css.model.interfaces.ICSSModel
   */
  public void styleUpdate(ICSSModel srcModel) {
    IDOMNode node = (IDOMNode) getElement();
    if (node == null)
      return;
    IDOMModel model = node.getModel();
    if (model == null)
      return;
    XMLModelNotifier notifier = model.getModelNotifier();
    if (notifier == null)
      return;
View Full Code Here

    if (Debug.displayInfo) {
      Logger.log(Logger.INFO_DEBUG, "-----------------------ModelQueryAdapterFactoryForHTML.createAdapter" + target); //$NON-NLS-1$
    }
    if (modelQueryAdapter == null) {
      if (target instanceof IDOMNode) {
        IDOMNode xmlNode = (IDOMNode) target;
        modelStateNotifier = xmlNode.getModel();
        modelStateNotifier.addModelStateListener(getInternalModelStateListener());

        IStructuredModel model = xmlNode.getModel();
        org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
        if (Debug.displayInfo)
          System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + resolver.getFileBaseLocation()); //$NON-NLS-1$

        /**
 
View Full Code Here

      if (type == null || !type.exists()) {
        Object severity = getMessageSeverity(preferenceScopes, preferenceKey);
        if (severity == null)
          return null;

        IDOMNode classElement = (IDOMNode) classSpecifier;
        Map markerValues = new HashMap();
        markerValues.put(IMarker.SEVERITY, severity);
        int start = classElement.getStartOffset();
        if (classElement.getStartStructuredDocumentRegion() != null && classElement.getEndStructuredDocumentRegion() != null)
          start = classElement.getStartStructuredDocumentRegion().getEndOffset();
        markerValues.put(IMarker.CHAR_START, new Integer(start));
        int end = classElement.getEndOffset();
        if (classElement.getStartStructuredDocumentRegion() != null && classElement.getEndStructuredDocumentRegion() != null)
          end = classElement.getEndStructuredDocumentRegion().getStartOffset();
        markerValues.put(IMarker.CHAR_END, new Integer(end));
        int line = classElement.getStructuredDocument().getLineOfOffset(start);
        markerValues.put(IMarker.LINE_NUMBER, new Integer(line + 1));
        markerValues.put(IMarker.MESSAGE, NLS.bind(errorMessage, (errorMessage.indexOf("{1}") >= 0) ? new String[]{getTagName(classSpecifier), className} : new String[]{className})); //$NON-NLS-1$
        return markerValues;
      }
    }
View Full Code Here

      IStructuredDocumentRegion region = ((IDOMNode) node).getFirstStructuredDocumentRegion();
      String regionType = region.getType();
      if(JSP_ROOT_TAG_NAME.equals(regionType))
        return super.cleanup(node);
      else if (JSP_DIRECTIVE_NAME.equals(regionType)){
        IDOMNode renamedNode = (IDOMNode) cleanupChildren(node);
        return quoteAttrValue(renamedNode);
      }
    }
    return node;
  }
View Full Code Here

    if (node != null) {
      short nodeType = node.getNodeType();
      if (nodeType == Node.DOCUMENT_TYPE_NODE) {
        // handle doc type node
        IDOMNode docNode = (IDOMNode) node;
        hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
      }
      else if (nodeType == Node.ATTRIBUTE_NODE) {
        // handle attribute nodes
        IDOMAttr att = (IDOMAttr) node;
        // do not include quotes in attribute value region
        int regOffset = att.getValueRegionStartOffset();
        ITextRegion valueRegion = att.getValueRegion();
        if (valueRegion != null) {
          int regLength = valueRegion.getTextLength();
          String attValue = att.getValueRegionText();
          if (StringUtils.isQuoted(attValue)) {
            ++regOffset;
            regLength = regLength - 2;
          }
          hyperRegion = new Region(regOffset, regLength);
        }
      }
      if (nodeType == Node.ELEMENT_NODE) {
        // Handle doc type node
        IDOMNode docNode = (IDOMNode) node;
        hyperRegion = getNameRegion(docNode.getFirstStructuredDocumentRegion());
        if (hyperRegion == null) {
          hyperRegion = new Region(docNode.getStartOffset(), docNode.getFirstStructuredDocumentRegion().getTextLength());
        }
      }
    }
    /**
     * Only return a hyperlink region that overlaps the search region.
View Full Code Here

        if (command.text != null) {
          smartInsertForEndTag(command, document, model);
          smartRemoveEndTag(command, document, model);
          if (command.text.equals("%") && isPreferenceEnabled(JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS)) { //$NON-NLS-1$
            // scriptlet - add end %>
            IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
            if (node != null && prefixedWith(document, command.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
              command.text += " %>"; //$NON-NLS-1$
              command.shiftsCaret = false;
              command.caretOffset = command.offset + 1;
              command.doit = false;
            }
          }
          if (command.text.equals("{") && isPreferenceEnabled(JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES)) { //$NON-NLS-1$
            IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
            if (node != null && (prefixedWith(document, command.offset, "$") || prefixedWith(document, command.offset, "#")) && //$NON-NLS-1$ //$NON-NLS-2$
                  !node.getSource().endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$
              command.text += " }"; //$NON-NLS-1$
              command.shiftsCaret = false;
              command.caretOffset = command.offset + 1;
              command.doit = false;
            }
View Full Code Here

  }
 
  private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
    try {
      if (command.text.equals("/") && (document.getLength() >= 1) && document.get(command.offset - 1, 1).equals("<") && HTMLUIPlugin.getDefault().getPreferenceStore().getBoolean(HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
        IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
        if (isCommentNode(parentNode)) {
          // loop and find non comment node parent
          while ((parentNode != null) && isCommentNode(parentNode)) {
            parentNode = (IDOMNode) parentNode.getParentNode();
          }
        }

        if (!isDocumentNode(parentNode)) {
          // only add end tag if one does not already exist or if
          // add '/' does not create one already
          IStructuredDocumentRegion endTagStructuredDocumentRegion = parentNode.getEndStructuredDocumentRegion();
          IDOMNode ancestor = parentNode;
          boolean smartInsertForEnd = false;
          if(endTagStructuredDocumentRegion != null) {
            // Look for ancestors by the same name that are missing end tags
            while((ancestor = (IDOMNode) ancestor.getParentNode()) != null) {
              if(ancestor.getEndStructuredDocumentRegion() == null && parentNode.getNodeName().equals(ancestor.getNodeName())) {
                smartInsertForEnd = true;
                break;
              }
            }
          }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

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.