Changeset 15622


Ignore:
Timestamp:
05/21/08 21:34:29 (13 years ago)
Author:
ak19
Message:

DocumentEvent only fired in the WriterThread.run() method now since that is when the queued line (string) is finally written to the file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r12131 r15622  
    146146        // Queue the content to be written.
    147147        writer.queue(new_line_element);
    148         // Now fire an event so everyone knows the content has changed.
    149         DocumentEvent event = new AppendLineOnlyFileDocumentEvent(new_line_element, (int)start_offset, str_length, DocumentEvent.EventType.INSERT);
    150         Object[] listeners = listeners_list.getListenerList();
    151         for (int i = listeners.length - 2; i >= 0; i = i - 2) {
    152         if (listeners[i] == DocumentListener.class) {
    153             ((DocumentListener)listeners[i+1]).insertUpdate(event);
    154         }
    155         }
    156         listeners = null;
    157         event = null;
     148        // moved the firing of DocumentEvent to the WriterThread.run() method for when the new line is *actually* written to the document
    158149        new_line_element = null;
    159150    }
     
    781772            try {
    782773                write(element.getStartOffset(), element.getEndOffset(), content, content.getBytes("UTF-8").length);
     774                // Now fire an event so everyone knows the Document's content has changed.
     775                int str_length = content.getBytes("UTF-8").length;
     776                long start_offset = length;
     777                long end_offset = start_offset + (long) str_length;
     778                length = length + str_length;
     779                DocumentEvent event = new AppendLineOnlyFileDocumentEvent(element, (int)start_offset, str_length, DocumentEvent.EventType.INSERT);
     780                Object[] listeners = AppendLineOnlyFileDocument.this.listeners_list.getListenerList();
     781                for (int i = listeners.length - 2; i >= 0; i = i - 2) {
     782                if (listeners[i] == DocumentListener.class) {
     783                    ((DocumentListener)listeners[i+1]).insertUpdate(event);
     784                }
     785                }
     786                listeners = null;
     787                event = null;
    783788            }
    784789            catch(Exception error) {
Note: See TracChangeset for help on using the changeset viewer.