- Timestamp:
- 2003-12-19T14:49:04+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java
r6087 r6321 62 62 public class OptionsPane 63 63 extends JPanel 64 implements AppendLineOnlyFileDocumentOwner {64 implements AppendLineOnlyFileDocumentOwner, MouseListener { 65 65 66 66 static final public char SUCCESSFUL = 's'; … … 72 72 public JTextArea log_textarea = null; 73 73 74 private ArrayList current_controls; 75 74 76 /** The <strong>BuildOptions</strong> data object contains all the option settings we wish to persist between Gatherer sessions (and thus is stored in <strong>Collection</strong>). */ 75 77 private BuildOptions build_options = null; 76 78 77 79 private FileEntry file_entry = null; 80 78 81 /** the log pane - we only create it once now, not each time */ 79 82 private JPanel log_pane = null; … … 93 96 public OptionsPane(BuildOptions build_options) { 94 97 this.build_options = build_options; 98 this.current_controls = new ArrayList(); 95 99 this.writing_documents = new Vector(); 96 100 … … 104 108 */ 105 109 public JPanel buildBuild() { 110 current_controls.clear(); 106 111 JPanel pane = new JPanel(); 107 112 pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); … … 117 122 ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value); 118 123 pane.add(argument_control); 119 } 124 current_controls.add(argument_control); 125 } 126 pane.addMouseListener(this); 120 127 return pane; 121 128 } … … 124 131 */ 125 132 public JPanel buildImport() { 133 current_controls.clear(); 126 134 JPanel pane = new JPanel(); 127 135 pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); … … 137 145 ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value); 138 146 pane.add(argument_control); 139 } 147 current_controls.add(argument_control); 148 } 149 pane.addMouseListener(this); 140 150 return pane; 141 151 } … … 153 163 File children[] = log_directory.listFiles(); 154 164 for(int i = 0; children != null && i < children.length; i++) { 155 if(children[i].getName().startsWith("build_log") && children[i].getName().endsWith(".txt") ) { 156 FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath()); 157 // We are about to insert it. But where. 158 boolean found = false; 159 for(int j = 0; !found && j < contents.size(); j++) { 160 FileEntry sibling = (FileEntry) contents.getElementAt(j); 161 int order = entry.compareTo(sibling); 162 if(order > 0) { 163 contents.insertElementAt(entry, j); 164 found = true; 165 String filename = children[i].getName(); 166 if(filename.startsWith("build_log.") && filename.endsWith(".txt") ) { 167 String datestamp = filename.substring(filename.indexOf(".") + 1, filename.lastIndexOf(".")).toLowerCase(); 168 if(datestamp.indexOf("s") == -1 && datestamp.indexOf("u") == -1 && datestamp.indexOf("c") == -1 && datestamp.indexOf("x") == -1) { 169 FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath()); 170 // We are about to insert it. But where. 171 boolean found = false; 172 for(int j = 0; !found && j < contents.size(); j++) { 173 FileEntry sibling = (FileEntry) contents.getElementAt(j); 174 int order = entry.compareTo(sibling); 175 if(order > 0) { 176 contents.insertElementAt(entry, j); 177 found = true; 178 } 165 179 } 166 }167 if(!found) {168 contents.addElement(entry);180 if(!found) { 181 contents.addElement(entry); 182 } 169 183 } 170 184 } … … 250 264 } 251 265 266 /** Implementation side-effect 267 * @param e a MouseEvent 268 */ 269 public void mouseClicked(MouseEvent e) {} 270 271 /** Implementation side-effect 272 * @param e a MouseEvent 273 */ 274 public void mouseEntered(MouseEvent e) {} 275 276 /** Implemented to ensure that, by the time the mouse pointer leaves the current build options screen, ang changes to the value the JSpinners have been commited 277 * @param e a MouseEvent 278 */ 279 public void mouseExited(MouseEvent e) { 280 // Loop through the controls, and if the current control is a JSpinner, commit its current editing 281 for(int i = 0; i < current_controls.size(); i++) { 282 ArgumentControl control = (ArgumentControl) current_controls.get(i); 283 JComponent value_control = control.getValueControl(); 284 if(value_control instanceof JSpinner) { 285 try { 286 ((JSpinner)value_control).commitEdit(); 287 } 288 catch(Exception exception) { 289 Gatherer.println("Exception in OptionsPane.mouseExited() - unexpected"); 290 Gatherer.printStackTrace(exception); 291 } 292 } 293 value_control = null; 294 control = null; 295 } 296 } 297 298 /** Implementation side-effect 299 * @param e a MouseEvent 300 */ 301 public void mousePressed(MouseEvent e) {} 302 303 /** Implementation side-effect 304 * @param e a MouseEvent 305 */ 306 public void mouseReleased(MouseEvent e) {} 307 252 308 private class ArgumentControl 253 309 extends JPanel { … … 389 445 add(enabled, BorderLayout.WEST); 390 446 } 447 } 448 449 /** Retrieve the control used for storing values. 450 * @return JComponent 451 */ 452 public JComponent getValueControl() { 453 return value_control; 391 454 } 392 455
Note:
See TracChangeset
for help on using the changeset viewer.