JAL-3676 Allow extra header information in Java Console for release version when...
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 7 Nov 2024 12:26:55 +0000 (12:26 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 7 Nov 2024 12:26:55 +0000 (12:26 +0000)
src/jalview/bin/Cache.java
src/jalview/gui/Console.java

index 6a82e7d..c7490ea 100755 (executable)
@@ -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
index 41da01f..e01cf5d 100644 (file)
@@ -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();
+  }
 }