Changeset 15862 for gli/trunk/src/org/greenstone/gatherer
- Timestamp:
- 2008-06-04T18:05:12+12:00 (16 years ago)
- 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 606 606 } 607 607 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. */ 610 609 private class BuildButtonListener 611 implements ActionListener , DocumentListener{610 implements ActionListener { 612 611 /** 613 612 * This method checks to see what needs to be done for a build, and starts the process off. … … 677 676 document = options_pane.createNewLogDocument(); 678 677 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 refresh681 document.addDocumentListener(this);682 678 options_pane.log_textarea.setDocument(document); 683 679 // Change the view. … … 691 687 import_monitor.setStop(false); 692 688 } 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 701 691 702 692 /** This class serves as the listener for actions on the cancel button. */ -
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.