X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FConsole.java;h=41da01fc2da4b49da87360308c47e4b6034ae3db;hb=9fef0746bf53cc0faff2bd45f1dbdb82398f4c62;hp=bf3942aa305176d1eb254daf78f20629128d3733;hpb=d76c189f5d49526a39d03e291f84400b95c177b2;p=jalview.git diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index bf3942a..41da01f 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -50,10 +50,10 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.text.DefaultCaret; -import jalview.bin.Cache; import jalview.log.JLoggerI.LogLevel; import jalview.log.JLoggerLog4j; import jalview.log.JalviewAppender; @@ -217,30 +217,14 @@ public class Console extends WindowAdapter // logLevelCombo.addItem(LogLevel.ERROR); // logLevelCombo.addItem(LogLevel.OFF); // set startingLogLevel - if (jalview.bin.Console.log == null) + + if (jalview.bin.Console.getLogger() == null) { - try - { - startingLogLevel = LogLevel - .valueOf(Cache.getDefault(Cache.JALVIEWLOGLEVEL, null)); - } catch (IllegalArgumentException e1) - { - jalview.bin.Console.debug( - "Invalid value for preference " + Cache.JALVIEWLOGLEVEL); - } catch (NullPointerException e2) - { - // no value in preferences - } finally - { - if (startingLogLevel == null) - { - startingLogLevel = LogLevel.INFO; - } - } + startingLogLevel = jalview.bin.Console.getCachedLogLevel(); } else { - startingLogLevel = jalview.bin.Console.log.getLevel(); + startingLogLevel = jalview.bin.Console.getLogger().getLevel(); } setChosenLogLevelCombo(); logLevelCombo.addActionListener(new ActionListener() @@ -638,10 +622,6 @@ public class Console extends WindowAdapter try { this.wait(100); - if (pin.available() == 0) - { - trimBuffer(false); - } } catch (InterruptedException ie) { jalview.bin.Console.debug("pin.available() error", ie); @@ -670,7 +650,7 @@ public class Console extends WindowAdapter { try { - this.wait(100); + this.wait(100); // ##### implicated BLOCKED if (pin2.available() == 0) { trimBuffer(false); @@ -702,23 +682,23 @@ public class Console extends WindowAdapter // check string buffer - if greater than console, clear console and // replace with last segment of content, otherwise, append all to // content. - long count; while (displayPipe.length() > 0) { - count = 0; StringBuffer tmp = new StringBuffer(), replace; synchronized (displayPipe) { replace = displayPipe; displayPipe = tmp; } - // simply append whole buffer - textArea.append(replace.toString()); - count += replace.length(); - if (count > byteslim) + // Append formatted message to textarea using the Swing Thread. + SwingUtilities.invokeLater(new Runnable() { - trimBuffer(false); - } + public void run() + { + textArea.append(replace.toString()); + trimBuffer(false); + } + }); } if (displayPipe.length() == 0) { @@ -727,7 +707,14 @@ public class Console extends WindowAdapter this.wait(100); if (displayPipe.length() == 0) { - trimBuffer(false); + // post a trim on Swing Thread. + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + trimBuffer(false); + } + }); } } catch (InterruptedException e) { @@ -789,9 +776,7 @@ public class Console extends WindowAdapter @Override public void run() { - displayPipe.append(input); // change to stringBuffer - // displayPipe.flush(); - + displayPipe.append(input); } }); // stderr.println("Time taken to Spawnappend:\t" + (System.nanoTime() -