X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FConsole.java;h=41da01fc2da4b49da87360308c47e4b6034ae3db;hb=ccc53e88e3260886f5d3bdacc619c0f374be9b8f;hp=89380a32b31f0e081896139c4ed21b7e4e9b1e3e;hpb=b4151f8875efd004ab1b4c9501ae8a5b265a36c4;p=jalview.git diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 89380a3..41da01f 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -107,7 +107,7 @@ public class Console extends WindowAdapter private JComboBox logLevelCombo = new JComboBox(); - protected LogLevel startingLogLevel = LogLevel.INFO; + protected LogLevel startingLogLevel = null; public Console() { @@ -148,6 +148,7 @@ public class Console extends WindowAdapter scrollPane.setBorder(noBorder); textArea.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) @@ -173,6 +174,7 @@ public class Console extends WindowAdapter MessageManager.getString("label.copy_to_clipboard")); copyToClipboardButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { copyConsoleTextToClipboard(); @@ -184,12 +186,14 @@ public class Console extends WindowAdapter private Color fg = textArea.getForeground(); + @Override public void mousePressed(MouseEvent e) { textArea.setBackground(textArea.getSelectionColor()); textArea.setForeground(textArea.getSelectedTextColor()); } + @Override public void mouseReleased(MouseEvent e) { textArea.setBackground(bg); @@ -213,11 +217,19 @@ public class Console extends WindowAdapter // logLevelCombo.addItem(LogLevel.ERROR); // logLevelCombo.addItem(LogLevel.OFF); // set startingLogLevel - startingLogLevel = jalview.bin.Console.log == null ? LogLevel.INFO - : jalview.bin.Console.log.getLevel(); + + if (jalview.bin.Console.getLogger() == null) + { + startingLogLevel = jalview.bin.Console.getCachedLogLevel(); + } + else + { + startingLogLevel = jalview.bin.Console.getLogger().getLevel(); + } setChosenLogLevelCombo(); logLevelCombo.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (jalview.bin.Console.log != null) @@ -314,7 +326,7 @@ public class Console extends WindowAdapter boolean added = false; for (int i = 0; i < logLevelCombo.getItemCount(); i++) { - LogLevel l = (LogLevel) logLevelCombo.getItemAt(i); + LogLevel l = logLevelCombo.getItemAt(i); if (l.compareTo(setLogLevel) >= 0) { logLevelCombo.insertItemAt(setLogLevel, i); @@ -476,36 +488,32 @@ public class Console extends WindowAdapter */ public Console(Desktop desktop) { - this(desktop, true); - } - - /** - * attach a console to the desktop - the desktop will open it if requested. - * - * @param desktop - * @param showjconsole - * - if true, then redirect stdout immediately - */ - public Console(Desktop desktop, boolean showjconsole) - { parent = desktop; // window name - get x,y,width, height possibly scaled - Rectangle bounds = desktop.getLastKnownDimensions("JAVA_CONSOLE_"); - if (bounds == null) + Rectangle bounds = parent == null ? null + : parent.getLastKnownDimensions("JAVA_CONSOLE_"); + if (bounds != null) { frame = initFrame( ChannelProperties.getProperty("app_name") + " Java Console", - desktop.getWidth() / 2, desktop.getHeight() / 4, - desktop.getX(), desktop.getY()); + bounds.width, bounds.height, bounds.x, bounds.y); + } + else if (parent != null && parent.getWidth() > 0 + && parent.getHeight() > 0) + { + frame = initFrame( + ChannelProperties.getProperty("app_name") + " Java Console", + parent.getWidth() / 2, parent.getHeight() / 4, parent.getX(), + parent.getY()); } else { frame = initFrame( ChannelProperties.getProperty("app_name") + " Java Console", - bounds.width, bounds.height, bounds.x, bounds.y); + MIN_WIDTH, MIN_HEIGHT, 10, 10); } frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); - // desktop.add(frame); + // parent.add(frame); initConsole(false); LogLevel level = (LogLevel) logLevelCombo.getSelectedItem(); if (!Platform.isJS()) @@ -538,6 +546,7 @@ public class Console extends WindowAdapter pin.close(); } catch (Exception e) { + jalview.bin.Console.debug("pin.close() error", e); } try { @@ -545,12 +554,14 @@ public class Console extends WindowAdapter pin2.close(); } catch (Exception e) { + jalview.bin.Console.debug("pin2.close() error", e); } try { textAppender.join(10); } catch (Exception e) { + jalview.bin.Console.debug("textAppender.join(10) error", e); } } /* @@ -611,12 +622,9 @@ 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); } } @@ -642,13 +650,14 @@ public class Console extends WindowAdapter { try { - this.wait(100); + this.wait(100); // ##### implicated BLOCKED if (pin2.available() == 0) { trimBuffer(false); } } catch (InterruptedException ie) { + jalview.bin.Console.debug("pin.available() error", ie); } } while (pin2.available() != 0) @@ -689,7 +698,7 @@ public class Console extends WindowAdapter textArea.append(replace.toString()); trimBuffer(false); } - }); + }); } if (displayPipe.length() == 0) { @@ -709,6 +718,7 @@ public class Console extends WindowAdapter } } catch (InterruptedException e) { + jalview.bin.Console.debug("displayPipe.length() error", e); } } } @@ -719,7 +729,7 @@ public class Console extends WindowAdapter this.wait(100); } catch (InterruptedException e) { - + jalview.bin.Console.debug("this.wait(100) error", e); } } if (quit) @@ -746,6 +756,7 @@ public class Console extends WindowAdapter this.wait(1000); } catch (InterruptedException ie) { + jalview.bin.Console.debug("this.wait(1000) error", ie); } throw new NullPointerException( MessageManager.getString("exception.application_test_npe")); @@ -765,7 +776,7 @@ public class Console extends WindowAdapter @Override public void run() { - displayPipe.append(input); + displayPipe.append(input); } }); // stderr.println("Time taken to Spawnappend:\t" + (System.nanoTime() - @@ -787,7 +798,7 @@ public class Console extends WindowAdapter + "\nTruncated...\n"; } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } } // trim the buffer @@ -811,7 +822,7 @@ public class Console extends WindowAdapter } } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } // lines = textArea.getLineCount(); }