JAL-4409 JAL-4160 Don't let getdown turn jalviewX:// URIs into absolute local file...
[jalview.git] / src / jalview / bin / Commands.java
index a72da0d..97ab98e 100644 (file)
@@ -22,6 +22,7 @@ package jalview.bin;
 
 import java.awt.Color;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -235,7 +236,8 @@ public class Commands
       {
         Arg a = av.getArg();
         SubVals sv = av.getSubVals();
-        String openFile = av.getValue();
+        String openFile0 = av.getValue();
+        String openFile = HttpUtils.equivalentJalviewUrl(openFile0);
         if (openFile == null)
           continue;
 
@@ -286,6 +288,10 @@ public class Commands
         try
         {
           format = new IdentifyFile().identify(openFile, protocol);
+        } catch (FileNotFoundException e0)
+        {
+          addError((protocol == DataSourceType.URL ? "File at URL" : "File")
+                  + " '" + openFile + "' not found");
         } catch (FileFormatException e1)
         {
           addError("Unknown file format for '" + openFile + "'");
@@ -312,6 +318,10 @@ public class Commands
           {
             af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
                     format);
+            if (!openFile.equals(openFile0))
+            {
+              af.setTitle(openFile0);
+            }
           } catch (Throwable thr)
           {
             xception = true;
@@ -331,9 +341,17 @@ public class Commands
           }
 
           // colour alignment
-          String colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv,
-                  null, "DEFAULT_COLOUR_PROT", "");
-          this.colourAlignFrame(af, colour);
+          String colour = null;
+          if (avm.containsArg(Arg.COLOUR)
+                  || !(format == FileFormat.Jalview))
+          {
+            colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv, null,
+                    "DEFAULT_COLOUR_PROT", null);
+          }
+          if (colour != null)
+          {
+            this.colourAlignFrame(af, colour);
+          }
 
           // Change alignment frame title
           String title = avm.getFromSubValArgOrPref(av, Arg.TITLE, sv, null,
@@ -1293,8 +1311,23 @@ public class Commands
 
   private void colourAlignFrame(AlignFrame af, ColourSchemeI cs)
   {
-    // Note that cs == null removes colour scheme from af
-    af.changeColour(cs);
+    try
+    {
+      SwingUtilities.invokeAndWait(new Runnable()
+      {
+        @Override
+        public void run()
+        {
+          // Note that cs == null removes colour scheme from af
+          af.changeColour(cs);
+        }
+      });
+    } catch (Exception x)
+    {
+      Console.trace("Interrupted whilst waiting for colorAlignFrame action",
+              x);
+
+    }
   }
 
   private ColourSchemeI getColourScheme(AlignFrame af)