JAL-4298 Added diagnostics and minor dimension changes to Java Console. Added a...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 11 Oct 2023 11:11:09 +0000 (12:11 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 11 Oct 2023 11:11:09 +0000 (12:11 +0100)
help/help/html/features/clarguments-reference.html
src/jalview/bin/Cache.java
src/jalview/bin/argparser/Arg.java
src/jalview/gui/Console.java
src/jalview/gui/Desktop.java

index b2e29e9..b1588e5 100644 (file)
     </tr>
 
     <tr valign="top">
     </tr>
 
     <tr valign="top">
+    <td><code>&#8209;&#8209;javaconsole / &#8209;&#8209;nojavaconsole</code></td>
+    <td>Show (/ or don't show) the Java Console.  Using one of these overrides any saved Preference.</td>
+    </tr>
+
+    <tr valign="top">
     <td><code>&#8209;&#8209;questionnaire / &#8209;&#8209;noquestionnaire</code></td>
     <td>Show (/ or don't show) the questionnaire if one is available.</td>
     </tr>
     <td><code>&#8209;&#8209;questionnaire / &#8209;&#8209;noquestionnaire</code></td>
     <td>Show (/ or don't show) the questionnaire if one is available.</td>
     </tr>
index a44d474..483b1fc 100755 (executable)
@@ -54,6 +54,8 @@ import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
 
 import jalview.analytics.Plausible;
 import javax.swing.UIManager;
 
 import jalview.analytics.Plausible;
+import jalview.bin.argparser.Arg;
+import jalview.bin.argparser.ArgParser;
 import jalview.datamodel.PDBEntry;
 import jalview.gui.Preferences;
 import jalview.gui.UserDefinedColours;
 import jalview.datamodel.PDBEntry;
 import jalview.gui.Preferences;
 import jalview.gui.UserDefinedColours;
@@ -1732,4 +1734,10 @@ public class Cache
   {
     return key == null ? null : sessionProperties.get(key);
   }
   {
     return key == null ? null : sessionProperties.get(key);
   }
+
+  public static boolean getArgCacheDefault(Arg a, String pref, boolean def)
+  {
+    ArgParser ap = Jalview.getInstance().getArgParser();
+    return ap.isSet(a) ? ap.getBoolean(a) : getDefault(pref, def);
+  }
 }
 }
index 2a3a4a1..93156ac 100644 (file)
@@ -44,6 +44,8 @@ public enum Arg
   QUESTIONNAIRE(Type.CONFIG,
           "Show (or don't show) the questionnaire if one is available.",
           true, Opt.BOOLEAN, Opt.BOOTSTRAP),
   QUESTIONNAIRE(Type.CONFIG,
           "Show (or don't show) the questionnaire if one is available.",
           true, Opt.BOOLEAN, Opt.BOOTSTRAP),
+  JAVACONSOLE(Type.CONFIG, "Show (or don't show) the Java Console.", false,
+          Opt.BOOLEAN, Opt.BOOTSTRAP),
   NOUSAGESTATS(Type.CONFIG, "Don't send initial launch usage stats.",
           Opt.UNARY, Opt.BOOTSTRAP),
   NOSTARTUPFILE(Type.CONFIG, "Don't show the default startup file.",
   NOUSAGESTATS(Type.CONFIG, "Don't send initial launch usage stats.",
           Opt.UNARY, Opt.BOOTSTRAP),
   NOSTARTUPFILE(Type.CONFIG, "Don't show the default startup file.",
index 4600719..bf3942a 100644 (file)
@@ -506,8 +506,16 @@ public class Console extends WindowAdapter
   {
     parent = desktop;
     // window name - get x,y,width, height possibly scaled
   {
     parent = desktop;
     // window name - get x,y,width, height possibly scaled
-    Rectangle bounds = parent.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",
+              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",
     {
       frame = initFrame(
               ChannelProperties.getProperty("app_name") + " Java Console",
@@ -518,7 +526,7 @@ public class Console extends WindowAdapter
     {
       frame = initFrame(
               ChannelProperties.getProperty("app_name") + " Java Console",
     {
       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));
     // parent.add(frame);
     }
     frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
     // parent.add(frame);
@@ -554,6 +562,7 @@ public class Console extends WindowAdapter
         pin.close();
       } catch (Exception e)
       {
         pin.close();
       } catch (Exception e)
       {
+        jalview.bin.Console.debug("pin.close() error", e);
       }
       try
       {
       }
       try
       {
@@ -561,12 +570,14 @@ public class Console extends WindowAdapter
         pin2.close();
       } catch (Exception e)
       {
         pin2.close();
       } catch (Exception e)
       {
+        jalview.bin.Console.debug("pin2.close() error", e);
       }
       try
       {
         textAppender.join(10);
       } catch (Exception e)
       {
       }
       try
       {
         textAppender.join(10);
       } catch (Exception e)
       {
+        jalview.bin.Console.debug("textAppender.join(10) error", e);
       }
     }
     /*
       }
     }
     /*
@@ -633,6 +644,7 @@ public class Console extends WindowAdapter
             }
           } catch (InterruptedException ie)
           {
             }
           } catch (InterruptedException ie)
           {
+            jalview.bin.Console.debug("pin.available() error", ie);
           }
         }
 
           }
         }
 
@@ -665,6 +677,7 @@ public class Console extends WindowAdapter
             }
           } catch (InterruptedException ie)
           {
             }
           } catch (InterruptedException ie)
           {
+            jalview.bin.Console.debug("pin.available() error", ie);
           }
         }
         while (pin2.available() != 0)
           }
         }
         while (pin2.available() != 0)
@@ -718,6 +731,7 @@ public class Console extends WindowAdapter
               }
             } catch (InterruptedException e)
             {
               }
             } catch (InterruptedException e)
             {
+              jalview.bin.Console.debug("displayPipe.length() error", e);
             }
           }
         }
             }
           }
         }
@@ -728,7 +742,7 @@ public class Console extends WindowAdapter
             this.wait(100);
           } catch (InterruptedException e)
           {
             this.wait(100);
           } catch (InterruptedException e)
           {
-
+            jalview.bin.Console.debug("this.wait(100) error", e);
           }
         }
         if (quit)
           }
         }
         if (quit)
@@ -755,6 +769,7 @@ public class Console extends WindowAdapter
         this.wait(1000);
       } catch (InterruptedException ie)
       {
         this.wait(1000);
       } catch (InterruptedException ie)
       {
+        jalview.bin.Console.debug("this.wait(1000) error", ie);
       }
       throw new NullPointerException(
               MessageManager.getString("exception.application_test_npe"));
       }
       throw new NullPointerException(
               MessageManager.getString("exception.application_test_npe"));
@@ -798,7 +813,7 @@ public class Console extends WindowAdapter
                 + "\nTruncated...\n";
       } catch (Exception e)
       {
                 + "\nTruncated...\n";
       } catch (Exception e)
       {
-        e.printStackTrace();
+        jalview.bin.Console.warn("textArea Exception", e);
       }
     }
     // trim the buffer
       }
     }
     // trim the buffer
@@ -822,7 +837,7 @@ public class Console extends WindowAdapter
           }
         } catch (Exception e)
         {
           }
         } catch (Exception e)
         {
-          e.printStackTrace();
+          jalview.bin.Console.warn("textArea Exception", e);
         }
         // lines = textArea.getLineCount();
       }
         }
         // lines = textArea.getLineCount();
       }
index 47b8893..e0e2307 100644 (file)
@@ -113,6 +113,7 @@ import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.bin.Jalview.ExitCode;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.bin.Jalview.ExitCode;
+import jalview.bin.argparser.Arg;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
@@ -498,7 +499,8 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false);
 
 
     boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false);
 
-    boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false);
+    boolean showjconsole = Cache.getArgCacheDefault(Arg.JAVACONSOLE,
+            "SHOW_JAVA_CONSOLE", false);
 
     // start dialogue queue for single dialogues
     startDialogQueue();
 
     // start dialogue queue for single dialogues
     startDialogQueue();
@@ -800,17 +802,17 @@ public class Desktop extends jalview.jbgui.GDesktop
         iw = (int) (iw * sw);
         iy = (int) (iy * sh);
         ih = (int) (ih * sh);
         iw = (int) (iw * sw);
         iy = (int) (iy * sh);
         ih = (int) (ih * sh);
-        while (ix >= screenSize.width)
+        if (ix >= screenSize.width)
         {
           jalview.bin.Console.debug(
                   "Window geometry location recall error: shifting horizontal to within screenbounds.");
         {
           jalview.bin.Console.debug(
                   "Window geometry location recall error: shifting horizontal to within screenbounds.");
-          ix -= screenSize.width;
+          ix = ix % screenSize.width;
         }
         }
-        while (iy >= screenSize.height)
+        if (iy >= screenSize.height)
         {
           jalview.bin.Console.debug(
                   "Window geometry location recall error: shifting vertical to within screenbounds.");
         {
           jalview.bin.Console.debug(
                   "Window geometry location recall error: shifting vertical to within screenbounds.");
-          iy -= screenSize.height;
+          iy = iy % screenSize.height;
         }
         jalview.bin.Console.debug(
                 "Got last known dimensions for " + windowName + ": x:" + ix
         }
         jalview.bin.Console.debug(
                 "Got last known dimensions for " + windowName + ": x:" + ix