Package org.eclipse.jst.pagedesigner.dom

Examples of org.eclipse.jst.pagedesigner.dom.DOMPosition


    int location2 = EditHelper.getInstance().getLocation(currentNode,
        node.getPosOffsets()[1], true);
    // left index
    if (currentNode.getData().length() > 0) {
      if (location1 == EditHelper.IN_MIDDLE) {
        IDOMPosition position = new DOMPosition(currentNode, node
            .getPosOffsets()[0]);
        setOperationPosition(position);
        position = DOMPositionHelper.splitText(position);
        Node nnode = position.getNextSiblingNode();
        if (nnode instanceof Text) {
          currentNode = (Text) nnode;
          offsets[1] -= offsets[0] > 0 ? offsets[0] : 0;
        }
      } else {
        // setOperationPosition(new DOMRefPosition(currentNode, false));
        if (currentNode.getPreviousSibling() != null) {
          setOperationPosition(new DOMRefPosition(currentNode
              .getPreviousSibling(), true));
        } else {
          setOperationPosition(new DOMPosition(currentNode
              .getParentNode(), 0));
        }
      }
      // right index
      if (location2 >= EditHelper.IN_MIDDLE) {
        IDOMPosition position = new DOMPosition(currentNode, offsets[1]);
        position = DOMPositionHelper.splitText(position);
        second = position.getPreviousSiblingNode();
      }
      return second != null ? (Text) EditHelper.deleteNode(second) : null;
    }
        setOperationPosition(new DOMRefPosition(currentNode, false));
        return (Text) EditHelper.deleteNode(currentNode);
View Full Code Here


        start = split(start);
        // parent is splited
        if (start != old) {
          container = start.getNextSiblingNode();
          offset2 -= offset1;
          end = new DOMPosition(container, offset2);
        }
        end = split(end);
      } else {
        start = split(common, start);
        end = split(common, end);
View Full Code Here

            .equals(
                ((Element) parentNode)
                    .getAttribute(IHTMLConstants.ATTR_ALIGN))) {
          ((Element) parentNode)
              .removeAttribute(IHTMLConstants.ATTR_ALIGN);
          IDOMPosition startPos = new DOMPosition(parentNode, 0);
          IDOMPosition endPos = new DOMRefPosition(endNode, true);
          return new DOMRange(startPos, endPos);
        }
        // else replace the align attribute
        /**
         * this._applyingNode.appendChild(startNode);
         * parentNode.getParentNode().replaceChild(this._applyingNode,
         * parentNode);
         */
        String align = this.getApplyingNode()
            .getAttribute(IHTMLConstants.ATTR_ALIGN);
        ((Element) parentNode).setAttribute(IHTMLConstants.ATTR_ALIGN,
            align);

        IDOMPosition startPos = new DOMPosition(parentNode, 0);
        IDOMPosition endPos = new DOMRefPosition(endNode, true);
        return new DOMRange(startPos, endPos);
      }
    } else {
      if (parentNode != null
          && parentNode.getNodeName().equalsIgnoreCase(
              IHTMLConstants.TAG_P)
          && parentNode.getChildNodes().getLength() == len) {
        if (this.getApplyingNode()
            .getAttribute(IHTMLConstants.ATTR_ALIGN)
            .equals(
                ((Element) parentNode)
                    .getAttribute(IHTMLConstants.ATTR_ALIGN))) {
          ((Element) parentNode)
              .removeAttribute(IHTMLConstants.ATTR_ALIGN);
          IDOMPosition startPos = new DOMPosition(parentNode, 0);
          IDOMPosition endPos = new DOMRefPosition(endNode, true);
          return new DOMRange(startPos, endPos);
        }

        /**
         * Node sibling = startNode.getNextSibling();
         * this._applyingNode.appendChild(startNode); Node
         * endNodeSibling = endNode.getNextSibling(); while (sibling !=
         * null && startNode != endNode && sibling != endNodeSibling) {
         * Node tempNode = sibling.getNextSibling();
         * this._applyingNode.appendChild(sibling); sibling = tempNode; }
         * parentNode.getParentNode().replaceChild(this._applyingNode,
         * parentNode);
         */
        String align = this.getApplyingNode()
            .getAttribute(IHTMLConstants.ATTR_ALIGN);
        ((Element) parentNode).setAttribute(IHTMLConstants.ATTR_ALIGN,
            align);

        IDOMPosition startPos = new DOMPosition(parentNode, 0);
        IDOMPosition endPos = new DOMRefPosition(endNode, true);
        return new DOMRange(startPos, endPos);
      }
    }
    return null;
View Full Code Here

          Node tempNode = sibling.getNextSibling();
          newNode.appendChild(sibling);
          sibling = tempNode;
        }

        IDOMPosition startPos = new DOMPosition(newNode, 0);
        IDOMPosition endPos = new DOMRefPosition(endContainer, true);
        return new DOMRange(startPos, endPos);
  }
View Full Code Here

    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);
      }
      // XXX: not skip header here. So if there is some header with wrong
      // location, we will respect user.
View Full Code Here

          }
        }
        if (child != null) {
          return new DOMRefPosition(child, false);
        }
        return new DOMPosition(parent, parent.getChildNodes()
            .getLength());
  }
View Full Code Here

            return new DOMRefPosition2(ele, true);
          } else if (nextSibling.getParentNode() == ele) {
            // next sibling is not in header part
            return new DOMRefPosition(nextSibling, false);
          } else {
            return new DOMPosition(ele, 0);
          }
        }
                return position;
      }
      node = node.getParentNode();
View Full Code Here

      // since the head tag is a widget, the offset will need
      // to be updated in the position so that new node is
      // appended to the list of children.
      Node node = domposition.getContainerNode();
      domposition = new DOMPosition(node, node.getChildNodes().getLength());

      return new CreateItemCommand(
          PDPlugin
              .getResourceString("ItemCreationEditPolicy.CommandLabel.CreateItem"),//$NON-NLS-1$
          getViewer(getHost()).getModel(), domposition, r.getTagCreationProvider());
View Full Code Here

                        TagToolCreationAdapter.findProviderForContainer(uri, tagName, PaletteItemManager.createPaletteContext(fileForDocument));
                    final ITaglibDomainMetaDataModelContext modelContext =
                        TaglibDomainMetaDataQueryHelper
                            .createMetaDataModelContext(fileForDocument.getProject(), child.getTagIdentifier().getUri());
//                        .createMetaDataModelContext(project, child.getTagIdentifier().getUri());
                    IDOMPosition domPosition = new DOMPosition(_element, childCount++);
                    CreationData creationData = new CreationData(creationProvider,_model, domPosition, modelContext, child);

                    ElementCustomizationCommand command = new UserCustomizedElementCustomizationCommand(_model, childNode, creationData);
                    command.execute();
                }
View Full Code Here

              final IMetaDataModelContext modelContext = CommandUtil.getMetadataModelContext(child.getTagIdentifier().getUri(), _model);
//                    final ITaglibDomainMetaDataModelContext modelContext =
//                        TaglibDomainMetaDataQueryHelper
//                            .createMetaDataModelContext(fileForDocument.getProject(), child.getTagIdentifier().getUri());
//                        .createMetaDataModelContext(project, child.getTagIdentifier().getUri());
                    IDOMPosition domPosition = new DOMPosition(_element, childCount++);
                    CreationData creationData = new CreationData(creationProvider,_model, domPosition, modelContext, child);

                    ElementCustomizationCommand command = new UserCustomizedElementCustomizationCommand(_model, childNode, creationData);
                    command.execute();
                }
View Full Code Here

TOP

Related Classes of org.eclipse.jst.pagedesigner.dom.DOMPosition

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.