()
| 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public void run() { |
| 421 | |
| 422 | if(cboAppend.isSelected() && logFileWriter != null) { |
| 423 | // if logging to a file is enabled then do the logging |
| 424 | logFileWriter.print(text); |
| 425 | logFileWriter.flush(); |
| 426 | } |
| 427 | |
| 428 | try { |
| 429 | // endPos is always one past the real end position because of the |
| 430 | // implicit newline character at the end of any Document |
| 431 | getDocument().insertString(endPos.getOffset() - 1, text, style); |
| 432 | |
| 433 | if(cboLogSize.isSelected() |
| 434 | && getDocument().getLength() > logSizeModel.getNumber().intValue()) { |
| 435 | // if the document is now over the buffer size then trim it roughly to |
| 436 | // length by finding the first new line within the valid buffer size |
| 437 | // and cutting there or if there is no new line then just trim to |
| 438 | // length |
| 439 | int index = |
| 440 | getText().indexOf( |
| 441 | "\n", |
| 442 | getDocument().getLength() |
| 443 | - logSizeModel.getNumber().intValue()) + 1; |
| 444 | getDocument().remove( |
| 445 | 0, |
| 446 | index != 0 ? index : getDocument().getLength() |
| 447 | - logSizeModel.getNumber().intValue()); |
| 448 | } |
| 449 | |
| 450 | if(!btnScrollLock.isSelected()) { |
| 451 | setCaretPosition(getDocument().getLength()); |
| 452 | } |
| 453 | } catch(BadLocationException e) { |
| 454 | // a BLE here is a real problem |
| 455 | handleBadLocationException(e, text, style); |
| 456 | }// End try |
| 457 | } |
| 458 | |
| 459 | String text; |
| 460 |
nothing calls this directly
no test coverage detected