Changeset 15641

Show
Ignore:
Timestamp:
22.05.2008 14:59:19 (11 years ago)
Author:
ak19
Message:

Added a fireInsertUpdate(DocEvent?) method

Files:
1 modified

Legend:

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

    r15622 r15641  
    117117    } 
    118118 
     119    protected void fireInsertUpdate(DocumentEvent event) { 
     120    Object[] listeners = listeners_list.getListenerList();  
     121    for (int i = listeners.length - 2; i >= 0; i = i - 2) { 
     122        try { 
     123        if (listeners[i] == DocumentListener.class) {  
     124            ((DocumentListener)listeners[i+1]).insertUpdate(event);  
     125        }  
     126        } catch(Exception e) {} 
     127    }  
     128    listeners = null;  
     129    event = null;  
     130    } 
     131 
    119132    /** Adds a document listener for notification of any changes.  
    120133     * @param listener the new DocumentListener to keep track of 
     
    147160        writer.queue(new_line_element); 
    148161        // moved the firing of DocumentEvent to the WriterThread.run() method for when the new line is *actually* written to the document 
     162        // DocumentEvent event = new AppendLineOnlyFileDocumentEvent(new_line_element, (int)start_offset, str_length, DocumentEvent.EventType.INSERT);  
     163        // fireInsertUpdate(event); 
    149164        new_line_element = null; 
    150165    } 
     
    772787            try { 
    773788                write(element.getStartOffset(), element.getEndOffset(), content, content.getBytes("UTF-8").length); 
     789                 
    774790                // Now fire an event so everyone knows the Document's content has changed. 
    775791                int str_length = content.getBytes("UTF-8").length; 
    776792                long start_offset = length; 
    777                 long end_offset = start_offset + (long) str_length; 
    778                 length = length + str_length; 
    779793                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; 
     794                AppendLineOnlyFileDocument.this.fireInsertUpdate(event); 
     795                 
    788796            } 
    789797            catch(Exception error) { 
    790                 DebugStream.printStackTrace(error); 
     798                DebugStream.printStackTrace(error);              
    791799            } 
    792800            element.clearContent();