rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
this.e = e; this.index = i; addRemovedElements(removed); addAddedElements(added); | this(el, i, false); | public Edit(Element e, int i, Element[] removed, Element[] added) { this.e = e; this.index = i; addRemovedElements(removed); addAddedElements(added); } |
elementStack = new Stack(); | public ElementBuffer(Element root) { this.root = root; elementStack = new Stack(); } |
|
if (length == 0) return; this.offset = offset; this.pos = offset; this.length = length; documentEvent = ev; | prepareEdit(offset, length); | public void change(int offset, int length, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.pos = offset; this.length = length; documentEvent = ev; changeUpdate(); } |
finishEdit(ev); | public void change(int offset, int length, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.pos = offset; this.length = length; documentEvent = ev; changeUpdate(); } |
|
Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) | boolean didEnd = split(offset, length); if (! didEnd) | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
Element[] removed; Element[] added; if (res[0] == null) | while (elementStack.size() != 0) | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
removed = new Element[0]; added = new Element[] { res[1] }; index++; | pop(); | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); | split(offset + length, 0); | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) | while (elementStack.size() != 0) | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); | pop(); | protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); int index = par.getElementIndex(offset); Edit edit = getEditForParagraphAndIndex(par, index); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[] { el }; added = new Element[] { res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } } |
BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); AttributeSet atts = child.getAttributes(); | Edit edit = (Edit) elementStack.peek(); Element child = edit.e.getElement(edit.index); | private void createFracture(ElementSpec[] data) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); AttributeSet atts = child.getAttributes(); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset); edit.addAddedElement(newEl1); edit.addRemovedElement(child); } } |
Element newEl1 = createLeafElement(paragraph, atts, | Element newChild = createLeafElement(edit.e, child.getAttributes(), | private void createFracture(ElementSpec[] data) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); AttributeSet atts = child.getAttributes(); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset); edit.addAddedElement(newEl1); edit.addRemovedElement(child); } } |
edit.addAddedElement(newEl1); edit.addRemovedElement(child); | edit.added.add(newChild); | private void createFracture(ElementSpec[] data) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); AttributeSet atts = child.getAttributes(); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset); edit.addAddedElement(newEl1); edit.addRemovedElement(child); } } |
edit.removed.add(child); if (child.getEndOffset() != endOffset) recreateLeafs = true; else offsetLastIndex = true; | private void createFracture(ElementSpec[] data) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); AttributeSet atts = child.getAttributes(); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset); edit.addAddedElement(newEl1); edit.addRemovedElement(child); } } |
|
if (length == 0) return; this.offset = offset; this.pos = offset; this.endOffset = offset + length; this.length = length; documentEvent = ev; edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false; insertUpdate(data); int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); if (removed.length > 0 || added.length > 0) { if (curr.index + removed.length <= e.getElementCount()) { e.replace(curr.index, removed.length, added); ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee); } else { System.err.println("WARNING: Tried to replace elements "); System.err.print("beyond boundaries: elementCount: "); System.err.println(e.getElementCount()); System.err.print("index: " + curr.index); System.err.println(", removed.length: " + removed.length); } } | if (length > 0) { prepareEdit(offset, length); insertUpdate(data); finishEdit(ev); } | public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.pos = offset; this.endOffset = offset + length; this.length = length; documentEvent = ev; edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false; insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); // FIXME: We probably shouldn't create the empty Element[] in the // first place. if (removed.length > 0 || added.length > 0) { if (curr.index + removed.length <= e.getElementCount()) { e.replace(curr.index, removed.length, added); ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee); } else { System.err.println("WARNING: Tried to replace elements "); System.err.print("beyond boundaries: elementCount: "); System.err.println(e.getElementCount()); System.err.print("index: " + curr.index); System.err.println(", removed.length: " + removed.length); } } } } |
} | public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.pos = offset; this.endOffset = offset + length; this.length = length; documentEvent = ev; edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false; insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); // FIXME: We probably shouldn't create the empty Element[] in the // first place. if (removed.length > 0 || added.length > 0) { if (curr.index + removed.length <= e.getElementCount()) { e.replace(curr.index, removed.length, added); ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee); } else { System.err.println("WARNING: Tried to replace elements "); System.err.print("beyond boundaries: elementCount: "); System.err.println(e.getElementCount()); System.err.print("index: " + curr.index); System.err.println(", removed.length: " + removed.length); } } } } |
|
private void insertContentTag(ElementSpec tag) | private void insertContentTag(ElementSpec tag, Edit edit) | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
BranchElement paragraph = (BranchElement) elementStack.peek(); | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
|
AttributeSet tagAtts = tag.getAttributes(); | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
|
int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) | if (! edit.isFracture) | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) | Element first = null; if (insertPath != null) | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else | for (int p = insertPath.length - 1; p >= 0; p--) | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) | if (insertPath[p] == edit) | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); | if (p != insertPath.length - 1) first = edit.e.getElement(edit.index); break; } | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); | Element first = edit.e.getElement(0); Element leaf = createLeafElement(edit.e, first.getAttributes(), pos, first.getEndOffset()); edit.added.add(leaf); edit.removed.add(first); } | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
paragraph.replace(0, 0, new Element[] { leaf }); | { Element leaf = createLeafElement(edit.e, tag.getAttributes(), pos, pos + len); edit.added.add(leaf); | private void insertContentTag(ElementSpec tag) { BranchElement paragraph = (BranchElement) elementStack.peek(); int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next); edit.addRemovedElement(target); } else { BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); } } } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); // Check for overlap with other leaves/branches if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; // Check if we should place the leaf before or after target if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; } |
BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; | Edit edit = (Edit) elementStack.peek(); Element current = edit.e.getElement(edit.index); int firstEndOffset = offset + first.length; | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
Edit edit = getEditForParagraphAndIndex(paragraph, index); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
|
if (current.getEndOffset() != newEndOffset && !onlyContent) | if (current.getEndOffset() != firstEndOffset && ! onlyContent) | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
Element newEl1 = createLeafElement(paragraph, | Element newEl1 = createLeafElement(edit.e, | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; | firstEndOffset); edit.added.add(newEl1); edit.removed.add(current); if (current.getEndOffset() != endOffset) recreateLeafs = true; else offsetLastIndex = true; } else { offsetLastIndex = true; offsetLastIndexReplace = true; | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
if (pos != 0) | if (offset != 0) | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); | offset); edit.added.add(newEl1); Element next = edit.e.getElement(edit.index + 1); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); | newEl1 = createLeafElement(edit.e, next.getAttributes(), offset, next.getEndOffset()); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; | newEl1 = createLeafElement(edit.e, next.getAttributes(), offset, firstEndOffset); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); | edit.added.add(newEl1); edit.removed.add(current); edit.removed.add(next); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
default: if (current.getStartOffset() != pos) | default: if (current.getStartOffset() != offset) | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
Element newEl = createLeafElement(paragraph, | Element newEl = createLeafElement(edit.e, | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
pos); edit.addAddedElement(newEl); | offset); edit.added.add(newEl); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); | edit.removed.add(current); Element newEl1 = createLeafElement(edit.e, first.getAttributes(), offset, firstEndOffset); edit.added.add(newEl1); | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
recreateLeaves(newEndOffset, paragraph, onlyContent); | recreateLeafs = true; | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
offset = newEndOffset; | offsetLastIndex = true; | private void insertFirstContentTag(ElementSpec[] data) { ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(pos); Element current = paragraph.getElement(index); int newEndOffset = pos + first.length; boolean onlyContent = data.length == 1; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); offset = newEndOffset; } break; case ElementSpec.JoinNextDirection: if (pos != 0) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1); if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); else { newEl1 = createLeafElement(paragraph, next.getAttributes(), pos, newEndOffset); pos = newEndOffset; } edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addRemovedElement(next); } break; default: if (current.getStartOffset() != pos) { Element newEl = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), pos); edit.addAddedElement(newEl); } edit.addRemovedElement(current); Element newEl1 = createLeafElement(paragraph, first.getAttributes(), pos, newEndOffset); edit.addAddedElement(newEl1); if (current.getEndOffset() != endOffset) recreateLeaves(newEndOffset, paragraph, onlyContent); else offset = newEndOffset; break; } } |
int index; while (!current.isLeaf()) | int index = current.getElementIndex(offset); while (! current.isLeaf()) | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
elementStack.push(current); current = current.getElement(index); | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
|
BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) | insertElement(data[i]); } if (! createdFracture) fracture(-1); while (elementStack.size() != 0) pop(); if (offsetLastIndex && offsetLastIndexReplace) insertPath[insertPath.length - 1].index++; for (int p = insertPath.length - 1; p >= 0; p--) | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
case ElementSpec.StartTagType: switch (data[i].getDirection()) | Edit edit = insertPath[p]; if (edit.e == fracturedParent) edit.added.add(fracturedChild); if ((edit.added.size() > 0 || edit.removed.size() > 0) && ! edits.contains(edit)) edits.add(edit); } if (offset == 0 && fracturedParent != null && data[0].getType() == ElementSpec.EndTagType) | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
case ElementSpec.JoinFractureDirection: fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) | for (int p = 0; p < data.length && data[p].getType() == ElementSpec.EndTagType; p++) | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); | Edit edit = insertPath[insertPath.length - p - 1]; edit.index--; edit.removed.add(0, edit.e.getElement(edit.index)); | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
break; case ElementSpec.JoinNextDirection: int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
|
else br = insertParagraph(paragraph, pos); break; | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
|
break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } | protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. insertFirstContentTag(data); pos += data[0].length; i = 1; } else { createFracture(data); i = 0; } // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. fracNotCreated = false; insertFracture(data[i]); if (fracNotCreated) { if (lastFractured != null) elementStack.push(lastFractured.getParentElement()); else elementStack.push(paragraph.getElement(0)); } break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix)); break; default: Element br = null; if (data.length > i + 1) { // leaves will be added to paragraph later int x = 0; if (paragraph.getElementCount() > 0) x = paragraph.getElementIndex(pos) + 1; Edit e = getEditForParagraphAndIndex(paragraph, x); br = (BranchElement) createBranchElement(paragraph, data[i].getAttributes()); e.added.add(br); elementStack.push(br); } else // need to add leaves to paragraph now br = insertParagraph(paragraph, pos); break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); offset = pos; break; } } } |
|
if (len == 0) return; offset = offs; length = len; pos = offset; documentEvent = ev; | prepareEdit(offs, len); | public void remove(int offs, int len, DefaultDocumentEvent ev) { if (len == 0) return; offset = offs; length = len; pos = offset; documentEvent = ev; removeUpdate(); } |
finishEdit(ev); | public void remove(int offs, int len, DefaultDocumentEvent ev) { if (len == 0) return; offset = offs; length = len; pos = offset; documentEvent = ev; removeUpdate(); } |
|
int startParagraph = root.getElementIndex(offset); int endParagraph = root.getElementIndex(offset + length); Element[] empty = new Element[0]; int removeStart = -1; int removeEnd = -1; for (int i = startParagraph; i < endParagraph; i++) { BranchElement paragraph = (BranchElement) root.getElement(i); int contentStart = paragraph.getElementIndex(offset); int contentEnd = paragraph.getElementIndex(offset + length); if (contentStart == paragraph.getStartOffset() && contentEnd == paragraph.getEndOffset()) { if (removeStart == -1) { removeStart = i; removeEnd = i; } else removeEnd = i; } else { int removeLen = contentEnd - contentStart; Element[] removed = new Element[removeLen]; for (int j = contentStart; j < contentEnd; j++) removed[j] = paragraph.getElement(j); Edit edit = getEditForParagraphAndIndex(paragraph, contentStart); edit.addRemovedElements(removed); } } if (removeStart != -1) { int removeLen = removeEnd - removeStart; Element[] removed = new Element[removeLen]; for (int i = removeStart; i < removeEnd; i++) removed[i] = root.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) root, removeStart); edit.addRemovedElements(removed); } | removeElements(root, offset, endOffset); | protected void removeUpdate() { int startParagraph = root.getElementIndex(offset); int endParagraph = root.getElementIndex(offset + length); Element[] empty = new Element[0]; int removeStart = -1; int removeEnd = -1; for (int i = startParagraph; i < endParagraph; i++) { BranchElement paragraph = (BranchElement) root.getElement(i); int contentStart = paragraph.getElementIndex(offset); int contentEnd = paragraph.getElementIndex(offset + length); if (contentStart == paragraph.getStartOffset() && contentEnd == paragraph.getEndOffset()) { // In this case we only need to remove the whole paragraph. We // do this in one go after this loop and only record the indices // here. if (removeStart == -1) { removeStart = i; removeEnd = i; } else removeEnd = i; } else { // In this case we remove a couple of child elements from this // paragraph. int removeLen = contentEnd - contentStart; Element[] removed = new Element[removeLen]; for (int j = contentStart; j < contentEnd; j++) removed[j] = paragraph.getElement(j); Edit edit = getEditForParagraphAndIndex(paragraph, contentStart); edit.addRemovedElements(removed); } } // Now we remove paragraphs from the root that have been tagged for // removal. if (removeStart != -1) { int removeLen = removeEnd - removeStart; Element[] removed = new Element[removeLen]; for (int i = removeStart; i < removeEnd; i++) removed[i] = root.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) root, removeStart); edit.addRemovedElements(removed); } } |
private Element[] split(Element el, int offset, int space, int editIndex) | private boolean split(int offs, int len) { boolean splitEnd = false; Element e = root; int index = e.getElementIndex(offs); while (! e.isLeaf()) { elementStack.push(new Edit(e, index)); e = e.getElement(index); index = e.getElementIndex(offs); } Edit ec = (Edit) elementStack.peek(); Element child = ec.e.getElement(ec.index); if (child.getStartOffset() < offs && offs < child.getEndOffset()) { int index0 = ec.index; int index1 = index0; if (((offs + len) < ec.e.getEndOffset()) && (len != 0)) { index1 = ec.e.getElementIndex(offs+len); if (index1 == index0) { ec.removed.add(child); e = createLeafElement(ec.e, child.getAttributes(), child.getStartOffset(), offs); ec.added.add(e); e = createLeafElement(ec.e, child.getAttributes(), offs, offs + len); ec.added.add(e); e = createLeafElement(ec.e, child.getAttributes(), offs + len, child.getEndOffset()); ec.added.add(e); return true; } else { child = ec.e.getElement(index1); if ((offs + len) == child.getStartOffset()) | private Element[] split(Element el, int offset, int space, int editIndex) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we // recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space, editIndex); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (result[1] != null) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[] {}; } // This is the case when we may not keep the first // element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[] { result[0] }; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[] { el1, el2 }; } return res; } |
if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space, editIndex); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (result[1] != null) { if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[] {}; } else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[] { result[0] }; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } | index1 = index0; } } splitEnd = true; } pos = offs; child = ec.e.getElement(index0); ec.removed.add(child); e = createLeafElement(ec.e, child.getAttributes(), child.getStartOffset(), pos); ec.added.add(e); e = createLeafElement(ec.e, child.getAttributes(), pos, child.getEndOffset()); ec.added.add(e); for (int i = index0 + 1; i < index1; i++) { child = ec.e.getElement(i); ec.removed.add(child); ec.added.add(child); } if (index1 != index0) { child = ec.e.getElement(index1); pos = offs + len; ec.removed.add(child); e = createLeafElement(ec.e, child.getAttributes(), child.getStartOffset(), pos); ec.added.add(e); e = createLeafElement(ec.e, child.getAttributes(), pos, child.getEndOffset()); | private Element[] split(Element el, int offset, int space, int editIndex) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we // recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space, editIndex); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (result[1] != null) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[] {}; } // This is the case when we may not keep the first // element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[] { result[0] }; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[] { el1, el2 }; } return res; } |
Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[] { el1, el2 }; } return res; } | ec.added.add(e); } } return splitEnd; } | private Element[] split(Element el, int offset, int space, int editIndex) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we // recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space, editIndex); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (result[1] != null) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[] {}; } // This is the case when we may not keep the first // element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[] { result[0] }; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex); edit.addRemovedElements(removed); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[] { el1, el2 }; } return res; } |
super.insertUpdate(ev, attr); | int offs = ev.getOffset(); int len = ev.getLength(); int endOffs = offs + len; | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); | Element paragraph = getParagraphElement(endOffs); AttributeSet pAttr = paragraph.getAttributes(); Element paragraph2 = getParagraphElement(offs); int contIndex = paragraph2.getElementIndex(offs); Element content = paragraph2.getElement(contIndex); AttributeSet cAttr = content.getAttributes(); boolean insertAtBoundary = content.getEndOffset() == endOffs; | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
getText(offset, length, txt); | Segment s = new Segment(); ArrayList buf = new ArrayList(); ElementSpec lastStartTag = null; boolean insertAfterNewline = false; short lastStartDir = ElementSpec.OriginateDirection; if (offs > 0) { getText(offs - 1, 1, s); if (s.array[s.offset] == '\n') { insertAfterNewline = true; lastStartDir = insertAfterNewline(paragraph, paragraph2, pAttr, buf, offs, endOffs); for (int i = buf.size() - 1; i >= 0 && lastStartTag == null; i--) { ElementSpec tag = (ElementSpec) buf.get(i); if (tag.getType() == ElementSpec.StartTagType) { lastStartTag = tag; } } } } if (! insertAfterNewline) pAttr = paragraph2.getAttributes(); getText(offs, len, s); int end = s.offset + s.count; int last = s.offset; for (int i = s.offset; i < end; i++) { if (s.array[i] == '\n') { int breakOffs = i + 1; buf.add(new ElementSpec(attr, ElementSpec.ContentType, breakOffs - last)); buf.add(new ElementSpec(null, ElementSpec.EndTagType)); lastStartTag = new ElementSpec(pAttr, ElementSpec.StartTagType); buf.add(lastStartTag); last = breakOffs; } } if (last < end) { buf.add(new ElementSpec(attr, ElementSpec.ContentType, end - last)); } ElementSpec first = (ElementSpec) buf.get(0); int doclen = getLength(); if (first.getType() == ElementSpec.ContentType && cAttr.isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); if (lastStartTag != null) { if (insertAfterNewline) lastStartTag.setDirection(lastStartDir); else if (paragraph2.getEndOffset() != endOffs) lastStartTag.setDirection(ElementSpec.JoinFractureDirection); else { Element par = paragraph2.getParentElement(); int par2Index = par.getElementIndex(offs); if (par2Index + 1 < par.getElementCount() && ! par.getElement(par2Index + 1).isLeaf()) lastStartTag.setDirection(ElementSpec.JoinNextDirection); } } if (insertAtBoundary && endOffs < doclen) { ElementSpec lastTag = (ElementSpec) buf.get(buf.size() - 1); if (lastTag.getType() == ElementSpec.ContentType && ((lastStartTag == null && (paragraph == paragraph2 || insertAfterNewline)) || (lastStartTag != null && lastStartTag.getDirection() != ElementSpec.OriginateDirection))) { int nextIndex = paragraph.getElementIndex(endOffs); Element nextRun = paragraph.getElement(nextIndex); if (nextRun.isLeaf() && attr.isEqual(nextRun.getAttributes())) lastTag.setDirection(ElementSpec.JoinNextDirection); } } else if (! insertAtBoundary && lastStartTag != null && lastStartTag.getDirection() == ElementSpec.JoinFractureDirection) { ElementSpec lastTag = (ElementSpec) buf.get(buf.size() - 1); if (lastTag.getType() == ElementSpec.ContentType && lastTag.getDirection() != ElementSpec.JoinPreviousDirection && attr.isEqual(cAttr)) { lastTag.setDirection(ElementSpec.JoinNextDirection); } } ElementSpec[] specs = new ElementSpec[buf.size()]; specs = (ElementSpec[]) buf.toArray(specs); buffer.insert(offs, len, specs, ev); | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; | ex.printStackTrace(); | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } | super.insertUpdate(ev, attr); | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } | protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); } |
|
Element root = getDefaultRootElement(); | public void setCharacterAttributes(int offset, int length, AttributeSet attributes, boolean replace) { // Exit early if length is 0, so no DocumentEvent is created or fired. if (length == 0) return; try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally block to make // sure that locking happens in a balanced manner. writeLock(); DefaultDocumentEvent ev = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE); // Modify the element structure so that the interval begins at an // element // start and ends at an element end. buffer.change(offset, length, ev); Element root = getDefaultRootElement(); // Visit all paragraph elements within the specified interval int end = offset + length; Element curr; for (int pos = offset; pos < end;) { // Get the CharacterElement at offset pos. curr = getCharacterElement(pos); if (pos == curr.getEndOffset()) break; MutableAttributeSet a = (MutableAttributeSet) curr.getAttributes(); ev.addEdit(new AttributeUndoableEdit(curr, attributes, replace)); // If replace is true, remove all the old attributes. if (replace) a.removeAttributes(a); // Add all the new attributes. a.addAttributes(attributes); // Increment pos so we can check the next CharacterElement. pos = curr.getEndOffset(); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } } |
|
return "destination"; | return "spool-data-destination"; | public String getName() { return "destination"; } |
public void setLayer(Integer layer) | public void setLayer(int layer) | public void setLayer(Integer layer) { JDesktopPane p = getDesktopPane(); if (p != null) { int pos = p.getPosition(this); p.setLayer(this, layer.intValue(), pos); } } |
JDesktopPane p = getDesktopPane(); if (p != null) { int pos = p.getPosition(this); p.setLayer(this, layer.intValue(), pos); } | setLayer(new Integer(layer)); | public void setLayer(Integer layer) { JDesktopPane p = getDesktopPane(); if (p != null) { int pos = p.getPosition(this); p.setLayer(this, layer.intValue(), pos); } } |
*/ return stack[3].getClassLoader(); | ClassLoader getCallingClassLoader() { Class[] stack = getClassContext(); for (int i = 0; i < stack.length; i++) { if (stack[i] != Security.class && stack[i] != ResourceBundle.class) return stack[i].getClassLoader(); } return null; } |
|
super(); SwingToolkit.add(label, this); SwingToolkit.copyAwtProperties(label, this); setText(label.getText()); } | this.label = label; SwingToolkit.add(label, this); SwingToolkit.copyAwtProperties(label, this); setText(label.getText()); } | public SwingLabelPeer(Label label) { super(); SwingToolkit.add(label, this); SwingToolkit.copyAwtProperties(label, this); setText(label.getText()); } |
protected Object getArray() | protected final Object getArray() | protected Object getArray() { return buffer; } |
throw new BadLocationException("the where argument cannot be greater" | throw new BadLocationException("The where argument cannot be greater" | public UndoableEdit insertString(int where, String str) throws BadLocationException { // check arguments int length = length(); int strLen = str.length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); replace(where, 0, str.toCharArray(), strLen); return new InsertUndo(where, strLen); } |
final Point p = source.getLocationOnScreen(); final boolean popupTrigger = (button == MouseEvent.BUTTON2); final MouseEvent me = new MouseEvent(source, id, System.currentTimeMillis(), 0, x - p.x, y - p.y, 1, popupTrigger, button); JNodeGenericPeer.eventQueue.postEvent(me); | if (source.isVisible()) { final Point p = source.getLocationOnScreen(); final boolean popupTrigger = (button == MouseEvent.BUTTON2); final MouseEvent me = new MouseEvent(source, id, System.currentTimeMillis(), 0, x - p.x, y - p.y, 1, popupTrigger, button); JNodeGenericPeer.eventQueue.postEvent(me); } | private Component postEvent(Component source, int id, int button) { if (source == null) { final JNodeToolkit tk = (JNodeToolkit) Toolkit.getDefaultToolkit(); source = tk.getTopComponentAt(x, y); } //log.debug("Source: " + source.getClass().getName()); //TODO full support for modifiers final Point p = source.getLocationOnScreen(); final boolean popupTrigger = (button == MouseEvent.BUTTON2); final MouseEvent me = new MouseEvent(source, id, System.currentTimeMillis(), 0, x - p.x, y - p.y, 1, popupTrigger, button); JNodeGenericPeer.eventQueue.postEvent(me); return source; } |
ex.printStackTrace(); | log.warn("In constructor: ", ex); | public Screen5250(Gui5250 gui, SessionConfig config) {// ImageIcon ic = new ImageIcon("transtable1.jpg");// tileimage = ic.getImage(); this.gui = gui; this.config = config; // load the session properties from it's profile. loadProps(); try { jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } |
System.out.println("Copying"); | log.debug("Copying"); | protected final void copyField(int pos) { Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); StringBuffer s = new StringBuffer(); screenFields.saveCurrentField(); isInField(pos); System.out.println("Copying"); StringSelection contents = new StringSelection(screenFields.getCurrentFieldText()); cb.setContents(contents, null); screenFields.restoreCurrentField(); } |
System.out.println("Copying" + workR); | log.debug("Copying" + workR); | public final void copyMe() { Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); StringBuffer s = new StringBuffer(); // lets get the bounding area using a rectangle that we have already // allocated getBoundingArea(workR); gui.rubberband.reset(); gui.repaint(); System.out.println("Copying" + workR); // loop through all the screen characters to send them to the clip board int m = workR.x; int i = 0; int t = 0; while (workR.height-- > 0) { t = workR.width; i = workR.y; while (t-- > 0) { // only copy printable characters (in this case >= ' ') char c = screen[getPos(m - 1,i - 1)].getChar(); if (c >= ' ' && !screen[getPos(m - 1,i - 1)].nonDisplay) s.append(c); else s.append(' '); i++; } s.append('\n'); m++; } StringSelection contents = new StringSelection(s.toString()); cb.setContents(contents, null); } |
if(log.isDebugEnabled()) { log.debug((getRow(pos)) + "," + (getCol(pos))); log.debug(e.getX() + "," + e.getY()+ "," + fmWidth+ "," + fmHeight); } | public void moveCursor (MouseEvent e) { if(!keyboardLocked) { int pos = getPosFromView(e.getX(),e.getY());// System.out.println((getRow(pos)) + "," + (getCol(pos)));// System.out.println(e.getX() + "," + e.getY()+ "," + fmWidth+ "," + fmHeight); if (pos < 0) return ; // because getRowColFromPoint returns offset of 1,1 we need to // translate to offset 0,0// pos -= (numCols + 1); int g = screen[pos].getWhichGUI(); // lets check for hot spots if (g >= ScreenChar.BUTTON_LEFT && g <= ScreenChar.BUTTON_LAST) { StringBuffer aid = new StringBuffer(); boolean aidFlag = true; switch (g) { case ScreenChar.BUTTON_RIGHT: case ScreenChar.BUTTON_MIDDLE: while (screen[--pos].getWhichGUI() != ScreenChar.BUTTON_LEFT) { } case ScreenChar.BUTTON_LEFT: if (screen[pos].getChar() == 'F') { pos++; } else aidFlag=false; if (screen[pos+1].getChar() != '=' && screen[pos+1].getChar() != '.' && screen[pos+1].getChar() != '/' ) {// System.out.println(" Hotspot clicked!!! we will send characters " +// screen[pos].getChar() +// screen[pos+1].getChar()); aid.append(screen[pos].getChar()); aid.append(screen[pos + 1].getChar()); } else {// System.out.println(" Hotspot clicked!!! we will send character " +// screen[pos].getChar());// aid.append(screen[pos].getChar()); } break; } if (aidFlag) { switch (g) { case ScreenChar.BUTTON_LEFT_UP: case ScreenChar.BUTTON_MIDDLE_UP: case ScreenChar.BUTTON_RIGHT_UP: case ScreenChar.BUTTON_ONE_UP: case ScreenChar.BUTTON_SB_UP: case ScreenChar.BUTTON_SB_GUIDE: gui.sendAidKey(tnvt.AID_ROLL_UP); break; case ScreenChar.BUTTON_LEFT_DN: case ScreenChar.BUTTON_MIDDLE_DN: case ScreenChar.BUTTON_RIGHT_DN: case ScreenChar.BUTTON_ONE_DN: case ScreenChar.BUTTON_SB_DN: case ScreenChar.BUTTON_SB_THUMB: gui.sendAidKey(tnvt.AID_ROLL_DOWN); break; case ScreenChar.BUTTON_LEFT_EB: case ScreenChar.BUTTON_MIDDLE_EB: case ScreenChar.BUTTON_RIGHT_EB: System.out.println("Send to external Browser"); break; default: int aidKey = Integer.parseInt(aid.toString()); if (aidKey >= 1 && aidKey <= 12) gui.sendAidKey(0x30 + aidKey); if (aidKey >= 13 && aidKey <= 24) gui.sendAidKey(0xB0 + (aidKey - 12)); } } else { if (screenFields.getCurrentField() != null) { int xPos = screenFields.getCurrentField().startPos(); for (int x = 0; x < aid.length(); x++) {// System.out.println(sr + "," + (sc + x) + " " + aid.charAt(x)); screen[xPos + x].setChar(aid.charAt(x)); }// System.out.println(aid); screenFields.setCurrentFieldMDT(); gui.sendAidKey(tnvt.AID_ENTER); } } } else { // this is a note to not execute this code here when we implement // the remain after edit function option. if (gui.rubberband.isAreaSelected()) { gui.rubberband.reset(); gui.repaint(); } else { goto_XY(pos); isInField(lastPos); } } } gui.requestFocus(); } |
|
log.debug(" Hotspot clicked!!! we will send character " + screen[pos].getChar()); | public void moveCursor (MouseEvent e) { if(!keyboardLocked) { int pos = getPosFromView(e.getX(),e.getY());// System.out.println((getRow(pos)) + "," + (getCol(pos)));// System.out.println(e.getX() + "," + e.getY()+ "," + fmWidth+ "," + fmHeight); if (pos < 0) return ; // because getRowColFromPoint returns offset of 1,1 we need to // translate to offset 0,0// pos -= (numCols + 1); int g = screen[pos].getWhichGUI(); // lets check for hot spots if (g >= ScreenChar.BUTTON_LEFT && g <= ScreenChar.BUTTON_LAST) { StringBuffer aid = new StringBuffer(); boolean aidFlag = true; switch (g) { case ScreenChar.BUTTON_RIGHT: case ScreenChar.BUTTON_MIDDLE: while (screen[--pos].getWhichGUI() != ScreenChar.BUTTON_LEFT) { } case ScreenChar.BUTTON_LEFT: if (screen[pos].getChar() == 'F') { pos++; } else aidFlag=false; if (screen[pos+1].getChar() != '=' && screen[pos+1].getChar() != '.' && screen[pos+1].getChar() != '/' ) {// System.out.println(" Hotspot clicked!!! we will send characters " +// screen[pos].getChar() +// screen[pos+1].getChar()); aid.append(screen[pos].getChar()); aid.append(screen[pos + 1].getChar()); } else {// System.out.println(" Hotspot clicked!!! we will send character " +// screen[pos].getChar());// aid.append(screen[pos].getChar()); } break; } if (aidFlag) { switch (g) { case ScreenChar.BUTTON_LEFT_UP: case ScreenChar.BUTTON_MIDDLE_UP: case ScreenChar.BUTTON_RIGHT_UP: case ScreenChar.BUTTON_ONE_UP: case ScreenChar.BUTTON_SB_UP: case ScreenChar.BUTTON_SB_GUIDE: gui.sendAidKey(tnvt.AID_ROLL_UP); break; case ScreenChar.BUTTON_LEFT_DN: case ScreenChar.BUTTON_MIDDLE_DN: case ScreenChar.BUTTON_RIGHT_DN: case ScreenChar.BUTTON_ONE_DN: case ScreenChar.BUTTON_SB_DN: case ScreenChar.BUTTON_SB_THUMB: gui.sendAidKey(tnvt.AID_ROLL_DOWN); break; case ScreenChar.BUTTON_LEFT_EB: case ScreenChar.BUTTON_MIDDLE_EB: case ScreenChar.BUTTON_RIGHT_EB: System.out.println("Send to external Browser"); break; default: int aidKey = Integer.parseInt(aid.toString()); if (aidKey >= 1 && aidKey <= 12) gui.sendAidKey(0x30 + aidKey); if (aidKey >= 13 && aidKey <= 24) gui.sendAidKey(0xB0 + (aidKey - 12)); } } else { if (screenFields.getCurrentField() != null) { int xPos = screenFields.getCurrentField().startPos(); for (int x = 0; x < aid.length(); x++) {// System.out.println(sr + "," + (sc + x) + " " + aid.charAt(x)); screen[xPos + x].setChar(aid.charAt(x)); }// System.out.println(aid); screenFields.setCurrentFieldMDT(); gui.sendAidKey(tnvt.AID_ENTER); } } } else { // this is a note to not execute this code here when we implement // the remain after edit function option. if (gui.rubberband.isAreaSelected()) { gui.rubberband.reset(); gui.repaint(); } else { goto_XY(pos); isInField(lastPos); } } } gui.requestFocus(); } |
|
System.out.println("Send to external Browser"); | log.info("Send to external Browser"); | public void moveCursor (MouseEvent e) { if(!keyboardLocked) { int pos = getPosFromView(e.getX(),e.getY());// System.out.println((getRow(pos)) + "," + (getCol(pos)));// System.out.println(e.getX() + "," + e.getY()+ "," + fmWidth+ "," + fmHeight); if (pos < 0) return ; // because getRowColFromPoint returns offset of 1,1 we need to // translate to offset 0,0// pos -= (numCols + 1); int g = screen[pos].getWhichGUI(); // lets check for hot spots if (g >= ScreenChar.BUTTON_LEFT && g <= ScreenChar.BUTTON_LAST) { StringBuffer aid = new StringBuffer(); boolean aidFlag = true; switch (g) { case ScreenChar.BUTTON_RIGHT: case ScreenChar.BUTTON_MIDDLE: while (screen[--pos].getWhichGUI() != ScreenChar.BUTTON_LEFT) { } case ScreenChar.BUTTON_LEFT: if (screen[pos].getChar() == 'F') { pos++; } else aidFlag=false; if (screen[pos+1].getChar() != '=' && screen[pos+1].getChar() != '.' && screen[pos+1].getChar() != '/' ) {// System.out.println(" Hotspot clicked!!! we will send characters " +// screen[pos].getChar() +// screen[pos+1].getChar()); aid.append(screen[pos].getChar()); aid.append(screen[pos + 1].getChar()); } else {// System.out.println(" Hotspot clicked!!! we will send character " +// screen[pos].getChar());// aid.append(screen[pos].getChar()); } break; } if (aidFlag) { switch (g) { case ScreenChar.BUTTON_LEFT_UP: case ScreenChar.BUTTON_MIDDLE_UP: case ScreenChar.BUTTON_RIGHT_UP: case ScreenChar.BUTTON_ONE_UP: case ScreenChar.BUTTON_SB_UP: case ScreenChar.BUTTON_SB_GUIDE: gui.sendAidKey(tnvt.AID_ROLL_UP); break; case ScreenChar.BUTTON_LEFT_DN: case ScreenChar.BUTTON_MIDDLE_DN: case ScreenChar.BUTTON_RIGHT_DN: case ScreenChar.BUTTON_ONE_DN: case ScreenChar.BUTTON_SB_DN: case ScreenChar.BUTTON_SB_THUMB: gui.sendAidKey(tnvt.AID_ROLL_DOWN); break; case ScreenChar.BUTTON_LEFT_EB: case ScreenChar.BUTTON_MIDDLE_EB: case ScreenChar.BUTTON_RIGHT_EB: System.out.println("Send to external Browser"); break; default: int aidKey = Integer.parseInt(aid.toString()); if (aidKey >= 1 && aidKey <= 12) gui.sendAidKey(0x30 + aidKey); if (aidKey >= 13 && aidKey <= 24) gui.sendAidKey(0xB0 + (aidKey - 12)); } } else { if (screenFields.getCurrentField() != null) { int xPos = screenFields.getCurrentField().startPos(); for (int x = 0; x < aid.length(); x++) {// System.out.println(sr + "," + (sc + x) + " " + aid.charAt(x)); screen[xPos + x].setChar(aid.charAt(x)); }// System.out.println(aid); screenFields.setCurrentFieldMDT(); gui.sendAidKey(tnvt.AID_ENTER); } } } else { // this is a note to not execute this code here when we implement // the remain after edit function option. if (gui.rubberband.isAreaSelected()) { gui.rubberband.reset(); gui.repaint(); } else { goto_XY(pos); isInField(lastPos); } } } gui.requestFocus(); } |
System.out.println("pasted >" + pd + "<"); | log.debug("pasted >" + pd + "<"); | protected final void pasteMe(boolean special) { setCursorActive(false); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable content = cb.getContents(this); try { StringBuffer sb = new StringBuffer((String)content.getTransferData(DataFlavor.stringFlavor)); StringBuffer pd = new StringBuffer(); int r = getRow(lastPos); int nextChar = 0; int nChars = sb.length(); boolean omitLF = false; boolean done = false; screenFields.saveCurrentField(); int lr = getRow(lastPos); int lc = getCol(lastPos); resetDirty(lastPos); while (!done) { if (nextChar >= nChars) { /* EOF */ done = true; break; } pd.setLength(0); boolean eol = false; char c = 0; int i; /* Skip a leftover '\n', if necessary */ if (omitLF && (sb.charAt(nextChar) == '\n')) nextChar++; boolean skipLF = false; omitLF = false; charLoop: for (i = nextChar; i < nChars; i++) { c = sb.charAt(i); if ((c == '\n') || (c == '\r')) { eol = true; break charLoop; } } int startChar = nextChar; nextChar = i; pd.append(sb.substring(startChar, startChar + (i - startChar))); if (eol) { nextChar++; if (c == '\r') { skipLF = true; } } System.out.println("pasted >" + pd + "<"); int col = getCol(lastPos); int t = numCols - col; if (t > pd.length()) t = pd.length(); int p = 0; char pc; boolean setIt; while (t-- > 0) { pc = pd.charAt(p); setIt = true; if (special && (!Character.isLetter(pc) && !Character.isDigit(pc))) setIt = false; if (isInField(r,col) && setIt) { screen[getPos(r,col)].setChar(pc); setDirty(r,col); screenFields.setCurrentFieldMDT(); } p++; if (setIt) col++; } r++; } screenFields.restoreCurrentField(); updateDirty(); goto_XY(lr+1,lc+1); setCursorActive(true); } catch (Throwable exc) { System.err.println(exc); } } |
System.err.println(exc); | log.warn(""+exc.getMessage()); | protected final void pasteMe(boolean special) { setCursorActive(false); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable content = cb.getContents(this); try { StringBuffer sb = new StringBuffer((String)content.getTransferData(DataFlavor.stringFlavor)); StringBuffer pd = new StringBuffer(); int r = getRow(lastPos); int nextChar = 0; int nChars = sb.length(); boolean omitLF = false; boolean done = false; screenFields.saveCurrentField(); int lr = getRow(lastPos); int lc = getCol(lastPos); resetDirty(lastPos); while (!done) { if (nextChar >= nChars) { /* EOF */ done = true; break; } pd.setLength(0); boolean eol = false; char c = 0; int i; /* Skip a leftover '\n', if necessary */ if (omitLF && (sb.charAt(nextChar) == '\n')) nextChar++; boolean skipLF = false; omitLF = false; charLoop: for (i = nextChar; i < nChars; i++) { c = sb.charAt(i); if ((c == '\n') || (c == '\r')) { eol = true; break charLoop; } } int startChar = nextChar; nextChar = i; pd.append(sb.substring(startChar, startChar + (i - startChar))); if (eol) { nextChar++; if (c == '\r') { skipLF = true; } } System.out.println("pasted >" + pd + "<"); int col = getCol(lastPos); int t = numCols - col; if (t > pd.length()) t = pd.length(); int p = 0; char pc; boolean setIt; while (t-- > 0) { pc = pd.charAt(p); setIt = true; if (special && (!Character.isLetter(pc) && !Character.isDigit(pc))) setIt = false; if (isInField(r,col) && setIt) { screen[getPos(r,col)].setChar(pc); setDirty(r,col); screenFields.setCurrentFieldMDT(); } p++; if (setIt) col++; } r++; } screenFields.restoreCurrentField(); updateDirty(); goto_XY(lr+1,lc+1); setCursorActive(true); } catch (Throwable exc) { System.err.println(exc); } } |
System.out.println(getStringProperty("cursorBlink")); | log.debug(getStringProperty("cursorBlink")); | public void propertyChange(PropertyChangeEvent pce) { String pn = pce.getPropertyName(); boolean resetAttr = false; if (pn.equals("colorBg")) { colorBg = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorBlue")) { colorBlue = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorTurq")) { colorTurq = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorRed")) { colorRed = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorWhite")) { colorWhite = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorYellow")) { colorYellow = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorGreen")) { colorGreen = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorPink")) { colorPink = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorGUIField")) { colorGUIField = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorCursor")) { colorCursor = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorSep")) { colorSep = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("colorHexAttr")) { colorHexAttr = (Color)pce.getNewValue(); resetAttr = true; } if (pn.equals("cursorSize")) { if (pce.getNewValue().equals("Full")) cursorSize = 2; if (pce.getNewValue().equals("Half")) cursorSize = 1; if (pce.getNewValue().equals("Line")) cursorSize = 0; } if (pn.equals("crossHair")) { if (pce.getNewValue().equals("None")) crossHair = 0; if (pce.getNewValue().equals("Horz")) crossHair = 1; if (pce.getNewValue().equals("Vert")) crossHair = 2; if (pce.getNewValue().equals("Both")) crossHair = 3; } if (pn.equals("rulerFixed")) { if (pce.getNewValue().equals("Yes")) rulerFixed = true; else rulerFixed = false; } if (pn.equals("colSeparator")) { if (pce.getNewValue().equals("Line")) colSepLine = 0; if (pce.getNewValue().equals("ShortLine")) colSepLine = 1; if (pce.getNewValue().equals("Dot")) colSepLine = 2; if (pce.getNewValue().equals("Hide")) colSepLine = 3; } if (pn.equals("showAttr")) { if (pce.getNewValue().equals("Hex")) showHex = true; else showHex= false; } if (pn.equals("guiInterface")) { if (pce.getNewValue().equals("Yes")) guiInterface = true; else guiInterface = false; } if (pn.equals("guiShowUnderline")) { if (pce.getNewValue().equals("Yes")) guiShowUnderline = true; else guiShowUnderline = false; } if (pn.equals("hotspots")) { if (pce.getNewValue().equals("Yes")) hotSpots = true; else hotSpots = false; } if (pn.equals("defaultPrinter")) { if (pce.getNewValue().equals("Yes")) defaultPrinter = true; else defaultPrinter = false; } if (pn.equals("resetRequired")) { if (pce.getNewValue().equals("Yes")) resetRequired = true; else resetRequired = false; } if (pn.equals("hsMore")) { hsMore.setLength(0); hsMore.append((String)pce.getNewValue()); } if (pn.equals("hsBottom")) { hsBottom.setLength(0); hsBottom.append((String)pce.getNewValue()); } if (pn.equals("font")) { font = new Font((String)pce.getNewValue(),Font.PLAIN,14); updateFont = true; } if (pn.equals("useAntialias")) { if (pce.getNewValue().equals("Yes")) bi.setUseAntialias(true); else bi.setUseAntialias(false); updateFont = true; } if (pn.equals("fontScaleHeight")) {// try { sfh = Float.parseFloat((String)pce.getNewValue()); updateFont = true;// } } if (pn.equals("fontScaleWidth")) {// try { sfw = Float.parseFloat((String)pce.getNewValue()); updateFont = true;// } } if (pn.equals("fontPointSize")) {// try { ps132 = Float.parseFloat((String)pce.getNewValue()); updateFont = true;// } } if (pn.equals("cursorBottOffset")) { cursorBottOffset = getIntProperty("cursorBottOffset"); } if (pn.equals("cursorBlink")) { System.out.println(getStringProperty("cursorBlink")); if (pce.getNewValue().equals("Yes")) { if (blinker == null) { blinker = new javax.swing.Timer(500,this); blinker.start(); } } else { if (blinker != null) { blinker.stop(); blinker = null; } } } if (updateFont) { Rectangle r = gui.getDrawingBounds(); resizeScreenArea(r.width,r.height); updateFont = false; } if (resetAttr) { for (int y = 0;y < lenScreen; y++) { screen[y].setAttribute(screen[y].getCharAttr()); } bi.drawOIA(fmWidth,fmHeight,numRows,numCols,font,colorBg,colorBlue); } gui.validate(); gui.repaint(); } |
System.out.println(" send keys mnemonic " + s); | log.info(" send keys mnemonic " + s); | public void sendKeys(String text) {// if (text == null) {// return;// } if (isStatusErrorCode() && !resetRequired) { setCursorActive(false); simulateMnemonic(getMnemonicValue("[reset]")); setCursorActive(true); } if (keyboardLocked) { if(text.equals("[reset]") || text.equals("[sysreq]") || text.equals("[attn]")) { setCursorActive(false); simulateMnemonic(getMnemonicValue(text)); setCursorActive(true); } else { if (isStatusErrorCode()) { Toolkit.getDefaultToolkit().beep(); return; } keysBuffered = true; setKBIndicatorOn(); if(bufferedKeys == null){ bufferedKeys = text; return; } else { bufferedKeys += text; return; } } } else { if (keysBuffered) { if (bufferedKeys != null) { text = bufferedKeys + text; }// if (text.length() == 0) { keysBuffered = false; setKBIndicatorOff();// } bufferedKeys = null; } // check to see if position is in a field and if it is then change // current field to that field isInField(lastPos,true); if (text.length() == 1 && !text.equals("[") && !text.equals("]")) {// setCursorOff2(); setCursorActive(false); simulateKeyStroke(text.charAt(0)); setCursorActive(true);// setCursorOn2();// System.out.println(" text one"); } else { strokenizer.setKeyStrokes(text); String s; boolean done = false;// setCursorOff2(); setCursorActive(false); while (!done) {// while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked &&// !isStatusErrorCode() && !done) { if (strokenizer.hasMoreKeyStrokes()) { // check to see if position is in a field and if it is then change // current field to that field isInField(lastPos,true); s = strokenizer.nextKeyStroke(); if (s.length() == 1) {// setCursorOn();// if (!keysBuffered) {// System.out.println(" s two" + s);// setCursorOn();// }// try { new Thread().sleep(400);} catch (InterruptedException ie) {} simulateKeyStroke(s.charAt(0));// System.out.println(" s two " + s + " " + cursorActive);// if (cursorActive && !keysBuffered) {// System.out.println(" s two" + s);// setCursorOn();// } } else { if (s != null) { simulateMnemonic(getMnemonicValue(s));// if (!cursorActive && !keysBuffered) {// System.out.println(" m one");// setCursorOn();// } } else System.out.println(" send keys mnemonic " + s); } if (keyboardLocked) { bufferedKeys = strokenizer.getUnprocessedKeyStroked(); if (bufferedKeys != null) { keysBuffered = true; setKBIndicatorOn(); } done = true; } } else {// setCursorActive(true);// setCursorOn(); done = true; } } setCursorActive(true); } } } |
System.out.println(" Mnemonic not supported " + mnem); | log.info(" Mnemonic not supported " + mnem); | protected boolean simulateMnemonic(int mnem){ boolean simulated = false; switch (mnem) { case AID_CLEAR : case AID_ENTER : case AID_PF1 : case AID_PF2 : case AID_PF3 : case AID_PF4 : case AID_PF5 : case AID_PF6 : case AID_PF7 : case AID_PF8 : case AID_PF9 : case AID_PF10 : case AID_PF11 : case AID_PF12 : case AID_PF13 : case AID_PF14 : case AID_PF15 : case AID_PF16 : case AID_PF17 : case AID_PF18 : case AID_PF19 : case AID_PF20 : case AID_PF21 : case AID_PF22 : case AID_PF23 : case AID_PF24 : case AID_ROLL_DOWN : case AID_ROLL_UP : case AID_ROLL_LEFT : case AID_ROLL_RIGHT : if (!screenFields.isCanSendAid()) { displayError(ERR_ENTER_NO_ALLOWED); } else sendAid(mnem); simulated = true; break; case AID_HELP : sessionVT.sendHelpRequest(); simulated = true; break; case AID_PRINT : sessionVT.hostPrint(1); simulated = true; break; case BACK_SPACE : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { if (screenFields.getCurrentField().startPos() == lastPos) displayError(ERR_CURSOR_PROTECTED); else { screenFields.getCurrentField().getKeyPos(lastPos); screenFields.getCurrentField().changePos(-1); resetDirty(screenFields.getCurrentField().getCurrentPos()); shiftLeft(screenFields.getCurrentField().getCurrentPos()); updateDirty(); screenFields.setCurrentFieldMDT(); simulated = true; } } else { displayError(ERR_CURSOR_PROTECTED); } break; case BACK_TAB : if (screenFields.getCurrentField() != null && screenFields.isCurrentFieldHighlightedEntry()) { resetDirty(screenFields.getCurrentField().startPos); gotoFieldPrev(); updateDirty(); } else gotoFieldPrev(); if (screenFields.isCurrentFieldContinued()) { do { gotoFieldPrev(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } isInField(lastPos); simulated = true; break; case UP : case MARK_UP : process_XY(lastPos - numCols); simulated = true; break; case DOWN : case MARK_DOWN : process_XY(lastPos + numCols); simulated = true; break; case LEFT : case MARK_LEFT : process_XY(lastPos - 1); simulated = true; break; case RIGHT : case MARK_RIGHT : process_XY(lastPos + 1); simulated = true; break; case NEXTWORD : gotoNextWord(); simulated = true; break; case PREVWORD : gotoPrevWord(); simulated = true; break; case DELETE : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { resetDirty(lastPos); screenFields.getCurrentField().getKeyPos(lastPos); shiftLeft(screenFields.getCurrentFieldPos()); screenFields.setCurrentFieldMDT(); updateDirty(); simulated = true; } else { displayError(ERR_CURSOR_PROTECTED); } break; case TAB : if (screenFields.getCurrentField() != null && !screenFields.isCurrentFieldContinued()) { if (screenFields.isCurrentFieldHighlightedEntry()) { resetDirty(screenFields.getCurrentField().startPos); gotoFieldNext(); updateDirty(); } else gotoFieldNext(); } else { do { gotoFieldNext(); } while (screenFields.getCurrentField() != null && (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast())); } isInField(lastPos); simulated = true; break; case EOF : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int where = endOfField(screenFields.getCurrentField().startPos(),true); if (where > 0) { goto_XY((where / numCols) + 1,(where % numCols) + 1); } simulated = true; } else { displayError(ERR_CURSOR_PROTECTED); } resetDirty(lastPos); break; case ERASE_EOF : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int where = lastPos; resetDirty(lastPos); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); if (screenFields.isCurrentFieldContinued()) fieldExit(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } } updateDirty(); goto_XY(where); simulated = true; } else { displayError(ERR_CURSOR_PROTECTED); } break; case ERASE_FIELD : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int where = lastPos; lastPos = screenFields.getCurrentField().startPos(); resetDirty(lastPos); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); if (screenFields.isCurrentFieldContinued()) fieldExit(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } } updateDirty(); goto_XY(where); simulated = true; } else { displayError(ERR_CURSOR_PROTECTED); } break; case INSERT : // we toggle it insertMode = insertMode ? false : true; break; case HOME : // position to the home position set if (lastPos + numCols + 1 != homePos) { goto_XY(homePos - numCols - 1); // now check if we are in a field isInField(lastPos); } else gotoField(1); break; case KEYPAD_0 : simulated = simulateKeyStroke('0'); break; case KEYPAD_1 : simulated = simulateKeyStroke('1'); break; case KEYPAD_2 : simulated = simulateKeyStroke('2'); break; case KEYPAD_3 : simulated = simulateKeyStroke('3'); break; case KEYPAD_4 : simulated = simulateKeyStroke('4'); break; case KEYPAD_5 : simulated = simulateKeyStroke('5'); break; case KEYPAD_6 : simulated = simulateKeyStroke('6'); break; case KEYPAD_7 : simulated = simulateKeyStroke('7'); break; case KEYPAD_8 : simulated = simulateKeyStroke('8'); break; case KEYPAD_9 : simulated = simulateKeyStroke('9'); break; case KEYPAD_PERIOD : simulated = simulateKeyStroke('.'); break; case KEYPAD_COMMA : simulated = simulateKeyStroke(','); break; case KEYPAD_MINUS : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int s = screenFields.getCurrentField().getFieldShift(); if (s == 3 || s == 5 || s == 7) { screen[lastPos].setChar('-'); resetDirty(lastPos); advancePos(); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } simulated = true; updateDirty(); if (screenFields.isCurrentFieldAutoEnter()) sendAid(AID_ENTER); } } else { displayError(ERR_FIELD_MINUS); } } else { displayError(ERR_CURSOR_PROTECTED); } break; case FIELD_EXIT : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { resetDirty(lastPos); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); if (screenFields.isCurrentFieldContinued()) fieldExit(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } } updateDirty(); simulated = true; if (screenFields.isCurrentFieldAutoEnter()) sendAid(AID_ENTER); } else { displayError(ERR_CURSOR_PROTECTED); } break; case FIELD_PLUS : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { resetDirty(lastPos); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } } updateDirty(); simulated = true; if (screenFields.isCurrentFieldAutoEnter()) sendAid(AID_ENTER); } else { displayError(ERR_CURSOR_PROTECTED); } break; case FIELD_MINUS : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int s = screenFields.getCurrentField().getFieldShift(); if (s == 3 || s == 5 || s == 7) { screen[lastPos].setChar('-'); resetDirty(lastPos); advancePos(); if (fieldExit()) { screenFields.setCurrentFieldMDT(); if (!screenFields.isCurrentFieldContinued()) { gotoFieldNext(); } else { do { gotoFieldNext(); } while (screenFields.isCurrentFieldContinuedMiddle() || screenFields.isCurrentFieldContinuedLast()); } } updateDirty(); simulated = true; if (screenFields.isCurrentFieldAutoEnter()) sendAid(AID_ENTER); } else { displayError(ERR_FIELD_MINUS); } } else { displayError(ERR_CURSOR_PROTECTED); } break; case BOF : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { int where = screenFields.getCurrentField().startPos(); if (where > 0) { goto_XY(where); } simulated = true; } else { displayError(ERR_CURSOR_PROTECTED); } resetDirty(lastPos); break; case SYSREQ : sessionVT.systemRequest(); simulated = true; break; case RESET : if (isStatusErrorCode()) { resetError(); isInField(lastPos); updateDirty(); } else { setPrehelpState(false,isKeyboardLocked(),false); } gui.repaint(); simulated = true; break; case COPY : copyMe(); break; case PASTE : pasteMe(false); break; case ATTN : sessionVT.sendAttentionKey(); simulated = true; break; case DUP_FIELD : if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { if (screenFields.isCurrentFieldDupEnabled()) { resetDirty(lastPos); screenFields.getCurrentField().setFieldChar(lastPos,(char)0x1C); screenFields.setCurrentFieldMDT(); gotoFieldNext(); updateDirty(); simulated = true; } else { displayError(ERR_DUP_KEY_NOT_ALLOWED); } } else { displayError(ERR_CURSOR_PROTECTED); } break; case NEW_LINE : if (screenFields.getSize() > 0) { int startRow = getRow(lastPos) + 1; int startPos = lastPos; boolean isthere = false; if (startRow == getRows()) startRow = 0; goto_XY(++startRow,1); if (!isInField() && screenFields.getCurrentField() != null && !screenFields.isCurrentFieldBypassField()) { while (!isInField() && screenFields.getCurrentField() != null && !screenFields.isCurrentFieldBypassField()) { // lets keep going advancePos(); // Have we looped the screen? if (lastPos == startPos) { // if so then go back to starting point goto_XY(startPos); break; } } } } simulated = true; break; case JUMP_NEXT_SESS : gui.nextSession(); simulated = true; break; case JUMP_PREV_SESS : gui.prevSession(); simulated = true; break; default : System.out.println(" Mnemonic not supported " + mnem); break; } return simulated; } |
log.debug("Summing"); | protected final Vector sumThem(boolean which) { StringBuffer s = new StringBuffer(); getBoundingArea(workR);// gui.rubberband.reset();// gui.repaint();// System.out.println("Summing"); // obtain the decimal format for parsing DecimalFormat df = (DecimalFormat)NumberFormat.getInstance() ; DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); if (which) { dfs.setDecimalSeparator('.'); dfs.setGroupingSeparator(','); } else { dfs.setDecimalSeparator(','); dfs.setGroupingSeparator('.'); } df.setDecimalFormatSymbols(dfs); Vector sumVector = new Vector(); // loop through all the screen characters to send them to the clip board int m = workR.x; int i = 0; int t = 0; double sum = 0.0; while (workR.height-- > 0) { t = workR.width; i = workR.y; while (t-- > 0) { // only copy printable numeric characters (in this case >= ' ') char c = screen[getPos(m - 1,i - 1)].getChar(); if (((c >= '0' && c <= '9') || c== '.' || c == ',' || c == '-') && !screen[getPos(m - 1,i - 1)].nonDisplay) { s.append(c); } i++; } if (s.length() > 0) { if (s.charAt(s.length()-1) == '-') { s.insert(0,'-'); s.deleteCharAt(s.length()-1); } try { Number n = df.parse(s.toString());// System.out.println(s + " " + n.doubleValue()); sumVector.add(new Double(n.doubleValue())); sum += n.doubleValue(); } catch (ParseException pe) { System.out.println(pe.getMessage() + " at " + pe.getErrorOffset()); } } s.setLength(0); m++; }// System.out.println(sum); return sumVector; } |
|
log.debug(""+sum); | protected final Vector sumThem(boolean which) { StringBuffer s = new StringBuffer(); getBoundingArea(workR);// gui.rubberband.reset();// gui.repaint();// System.out.println("Summing"); // obtain the decimal format for parsing DecimalFormat df = (DecimalFormat)NumberFormat.getInstance() ; DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); if (which) { dfs.setDecimalSeparator('.'); dfs.setGroupingSeparator(','); } else { dfs.setDecimalSeparator(','); dfs.setGroupingSeparator('.'); } df.setDecimalFormatSymbols(dfs); Vector sumVector = new Vector(); // loop through all the screen characters to send them to the clip board int m = workR.x; int i = 0; int t = 0; double sum = 0.0; while (workR.height-- > 0) { t = workR.width; i = workR.y; while (t-- > 0) { // only copy printable numeric characters (in this case >= ' ') char c = screen[getPos(m - 1,i - 1)].getChar(); if (((c >= '0' && c <= '9') || c== '.' || c == ',' || c == '-') && !screen[getPos(m - 1,i - 1)].nonDisplay) { s.append(c); } i++; } if (s.length() > 0) { if (s.charAt(s.length()-1) == '-') { s.insert(0,'-'); s.deleteCharAt(s.length()-1); } try { Number n = df.parse(s.toString());// System.out.println(s + " " + n.doubleValue()); sumVector.add(new Double(n.doubleValue())); sum += n.doubleValue(); } catch (ParseException pe) { System.out.println(pe.getMessage() + " at " + pe.getErrorOffset()); } } s.setLength(0); m++; }// System.out.println(sum); return sumVector; } |
|
if(pos >= screen.length) { pos = screen.length-1; } | public Point translateEnd(Point end) { // because getRowColFromPoint returns position offset as 1,1 we need // to translate as offset 0,0 int pos = getPosFromView(end.x,end.y); int x = screen[pos].x + fmWidth - 1; int y = screen[pos].y + fmHeight - 1; end.setLocation(x,y); return end; } |
|
s.setScreenData(text,startPos); | int y = length; cursorPos = startPos; int len = text.length(); char[] c = text.toCharArray(); char tc = ' '; | public void setString(String text) {// int y = length;// cursorPos = startPos;// int len = text.length();// char[] c = text.toCharArray();// char tc = ' ';// for (int x = 0; x < y; x++) {// tc = ' ';// if (x < len) {// tc = c[x];// }// data[x] = tc; s.setScreenData(text,startPos);// changePos(1);// } } |
for (int x = 0; x < y; x++) { tc = ' '; if (x < len) { tc = c[x]; } s.getPlanes().setChar(cursorPos,tc); changePos(1); } setMDT(); s.getScreenFields().setMasterMDT(); | public void setString(String text) {// int y = length;// cursorPos = startPos;// int len = text.length();// char[] c = text.toCharArray();// char tc = ' ';// for (int x = 0; x < y; x++) {// tc = ' ';// if (x < len) {// tc = c[x];// }// data[x] = tc; s.setScreenData(text,startPos);// changePos(1);// } } |
|
throw new BAD_OPERATION("Invalid enumeration code " + code); | BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code); bad.minor = Minor.PolicyType; throw bad; | public static RequestProcessingPolicyValue from_int(int code) { try { return enume [ code ]; } catch (ArrayIndexOutOfBoundsException ex) { throw new BAD_OPERATION("Invalid enumeration code " + code); } } |
if (this instanceof Cloneable) | public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) return super.clone(); else throw new CloneNotSupportedException(); } |
|
else throw new CloneNotSupportedException(); | public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) return super.clone(); else throw new CloneNotSupportedException(); } |
|
int cp = screen52.getCurrentPos(); | public final void saveScreen() throws IOException { ByteArrayOutputStream sc = new ByteArrayOutputStream(); sc.write(4); sc.write(0x12); // 18 sc.write(0); // 18 sc.write(0); // 18 sc.write((byte) screen52.getRows()); // store the current size sc.write((byte) screen52.getColumns()); // "" //int cp = screen52.getCurrentPos(); // save off current position // fix below submitted by Mitch Blevins int cp = screen52.getScreenFields().getCurrentFieldPos(); // save off current position sc.write((byte) (cp >> 8 & 0xff)); // "" sc.write((byte) (cp & 0xff)); // "" sc.write((byte) (screen52.homePos >> 8 & 0xff)); // save home pos sc.write((byte) (screen52.homePos & 0xff)); // "" int rows = screen52.getRows(); // store the current size int cols = screen52.getColumns(); // ""// byte[] sa = new byte[rows * cols]; fillRegenerationBuffer(sc,rows,cols);// fillScreenArray(sa, rows, cols);//// sc.write(sa);// sa = null; int sizeFields = screen52.getScreenFields().getSize(); sc.write((byte) (sizeFields >> 8 & 0xff)); // "" sc.write((byte) (sizeFields & 0xff)); // "" if (sizeFields > 0) { int x = 0; int s = screen52.getScreenFields().getSize(); ScreenField sf = null; while (x < s) { sf = screen52.getScreenFields().getField(x); sc.write((byte) sf.getAttr()); // attribute int sp = sf.startPos(); sc.write((byte) (sp >> 8 & 0xff)); // "" sc.write((byte) (sp & 0xff)); // "" if (sf.mdt) sc.write((byte) 1); else sc.write((byte) 0); sc.write((byte) (sf.getLength() >> 8 & 0xff)); // "" sc.write((byte) (sf.getLength() & 0xff)); // "" sc.write((byte) sf.getFFW1() & 0xff); sc.write((byte) sf.getFFW2() & 0xff); sc.write((byte) sf.getFCW1() & 0xff); sc.write((byte) sf.getFCW2() & 0xff); log.debug("Saved "); log.debug(sf.toString()); x++; } sf = null; } // The following two lines of code looks to have caused all sorts of // problems so for now we have commented them out. // screen52.getScreenFields().setCurrentField(null); // set it to null // for GC ? // screen52.clearTable(); try { writeGDS(0, 3, sc.toByteArray()); } catch (IOException ioe) { log.warn(ioe.getMessage()); } sc = null; log.debug("Save Screen end "); } |
|
int cp = screen52.getScreenFields().getCurrentFieldPos(); | public final void saveScreen() throws IOException { ByteArrayOutputStream sc = new ByteArrayOutputStream(); sc.write(4); sc.write(0x12); // 18 sc.write(0); // 18 sc.write(0); // 18 sc.write((byte) screen52.getRows()); // store the current size sc.write((byte) screen52.getColumns()); // "" //int cp = screen52.getCurrentPos(); // save off current position // fix below submitted by Mitch Blevins int cp = screen52.getScreenFields().getCurrentFieldPos(); // save off current position sc.write((byte) (cp >> 8 & 0xff)); // "" sc.write((byte) (cp & 0xff)); // "" sc.write((byte) (screen52.homePos >> 8 & 0xff)); // save home pos sc.write((byte) (screen52.homePos & 0xff)); // "" int rows = screen52.getRows(); // store the current size int cols = screen52.getColumns(); // ""// byte[] sa = new byte[rows * cols]; fillRegenerationBuffer(sc,rows,cols);// fillScreenArray(sa, rows, cols);//// sc.write(sa);// sa = null; int sizeFields = screen52.getScreenFields().getSize(); sc.write((byte) (sizeFields >> 8 & 0xff)); // "" sc.write((byte) (sizeFields & 0xff)); // "" if (sizeFields > 0) { int x = 0; int s = screen52.getScreenFields().getSize(); ScreenField sf = null; while (x < s) { sf = screen52.getScreenFields().getField(x); sc.write((byte) sf.getAttr()); // attribute int sp = sf.startPos(); sc.write((byte) (sp >> 8 & 0xff)); // "" sc.write((byte) (sp & 0xff)); // "" if (sf.mdt) sc.write((byte) 1); else sc.write((byte) 0); sc.write((byte) (sf.getLength() >> 8 & 0xff)); // "" sc.write((byte) (sf.getLength() & 0xff)); // "" sc.write((byte) sf.getFFW1() & 0xff); sc.write((byte) sf.getFFW2() & 0xff); sc.write((byte) sf.getFCW1() & 0xff); sc.write((byte) sf.getFCW2() & 0xff); log.debug("Saved "); log.debug(sf.toString()); x++; } sf = null; } // The following two lines of code looks to have caused all sorts of // problems so for now we have commented them out. // screen52.getScreenFields().setCurrentField(null); // set it to null // for GC ? // screen52.clearTable(); try { writeGDS(0, 3, sc.toByteArray()); } catch (IOException ioe) { log.warn(ioe.getMessage()); } sc = null; log.debug("Save Screen end "); } |
|
public View getLogicalView(FlowView fv) | protected View getLogicalView(FlowView fv) | public View getLogicalView(FlowView fv) { return fv.layoutPool; } |
else offset = -1; | protected int layoutRow(FlowView fv, int rowIndex, int pos) { View row = fv.getView(rowIndex); int axis = fv.getFlowAxis(); int span = fv.getFlowSpan(rowIndex); int x = fv.getFlowStart(rowIndex); int offset = pos; View logicalView = getLogicalView(fv); // Special case when span == 0. We need to layout the row as if it had // a span of Integer.MAX_VALUE. if (span == 0) span = Integer.MAX_VALUE; while (span > 0) { if (logicalView.getViewIndex(offset, Position.Bias.Forward) == -1) break; View view = createView(fv, offset, span, rowIndex); if (view == null) break; int viewSpan = (int) view.getPreferredSpan(axis); row.append(view); int breakWeight = view.getBreakWeight(axis, x, span); if (breakWeight >= View.ForcedBreakWeight) break; x += viewSpan; span -= viewSpan; offset += (view.getEndOffset() - view.getStartOffset()); } if (span < 0) { int flowStart = fv.getFlowStart(axis); int flowSpan = fv.getFlowSpan(axis); adjustRow(fv, rowIndex, flowSpan, flowStart); int rowViewCount = row.getViewCount(); offset = row.getView(rowViewCount - 1).getEndOffset(); } return offset != pos ? offset : -1; } |
|
{ | public AccessibleContext getAccessibleContext() { /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTCanvas(); } return accessibleContext; } |
|
} | public AccessibleContext getAccessibleContext() { /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTCanvas(); } return accessibleContext; } |
|
fireColumnAdded(new TableColumnModelEvent(this,0,tableColumns.size())); | fireColumnAdded(new TableColumnModelEvent(this, 0, tableColumns.size() - 1)); | public void addColumn(TableColumn col) { tableColumns.add(col); invalidateWidthCache(); fireColumnAdded(new TableColumnModelEvent(this,0,tableColumns.size())); } |
return tableColumns.indexOf(identifier, 0); | if (identifier == null) throw new IllegalArgumentException("Null identifier."); int columnCount = tableColumns.size(); for (int i = 0; i < columnCount; i++) { TableColumn tc = (TableColumn) tableColumns.get(i); if (identifier.equals(tc.getIdentifier())) return i; } throw new IllegalArgumentException("No TableColumn with that identifier."); | public int getColumnIndex(Object identifier) { return tableColumns.indexOf(identifier, 0); } |
Object tmp = tableColumns.get(i); tableColumns.set(i, tableColumns.get(j)); tableColumns.set(j, tmp); fireColumnAdded(new TableColumnModelEvent(this,i,j)); | int columnCount = getColumnCount(); if (i < 0 || i >= columnCount) throw new IllegalArgumentException("Index 'i' out of range."); if (j < 0 || j >= columnCount) throw new IllegalArgumentException("Index 'j' out of range."); Object column = tableColumns.remove(i); tableColumns.add(j, column); fireColumnAdded(new TableColumnModelEvent(this, i, j)); | public void moveColumn(int i, int j) { Object tmp = tableColumns.get(i); tableColumns.set(i, tableColumns.get(j)); tableColumns.set(j, tmp); fireColumnAdded(new TableColumnModelEvent(this,i,j)); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.