From 69766c1dcb7fd50c02c100addb3f0d3a689e9169 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 7 Nov 2024 12:26:55 +0000 Subject: [PATCH] JAL-3676 Allow extra header information in Java Console for release version when DEBUG is selected --- src/jalview/bin/Cache.java | 16 +++++++++++----- src/jalview/gui/Console.java | 13 +++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 6a82e7d..c7490ea 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1226,7 +1226,12 @@ public class Cache */ public static String getVersionDetailsForConsole() { - boolean extra = Console.isDebugEnabled() + return getVersionDetailsForConsole(false); + } + + public static String getVersionDetailsForConsole(boolean forceExtra) + { + boolean extra = forceExtra || Console.isDebugEnabled() || !"release".equals(ChannelProperties.getProperty("channel")); StringBuilder sb = new StringBuilder(); sb.append(ChannelProperties.getProperty("app_name")) @@ -1500,10 +1505,11 @@ public class Cache if (customProxySet && // we have a username but no password for the scheme being // requested - (protocol.equalsIgnoreCase("http") - && (httpUser != null && httpUser.length() > 0 - && (httpPassword == null - || httpPassword.length == 0))) + (protocol.equalsIgnoreCase("http") + && (httpUser != null + && httpUser.length() > 0 + && (httpPassword == null + || httpPassword.length == 0))) || (protocol.equalsIgnoreCase("https") && (httpsUser != null && httpsUser.length() > 0 diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 41da01f..e01cf5d 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -54,6 +54,7 @@ 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; @@ -606,6 +607,10 @@ public class Console extends WindowAdapter @Override public synchronized void actionPerformed(ActionEvent evt) { + if (getSelectedLogLevel() == LogLevel.DEBUG) + { + setHeader(Cache.getVersionDetailsForConsole(true)); + } trimBuffer(true); // textArea.setText(""); } @@ -693,6 +698,7 @@ public class Console extends WindowAdapter // Append formatted message to textarea using the Swing Thread. SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { textArea.append(replace.toString()); @@ -710,6 +716,7 @@ public class Console extends WindowAdapter // post a trim on Swing Thread. SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { trimBuffer(false); @@ -920,4 +927,10 @@ public class Console extends WindowAdapter { return header; } + + public LogLevel getSelectedLogLevel() + { + return logLevelCombo == null ? null + : (LogLevel) logLevelCombo.getSelectedItem(); + } } -- 1.7.10.2