JAL-3446 no actual changes; just using meaningful frame options
[jalview.git] / src / jalview / gui / Desktop.java
index d11813d..7115e18 100644 (file)
@@ -482,7 +482,6 @@ public class Desktop extends GDesktop
 
         experimentalFeatures.setSelected(showExperimental());
 
-
         checkURLLinks();
 
         // Spawn a thread that shows the splashscreen
@@ -659,8 +658,8 @@ public class Desktop extends GDesktop
         public void run()
         {
           long now = System.currentTimeMillis();
-          setProgressBar(
-                  MessageManager.getString("status.refreshing_news"), now);
+          setProgressBar(MessageManager.getString("status.refreshing_news"),
+                  now);
           jvnews.refreshNews();
           setProgressBar(null, now);
           jvnews.showNews();
@@ -768,48 +767,60 @@ public class Desktop extends GDesktop
     }
   }
 
-  /**
-   * Adds and opens the given frame to the desktop
-   * 
-   * @param frame
-   *          Frame to show
-   * @param title
-   *          Visible Title
-   * @param w
-   *          width
-   * @param h
-   *          height
-   */
-  public static synchronized void addInternalFrame(
-          final JInternalFrame frame, String title, int w, int h)
-  {
-    addInternalFrame(frame, title, true, w, h, true, false);
-  }
-
-  /**
-   * Add an internal frame to the Jalview desktop
-   * 
-   * @param frame
-   *          Frame to show
-   * @param title
-   *          Visible Title
-   * @param makeVisible
-   *          When true, display frame immediately, otherwise, caller must call
-   *          setVisible themselves.
-   * @param w
-   *          width
-   * @param h
-   *          height
-   */
-  public static synchronized void addInternalFrame(
-          final JInternalFrame frame, String title, boolean makeVisible,
-          int w, int h)
-  {
-    addInternalFrame(frame, title, makeVisible, w, h, true, false);
-  }
+//  /**
+//   * Add an internal frame to the Jalview desktop that is allowed to be resized,
+//   * has a minimum size of 300px and might or might not be visible
+//   * 
+//   * @param frame
+//   *          Frame to show
+//   * @param title
+//   *          Visible Title
+//   * @param makeVisible
+//   *          When true, display frame immediately, otherwise, caller must call
+//   *          setVisible themselves.
+//   * @param w
+//   *          width
+//   * @param h
+//   *          height
+//   */
+//  @Deprecated
+//  public static synchronized void addInternalFrame(
+//          final JInternalFrame frame, String title, boolean makeVisible,
+//          int w, int h)
+//  {
+//    // textbox, web services, sequenceFetcher, featureSettings
+//    getInstance().addFrame(frame, title, makeVisible, w, h,
+//            FRAME_ALLOW_RESIZE, FRAME_SET_MIN_SIZE_300);
+//  }
+//
+//  /**
+//   * Add an internal frame to the Jalview desktop that is visible, has a minimum
+//   * size of 300px, and may or may not be resizable
+//   * 
+//   * @param frame
+//   *          Frame to show
+//   * @param title
+//   *          Visible Title
+//   * @param w
+//   *          width
+//   * @param h
+//   *          height
+//   * @param resizable
+//   *          Allow resize
+//   */
+//  @Deprecated
+//  public static synchronized void addInternalFrame(
+//          final JInternalFrame frame, String title, int w, int h,
+//          boolean resizable)
+//  {
+//    // annotation, font, calculation, user-defined colors
+//    getInstance().addFrame(frame, title, FRAME_MAKE_VISIBLE, w, h,
+//            resizable, FRAME_SET_MIN_SIZE_300);
+//  }
 
   /**
-   * Add an internal frame to the Jalview desktop and make it visible
+   * Adds and opens the given frame to the desktop that is visible, allowed to
+   * resize, and has a 300px minimum width.
    * 
    * @param frame
    *          Frame to show
@@ -819,18 +830,18 @@ public class Desktop extends GDesktop
    *          width
    * @param h
    *          height
-   * @param resizable
-   *          Allow resize
    */
   public static synchronized void addInternalFrame(
-          final JInternalFrame frame, String title, int w, int h,
-          boolean resizable)
+          final JInternalFrame frame, String title, int w, int h)
   {
-    addInternalFrame(frame, title, true, w, h, resizable, false);
+    // 58 classes
+    getInstance().addFrame(frame, title, Desktop.FRAME_MAKE_VISIBLE, w, h,
+            FRAME_ALLOW_RESIZE, FRAME_SET_MIN_SIZE_300);
   }
 
   /**
-   * Add an internal frame to the Jalview desktop
+   * Add an internal frame to the Jalview desktop that may optionally be
+   * visible, resizable, and allowed to be any size
    * 
    * @param frame
    *          Frame to show
@@ -852,21 +863,36 @@ public class Desktop extends GDesktop
           final JInternalFrame frame, String title, boolean makeVisible,
           int w, int h, boolean resizable, boolean ignoreMinSize)
   {
-    
-    getInstance().addFrame(frame, title, makeVisible, w, h, resizable, ignoreMinSize);
+    // 15 classes
+    getInstance().addFrame(frame, title, makeVisible, w, h, resizable,
+            ignoreMinSize);
   }
+
+  // These can now by put into a single int flag, if desired:
   
-    private void addFrame(JInternalFrame frame, String title,
+  public final static boolean FRAME_MAKE_VISIBLE = true;
+
+  public final static boolean FRAME_NOT_VISIBLE = false;
+
+  public final static boolean FRAME_ALLOW_RESIZE = true;
+
+  public final static boolean FRAME_NOT_RESIZABLE = false;
+
+  public final static boolean FRAME_ALLOW_ANY_SIZE = true;
+
+  public final static boolean FRAME_SET_MIN_SIZE_300 = false;
+
+  private void addFrame(JInternalFrame frame, String title,
           boolean makeVisible, int w, int h, boolean resizable,
           boolean ignoreMinSize)
   {
-      // TODO: allow callers to determine X and Y position of frame (eg. via
-      // bounds object).
-      // TODO: consider fixing method to update entries in the window submenu with
-      // the current window title
+    // TODO: allow callers to determine X and Y position of frame (eg. via
+    // bounds object).
+    // TODO: consider fixing method to update entries in the window submenu with
+    // the current window title
 
-      frame.setTitle(title);
-      if (frame.getWidth() < 1 || frame.getHeight() < 1)
+    frame.setTitle(title);
+    if (frame.getWidth() < 1 || frame.getHeight() < 1)
     {
       frame.setSize(w, h);
     }
@@ -921,7 +947,7 @@ public class Desktop extends GDesktop
       public void internalFrameActivated(InternalFrameEvent evt)
       {
         JInternalFrame itf = getDesktopPane().getSelectedFrame();
-       if (itf != null)
+        if (itf != null)
         {
           if (itf instanceof AlignFrame)
           {
@@ -1311,8 +1337,9 @@ public class Desktop extends GDesktop
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
     cap.setForInput(viewPanel);
     addInternalFrame(cap,
-            MessageManager.getString("label.cut_paste_alignmen_file"), true,
-            600, 500);
+            MessageManager.getString("label.cut_paste_alignmen_file"),
+            FRAME_MAKE_VISIBLE, 600, 500, FRAME_ALLOW_RESIZE,
+            FRAME_SET_MIN_SIZE_300);
   }
 
   /*
@@ -1808,7 +1835,7 @@ public class Desktop extends GDesktop
             {
               Cache.log.error(
                       "Problems whilst loading project from " + choice, ex);
-              JvOptionPane.showMessageDialog( getDesktopPane(),
+              JvOptionPane.showMessageDialog(getDesktopPane(),
                       MessageManager.formatMessage(
                               "label.error_whilst_loading_project_from",
                               new Object[]
@@ -1961,7 +1988,7 @@ public class Desktop extends GDesktop
   public static AlignmentViewport[] getViewports(String sequenceSetId)
   {
     List<AlignmentViewport> viewp = new ArrayList<>();
-    if ( getDesktopPane() != null)
+    if (getDesktopPane() != null)
     {
       AlignFrame[] frames = getAlignFrames();
 
@@ -2328,7 +2355,7 @@ public class Desktop extends GDesktop
       return new AlignFrame[] { Jalview.getInstance().currentAlignFrame };
     }
 
-    JInternalFrame[] frames =  getDesktopPane().getAllFrames();
+    JInternalFrame[] frames = getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -2610,7 +2637,7 @@ public class Desktop extends GDesktop
    */
   public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
   {
-    if ( getDesktopPane() != null)
+    if (getDesktopPane() != null)
     {
       AlignmentPanel[] aps = getAlignmentPanels(
               viewport.getSequenceSetId());
@@ -2821,7 +2848,7 @@ public class Desktop extends GDesktop
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
-          JvOptionPane.showInternalMessageDialog( getDesktopPane(),
+          JvOptionPane.showInternalMessageDialog(getDesktopPane(),
                   MessageManager
                           .getString("label.web_browser_not_found_unix"),
                   MessageManager.getString("label.web_browser_not_found"),
@@ -2924,7 +2951,7 @@ public class Desktop extends GDesktop
         {
           return;
         }
-       try
+        try
         {
           SwingUtilities.invokeAndWait(prompter);
         } catch (Exception q)