Changeset 6533 for trunk/gli/src
- Timestamp:
- 2004-01-16T15:52:11+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java
r6389 r6533 95 95 static private Dimension ARGUMENT_SIZE = new Dimension(800,90); 96 96 /** The size of the buttons at the bottom of the screen. */ 97 static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);97 static private Dimension BUTTON_SIZE = new Dimension (256, 40);//(386, 50); 98 98 /** The size of the labels on the progress pane. */ 99 99 static private Dimension LABEL_SIZE = new Dimension(140, 25); … … 128 128 /** The button for viewing the collection. */ 129 129 private JButton preview_button = null; 130 private JButton simple_build_button; 131 private JButton simple_cancel_button; 132 private JButton simple_preview_button; 130 133 /** The label displaying the number of documents in this collection. */ 131 134 private JLabel document_count = null; … … 136 139 /** The label alongside the import progress bar gets some special treatment so... */ 137 140 private JLabel progress_import_label = null; 138 /** A panel containing the two progress bars. */139 141 private JPanel bar_area; 140 142 /** The panel on which buttons are rendered on higher detail modes. */ … … 232 234 Dictionary.registerText(progress_build_label, "CreatePane.Build_Progress"); 233 235 234 build_monitor = new GBuildProgressMonitor( ); //GBasicProgressMonitor();236 build_monitor = new GBuildProgressMonitor(import_monitor.getSharedProgress()); //GBasicProgressMonitor(); 235 237 Gatherer.c_man.registerBuildMonitor(build_monitor); 236 238 … … 241 243 242 244 // Buttons 245 BuildButtonListener bbl = new BuildButtonListener(); 246 CancelButtonListener cbl = new CancelButtonListener(); 247 PreviewButtonListener pbl = new PreviewButtonListener(); 248 243 249 build_button = new GLIButton(); 244 build_button.addActionListener( new BuildButtonListener());250 build_button.addActionListener(bbl); 245 251 build_button.setMnemonic(KeyEvent.VK_B); 246 252 build_button.setPreferredSize(BUTTON_SIZE); … … 248 254 249 255 cancel_button = new GLIButton(); 250 cancel_button.addActionListener( new CancelButtonListener());256 cancel_button.addActionListener(cbl); 251 257 cancel_button.setEnabled(false); 252 258 cancel_button.setMnemonic(KeyEvent.VK_C); … … 255 261 256 262 preview_button = new GLIButton(); 257 preview_button.addActionListener(new PreviewButtonListener()); 258 preview_button.setEnabled(false); 263 preview_button.addActionListener(pbl); 264 if(Gatherer.c_man != null) { 265 preview_button.setEnabled(Gatherer.c_man.built()); 266 } 267 else { 268 preview_button.setEnabled(false); 269 } 259 270 preview_button.setMnemonic(KeyEvent.VK_P); 260 271 preview_button.setPreferredSize(BUTTON_SIZE); 261 272 Dictionary.registerBoth(preview_button, "CreatePane.Preview_Collection", "CreatePane.Preview_Collection_Tooltip"); 273 274 simple_build_button = new GLIButton(); 275 simple_build_button.addActionListener(bbl); 276 simple_build_button.setMnemonic(KeyEvent.VK_B); 277 simple_build_button.setPreferredSize(BUTTON_SIZE); 278 Dictionary.registerBoth(simple_build_button, "CreatePane.Build_Collection", "CreatePane.Build_Collection_Tooltip"); 279 280 simple_cancel_button = new GLIButton(); 281 simple_cancel_button.addActionListener(cbl); 282 simple_cancel_button.setEnabled(false); 283 simple_cancel_button.setMnemonic(KeyEvent.VK_C); 284 simple_cancel_button.setPreferredSize(BUTTON_SIZE); 285 Dictionary.registerBoth(simple_cancel_button, "CreatePane.Cancel_Build", "CreatePane.Cancel_Build_Tooltip"); 286 287 simple_preview_button = new GLIButton(); 288 simple_preview_button.addActionListener(pbl); 289 if(Gatherer.c_man != null) { 290 simple_preview_button.setEnabled(Gatherer.c_man.built()); 291 } 292 else { 293 simple_preview_button.setEnabled(false); 294 } 295 simple_preview_button.setMnemonic(KeyEvent.VK_P); 296 simple_preview_button.setPreferredSize(BUTTON_SIZE); 297 Dictionary.registerBoth(simple_preview_button, "CreatePane.Preview_Collection", "CreatePane.Preview_Collection_Tooltip"); 298 299 bbl = null; 300 cbl = null; 301 pbl = null; 262 302 } 263 303 … … 295 335 if (!Gatherer.c_man.built() || Gatherer.config.exec_address == null) { 296 336 preview_button.setEnabled(false); 337 simple_preview_button.setEnabled(false); 297 338 } else { 298 339 preview_button.setEnabled(true); 340 simple_preview_button.setEnabled(true); 299 341 } 300 342 } … … 332 374 button_pane = new JPanel(); 333 375 button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10)); 334 button_pane.setLayout(new GridLayout(1,2)); 335 if(current_mode >= THRESHOLD) { 336 button_pane.add(build_button); 337 button_pane.add(cancel_button); 338 button_pane.add(preview_button); 339 } 376 button_pane.setLayout(new GridLayout(1,3)); 377 button_pane.add(build_button); 378 button_pane.add(cancel_button); 379 button_pane.add(preview_button); 340 380 341 381 control_pane.setLayout(new BorderLayout()); … … 367 407 progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); 368 408 progress_pane.setLayout(new BorderLayout()); 409 progress_pane.add(bar_area, BorderLayout.NORTH); 369 410 if(current_mode >= THRESHOLD) { 370 progress_pane.add(bar_area, BorderLayout.NORTH);371 411 progress_pane.add(log_scroll, BorderLayout.CENTER); 372 412 } … … 375 415 sbutton_panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); 376 416 sbutton_panel.setLayout(new GridLayout(3,1)); 377 if(current_mode < THRESHOLD) { 378 sbutton_panel.add(build_button); 379 sbutton_panel.add(cancel_button); 380 sbutton_panel.add(preview_button); 381 } 417 sbutton_panel.add(simple_build_button); 418 sbutton_panel.add(simple_cancel_button); 419 sbutton_panel.add(simple_preview_button); 420 421 JPanel simple_bar_area = new JPanel(new GridLayout(3,1)); 422 simple_bar_area.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); 423 simple_bar_area.add(import_monitor.getSharedProgress()); 382 424 383 425 sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0)); 384 426 sinner_panel.setLayout(new BorderLayout()); 385 if(current_mode < THRESHOLD) { 386 sinner_panel.add(bar_area, BorderLayout.CENTER); 387 } 388 sinner_panel.add(sbutton_panel, BorderLayout.EAST); 427 sinner_panel.add(sbutton_panel, BorderLayout.WEST); 428 sinner_panel.add(simple_bar_area, BorderLayout.CENTER); 389 429 390 430 if(options_pane != null) { … … 435 475 } 436 476 else if(!processing) { 477 // Move the buttons to control 478 control_pane.add(button_pane, BorderLayout.SOUTH); 437 479 card_layout.show(main_pane, CONTROL); 438 480 } 439 481 else { 482 // Move the buttons to progress 483 progress_pane.add(button_pane, BorderLayout.SOUTH); 440 484 card_layout.show(main_pane, PROGRESS); 441 485 } … … 484 528 souter_panel.add(sinner_panel); 485 529 // Remove the shared components from the expert panels 486 button_pane.remove(build_button);487 button_pane.remove(cancel_button);488 button_pane.remove(preview_button);489 progress_pane.remove(bar_area);490 530 progress_pane.remove(log_scroll); 491 531 // And add to simple one 492 sbutton_panel.add(build_button);493 sbutton_panel.add(cancel_button);494 sbutton_panel.add(preview_button);495 sinner_panel.add(bar_area, BorderLayout.CENTER);496 532 simple_panel.add(log_scroll, BorderLayout.CENTER); 497 533 // And bring the card to the front … … 501 537 else { 502 538 // Remove the shared components from the simple panel 503 sbutton_panel.remove(build_button);504 sbutton_panel.remove(cancel_button);505 sbutton_panel.remove(preview_button);506 sinner_panel.remove(bar_area);507 539 simple_panel.remove(log_scroll); 508 540 // And add then to the expert ones 509 button_pane.add(build_button);510 button_pane.add(cancel_button);511 button_pane.add(preview_button);512 progress_pane.add(bar_area, BorderLayout.NORTH);513 541 progress_pane.add(log_scroll, BorderLayout.CENTER); 514 542 // And bring the appropriate card to the front 515 543 if(!processing) { 544 control_pane.add(button_pane, BorderLayout.SOUTH); 516 545 card_layout.show(main_pane, CONTROL); 517 546 } 518 547 else { 548 progress_pane.add(button_pane, BorderLayout.SOUTH); 519 549 card_layout.show(main_pane, PROGRESS); 520 550 } … … 536 566 if(event.getType() == GShell.BUILD) { 537 567 processing = false; 568 build_button.setEnabled(true); 538 569 cancel_button.setEnabled(false); 539 build_button.setEnabled(true);540 570 preview_button.setEnabled(true); 571 simple_build_button.setEnabled(true); 572 simple_cancel_button.setEnabled(false); 573 simple_preview_button.setEnabled(true); 541 574 int status = event.getStatus(); 542 575 document.setSpecialCharacter(OptionsPane.SUCCESSFUL); … … 545 578 import_monitor.reset(); 546 579 if(Gatherer.config.getMode() >= THRESHOLD) { 580 control_pane.add(button_pane, BorderLayout.SOUTH); 547 581 card_layout.show(main_pane, CONTROL); 548 582 } … … 556 590 // The build may have failed, but a previous index may still be in place 557 591 preview_button.setEnabled(Gatherer.c_man.built()); 592 593 simple_build_button.setEnabled(true); 594 simple_cancel_button.setEnabled(false); 595 simple_preview_button.setEnabled(Gatherer.c_man.built()); 558 596 if(event.getStatus() == GShell.CANCELLED) { 559 597 document.setSpecialCharacter(OptionsPane.CANCELLED); … … 564 602 options_pane.resetFileEntry(); 565 603 if(Gatherer.config.getMode() >= THRESHOLD) { 604 control_pane.add(button_pane, BorderLayout.SOUTH); 566 605 card_layout.show(main_pane, CONTROL); 567 606 } … … 618 657 cancel_button.setEnabled(true); 619 658 preview_button.setEnabled(false); 659 660 simple_build_button.setEnabled(false); 661 simple_cancel_button.setEnabled(true); 662 simple_preview_button.setEnabled(false); 663 620 664 document = options_pane.createNewLogDocument(); 621 665 log_textarea.setDocument(document); … … 624 668 processing = true; 625 669 if(Gatherer.config.getMode() >= THRESHOLD) { 670 progress_pane.add(button_pane, BorderLayout.SOUTH); 626 671 card_layout.show(main_pane, PROGRESS); 627 672 } … … 652 697 cancel_button.setEnabled(false); 653 698 preview_button.setEnabled(false); 699 700 simple_build_button.setEnabled(true); 701 simple_cancel_button.setEnabled(false); 702 simple_preview_button.setEnabled(false); 703 654 704 processing = false; 655 705 document.setSpecialCharacter(OptionsPane.CANCELLED); 656 706 if(Gatherer.config.getMode() >= THRESHOLD) { 707 control_pane.add(button_pane, BorderLayout.SOUTH); 657 708 card_layout.show(main_pane, CONTROL); 658 709 } 659 710 // Set the stop flag in all the process monitor. 711 import_monitor.setStop(true); 712 import_monitor.reset(); 660 713 build_monitor.setStop(true); 661 714 build_monitor.reset(); 662 copy_monitor.setStop(true);663 import_monitor.setStop(true);664 import_monitor.reset();665 715 // Set removeold automatically. 666 716 Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null); -
trunk/gli/src/org/greenstone/gatherer/shell/GBasicProgressMonitor.java
r6388 r6533 82 82 return this; 83 83 } 84 85 public JProgressBar getSharedProgress() { 86 return null; 87 } 88 84 89 /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor. 85 90 * @return A <strong>boolean</strong> indicating if the process has been asked to stop. -
trunk/gli/src/org/greenstone/gatherer/shell/GBuildProgressMonitor.java
r6388 r6533 121 121 /** The progress bar this monitor updates. */ 122 122 private JProgressBar progress_bar; 123 /** A progress bar that is shared between this this listener and the Import monitor. */ 124 private JProgressBar shared_progress_bar; 123 125 124 126 /** Construct a new GBuildProgressMonitor. */ 125 public GBuildProgressMonitor() { 127 public GBuildProgressMonitor(JProgressBar shared_progress_bar) { 128 this.shared_progress_bar = shared_progress_bar; 126 129 progress_bar = new JProgressBar(); 127 130 progress_bar.setMaximum(MAX); 128 131 progress_bar.setMinimum(MIN); 129 progress_bar.setValue(MIN); 132 progress_bar.setString(null); 133 progress_bar.setStringPainted(true); 134 setValue(MIN); 130 135 } 131 136 … … 137 142 progress_bar.setMaximum(MAX); 138 143 progress_bar.setMinimum(MIN); 139 progress_bar.setValue(MIN); 144 progress_bar.setStringPainted(false); 145 progress_bar.setString(null); 146 setValue(MIN); 140 147 } 141 148 … … 155 162 return progress_bar; 156 163 } 164 165 public JProgressBar getSharedProgress() { 166 return shared_progress_bar; 167 } 168 157 169 /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor. 158 170 * @return A <strong>boolean</strong> indicating if the process has been asked to stop. 159 171 */ 160 public boolean hasSignalledStop() {172 public synchronized boolean hasSignalledStop() { 161 173 return stop; 162 174 } … … 193 205 state = BUILD; 194 206 // Produce a lower detail message if required 195 if(Gatherer.config.getMode() <= threshold ) {207 if(Gatherer.config.getMode() <= threshold && !stop) { 196 208 queue.add(new GShellEvent(event.getSource(), 0, event.getType(), Dictionary.get("GShell.Build.BuildBegun1"), event.getStatus())); 197 209 } … … 254 266 else if(name.equals(BUILD_ELEMENT) && element.isClosed()) { 255 267 progress_bar.setIndeterminate(false); 256 progress_bar.setValue(MAX);268 setValue(MAX); 257 269 state = BASE; 258 270 if(Gatherer.config.getMode() <= threshold) { … … 279 291 // One third complete 280 292 progress_bar.setIndeterminate(false); 281 progress_bar.setValue((int)(((double)current_stages + 0.3d) * MAX) / expected_stages);293 setValue((int)(((double)current_stages + 0.3d) * MAX) / expected_stages); 282 294 } 283 295 else if(value.equals(COMPRESSINGTEXT_VALUE)) { 284 296 // Two thirds complete 285 297 progress_bar.setIndeterminate(false); 286 progress_bar.setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);298 setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages); 287 299 } 288 300 else { … … 302 314 current_stages++; 303 315 progress_bar.setIndeterminate(false); 304 progress_bar.setValue((current_stages * MAX) / expected_stages);316 setValue((current_stages * MAX) / expected_stages); 305 317 state = BUILD; 306 318 } … … 323 335 // One fifth complete 324 336 progress_bar.setIndeterminate(false); 325 progress_bar.setValue((int)(((double)current_stages + 0.2d) * MAX) / expected_stages);337 setValue((int)(((double)current_stages + 0.2d) * MAX) / expected_stages); 326 338 } 327 339 else if(value.equals(CREATETHEWEIGHTS_VALUE)) { 328 340 // Two fifths complete 329 341 progress_bar.setIndeterminate(false); 330 progress_bar.setValue((int)(((double)current_stages + 0.4d) * MAX) / expected_stages);342 setValue((int)(((double)current_stages + 0.4d) * MAX) / expected_stages); 331 343 } 332 344 else if(value.equals(CREATESTEMMEDDIC_VALUE)) { 333 345 // Three fifths complete 334 346 progress_bar.setIndeterminate(false); 335 progress_bar.setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);347 setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages); 336 348 } 337 349 else if(value.equals(CREATINGSTEMINDX_VALUE)) { 338 350 // Four fifths complete 339 351 progress_bar.setIndeterminate(false); 340 progress_bar.setValue((int)(((double)current_stages + 0.8d) * MAX) / expected_stages);352 setValue((int)(((double)current_stages + 0.8d) * MAX) / expected_stages); 341 353 } 342 354 else { … … 359 371 current_stages++; 360 372 progress_bar.setIndeterminate(false); 361 progress_bar.setValue((current_stages * MAX) / expected_stages);373 setValue((current_stages * MAX) / expected_stages); 362 374 state = BUILD; 363 375 } … … 379 391 // One sixth complete 380 392 progress_bar.setIndeterminate(false); 381 progress_bar.setValue((int)(((double)current_stages + 0.16d) * MAX) / expected_stages);393 setValue((int)(((double)current_stages + 0.16d) * MAX) / expected_stages); 382 394 } 383 395 else if(value.equals(SORTANDRENUMBER_VALUE)) { 384 396 // Two sixths complete 385 397 progress_bar.setIndeterminate(false); 386 progress_bar.setValue((int)(((double)current_stages + 0.33d) * MAX) / expected_stages);398 setValue((int)(((double)current_stages + 0.33d) * MAX) / expected_stages); 387 399 } 388 400 else if(value.equals(PHRASEDATABASES_VALUE)) { 389 401 // Three sixths complete 390 402 progress_bar.setIndeterminate(false); 391 progress_bar.setValue((int)(((double)current_stages + 0.5d) * MAX) / expected_stages);403 setValue((int)(((double)current_stages + 0.5d) * MAX) / expected_stages); 392 404 } 393 405 else if(value.equals(WORDLEVELINDEXES_VALUE)) { 394 406 // Four sixths complete 395 407 progress_bar.setIndeterminate(false); 396 progress_bar.setValue((int)(((double)current_stages + 0.66d) * MAX) / expected_stages);408 setValue((int)(((double)current_stages + 0.66d) * MAX) / expected_stages); 397 409 } 398 410 else if(value.equals(DOCINFODATABASES_VALUE)) { 399 411 // Five sixths complete 400 412 progress_bar.setIndeterminate(false); 401 progress_bar.setValue((int)(((double)current_stages + 0.83d) * MAX) / expected_stages);413 setValue((int)(((double)current_stages + 0.83d) * MAX) / expected_stages); 402 414 } 403 415 else { … … 412 424 current_stages++; 413 425 progress_bar.setIndeterminate(false); 414 progress_bar.setValue((current_stages * MAX) / expected_stages);426 setValue((current_stages * MAX) / expected_stages); 415 427 state = BUILD; 416 428 } … … 429 441 current_stages++; 430 442 progress_bar.setIndeterminate(false); 431 progress_bar.setValue((current_stages * MAX) / expected_stages);443 setValue((current_stages * MAX) / expected_stages); 432 444 state = BUILD; 433 445 } … … 455 467 expected_stages = 0; 456 468 progress_bar.setIndeterminate(false); 457 progress_bar.setString( StaticStrings.SPACE_CHARACTER);458 progress_bar.setValue(MIN);469 progress_bar.setString(null); 470 setValue(MIN); 459 471 state = BASE; 460 stop = false;461 472 progress_bar.updateUI(); 462 473 } 463 474 464 475 public void saving() { 476 } 477 478 public void setSharedProgressBar(JProgressBar shared_progress_bar) { 479 this.shared_progress_bar = shared_progress_bar; 465 480 } 466 481 … … 468 483 * @param state The desired state of the stop flag as a <strong>boolean</strong>. 469 484 */ 470 public void setStop(boolean state) {471 stop = state;485 public synchronized void setStop(boolean state) { 486 this.stop = state; 472 487 progress_bar.setIndeterminate(false); 473 488 } … … 476 491 */ 477 492 public void start() { 478 progress_bar.setValue(MIN); 493 stop = false; 494 setValue(MIN); 479 495 expected_stages = 3; // Always compress text, create info database and auxiliary creation 480 496 // Retrieve cdm. … … 507 523 public void stop() { 508 524 progress_bar.setIndeterminate(false); 509 progress_bar.setValue(MAX); 525 setValue(MAX); 526 } 527 528 private void setValue(int value) { 529 progress_bar.setValue(value); 530 // Incrementing the shared progress bar is a little more problematic as we may very well be trying to set it to MIN but instead set it to halfway if we're not careful. 531 if(value > MIN) { 532 shared_progress_bar.setValue(MAX + value); 533 } 510 534 } 511 535 } -
trunk/gli/src/org/greenstone/gatherer/shell/GImportProgressMonitor.java
r6388 r6533 72 72 /** The progress bar this monitor updates. */ 73 73 private JProgressBar progress_bar; 74 75 /** The progress bar that is shared with build monitor. */ 76 private JProgressBar shared_progress_bar; 77 74 78 /** */ 75 79 static final private String BLOCKED_ATTRIBUTE = "blocked"; … … 102 106 progress_bar.setMaximum(CALCULATION + PROCESSED + EXTRACTED); 103 107 progress_bar.setMinimum(MIN); 104 progress_bar.setString( StaticStrings.SPACE_CHARACTER);108 progress_bar.setString(null); 105 109 progress_bar.setStringPainted(true); 110 next_progress_value = CALCULATION; 111 shared_progress_bar = new JProgressBar(); 112 shared_progress_bar.setIndeterminate(false); 113 shared_progress_bar.setMaximum((CALCULATION + PROCESSED + EXTRACTED) * 2); 114 shared_progress_bar.setMinimum(MIN); 115 shared_progress_bar.setString(null); // Default string 116 shared_progress_bar.setStringPainted(true); 106 117 setValue(MIN); 107 next_progress_value = CALCULATION;108 118 } 109 119 … … 143 153 } 144 154 155 public JProgressBar getSharedProgress() { 156 return shared_progress_bar; 157 } 158 145 159 /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor. 146 160 * @return A <strong>boolean</strong> indicating if the process has been asked to stop. 147 161 */ 148 public boolean hasSignalledStop() {162 public synchronized boolean hasSignalledStop() { 149 163 return stop; 150 164 } … … 168 182 line = line.substring(line.indexOf(StaticStrings.GREATER_THAN_CHARACTER) + 1); 169 183 line = line.trim(); 184 ///ystem.err.println("Process: " + line); 170 185 if(line.startsWith(StaticStrings.LESS_THAN_CHARACTER) && line.endsWith(StaticStrings.GREATER_THAN_CHARACTER)) { 171 186 // No original event is passed on, even in the lower modes … … 174 189 GShellElement element = new GShellElement(line); 175 190 String name = element.getElementName(); 191 ///ystem.err.println("Gatherer tag: " + name); 176 192 // We may be reading a file. Remember we have to offset process as we recieve this message 'before' a document is processed. Hence the use of 'next_progress_value' 177 193 if(name.equals(IMPORT_ELEMENT)) { 194 ///ystem.err.println("#Import"); 178 195 // We're into parsing output, so we don't need the 'calculating file size' etc string. 179 196 if(showing_string) { 180 progress_bar.setString( "");197 progress_bar.setString(null); 181 198 showing_string = false; 182 199 } … … 186 203 } 187 204 else if(name.equals(FILE_ELEMENT)) { 205 ///ystem.err.println("#File"); 188 206 file_count++; 189 207 // Set the next progress … … 197 215 // Or we're being told what plugin is actually processing the file 198 216 else if(name.equals(FILEPROCESSING_ELEMENT)) { 217 ///ystem.err.println("#FileProcessing"); 199 218 // If we are at lower mode settings fire a new 'dumbed down' event 200 219 if(Gatherer.config.getMode() <= threshold) { … … 243 262 num_docs = 0; 244 263 } 264 245 265 processed_str = null; 246 266 // The number of documents blocked … … 278 298 queue.add(new GShellEvent(event.getSource(), 0, event.getType(), Dictionary.get("GShell.Import.ImportComplete3"), event.getStatus())); 279 299 } 300 else { 301 // Try to set num docs 302 String processed_str = element.getAttribute(PROCESSED_ATTRIBUTE); 303 try { 304 num_docs = Integer.parseInt(processed_str); 305 } 306 catch(Exception exception) { 307 num_docs = 0; 308 } 309 } 280 310 } 281 311 else { … … 291 321 public void reset() { 292 322 setValue(MIN); 293 progress_bar.setString( StaticStrings.SPACE_CHARACTER);323 progress_bar.setString(null); 294 324 progress_bar.updateUI(); 295 325 } … … 303 333 * @param state The desired state of the stop flag as a <strong>boolean</strong>. 304 334 */ 305 public void setStop(boolean state) {306 stop = state;335 public synchronized void setStop(boolean state) { 336 this.stop = state; 307 337 } 308 338 … … 310 340 */ 311 341 public void start() { 342 stop = false; 312 343 setValue(MIN); 313 344 progress_bar.setString(Dictionary.get("FileActions.Calculating_Size")); … … 329 360 private void setValue(int value) { 330 361 progress_bar.setValue(value); 362 shared_progress_bar.setValue(value); 331 363 if(value != 0 && value < previous_value) { 332 364 Gatherer.println("Progress is decreasing! " + previous_value + " -> " + value); -
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r6388 r6533 42 42 import javax.swing.event.*; 43 43 import javax.swing.tree.*; 44 import org.greenstone.gatherer.Configuration; 44 45 import org.greenstone.gatherer.Dictionary; 45 46 import org.greenstone.gatherer.Gatherer; … … 228 229 } 229 230 } 230 231 // Of course, just because the process is finished doesn't mean the incoming streams are empty. Unfortunately I've got no chance of preserving order, so I'll process the error stream first, then the out stream 232 while(eisr.ready()) { 233 int c = eisr.read(); 234 ///atherer.println("eisr: '" + (char) c + "'"); 235 if(c == '\n' || c == '\r') { 236 if(eline_buffer.length() > 0) { 237 String eline = eline_buffer.toString(); 238 ///atherer.println("* " + eline + " *"); 239 fireMessage(type, typeAsString(type) + "> " + eline, status, bos); 240 eline = null; 241 eline_buffer = new StringBuffer(); 242 } 243 } 244 else { 245 eline_buffer.append((char)c); 246 } 247 } 248 while(stdisr.ready()) { 249 int c = stdisr.read(); 250 ///atherer.println("eisr: '" + (char) c + "'"); 251 if(c == '\n' || c == '\r') { 252 if(stdline_buffer.length() > 0) { 253 String stdline = stdline_buffer.toString(); 254 ///atherer.println("+ " + stdline + " +"); 255 fireMessage(type, typeAsString(type) + "> " + stdline, status, null); 256 stdline = null; 257 stdline_buffer = new StringBuffer(); 258 } 259 } 260 else { 261 stdline_buffer.append((char)c); 262 } 263 } 264 265 // Ensure that any messages still remaining in the string buffers are fired off. 266 if(eline_buffer.length() > 0) { 267 String eline = eline_buffer.toString(); 268 ///atherer.println("Last bit of eline: " + eline); 269 fireMessage(type, typeAsString(type) + "> " + eline, status, bos); 270 eline = null; 271 } 272 273 if(stdline_buffer.length() > 0) { 274 String stdline = stdline_buffer.toString(); 275 ///atherer.println("Last bit of stdline: " + stdline); 276 fireMessage(type, typeAsString(type) + "> " + stdline, status, null); 277 stdline = null; 231 if(!hasSignalledStop()) { 232 // Of course, just because the process is finished doesn't mean the incoming streams are empty. Unfortunately I've got no chance of preserving order, so I'll process the error stream first, then the out stream 233 while(eisr.ready()) { 234 int c = eisr.read(); 235 ///atherer.println("eisr: '" + (char) c + "'"); 236 if(c == '\n' || c == '\r') { 237 if(eline_buffer.length() > 0) { 238 String eline = eline_buffer.toString(); 239 ///atherer.println("* " + eline + " *"); 240 fireMessage(type, typeAsString(type) + "> " + eline, status, bos); 241 eline = null; 242 eline_buffer = new StringBuffer(); 243 } 244 } 245 else { 246 eline_buffer.append((char)c); 247 } 248 } 249 while(stdisr.ready()) { 250 int c = stdisr.read(); 251 ///atherer.println("eisr: '" + (char) c + "'"); 252 if(c == '\n' || c == '\r') { 253 if(stdline_buffer.length() > 0) { 254 String stdline = stdline_buffer.toString(); 255 ///atherer.println("+ " + stdline + " +"); 256 fireMessage(type, typeAsString(type) + "> " + stdline, status, null); 257 stdline = null; 258 stdline_buffer = new StringBuffer(); 259 } 260 } 261 else { 262 stdline_buffer.append((char)c); 263 } 264 } 265 266 // Ensure that any messages still remaining in the string buffers are fired off. 267 if(eline_buffer.length() > 0) { 268 String eline = eline_buffer.toString(); 269 ///atherer.println("Last bit of eline: " + eline); 270 fireMessage(type, typeAsString(type) + "> " + eline, status, bos); 271 eline = null; 272 } 273 274 if(stdline_buffer.length() > 0) { 275 String stdline = stdline_buffer.toString(); 276 ///atherer.println("Last bit of stdline: " + stdline); 277 fireMessage(type, typeAsString(type) + "> " + stdline, status, null); 278 stdline = null; 279 } 280 } 281 else { 282 System.err.println("We've been asked to stop."); 278 283 } 279 284 … … 312 317 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Complete"), status, null); 313 318 } 319 if(hasSignalledStop()) { 320 status = CANCELLED; 321 } 314 322 // We're done. 315 323 fireProcessComplete(type, status); … … 388 396 */ 389 397 protected void fireProcessComplete(int type, int status) { 390 // Tidy up by stopping the progress bar. 391 if(progress != null ) {398 // Tidy up by stopping the progress bar. If it was cancelled then the cancel command has arrived via the progress bars and they don't need to be told again (it actually causes problems). 399 if(progress != null && status != CANCELLED) { 392 400 progress.stop(); 401 } 402 403 // If we were cancelled, and we are lower details modes, fire off one last message. 404 if(status == CANCELLED && Gatherer.config.getMode() <= Configuration.SYSTEMS_MODE) { 405 GShellEvent current_event = new GShellEvent(this, 0, type, Dictionary.get("GShell.Build.BuildCancelled"), status); 406 Object[] concerned = listeners.getListenerList(); 407 for(int i = 0; i < concerned.length ; i++) { 408 if(concerned[i] == GShellListener.class) { 409 ((GShellListener)concerned[i+1]).message(current_event); 410 } 411 } 412 concerned = null; 393 413 } 394 414 // And firing off an event … … 408 428 boolean has_signalled_stop = false; 409 429 if(progress != null) { 410 returnprogress.hasSignalledStop();430 has_signalled_stop = progress.hasSignalledStop(); 411 431 } 412 432 return has_signalled_stop; -
trunk/gli/src/org/greenstone/gatherer/shell/GShellProgressMonitor.java
r6388 r6533 66 66 public int exitValue(); 67 67 68 public JProgressBar getSharedProgress(); 69 68 70 /** Method to retrieve whatever control is being used as the progress indicator. Usually a <strong>JProgressBar</strong> but there may be others implemented later. 69 71 * @return A <strong>Component</strong> on which the progress of the process is being displayed.
Note:
See TracChangeset
for help on using the changeset viewer.