Examples of IBodyInfo


Examples of org.eclipse.jst.pagedesigner.adapters.IBodyInfo

        && ((IDOMText) child).isElementContentWhitespace())
      return true;

    if ((flag & HEADER) != 0 && child.getNodeType() == Node.ELEMENT_NODE) {
      String uri = CMUtil.getElementNamespaceURI((Element) child);
      IBodyInfo parentInfo = getBodyInfo((IDOMNode) parent);
      if (parentInfo != null
          && parentInfo.isBodyHeader((IDOMNode) parent, uri,
              ((Element) child).getLocalName()))
        return true;
    }
    return false;
  }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.adapters.IBodyInfo

   * @return IDOMNode
   */
  public static IDOMNode findHeaderContainer(IDOMNode start, String uri,
      String tag) {
    while (start != null) {
      IBodyInfo designInfo = getBodyInfo(start);
      if (designInfo != null && designInfo.isBodyContainer(start)) {
        if (designInfo.isBodyHeader(start, uri, tag))
          return start;
      }
      start = (IDOMNode) start.getParentNode();
    }
    return null;
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.adapters.IBodyInfo

  public static IDOMPosition findBodyInsertLocation(IDOMPosition position) {
    // forward first.
    Node reference = position.getNextSiblingNode();
    Node container = position.getContainerNode();
    while (reference != null) {
      IBodyInfo info = getBodyInfo((IDOMNode) reference);
      if (info != null && info.isBodyContainer((IDOMNode) reference)) {
        // good, we find a body!
        position = new DOMPosition(reference, 0);
        return findBodyInsertLocation(position);
      }
      if (isSkippableChild(container, reference, EMPTY_TEXT | COMMENT
          | HEADER)) {
        reference = reference.getNextSibling();
        continue;
      }
            break;
    }

    // backward
    reference = position.getPreviousSiblingNode();
    while (reference != null) {
      IBodyInfo info = getBodyInfo((IDOMNode) reference);
      if (info != null && info.isBodyContainer((IDOMNode) reference)) {
        // good, we find a body!
        position = new DOMPosition(reference, reference.getChildNodes()
            .getLength());
        return findBodyInsertLocation(position);
      }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.adapters.IBodyInfo

   *
   */
  public static IDOMPosition adjustInsertPosition(String uri, String tag,
      IDOMPosition position) {
    IDOMNode parent = (IDOMNode) position.getContainerNode();
    IBodyInfo designInfo = getBodyInfo(parent);
    if (designInfo == null) {
      return position; // should not happen.
    }

    IDOMNode headerContainer = findHeaderContainer(parent, uri, tag);

    if (headerContainer == null) {
      // the new node is not header.
      if (shouldIgnoreAdjust(uri, tag)) {
        return position;
      }

      // new node is not body header. So should place inside the inner most
      // body.
      if (!designInfo.isBodyContainer(parent)) {
        return position; // it's parent is not body, so we suggest
        // it's parent already correctly located, and respect user's
        // choice.
      }

View Full Code Here

Examples of org.eclipse.jst.pagedesigner.adapters.IBodyInfo

   * @return the new dom position based on the insert.  May return null if
   * insert fails.
   */
  public static IDOMPosition insertBody(IDOMPosition position, QName body,
      String defaultPrefix) {
    IBodyInfo bodyInfo = getBodyInfo((IDOMNode) position.getContainerNode());

    Node node = position.getContainerNode();
    final Node originalContainer = node;
    final Node nextSibling = position.getNextSiblingNode();

    // create the body element first.
    Document ownerDoc;
    if (node instanceof Document) {
      ownerDoc = (Document) node;
    } else {
      ownerDoc = node.getOwnerDocument();
    }
    if (ownerDoc == null) {
      return null; // should not happen
    }

    final String prefix = JSPUtil.getOrCreatePrefix(((IDOMNode) node).getModel(),
        body.getNamespaceURI(), defaultPrefix);
    final Element ele = ownerDoc.createElement((prefix == null ? "" //$NON-NLS-1$
        : (prefix + ":")) //$NON-NLS-1$
        + body.getLocalPart());

    // need to find out the insertion point
    while (node instanceof IDOMNode) {
      if (bodyInfo.isBodyContainer((IDOMNode) node)) {
        // ok, node is a body container.
        // we could create the new node as child of node and move all
        // node's none header children
        // as children of the new node.

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.