/** * Resets children values from IStructuredDocumentRegion. */ void resetStructuredDocumentRegions() { for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) { child.resetStructuredDocumentRegions(); } this.flatNode = null; }
/** */ protected void setOwnerDocument(Document ownerDocument, boolean deep) { this.ownerDocument = (DocumentImpl) ownerDocument; if (deep) { for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) { child.setOwnerDocument(ownerDocument, deep); } } }
/** * normalize method */ public void normalize() { TextImpl prevText = null; for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) { switch (child.getNodeType()) { case TEXT_NODE : { if (prevText == null) { prevText = (TextImpl) child; break; } Text text = (Text) child; removeChild(text); prevText.appendText(text); child = prevText; break; } case ELEMENT_NODE : { Element element = (Element) child; element.normalize(); prevText = null; break; } default : prevText = null; break; } } }
public void setEditable(boolean editable, boolean deep) { if (deep) { IDOMNode node = (IDOMNode) getFirstChild(); while (node != null) { node.setEditable(editable, deep); node = (IDOMNode) node.getNextSibling(); } } setChildEditable(editable); setDataEditable(editable); }
/** * getStartOffset method * * @return int */ public int getStartOffset() { if (this.flatNode != null) return this.flatNode.getStart(); NodeImpl prev = (NodeImpl) getPreviousSibling(); if (prev != null) return prev.getEndOffset(); Node parent = getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { ElementImpl element = (ElementImpl) parent; if (element.hasStartTag()) return element.getStartEndOffset(); return element.getStartOffset(); } // final fallback to look into first child NodeImpl child = (NodeImpl) getFirstChild(); while (child != null) { IStructuredDocumentRegion childStructuredDocumentRegion = child.getStructuredDocumentRegion(); if (childStructuredDocumentRegion != null) return childStructuredDocumentRegion.getStart(); child = (NodeImpl) child.getFirstChild(); } return 0; }
this.nextNode = (NodeImpl) root.getFirstChild(); this.nextNode = (NodeImpl) root.getFirstChild(); this.nextNode = (NodeImpl) root.getFirstChild();
void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) { // future_TODO: optimize NodeImpl root = (NodeImpl) this.model.getDocument(); this.parentNode = root; this.nextNode = (NodeImpl) root.getFirstChild(); removeGapStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionBefore(flatNode.getStart()); changeStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionAfter(flatNode.getEnd()); }
void changeRegion(IStructuredDocumentRegion flatNode, ITextRegion region) { // future_TODO: optimize NodeImpl root = (NodeImpl) this.model.getDocument(); this.parentNode = root; this.nextNode = (NodeImpl) root.getFirstChild(); removeGapStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionBefore(flatNode.getStart()); changeStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionAfter(flatNode.getEnd()); }
/** * getNodeAt method * * @return org.w3c.dom.Node * @param offset * int */ Node getNodeAt(int offset) { IDOMNode parent = this; IDOMNode child = (IDOMNode) getFirstChild(); while (child != null) { if (child.getEndOffset() <= offset) { child = (IDOMNode) child.getNextSibling(); continue; } if (child.getStartOffset() > offset) { break; } IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion(); if (startStructuredDocumentRegion != null) { if (startStructuredDocumentRegion.getEnd() > offset) return child; } // dig more parent = child; child = (IDOMNode) parent.getFirstChild(); } return parent; }
Node child = root.getFirstChild(); if (child != null) this.context.setNextNode(child); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (offset >= ((NodeImpl) child).getEndOffset()) continue;
NodeImpl child = (NodeImpl) node.getFirstChild(); if (child != null) { node = child;
Node child = this.nextNode.getFirstChild(); if (child != null) { this.parentNode = this.nextNode;
Node child = this.nextNode.getFirstChild(); if (child != null) { this.parentNode = this.nextNode;
Node child = this.nextNode.getFirstChild(); if (child != null) { this.parentNode = this.nextNode;