rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
int index = getColumnIndex(col); fireColumnRemoved(new TableColumnModelEvent(this,index,0));
int index = this.tableColumns.indexOf(col); if (index < 0) return; fireColumnRemoved(new TableColumnModelEvent(this, index, 0));
public void removeColumn(TableColumn col) { int index = getColumnIndex(col); fireColumnRemoved(new TableColumnModelEvent(this,index,0)); tableColumns.remove(col); invalidateWidthCache(); }
MenuItem(String label)
MenuItem()
MenuItem(String label){ this.label = label;}
this.label = label;
MenuItem(String label){ this.label = label;}
ParsedArguments cmdLine = HELP_INFO.parse(args); File dir = ARG_DIR.getFile(cmdLine); if (dir == null) { dir = new File(System.getProperty("user.dir")); } if (dir.exists() && dir.isDirectory()) { final File[] list = dir.listFiles(); printList(list); } else if("/".equals(dir.getCanonicalPath())) { File[] roots = File.listRoots(); printList(roots); } else if (dir.exists() && dir.isFile()) { printList(new File[] { dir }); } else { System.err.println("No such directory " + dir); }
new DirCommand().execute(new CommandLine(args), System.in, System.out, System.err);
public static void main(String[] args) throws Exception { ParsedArguments cmdLine = HELP_INFO.parse(args); File dir = ARG_DIR.getFile(cmdLine); if (dir == null) { dir = new File(System.getProperty("user.dir")); } if (dir.exists() && dir.isDirectory()) { final File[] list = dir.listFiles(); printList(list); } else if("/".equals(dir.getCanonicalPath())) { File[] roots = File.listRoots(); printList(roots); } else if (dir.exists() && dir.isFile()) { printList(new File[] { dir }); } else { System.err.println("No such directory " + dir); } }
private static void printList(File[] list) {
private void printList(File[] list, PrintStream out) {
private static void printList(File[] list) { if (list != null) { for (int i = 0; i < list.length; i++) { File f = list[i]; if (f.isDirectory()) { System.out.print("[" + f.getName() + "]"); } else { System.out.print(f.getName() + " " + f.length()); } System.out.println(); } System.out.println(); } }
System.out.print("[" + f.getName() + "]");
out.print("[" + f.getName() + "]");
private static void printList(File[] list) { if (list != null) { for (int i = 0; i < list.length; i++) { File f = list[i]; if (f.isDirectory()) { System.out.print("[" + f.getName() + "]"); } else { System.out.print(f.getName() + " " + f.length()); } System.out.println(); } System.out.println(); } }
System.out.print(f.getName() + " " + f.length());
out.print(f.getName() + " " + f.length());
private static void printList(File[] list) { if (list != null) { for (int i = 0; i < list.length; i++) { File f = list[i]; if (f.isDirectory()) { System.out.print("[" + f.getName() + "]"); } else { System.out.print(f.getName() + " " + f.length()); } System.out.println(); } System.out.println(); } }
System.out.println();
out.println();
private static void printList(File[] list) { if (list != null) { for (int i = 0; i < list.length; i++) { File f = list[i]; if (f.isDirectory()) { System.out.print("[" + f.getName() + "]"); } else { System.out.print(f.getName() + " " + f.length()); } System.out.println(); } System.out.println(); } }
public final int getLineNr() {
public final String getLineNr() {
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
return bc.getLineNr(sfPc - 1);
return String.valueOf(bc.getLineNr(sfPc - 1));
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
return -1;
return "?";
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
final int lineNr = getLineNr();
final String lineNr = getLineNr();
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
if (lineNr < 0) {
/*if (lineNr < 0) {
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
}
}*/ line = lineNr;
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
public int getLineNr(Address address) { if (this.bytecode != null) { final int offset = (int) Address.distance(nativeCode, address); final int pc = addressTable.findPC(offset); return bytecode.getLineNr(pc); } return -1; }
public String getLineNr(Address address) { if (this.bytecode != null) { final int offset = (int) Address.distance(nativeCode, address); final int pc = addressTable.findPC(offset); return String.valueOf(bytecode.getLineNr(pc)) + ";" + pc + ";0x" + NumberUtils.hex(offset); } return "?"; }
public int getLineNr(Address address) { if (this.bytecode != null) { final int offset = (int) Address.distance(nativeCode, address); final int pc = addressTable.findPC(offset); return bytecode.getLineNr(pc); //return offset; } return -1; }
writeOut(outputstream, getStringData(locator));
if (hasMoreData) { writeOut(outputstream, getStringData(locator)); } else return;
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
if (noData != null) writeOut(outputstream, noData);
if (noData != null) { writeOut(outputstream, noData); }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
if (!locator.next())
if (!locator.next()) { hasMoreData = false;
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
} }
} } }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
while (locator.next()) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues);
synchronized (data) { hasMoreData = locator.hasNext(); while (hasMoreData) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues);
protected void writeFormattedData(OutputStream outputstream , Locator locator, FormattedXMLDataIOStyle readObj, AxisInterface fastestAxis, String[] noDataValues) { writeOut(outputstream, "<![CDATA["); List commands = readObj.getCommands(); while (locator.next()) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues); writeOut(outputstream, "]]>"); }
}
protected void writeFormattedData(OutputStream outputstream , Locator locator, FormattedXMLDataIOStyle readObj, AxisInterface fastestAxis, String[] noDataValues) { writeOut(outputstream, "<![CDATA["); List commands = readObj.getCommands(); while (locator.next()) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues); writeOut(outputstream, "]]>"); }
threadIterator = threads.values().iterator(); index = 1;
reset();
public ThreadListState(DebugState parent, int threadState) { super(STATE_NAMES[threadState], parent); threads = getAllThreads(threadState); threadIterator = threads.values().iterator(); index = 1; }
it.remove();
synchronized HTTPConnection get(String host, int port, boolean secure) { String ttl = SystemProperties.getProperty("classpath.net.http.keepAliveTTL"); connectionTTL = (ttl != null && ttl.length() > 0) ? 1000 * Math.max(1, Integer.parseInt(ttl)) : 10000; String mc = SystemProperties.getProperty("http.maxConnections"); maxConnections = (mc != null && mc.length() > 0) ? Math.max(Integer.parseInt(mc), 1) : 5; if (maxConnections < 1) maxConnections = 1; HTTPConnection c = null; ListIterator it = connectionPool.listIterator(0); while (it.hasNext()) { HTTPConnection cc = (HTTPConnection)it.next(); if (matches(cc, host, port, secure)) { c = cc; break; } } if (c == null) { c = new HTTPConnection(host, port, secure); c.setPool(this); } return c; }
public FileSystem create(Device device, boolean readOnly) throws FileSystemException {
public synchronized FileSystem create(Device device, boolean readOnly) throws FileSystemException {
public FileSystem create(Device device, boolean readOnly) throws FileSystemException { Ext2FileSystem fs = new Ext2FileSystem(device, readOnly); fs.read(); return fs; }
public FileSystem format(Device device, Object specificOptions) throws FileSystemException {
public synchronized FileSystem format(Device device, Object specificOptions) throws FileSystemException {
public FileSystem format(Device device, Object specificOptions) throws FileSystemException { //throw new FileSystemException("Not ye implemented"); //currently the only option is the block size int blockSize = 1024*((Integer)specificOptions).intValue(); Ext2FileSystem fs = new Ext2FileSystem(device, false); fs.create(blockSize); return fs; }
throw new MARSHAL("Unknow addressing method in request, " +
MARSHAL m = new MARSHAL("Unknow addressing method in request, " +
public void read(cdrInput in) { try { request_id = in.read_ulong(); response_flags = (byte) in.read(); // Skip 3 reserved octets: in.skip(3); // Read target address. AddressingDisposition = in.read_ushort(); switch (AddressingDisposition) { case KeyAddr : object_key = in.read_sequence(); break; // TODO FIXME add other addressing methods. case ProfileAddr : throw new NO_IMPLEMENT("Object addressing by IOP tagged profile"); case ReferenceAddr : throw new NO_IMPLEMENT("Object addressing by by IOR addressing info"); default : throw new MARSHAL("Unknow addressing method in request, " + AddressingDisposition ); } operation = in.read_string(); service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in); // No requesting principal in this new format. in.setCodeSet(cxCodeSet.find(service_context)); } catch (IOException ex) { MARSHAL t = new MARSHAL(); t.initCause(ex); throw t; } }
t.minor = Minor.Header;
public void read(cdrInput in) { try { request_id = in.read_ulong(); response_flags = (byte) in.read(); // Skip 3 reserved octets: in.skip(3); // Read target address. AddressingDisposition = in.read_ushort(); switch (AddressingDisposition) { case KeyAddr : object_key = in.read_sequence(); break; // TODO FIXME add other addressing methods. case ProfileAddr : throw new NO_IMPLEMENT("Object addressing by IOP tagged profile"); case ReferenceAddr : throw new NO_IMPLEMENT("Object addressing by by IOR addressing info"); default : throw new MARSHAL("Unknow addressing method in request, " + AddressingDisposition ); } operation = in.read_string(); service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in); // No requesting principal in this new format. in.setCodeSet(cxCodeSet.find(service_context)); } catch (IOException ex) { MARSHAL t = new MARSHAL(); t.initCause(ex); throw t; } }
tnvt (Screen5250 screen52) {
tnvt (Properties props, Screen5250 screen52, boolean type, boolean support132) {
tnvt (Screen5250 screen52) { this(screen52,false,false); }
this(screen52,false,false);
enhanced = type; this.support132 = support132;
tnvt (Screen5250 screen52) { this(screen52,false,false); }
sessProps = null; if (props != null) sessProps = props; if (sessProps.getProperty(SESSION_CODE_PAGE) != null) { setCodePage(sessProps.getProperty(SESSION_CODE_PAGE)); } else { setCodePage("37"); } this.screen52 = screen52; dataIncluded = new boolean[24]; baosp = new ByteArrayOutputStream(); baosrsp = new ByteArrayOutputStream();
tnvt (Screen5250 screen52) { this(screen52,false,false); }
if (!added.contains(e))
if (!contains(added, e))
public void addAddedElement (Element e) { if (!added.contains(e)) added.add(e); }
if (!added.contains(e[i]))
if (!contains(added, e[i]))
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
if (!removed.contains(e))
if (!contains(removed, e))
public void addRemovedElement (Element e) { if (!removed.contains(e)) removed.add(e); }
if (!removed.contains(e[i]))
if (!contains(removed, e[i]))
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
{
{ if (length == 0) return;
public void change(int offset, int length, DefaultDocumentEvent ev) { this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
this.pos = offset;
public void change(int offset, int length, DefaultDocumentEvent ev) { this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
Element[] res = split(el, offset, 0);
Element[] res = split(el, offset, 0, el.getElementIndex(offset));
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
int index = par.getElementIndex(offset);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
Edit edit = getEditForParagraphAndIndex(par, index);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
res = split(el, endOffset, 0);
res = split(el, endOffset, 0, el.getElementIndex(endOffset));
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
if (res[1] != null)
if (res[0] != null)
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); 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 edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
{ Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset);
{ Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset);
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
edit.addRemovedElement(child);
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
this.endOffset = offset + length;
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } 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(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); }
edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false;
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } 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(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
addEdit(e, curr.index, removed, added);
ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee);
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } 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(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
if (dir == ElementSpec.JoinPreviousDirection)
if (dir == ElementSpec.JoinNextDirection)
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
} else if (dir == ElementSpec.JoinNextDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset);
int index = paragraph.getElementIndex(pos);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
if (target.isLeaf() && paragraph.getElementCount() > (index + 1))
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)))
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index);
Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1];
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); }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
offset += len;
else { 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); if (end != toRec.getEndOffset()) { recreateLeaves(end, toRec, onlyContent); if (onlyContent) edit.addRemovedElement(target); } } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len;
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
if (current.getEndOffset() != newEndOffset)
if (current.getEndOffset() != newEndOffset && !onlyContent)
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset);
Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { }
offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset());
if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset());
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added);
{ newEl1 = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
} Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent);
edit.addRemovedElement(next);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
BranchElement previous = (BranchElement) parent.getElement(parentIndex); BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch);
AttributeSet parentAtts = parent.getAttributes(); Element toFracture = parent.getElement(parentIndex); int parSize = parent.getElementCount(); Edit edit = getEditForParagraphAndIndex(parent, parentIndex); Element frac = toFracture; int leftIns = 0; int indexOfFrac = toFracture.getElementIndex(offset); int size = toFracture.getElementCount(); frac = toFracture.getElement(indexOfFrac); while (!frac.isLeaf()) frac = frac.getElement(frac.getElementIndex(offset)); AttributeSet atts = frac.getAttributes(); int fracStart = frac.getStartOffset(); int fracEnd = frac.getEndOffset(); if (offset > fracStart && offset < fracEnd) { BranchElement rightBranch = new BranchElement(parent, parentAtts); BranchElement leftBranch = null; Element[] added = null; if (edit.added.size() > 0 || edit.removed.size() > 0) { added = new Element[] { rightBranch }; parentIndex++; } else { leftBranch = new BranchElement(parent, parentAtts); added = new Element[] { leftBranch, rightBranch }; Element leftFracturedLeaf = createLeafElement(leftBranch, atts, fracStart, offset); leftBranch.replace(leftIns, 0, new Element[] { leftFracturedLeaf }); } if (!toFracture.isLeaf()) { if (indexOfFrac > 0 && leftBranch != null) { Element[] add = new Element[indexOfFrac]; for (int i = 0; i < indexOfFrac; i++) add[i] = toFracture.getElement(i); leftIns = add.length; leftBranch.replace(0, 0, add); } int count = size - indexOfFrac - 1; if (count > 0) { Element[] add = new Element[count]; int j = 0; int i = indexOfFrac + 1; while (j < count) add[j++] = toFracture.getElement(i++); rightBranch.replace(0, 0, add); } } int rm = 0; int end = fracEnd; Element next = rightBranch.getElement(0); if (next != null && next.isLeaf() && next.getAttributes().isEqual(atts)) { end = next.getEndOffset(); rm = 1; } Element rightFracturedLeaf = createLeafElement(rightBranch, atts, offset, end); rightBranch.replace(0, rm, new Element[] { rightFracturedLeaf }); int remove = parSize - parentIndex; Element[] removed = new Element[0]; Element[] added2 = new Element[0]; if (remove > 0) { removed = new Element[remove]; int s = 0; for (int j = parentIndex; j < parSize; j++) removed[s++] = parent.getElement(j); edit.addRemovedElements(removed); added2 = recreateAfterFracture(removed, parent, 1, rightBranch.getEndOffset()); } edit.addAddedElements(added); edit.addAddedElements(added2); elementStack.push(rightBranch); lastFractured = rightFracturedLeaf; } else fracNotCreated = true;
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added);
e.addAddedElements(added); e.addRemovedElements(removed);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret);
e.addAddedElement(ret);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
if (data[0].getType() == ElementSpec.ContentType)
int type = data[0].getType(); if (type == ElementSpec.ContentType)
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == 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. i = 1; insertFirstContentTag(data); } else createFracture(data); // 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. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
insertFirstContentTag(data);
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == 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. i = 1; insertFirstContentTag(data); } else createFracture(data); // 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. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph);
int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix));
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == 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. i = 1; insertFirstContentTag(data); } else createFracture(data); // 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. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
offset = pos;
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == 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. i = 1; insertFirstContentTag(data); } else createFracture(data); // 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. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
pos = offset;
public void remove(int offs, int len, DefaultDocumentEvent ev) { offset = offs; length = len; documentEvent = ev; removeUpdate(); }
private Element[] split(Element el, int offset, int space) {
private Element[] split(Element el, int offset, int space, int editIndex) {
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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; }
Element[] result = split(child, offset, space);
Element[] result = split(child, offset, space, editIndex);
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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 (!(result[1] == null))
if (result[1] != null)
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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, index);
Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex);
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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; }
BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else
BranchElement newPar = (BranchElement) new BranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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; }
added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index);
Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex);
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar };
BranchElement newPar = (BranchElement) new BranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar };
private Element[] split(Element el, int offset, int space) { // 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); 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, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(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; }
BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start;
Element e = getDefaultRootElement(); while (!e.isLeaf()) e = e.getElement(e.getElementIndex(position));
public Element getParagraphElement(int position) { BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start; Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par; }
Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par;
if (e != null) return e.getParentElement(); return e;
public Element getParagraphElement(int position) { BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start; Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par; }
if (parent.getElementCount() > parent.getElementIndex(offset) + 1)
if (parent.getElementCount() > (parent.getElementIndex(offset) + 1))
short handleInsertAfterNewline(Vector specs, int offset, int endOffset, Element prevParagraph, Element paragraph, AttributeSet a) { if (prevParagraph.getParentElement() == paragraph.getParentElement()) { specs.add(new ElementSpec(a, ElementSpec.EndTagType)); specs.add(new ElementSpec(a, ElementSpec.StartTagType)); if (prevParagraph.getEndOffset() != endOffset) return ElementSpec.JoinFractureDirection; // If there is an Element after this one, use JoinNextDirection. Element parent = paragraph.getParentElement(); if (parent.getElementCount() > parent.getElementIndex(offset) + 1) return ElementSpec.JoinNextDirection; } else { // TODO: What to do here? } return ElementSpec.OriginateDirection; }
} else {
short handleInsertAfterNewline(Vector specs, int offset, int endOffset, Element prevParagraph, Element paragraph, AttributeSet a) { if (prevParagraph.getParentElement() == paragraph.getParentElement()) { specs.add(new ElementSpec(a, ElementSpec.EndTagType)); specs.add(new ElementSpec(a, ElementSpec.StartTagType)); if (prevParagraph.getEndOffset() != endOffset) return ElementSpec.JoinFractureDirection; // If there is an Element after this one, use JoinNextDirection. Element parent = paragraph.getParentElement(); if (parent.getElementCount() > parent.getElementIndex(offset) + 1) return ElementSpec.JoinNextDirection; } else { // TODO: What to do here? } return ElementSpec.OriginateDirection; }
if (e.getPropertyName().equals(JProgressBar.INDETERMINATE_CHANGED_PROPERTY))
if (e.getPropertyName().equals("inderterminate"))
public void propertyChange(PropertyChangeEvent e) { // Only need to listen for indeterminate changes. // All other things are done on a repaint. if (e.getPropertyName().equals(JProgressBar.INDETERMINATE_CHANGED_PROPERTY)) if (((Boolean) e.getNewValue()).booleanValue()) startAnimationTimer(); else stopAnimationTimer(); else progressBar.repaint(); }
public void incrementAnimationIndex()
protected void incrementAnimationIndex()
public void incrementAnimationIndex() { animationIndex++; //numFrames is like string length, it should be named numFrames or something if (animationIndex >= numFrames) animationIndex = 0; progressBar.repaint(); }
if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY))
if (e.getPropertyName().equals("orientation"))
public void propertyChange(PropertyChangeEvent e) { // Check for orientation changes. if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY)) recalculateIfOrientationChanged(); else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY)) { BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); oldModel.removeChangeListener(changeListener); slider.getModel().addChangeListener(changeListener); calculateThumbLocation(); } // elif the componentOrientation changes (this is a bound property, // just undocumented) we change leftToRightCache. In Sun's // implementation, the LTR cache changes on a repaint. This is strange // since there is no need to do so. We could events here and // update the cache. // elif the border/insets change, we recalculateInsets. slider.repaint(); }
else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY))
else if (e.getPropertyName().equals("model"))
public void propertyChange(PropertyChangeEvent e) { // Check for orientation changes. if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY)) recalculateIfOrientationChanged(); else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY)) { BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); oldModel.removeChangeListener(changeListener); slider.getModel().addChangeListener(changeListener); calculateThumbLocation(); } // elif the componentOrientation changes (this is a bound property, // just undocumented) we change leftToRightCache. In Sun's // implementation, the LTR cache changes on a repaint. This is strange // since there is no need to do so. We could events here and // update the cache. // elif the border/insets change, we recalculateInsets. slider.repaint(); }
public BindException(String message)
public BindException()
public BindException(String message) { super(message); }
super(message);
public BindException(String message) { super(message); }
public static Object copyObject(Object obj, javax.rmi.ORB orb)
public static java.lang.Object copyObject(java.lang.Object object, ORB orb)
public static Object copyObject(Object obj, javax.rmi.ORB orb) throws RemoteException { if(delegate != null) return delegate.copyObject(obj, orb); else return null; }
if(delegate != null) return delegate.copyObject(obj, orb); else return null;
return delegate.copyObject(object, orb);
public static Object copyObject(Object obj, javax.rmi.ORB orb) throws RemoteException { if(delegate != null) return delegate.copyObject(obj, orb); else return null; }
public static Object[] copyObjects(Object obj[], javax.rmi.ORB orb)
public static java.lang.Object[] copyObjects(java.lang.Object[] object, ORB orb)
public static Object[] copyObjects(Object obj[], javax.rmi.ORB orb) throws RemoteException { if(delegate != null) return delegate.copyObjects(obj, orb); else return null; }
if(delegate != null) return delegate.copyObjects(obj, orb); else return null;
return delegate.copyObjects(object, orb);
public static Object[] copyObjects(Object obj[], javax.rmi.ORB orb) throws RemoteException { if(delegate != null) return delegate.copyObjects(obj, orb); else return null; }
if(delegate != null)
public static ValueHandler createValueHandler() { if(delegate != null) return delegate.createValueHandler(); else return null; }
else return null;
public static ValueHandler createValueHandler() { if(delegate != null) return delegate.createValueHandler(); else return null; }
if(delegate != null)
public static String getCodebase(Class clz) { if(delegate != null) return delegate.getCodebase(clz); else return null; }
else return null;
public static String getCodebase(Class clz) { if(delegate != null) return delegate.getCodebase(clz); else return null; }
if(delegate != null)
public static Tie getTie(Remote target) { if(delegate != null) return delegate.getTie(target); else return null; }
else return null;
public static Tie getTie(Remote target) { if(delegate != null) return delegate.getTie(target); else return null; }
if(delegate != null)
public static boolean isLocal(Stub stub) throws RemoteException { if(delegate != null) return delegate.isLocal(stub); else return false; }