Ignore:
Timestamp:
2008-06-04T18:05:12+12:00 (16 years ago)
Author:
ak19
Message:

Reverted to older version since my changes to make the blocky chars during logging go away cause an Exception when run immediately after GLI is compiled. When I have tracked the cause down and have corrected it, I will commit that into the working version. I don't want the currently buggy version in the repository.

File:
1 edited

Legend:

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

    r15769 r15862  
    6767    /** 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. */
    6868    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
    7270   
    7371    public AppendLineOnlyFileDocument(String filename) {
     
    119117    }
    120118
    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 
    137119    /** Adds a document listener for notification of any changes.
    138120     * @param listener the new DocumentListener to keep track of
     
    164146        // Queue the content to be written.
    165147        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;
    170158        new_line_element = null;
    171159    }
     
    795783            }
    796784            catch(Exception error) {
    797                 DebugStream.printStackTrace(error);             
     785                DebugStream.printStackTrace(error);
    798786            }
    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();
    804788            }
    805789        }
     
    816800            }
    817801            print("WriterThread.wait() complete");
    818             }
     802           }
    819803        }
    820804        }
Note: See TracChangeset for help on using the changeset viewer.