JAL-3811 document SHOW_JWS2_SERVICES user preference and provide new menu option...
[jalview.git] / src / jalview / gui / Desktop.java
index 1ec6939..f06adc4 100644 (file)
@@ -143,7 +143,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
 
-  public static HashMap<String, FileWriter> savingFiles = new HashMap<>();
+  public static HashMap<String, FileWriter> savingFiles = new HashMap<String, FileWriter>();
 
   private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
 
@@ -927,7 +927,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     } catch (java.lang.ClassCastException cex)
     {
       Cache.log.warn(
-              "Squashed a possible GUI implementation error. If you can recreate this, please look at http://issues.jalview.org/browse/JAL-869",
+              "Squashed a possible GUI implementation error. If you can recreate this, please look at https://issues.jalview.org/browse/JAL-869",
               cex);
     }
   }
@@ -1135,7 +1135,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     panel.add(history);
     history.setPreferredSize(new Dimension(400, 20));
     history.setEditable(true);
-    history.addItem("http://www.");
+    history.addItem("https://www.");
 
     String historyItems = jalview.bin.Cache.getProperty("RECENT_URL");
 
@@ -1351,7 +1351,7 @@ public class Desktop extends jalview.jbgui.GDesktop
                       "..Checking..")
               + " is available for download from "
               + jalview.bin.Cache.getDefault("www.jalview.org",
-                      "http://www.jalview.org")
+                      "https://www.jalview.org")
               + " !!");
       if (red)
       {
@@ -1362,7 +1362,7 @@ public class Desktop extends jalview.jbgui.GDesktop
             "AUTHORFNAMES",
             "The Jalview Authors (See AUTHORS file for current list)")
             + "<br><br>Development managed by The Barton Group, University of Dundee, Scotland, UK.<br>"
-            + "<br><br>For help, see the FAQ at <a href=\"http://www.jalview.org/faq\">www.jalview.org/faq</a> and/or join the jalview-discuss@jalview.org mailing list"
+            + "<br><br>For help, see the FAQ at <a href=\"https://www.jalview.org/faq\">www.jalview.org/faq</a> and/or join the jalview-discuss@jalview.org mailing list"
             + "<br><br>If  you use Jalview, please cite:"
             + "<br>Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
             + "<br>Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
@@ -1923,11 +1923,28 @@ public class Desktop extends jalview.jbgui.GDesktop
       return;
     }
 
+    // FIXME: ideally should use UI interface API
+    FeatureSettings viewFeatureSettings = (af.featureSettings != null
+            && af.featureSettings.isOpen())
+            ? af.featureSettings
+            : null;
+    Rectangle fsBounds = af.getFeatureSettingsGeometry();
     for (int i = 0; i < size; i++)
     {
       AlignmentPanel ap = af.alignPanels.get(i);
+
       AlignFrame newaf = new AlignFrame(ap);
 
+      // transfer reference for existing feature settings to new alignFrame
+      if (ap == af.alignPanel)
+      {
+        if (viewFeatureSettings != null && viewFeatureSettings.fr.ap == ap)
+        {
+          newaf.featureSettings = viewFeatureSettings;
+        }
+        newaf.setFeatureSettingsGeometry(fsBounds);
+      }
+
       /*
        * Restore the view's last exploded frame geometry if known. Multiple
        * views from one exploded frame share and restore the same (frame)
@@ -1943,8 +1960,17 @@ public class Desktop extends jalview.jbgui.GDesktop
 
       addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
               AlignFrame.DEFAULT_HEIGHT);
+      // and materialise a new feature settings dialog instance for the new alignframe
+      // (closes the old as if 'OK' was pressed)
+      if (ap == af.alignPanel && newaf.featureSettings != null
+              && newaf.featureSettings.isOpen()
+              && af.alignPanel.getAlignViewport().isShowSequenceFeatures())
+      {
+        newaf.showFeatureSettingsUI();
+      }
     }
 
+    af.featureSettings = null;
     af.alignPanels.clear();
     af.closeMenuItem_actionPerformed(true);
 
@@ -1964,7 +1990,6 @@ public class Desktop extends jalview.jbgui.GDesktop
     source.viewport.setExplodedGeometry(source.getBounds());
     JInternalFrame[] frames = desktop.getAllFrames();
     String viewId = source.viewport.getSequenceSetId();
-
     for (int t = 0; t < frames.length; t++)
     {
       if (frames[t] instanceof AlignFrame && frames[t] != source)
@@ -1985,11 +2010,32 @@ public class Desktop extends jalview.jbgui.GDesktop
 
         if (gatherThis)
         {
+          if (af.featureSettings != null && af.featureSettings.isOpen())
+          {
+            if (source.featureSettings == null)
+            {
+              // preserve the feature settings geometry for this frame
+              source.featureSettings = af.featureSettings;
+              source.setFeatureSettingsGeometry(
+                      af.getFeatureSettingsGeometry());
+            }
+            else
+            {
+              // close it and forget
+              af.featureSettings.close();
+            }
+          }
           af.alignPanels.clear();
           af.closeMenuItem_actionPerformed(true);
         }
       }
     }
+    // refresh the feature setting UI for the source frame if it exists
+    if (source.featureSettings != null
+            && source.featureSettings.isOpen())
+    {
+      source.showFeatureSettingsUI();
+    }
 
   }
 
@@ -2525,13 +2571,36 @@ public class Desktop extends jalview.jbgui.GDesktop
     this.inBatchMode = inBatchMode;
   }
 
+  /**
+   * start service discovery and wait till it is done
+   */
   public void startServiceDiscovery()
   {
     startServiceDiscovery(false);
   }
 
+  /**
+   * start service discovery threads - blocking or non-blocking
+   * 
+   * @param blocking
+   */
   public void startServiceDiscovery(boolean blocking)
   {
+    startServiceDiscovery(blocking,false);
+  }
+
+  /**
+   * start service discovery threads
+   * 
+   * @param blocking
+   *          - false means call returns immediately
+   * @param ignore_SHOW_JWS2_SERVICES_preference
+   *          - when true JABA services are discovered regardless of user's JWS2
+   *          discovery preference setting
+   */
+  public void startServiceDiscovery(boolean blocking,
+          boolean ignore_SHOW_JWS2_SERVICES_preference)
+  {
     boolean alive = true;
     Thread t0 = null, t1 = null, t2 = null;
     // JAL-940 - JALVIEW 1 services are now being EOLed as of JABA 2.1 release
@@ -2549,7 +2618,8 @@ public class Desktop extends jalview.jbgui.GDesktop
       (t0 = new Thread(discoverer)).start();
     }
 
-    if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+    if (ignore_SHOW_JWS2_SERVICES_preference
+            || Cache.getDefault("SHOW_JWS2_SERVICES", true))
     {
       t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
               .startDiscoverer(changeSupport);