/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Text textNode; Node otherChild; doc = (Document) load("hc_staff", true); acronymList = doc.getElementsByTagName("acronym"); testNode = acronymList.item(3); attributes = testNode.getAttributes(); titleAttr = (Attr) attributes.getNamedItem("title"); textNode = (Text) titleAttr.getFirstChild(); assertNotNull("textNodeNotNull", textNode); value = textNode.getNodeValue(); assertEquals("child1IsYes", "Yes", value); otherChild = textNode.getNextSibling(); assertNull("nextSiblingIsNull", otherChild); otherChild = textNode.getPreviousSibling(); assertNull("previousSiblingIsNull", otherChild); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Text textNode; Node otherChild; doc = (Document) load("hc_staff", true); acronymList = doc.getElementsByTagName("acronym"); testNode = acronymList.item(3); attributes = testNode.getAttributes(); titleAttr = (Attr) attributes.getNamedItem("title"); textNode = (Text) titleAttr.getFirstChild(); assertNotNull("textNodeNotNull", textNode); value = textNode.getNodeValue(); assertEquals("child1IsYes", "Yes", value); otherChild = textNode.getNextSibling(); assertNull("nextSiblingIsNull", otherChild); otherChild = textNode.getPreviousSibling(); assertNull("previousSiblingIsNull", otherChild); } /**
public static Text splitDomText(EditPart part, DesignRange range) { if (part instanceof TextEditPart) { Text textNode = (Text) part.getModel(); DOMRange domRange = DOMRangeHelper.toDOMRange(range); IDOMPosition start = domRange.getStartPosition(); IDOMPosition end = domRange.getEndPosition(); int domTempStartOffset = computeOffset(start, textNode); int domTempEndOffset = computeOffset(end, textNode); int domStartOffset = Math.min(domTempStartOffset, domTempEndOffset); int domEndOffset = Math.max(domTempStartOffset, domTempEndOffset); Text lastNode = textNode; if (domStartOffset > 0) { lastNode = textNode.splitText(domStartOffset); } lastNode = lastNode.splitText(domEndOffset - domStartOffset); Text middleNode = (Text) lastNode.getPreviousSibling(); return middleNode; } return null; }
Node prev = text.getPreviousSibling(); if (prev != null) { String preTag = getCloseTag((IDOMNode) prev);
Node sibling = textNode.getPreviousSibling(); if (sibling != null && sibling.getNodeName().equalsIgnoreCase(getTag())) { Node previousSibling = textNode.getPreviousSibling(); Node nextSibling = textNode.getNextSibling();
Node prev = currentNode.getPreviousSibling(); while (prev != null) {
Node prev = currentNode.getPreviousSibling(); while (prev != null) {
Node prev = currentNode.getPreviousSibling(); while (prev != null) {
if (currentNode.getPreviousSibling() != null) { setOperationPosition(new DOMRefPosition(currentNode .getPreviousSibling(), true)); } else { setOperationPosition(new DOMPosition(currentNode