JAL-4298 Added diagnostics and minor dimension changes to Java Console. Added a...
[jalview.git] / src / jalview / gui / Console.java
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
-    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();
       }