- Timestamp:
- 2008-06-04T18:05:12+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java
r15769 r15862 67 67 /** An independant thread responsible for writing the 'in memory' contents of the document model to the random access file as appropriate. This is done so IO lag does not effect the gui as much as it used to. */ 68 68 private WriterThread writer; 69 70 /** Keeps track of the document insert update event to be fired next (after a line element is written) */ 71 private DocumentEvent event = null; 69 72 70 73 71 public AppendLineOnlyFileDocument(String filename) { … … 119 117 } 120 118 121 /** Notifies listeners of a document insert update event */122 protected void fireInsertUpdate(DocumentEvent event) {123 Object[] listeners = listeners_list.getListenerList();124 for (int i = listeners.length - 2; i >= 0; i = i - 2) {125 try {126 if (listeners[i] == DocumentListener.class) {127 ((DocumentListener)listeners[i+1]).insertUpdate(event);128 }129 } catch(Exception e) {130 DebugStream.println("Exception in fireInsertUpdate() " + e.getMessage());131 }132 }133 listeners = null;134 event = null;135 }136 137 119 /** Adds a document listener for notification of any changes. 138 120 * @param listener the new DocumentListener to keep track of … … 164 146 // Queue the content to be written. 165 147 writer.queue(new_line_element); 166 167 // moved the firing of DocumentEvent to the WriterThread.run() method for when the new line is *actually* written to the doc 168 event = new AppendLineOnlyFileDocumentEvent(new_line_element, (int)start_offset, str_length, DocumentEvent.EventType.INSERT); 169 //fireInsertUpdate(event); 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; 170 158 new_line_element = null; 171 159 } … … 795 783 } 796 784 catch(Exception error) { 797 DebugStream.printStackTrace(error); 785 DebugStream.printStackTrace(error); 798 786 } 799 // having written the element, we fire any document insert update event prepared earlier 800 if(event != null) { 801 AppendLineOnlyFileDocument.this.fireInsertUpdate(event); 802 } 803 element.clearContent(); 787 element.clearContent(); 804 788 } 805 789 } … … 816 800 } 817 801 print("WriterThread.wait() complete"); 818 802 } 819 803 } 820 804 }
Note:
See TracChangeset
for help on using the changeset viewer.