From: Ben Soares Date: Wed, 11 Oct 2023 11:11:09 +0000 (+0100) Subject: JAL-4298 Added diagnostics and minor dimension changes to Java Console. Added a... X-Git-Tag: Release_2_11_4_0~131^2~14 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d76c189f5d49526a39d03e291f84400b95c177b2;p=jalview.git JAL-4298 Added diagnostics and minor dimension changes to Java Console. Added a --javaconsole Arg. --- diff --git a/help/help/html/features/clarguments-reference.html b/help/help/html/features/clarguments-reference.html index b2e29e9..b1588e5 100644 --- a/help/help/html/features/clarguments-reference.html +++ b/help/help/html/features/clarguments-reference.html @@ -92,6 +92,11 @@ + ‑‑javaconsole / ‑‑nojavaconsole + Show (/ or don't show) the Java Console. Using one of these overrides any saved Preference. + + + ‑‑questionnaire / ‑‑noquestionnaire Show (/ or don't show) the questionnaire if one is available. diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index a44d474..483b1fc 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -54,6 +54,8 @@ import javax.swing.LookAndFeel; 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; @@ -1732,4 +1734,10 @@ public class Cache { 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); + } } diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index 2a3a4a1..93156ac 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -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), + 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.", diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 4600719..bf3942a 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -506,8 +506,16 @@ public class Console extends WindowAdapter { 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", @@ -518,7 +526,7 @@ public class Console extends WindowAdapter { 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); @@ -554,6 +562,7 @@ public class Console extends WindowAdapter pin.close(); } catch (Exception e) { + jalview.bin.Console.debug("pin.close() error", e); } try { @@ -561,12 +570,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); } } /* @@ -633,6 +644,7 @@ public class Console extends WindowAdapter } } catch (InterruptedException ie) { + jalview.bin.Console.debug("pin.available() error", ie); } } @@ -665,6 +677,7 @@ public class Console extends WindowAdapter } } catch (InterruptedException ie) { + jalview.bin.Console.debug("pin.available() error", ie); } } while (pin2.available() != 0) @@ -718,6 +731,7 @@ public class Console extends WindowAdapter } } 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) { - + jalview.bin.Console.debug("this.wait(100) error", e); } } if (quit) @@ -755,6 +769,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")); @@ -798,7 +813,7 @@ public class Console extends WindowAdapter + "\nTruncated...\n"; } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } } // trim the buffer @@ -822,7 +837,7 @@ public class Console extends WindowAdapter } } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } // lines = textArea.getLineCount(); } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 47b8893..e0e2307 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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.argparser.Arg; 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 showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false); + boolean showjconsole = Cache.getArgCacheDefault(Arg.JAVACONSOLE, + "SHOW_JAVA_CONSOLE", false); // 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); - while (ix >= screenSize.width) + if (ix >= screenSize.width) { 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."); - iy -= screenSize.height; + iy = iy % screenSize.height; } jalview.bin.Console.debug( "Got last known dimensions for " + windowName + ": x:" + ix