JAL-3741 http to https (and jar to jvp for exampleFile defaults!)
[jalview.git] / src / jalview / gui / Preferences.java
index 6972657..e3e3932 100755 (executable)
@@ -31,6 +31,7 @@ import java.awt.event.MouseEvent;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 import javax.help.HelpSetException;
 import javax.swing.JComboBox;
@@ -145,10 +146,10 @@ public class Preferences extends GPreferences
 
   /**
    * Holds name and link separated with | character. Sequence IDS and Sequences
-   * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
-   * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
-   * for first and second token specified after a pipe character at end |,|.
-   * (TODO: proper escape for using | to separate ids or sequences
+   * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and $SEQUENCES$
+   * or $SEQUENCES=/.possible | chars ./=$ and separation character for first and
+   * second token specified after a pipe character at end |,|. (TODO: proper
+   * escape for using | to separate ids or sequences
    */
 
   public static List<String> groupURLLinks;
@@ -219,19 +220,27 @@ public class Preferences extends GPreferences
 
   public static void openPreferences()
   {
-    openPreferences(0, null);
+    openPreferences(null, null);
   }
 
-  public static void openPreferences(int selectTab, String message)
+  public static void openPreferences(TabRef selectTab, String message)
   {
     Preferences p = getInstance();
-    p.selectTab(selectTab);
-    p.setMessage(message);
+    if (selectTab != null)
+      p.selectTab(selectTab, message);
     p.frame.show();
     p.frame.moveToFront();
     p.frame.grabFocus();
   }
 
+  public void selectTab(TabRef selectTab, String message)
+  {
+    this.selectTab(selectTab);
+    if (message != null)
+      this.setMessage(message);
+    this.frame.show();
+  }
+
   /**
    * Creates a new Preferences object.
    */
@@ -346,8 +355,8 @@ public class Preferences extends GPreferences
     startupCheckbox
             .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
     startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
-            Cache.getDefault("www.jalview.org", "http://www.jalview.org")
-                    + "/examples/exampleFile_2_3.jar"));
+            Cache.getDefault("www.jalview.org", "https://www.jalview.org")
+                    + "/examples/exampleFile_2_7.jvp"));
 
     /*
      * Set Colours tab defaults
@@ -1009,8 +1018,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * Do any necessary validation before saving settings. Return focus to the
-   * first tab which fails validation.
+   * Do any necessary validation before saving settings. Return focus to the first
+   * tab which fails validation.
    * 
    * @return
    */
@@ -1064,7 +1073,7 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *          DOCUMENT ME!
+   *            DOCUMENT ME!
    */
   @Override
   public void cancel_actionPerformed(ActionEvent e)
@@ -1086,7 +1095,7 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *          DOCUMENT ME!
+   *            DOCUMENT ME!
    */
   @Override
   public void annotations_actionPerformed(ActionEvent e)
@@ -1349,8 +1358,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * Returns true if structure viewer path is to a valid executable, else shows
-   * an error dialog. Does nothing if the path is empty, as is the case for Jmol
+   * Returns true if structure viewer path is to a valid executable, else shows an
+   * error dialog. Does nothing if the path is empty, as is the case for Jmol
    * (built in to Jalview) or when Jalview is left to try default paths.
    */
   private boolean validateViewerPath()
@@ -1371,8 +1380,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * If Chimera or ChimeraX or Pymol is selected, check it can be found on
-   * default or user-specified path, if not show a warning/help dialog
+   * If Chimera or ChimeraX or Pymol is selected, check it can be found on default
+   * or user-specified path, if not show a warning/help dialog
    */
   @Override
   protected void structureViewer_actionPerformed(String selectedItem)
@@ -1439,8 +1448,10 @@ public class Preferences extends GPreferences
                       MessageManager.getString("label.viewer_missing")),
               "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
               null, options, options[0]);
+
       if (showHelp == JvOptionPane.NO_OPTION)
       {
+        this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
         try
         {
           Help.showHelpWindow(HelpId.StructureViewer);
@@ -1449,6 +1460,24 @@ public class Preferences extends GPreferences
           e.printStackTrace();
         }
       }
+      else if (showHelp == JvOptionPane.OK_OPTION)
+      {
+        this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
+        CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
+          try
+          {
+            for (int i = 0; i < 3; i++)
+            {
+              structureViewerPath.setBackground(Color.PINK);
+              Thread.sleep(500);
+              structureViewerPath.setBackground(Color.WHITE);
+              Thread.sleep(500);
+            }
+          } catch (InterruptedException e)
+          {
+          }
+        });
+      }
     }
   }