Changeset 15862 for gli/trunk


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.

Location:
gli/trunk/src/org/greenstone/gatherer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/CreatePane.java

    r15621 r15862  
    606606    }
    607607
    608     /** This class serves as the listener for actions on the build button. It also ensures
    609      * that the log displayed is refreshed whenever the building progress display updates. */
     608    /** This class serves as the listener for actions on the build button. */
    610609    private class BuildButtonListener
    611     implements ActionListener, DocumentListener {
     610    implements ActionListener {
    612611    /**
    613612     * This method checks to see what needs to be done for a build, and starts the process off.
     
    677676        document = options_pane.createNewLogDocument();
    678677        log_textarea.setDocument(document);
    679         // Add a document listener to listen to DocumentEvents emitted by the custom document.
    680         // It prevents the blocks that appear in the log textarea that look like they need a refresh
    681         document.addDocumentListener(this);
    682678        options_pane.log_textarea.setDocument(document);
    683679        // Change the view.
     
    691687        import_monitor.setStop(false);
    692688    }
    693        
    694 
    695     // Called whenever the custom Document object has been updated (it then fires a DocumentEvent, handled here)
    696     public void changedUpdate(DocumentEvent e) { refreshLog(); }
    697     public void insertUpdate(DocumentEvent e) { refreshLog(); }
    698     public void removeUpdate(DocumentEvent e) { refreshLog(); }
    699     public void refreshLog() { CreatePane.this.log_textarea.repaint(); }
    700     }
     689    }
     690   
    701691   
    702692    /** This class serves as the listener for actions on the cancel button. */
  • 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.