JAL-1688 compiler warnings removed
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 26 Mar 2015 09:57:03 +0000 (09:57 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 26 Mar 2015 09:57:03 +0000 (09:57 +0000)
src/jalview/bin/Jalview.java
src/jalview/gui/Desktop.java
src/jalview/gui/RestInputParamEditDialog.java
src/jalview/ws/rest/RestServiceDescription.java
src/jalview/ws/seqfetcher/ASequenceFetcher.java

index 5bb5e98..0fe1664 100755 (executable)
  */
 package jalview.bin;
 
-import jalview.gui.AlignFrame;
-import jalview.gui.Desktop;
-import jalview.io.HtmlSvgOutput;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.ws.jws2.Jws2Discoverer;
-
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
@@ -45,13 +38,20 @@ import java.security.CodeSource;
 import java.security.PermissionCollection;
 import java.security.Permissions;
 import java.security.Policy;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Vector;
 
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
 
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.io.HtmlSvgOutput;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.ws.jws2.Jws2Discoverer;
+
 /**
  * Main class for Jalview Application <br>
  * <br>
@@ -820,7 +820,7 @@ public class Jalview
        * = new Binding(); binding.setVariable("input", "world");
        * gse.run("hello.groovy", binding); </code>
        */
-      Class[] bspec;
+      Class<?>[] bspec;
       Object[] binding;
       int blen = ((jalviewContext[0] == null) ? 0 : 1)
               + ((jalviewContext[1] == null) ? 0 : 1);
@@ -830,7 +830,7 @@ public class Jalview
       binding = new Object[blen * 2];
       blen = 0;
       ClassLoader cl = null;
-      Map vbinding = new Hashtable();
+      Map<String, Object> vbinding = new HashMap<String, Object>();
       for (int jc = 0; jc < jalviewContext.length; jc++)
       {
         if (jalviewContext[jc] != null)
@@ -847,8 +847,8 @@ public class Jalview
           blen++;
         }
       }
-      Class gbindingc = cl.loadClass("groovy.lang.Binding");
-      Constructor gbcons;
+      Class<?> gbindingc = cl.loadClass("groovy.lang.Binding");
+      Constructor<?> gbcons;
       Object gbinding;
       try
       {
@@ -858,15 +858,15 @@ public class Jalview
       {
         // old style binding config - using series of string/object values to
         // setVariable.
-        gbcons = gbindingc.getConstructor(null);
-        gbinding = gbcons.newInstance(null);
+        gbcons = gbindingc.getConstructor();
+        gbinding = gbcons.newInstance();
         java.lang.reflect.Method setvar = gbindingc.getMethod(
                 "setVariable", bspec);
         setvar.invoke(gbinding, binding);
       }
-      ;
-      Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
-      Constructor gseccons = gsec.getConstructor(new Class[]
+
+      Class<?> gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
+      Constructor<?> gseccons = gsec.getConstructor(new Class[]
       { URL[].class }); // String[].class });
       Object gse = gseccons.newInstance(new Object[]
       { new URL[]
@@ -966,7 +966,7 @@ public class Jalview
   private static FeatureFetcher startFeatureFetching(final Vector dasSources)
   {
     FeatureFetcher ff = new FeatureFetcher();
-    AlignFrame afs[] = Desktop.getAlignframes();
+    AlignFrame afs[] = Desktop.getAlignFrames();
     if (afs == null || afs.length == 0)
     {
       return null;
index 3f3950c..db5bbe5 100644 (file)
  */
 package jalview.gui;
 
-import jalview.bin.Cache;
-import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
-import jalview.io.IdentifyFile;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.jbgui.GStructureViewer;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.ws.params.ParamManager;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -69,6 +57,7 @@ import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.StringTokenizer;
 import java.util.Vector;
 import java.util.concurrent.ExecutorService;
@@ -95,6 +84,22 @@ import javax.swing.event.HyperlinkEvent.EventType;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GSplitFrame;
+import jalview.jbgui.GStructureViewer;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+import jalview.ws.params.ParamManager;
+
 /**
  * Jalview Desktop
  * 
@@ -162,6 +167,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   static final int yOffset = 30;
 
+  private static final int THREE = 3;
+
   public static jalview.ws.jws1.Discoverer discoverer;
 
   public static Object[] jalviewClipboard;
@@ -330,8 +337,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             + jalview.bin.Cache.getProperty("VERSION") + "\n"
             + "Jalview Installation: "
             + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")
-            + "\n"
-            + "Build Date: "
+            + "\n" + "Build Date: "
             + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n"
             + "Java version: " + System.getProperty("java.version") + "\n"
             + System.getProperty("os.arch") + " "
@@ -432,9 +438,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     {
       ssm.setAddTempFacAnnot(jalview.bin.Cache.getDefault(
               Preferences.ADD_TEMPFACT_ANN, true));
-    ssm.setProcessSecondaryStructure(jalview.bin.Cache.getDefault(Preferences.STRUCT_FROM_PDB, true));
-    ssm.setSecStructServices(jalview.bin.Cache.getDefault(Preferences.USE_RNAVIEW,
-            true));
+      ssm.setProcessSecondaryStructure(jalview.bin.Cache.getDefault(
+              Preferences.STRUCT_FROM_PDB, true));
+      ssm.setSecStructServices(jalview.bin.Cache.getDefault(
+              Preferences.USE_RNAVIEW, true));
     }
     else
     {
@@ -480,7 +487,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           public void run()
           {
             long instance = System.currentTimeMillis();
-            Desktop.instance.setProgressBar(MessageManager.getString("status.refreshing_news"), instance);
+            Desktop.instance.setProgressBar(
+                    MessageManager.getString("status.refreshing_news"),
+                    instance);
             jvnews.refreshNews();
             Desktop.instance.setProgressBar(null, instance);
             jvnews.showNews();
@@ -648,7 +657,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     addInternalFrame(frame, title, true, w, h, true);
   }
 
-
   /**
    * Add an internal frame to the Jalview desktop
    * 
@@ -1087,7 +1095,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       if (format.equals("URL NOT FOUND"))
       {
         JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                MessageManager.formatMessage("label.couldnt_locate", new String[]{url}), MessageManager.getString("label.url_not_found"),
+                MessageManager.formatMessage("label.couldnt_locate",
+                        new Object[]
+                        { url }), MessageManager
+                        .getString("label.url_not_found"),
                 JOptionPane.WARNING_MESSAGE);
 
         return;
@@ -1190,8 +1201,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     if (shortv)
     {
       message.append("<h1><strong>Version: "
-              + jalview.bin.Cache.getProperty("VERSION")
-              + "</strong></h1>");
+              + jalview.bin.Cache.getProperty("VERSION") + "</strong></h1>");
       message.append("<strong>Last Updated: <em>"
               + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
               + "</em></strong>");
@@ -1237,8 +1247,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
     message.append("<br>Authors:  "
             + jalview.bin.Cache
-                    .getDefault(
-                            "AUTHORFNAMES",
+                    .getDefault("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"
@@ -1363,7 +1372,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       return;
     }
 
-    AlignViewport source = null, target = null;
+    AlignmentViewport source = null, target = null;
     if (frames[0] instanceof AlignFrame)
     {
       source = ((AlignFrame) frames[0]).getCurrentView();
@@ -1475,8 +1484,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         public void run()
         {
 
-          setProgressBar(MessageManager.formatMessage("label.saving_jalview_project", new String[]{choice.getName()}),
-                  choice.hashCode());
+          setProgressBar(MessageManager.formatMessage(
+                  "label.saving_jalview_project", new Object[]
+                  { choice.getName() }), choice.hashCode());
           jalview.bin.Cache.setProperty("LAST_DIRECTORY",
                   choice.getParent());
           // TODO catch and handle errors for savestate
@@ -1493,10 +1503,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             Cache.log.error(
                     "Problems whilst trying to save to " + choice.getName(),
                     ex);
-            JOptionPane.showMessageDialog(
-                    me,
-                    MessageManager.formatMessage("label.error_whilst_saving_current_state_to", new String[]{ choice.getName()}),
-                    MessageManager.getString("label.couldnt_save_project"),
+            JOptionPane.showMessageDialog(me, MessageManager.formatMessage(
+                    "label.error_whilst_saving_current_state_to",
+                    new Object[]
+                    { choice.getName() }), MessageManager
+                    .getString("label.couldnt_save_project"),
                     JOptionPane.WARNING_MESSAGE);
           }
           setProgressBar(null, choice.hashCode());
@@ -1564,13 +1575,15 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       final File selectedFile = chooser.getSelectedFile();
       setProjectFile(selectedFile);
       final String choice = selectedFile.getAbsolutePath();
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
+      jalview.bin.Cache.setProperty("LAST_DIRECTORY",
+              selectedFile.getParent());
       new Thread(new Runnable()
       {
         public void run()
         {
-          setProgressBar(MessageManager.formatMessage("label.loading_jalview_project", new String[]{choice}),
-                  choice.hashCode());
+          setProgressBar(MessageManager.formatMessage(
+                  "label.loading_jalview_project", new Object[]
+                  { choice }), choice.hashCode());
           try
           {
             new Jalview2XML().loadJalviewAlign(choice);
@@ -1581,9 +1594,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           {
             Cache.log.error("Problems whilst loading project from "
                     + choice, ex);
-            JOptionPane.showMessageDialog(Desktop.desktop,
-                       MessageManager.formatMessage("label.error_whilst_loading_project_from", new String[]{choice}),
-                    MessageManager.getString("label.couldnt_load_project"), JOptionPane.WARNING_MESSAGE);
+            JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+                    .formatMessage(
+                            "label.error_whilst_loading_project_from",
+                            new Object[]
+                            { choice }), MessageManager
+                    .getString("label.couldnt_load_project"),
+                    JOptionPane.WARNING_MESSAGE);
           }
           setProgressBar(null, choice.hashCode());
         }
@@ -1604,7 +1621,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     if (fileLoadingCount == 0)
     {
-      fileLoadingPanels.add(addProgressPanel(MessageManager.formatMessage("label.loading_file", new String[]{fileName})));
+      fileLoadingPanels.add(addProgressPanel(MessageManager.formatMessage(
+              "label.loading_file", new Object[]
+              { fileName })));
     }
     fileLoadingCount++;
   }
@@ -1670,38 +1689,37 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   public static int getViewCount(String alignmentId)
   {
-    AlignViewport[] aps = getViewports(alignmentId);
+    AlignmentViewport[] aps = getViewports(alignmentId);
     return (aps == null) ? 0 : aps.length;
   }
 
   /**
    * 
    * @param alignmentId
+   *          - if null, all sets are returned
    * @return all AlignmentPanels concerning the alignmentId sequence set
    */
   public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
   {
-    int count = 0;
     if (Desktop.desktop == null)
     {
       // no frames created and in headless mode
       // TODO: verify that frames are recoverable when in headless mode
       return null;
     }
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
-    ArrayList aps = new ArrayList();
-    for (int t = 0; t < frames.length; t++)
+    List<AlignmentPanel> aps = new ArrayList<AlignmentPanel>();
+    AlignFrame[] frames = getAlignFrames();
+    if (frames == null)
     {
-      if (frames[t] instanceof AlignFrame)
+      return null;
+    }
+    for (AlignFrame af : frames)
+    {
+      for (AlignmentPanel ap : af.alignPanels)
       {
-        AlignFrame af = (AlignFrame) frames[t];
-        for (int a = 0; a < af.alignPanels.size(); a++)
+        if (alignmentId==null || alignmentId.equals(ap.av.getSequenceSetId()))
         {
-          if (alignmentId.equals(((AlignmentPanel) af.alignPanels
-                  .elementAt(a)).av.getSequenceSetId()))
-          {
-            aps.add(af.alignPanels.elementAt(a));
-          }
+          aps.add(ap);
         }
       }
     }
@@ -1709,11 +1727,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     {
       return null;
     }
-    AlignmentPanel[] vap = new AlignmentPanel[aps.size()];
-    for (int t = 0; t < vap.length; t++)
-    {
-      vap[t] = (AlignmentPanel) aps.get(t);
-    }
+    AlignmentPanel[] vap = aps.toArray(new AlignmentPanel[aps.size()]);
     return vap;
   }
 
@@ -1721,52 +1735,51 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * get all the viewports on an alignment.
    * 
    * @param sequenceSetId
-   *          unique alignment id
+   *          unique alignment id (may be null - all viewports returned in that
+   *          case)
    * @return all viewports on the alignment bound to sequenceSetId
    */
-  public static AlignViewport[] getViewports(String sequenceSetId)
+  public static AlignmentViewport[] getViewports(String sequenceSetId)
   {
-    Vector viewp = new Vector();
+    List<AlignmentViewport> viewp = new ArrayList<AlignmentViewport>();
     if (desktop != null)
     {
-      javax.swing.JInternalFrame[] frames = instance.getAllFrames();
+      AlignFrame[] frames = Desktop.getAlignFrames();
 
-      for (int t = 0; t < frames.length; t++)
+      for (AlignFrame afr : frames)
       {
-        if (frames[t] instanceof AlignFrame)
+        if (sequenceSetId==null || afr.getViewport().getSequenceSetId().equals(sequenceSetId))
         {
-          AlignFrame afr = ((AlignFrame) frames[t]);
-          if (afr.getViewport().getSequenceSetId().equals(sequenceSetId))
+          if (afr.alignPanels != null)
           {
-            if (afr.alignPanels != null)
+            for (AlignmentPanel ap : afr.alignPanels)
             {
-              for (int a = 0; a < afr.alignPanels.size(); a++)
+              if (sequenceSetId == null
+                      || sequenceSetId.equals(ap.av.getSequenceSetId()))
               {
-                if (sequenceSetId.equals(((AlignmentPanel) afr.alignPanels
-                        .elementAt(a)).av.getSequenceSetId()))
-                {
-                  viewp.addElement(((AlignmentPanel) afr.alignPanels
-                          .elementAt(a)).av);
-                }
+                viewp.add(ap.av);
               }
             }
-            else
-            {
-              viewp.addElement(((AlignFrame) frames[t]).getViewport());
-            }
+          }
+          else
+          {
+            viewp.add(afr.getViewport());
           }
         }
       }
       if (viewp.size() > 0)
       {
-        AlignViewport[] vp = new AlignViewport[viewp.size()];
-        viewp.copyInto(vp);
-        return vp;
+        return viewp.toArray(new AlignmentViewport[viewp.size()]);
       }
     }
     return null;
   }
 
+  /**
+   * Explode the views in the given frame into separate AlignFrame
+   * 
+   * @param af
+   */
   public void explodeViews(AlignFrame af)
   {
     int size = af.alignPanels.size();
@@ -1777,15 +1790,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     for (int i = 0; i < size; i++)
     {
-      AlignmentPanel ap = (AlignmentPanel) af.alignPanels.elementAt(i);
+      AlignmentPanel ap = af.alignPanels.get(i);
       AlignFrame newaf = new AlignFrame(ap);
-      if (ap.av.explodedPosition != null
-              && !ap.av.explodedPosition.equals(af.getBounds()))
+
+      /*
+       * Restore the view's last exploded frame geometry if known. Multiple
+       * views from one exploded frame share and restore the same (frame)
+       * position and size.
+       */
+      Rectangle geometry = ap.av.getExplodedGeometry();
+      if (geometry != null)
       {
-        newaf.setBounds(ap.av.explodedPosition);
+        newaf.setBounds(geometry);
       }
 
-      ap.av.gatherViewsHere = false;
+      ap.av.setGatherViewsHere(false);
 
       addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
               AlignFrame.DEFAULT_HEIGHT);
@@ -1796,10 +1815,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   }
 
+  /**
+   * Gather expanded views (separate AlignFrame's) with the same sequence set
+   * identifier back in to this frame as additional views, and close the
+   * expanded views. Note the expanded frames may themselves have multiple
+   * views. We take the lot.
+   * 
+   * @param source
+   */
   public void gatherViews(AlignFrame source)
   {
-    source.viewport.gatherViewsHere = true;
-    source.viewport.explodedPosition = source.getBounds();
+    source.viewport.setGatherViewsHere(true);
+    source.viewport.setExplodedGeometry(source.getBounds());
     JInternalFrame[] frames = desktop.getAllFrames();
     String viewId = source.viewport.getSequenceSetId();
 
@@ -1811,12 +1838,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         boolean gatherThis = false;
         for (int a = 0; a < af.alignPanels.size(); a++)
         {
-          AlignmentPanel ap = (AlignmentPanel) af.alignPanels.elementAt(a);
+          AlignmentPanel ap = af.alignPanels.get(a);
           if (viewId.equals(ap.av.getSequenceSetId()))
           {
             gatherThis = true;
-            ap.av.gatherViewsHere = false;
-            ap.av.explodedPosition = af.getBounds();
+            ap.av.setGatherViewsHere(false);
+            ap.av.setExplodedGeometry(af.getBounds());
             source.addAlignmentPanel(ap, false);
           }
         }
@@ -1842,7 +1869,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
               jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
 
       chooser.setFileView(new JalviewFileView());
-      chooser.setDialogTitle(MessageManager.getString("label.open_saved_vamsas_session"));
+      chooser.setDialogTitle(MessageManager
+              .getString("label.open_saved_vamsas_session"));
       chooser.setToolTipText(MessageManager
               .getString("label.select_vamsas_session_opened_as_new_vamsas_session"));
 
@@ -1858,7 +1886,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                           Desktop.desktop,
                           MessageManager.formatMessage(
                                   "label.couldnt_import_as_vamsas_session",
-                                  new String[]
+                                  new Object[]
                                   { fle }),
                           MessageManager
                                   .getString("label.vamsas_document_import_failed"),
@@ -1935,23 +1963,26 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       return false;
     }
 
-    setProgressBar(MessageManager.formatMessage("status.importing_vamsas_session_from", new String[]{file.getName()}),
-            file.hashCode());
+    setProgressBar(MessageManager.formatMessage(
+            "status.importing_vamsas_session_from", new Object[]
+            { file.getName() }), file.hashCode());
     try
     {
       v_client = new jalview.gui.VamsasApplication(this, file, null);
     } catch (Exception ex)
     {
-        setProgressBar(MessageManager.formatMessage("status.importing_vamsas_session_from", new String[]{file.getName()}),
-                file.hashCode());
+      setProgressBar(MessageManager.formatMessage(
+              "status.importing_vamsas_session_from", new Object[]
+              { file.getName() }), file.hashCode());
       jalview.bin.Cache.log.error(
               "New vamsas session from existing session file failed:", ex);
       return false;
     }
     setupVamsasConnectedGui();
     v_client.initial_update(); // TODO: thread ?
-    setProgressBar(MessageManager.formatMessage("status.importing_vamsas_session_from", new String[]{file.getName()}),
-            file.hashCode());
+    setProgressBar(MessageManager.formatMessage(
+            "status.importing_vamsas_session_from", new Object[]
+            { file.getName() }), file.hashCode());
     return v_client.inSession();
   }
 
@@ -1959,11 +1990,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     if (v_client != null)
     {
-      throw new Error(MessageManager.getString("error.try_join_vamsas_session_another"));
+      throw new Error(
+              MessageManager
+                      .getString("error.try_join_vamsas_session_another"));
     }
     if (mysesid == null)
     {
-      throw new Error(MessageManager.getString("error.invalid_vamsas_session_id"));
+      throw new Error(
+              MessageManager.getString("error.invalid_vamsas_session_id"));
     }
     v_client = new VamsasApplication(this, mysesid);
     setupVamsasConnectedGui();
@@ -2053,7 +2087,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           JMenuItem sessit = new JMenuItem();
           sessit.setText(sess[i]);
           sessit.setToolTipText(MessageManager.formatMessage(
-                  "label.connect_to_session", new String[]
+                  "label.connect_to_session", new Object[]
                   { sess[i] }));
           final Desktop dsktp = this;
           final String mysesid = sess[i];
@@ -2110,14 +2144,17 @@ public class Desktop extends jalview.jbgui.GDesktop implements
               { "Vamsas Document" }, "Vamsas Document");
 
       chooser.setFileView(new JalviewFileView());
-      chooser.setDialogTitle(MessageManager.getString("label.save_vamsas_document_archive"));
+      chooser.setDialogTitle(MessageManager
+              .getString("label.save_vamsas_document_archive"));
 
       int value = chooser.showSaveDialog(this);
 
       if (value == JalviewFileChooser.APPROVE_OPTION)
       {
         java.io.File choice = chooser.getSelectedFile();
-        JPanel progpanel = addProgressPanel(MessageManager.formatMessage("label.saving_vamsas_doc", new String[]{choice.getName()}));
+        JPanel progpanel = addProgressPanel(MessageManager.formatMessage(
+                "label.saving_vamsas_doc", new Object[]
+                { choice.getName() }));
         jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
         String warnmsg = null;
         String warnttl = null;
@@ -2169,7 +2206,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
     if (b)
     {
-      vamUpdate = this.addProgressPanel(MessageManager.getString("label.updating_vamsas_session"));
+      vamUpdate = this.addProgressPanel(MessageManager
+              .getString("label.updating_vamsas_session"));
     }
     vamsasStart.setVisible(!b);
     vamsasStop.setVisible(!b);
@@ -2204,6 +2242,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   public class MyDesktopPane extends JDesktopPane implements Runnable
   {
 
+    private static final float ONE_MB = 1048576f;
+
     boolean showMemoryUsage = false;
 
     Runtime runtime;
@@ -2243,9 +2283,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       {
         try
         {
-          maxMemory = runtime.maxMemory() / 1048576f;
-          allocatedMemory = runtime.totalMemory() / 1048576f;
-          freeMemory = runtime.freeMemory() / 1048576f;
+          maxMemory = runtime.maxMemory() / ONE_MB;
+          allocatedMemory = runtime.totalMemory() / ONE_MB;
+          freeMemory = runtime.freeMemory() / ONE_MB;
           totalFreeMemory = freeMemory + (maxMemory - allocatedMemory);
 
           percentUsage = (totalFreeMemory / maxMemory) * 100;
@@ -2279,7 +2319,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         {
           g.drawString(MessageManager.formatMessage(
                   "label.memory_stats",
-                  new String[]
+                  new Object[]
                   { df.format(totalFreeMemory), df.format(maxMemory),
                       df.format(percentUsage) }), 10,
                   getHeight() - fm.getHeight());
@@ -2319,8 +2359,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   /**
    * Accessor method to quickly get all the AlignmentFrames loaded.
+   * 
+   * @return an array of AlignFrame, or null if none found
    */
-  public static AlignFrame[] getAlignframes()
+  public static AlignFrame[] getAlignFrames()
   {
     JInternalFrame[] frames = Desktop.desktop.getAllFrames();
 
@@ -2328,35 +2370,43 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     {
       return null;
     }
-    Vector avp = new Vector();
-    try
+    List<AlignFrame> avp = new ArrayList<AlignFrame>();
+    // REVERSE ORDER
+    for (int i = frames.length - 1; i > -1; i--)
     {
-      // REVERSE ORDER
-      for (int i = frames.length - 1; i > -1; i--)
+      if (frames[i] instanceof AlignFrame)
       {
-        if (frames[i] instanceof AlignFrame)
+        avp.add((AlignFrame) frames[i]);
+      }
+      else if (frames[i] instanceof SplitFrame)
+      {
+        /*
+         * Also check for a split frame containing an AlignFrame
+         */
+        GSplitFrame sf = (GSplitFrame) frames[i];
+        if (sf.getTopFrame() instanceof AlignFrame)
+        {
+          avp.add((AlignFrame) sf.getTopFrame());
+        }
+        if (sf.getBottomFrame() instanceof AlignFrame)
         {
-          AlignFrame af = (AlignFrame) frames[i];
-          avp.addElement(af);
+          avp.add((AlignFrame) sf.getBottomFrame());
         }
       }
-    } catch (Exception ex)
-    {
-      ex.printStackTrace();
     }
     if (avp.size() == 0)
     {
       return null;
     }
-    AlignFrame afs[] = new AlignFrame[avp.size()];
-    for (int i = 0, j = avp.size(); i < j; i++)
-    {
-      afs[i] = (AlignFrame) avp.elementAt(i);
-    }
-    avp.clear();
+    AlignFrame afs[] = avp.toArray(new AlignFrame[avp.size()]);
     return afs;
   }
 
+  /**
+   * Returns an array of any AppJmol frames in the Desktop (or null if none).
+   * 
+   * @return
+   */
   public GStructureViewer[] getJmols()
   {
     JInternalFrame[] frames = Desktop.desktop.getAllFrames();
@@ -2365,32 +2415,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     {
       return null;
     }
-    Vector avp = new Vector();
-    try
+    List<GStructureViewer> avp = new ArrayList<GStructureViewer>();
+    // REVERSE ORDER
+    for (int i = frames.length - 1; i > -1; i--)
     {
-      // REVERSE ORDER
-      for (int i = frames.length - 1; i > -1; i--)
+      if (frames[i] instanceof AppJmol)
       {
-        if (frames[i] instanceof AppJmol)
-        {
-          GStructureViewer af = (GStructureViewer) frames[i];
-          avp.addElement(af);
-        }
+        GStructureViewer af = (GStructureViewer) frames[i];
+        avp.add(af);
       }
-    } catch (Exception ex)
-    {
-      ex.printStackTrace();
     }
     if (avp.size() == 0)
     {
       return null;
     }
-    GStructureViewer afs[] = new GStructureViewer[avp.size()];
-    for (int i = 0, j = avp.size(); i < j; i++)
-    {
-      afs[i] = (GStructureViewer) avp.elementAt(i);
-    }
-    avp.clear();
+    GStructureViewer afs[] = avp.toArray(new GStructureViewer[avp.size()]);
     return afs;
   }
 
@@ -2402,31 +2441,31 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     // use reflection to avoid creating compilation dependency.
     if (!jalview.bin.Cache.groovyJarsPresent())
     {
-      throw new Error(MessageManager.getString("error.implementation_error_cannot_create_groovyshell"));
+      throw new Error(
+              MessageManager
+                      .getString("error.implementation_error_cannot_create_groovyshell"));
     }
     try
     {
-      Class gcClass = Desktop.class.getClassLoader().loadClass(
+      Class<?> gcClass = Desktop.class.getClassLoader().loadClass(
               "groovy.ui.Console");
-      Constructor gccons = gcClass.getConstructor(null);
+      Constructor<?> gccons = gcClass.getConstructor();
       java.lang.reflect.Method setvar = gcClass.getMethod("setVariable",
               new Class[]
               { String.class, Object.class });
-      java.lang.reflect.Method run = gcClass.getMethod("run", null);
-      Object gc = gccons.newInstance(null);
+      java.lang.reflect.Method run = gcClass.getMethod("run");
+      Object gc = gccons.newInstance();
       setvar.invoke(gc, new Object[]
       { "Jalview", this });
-      run.invoke(gc, null);
+      run.invoke(gc);
     } catch (Exception ex)
     {
       jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
-      JOptionPane
-              .showInternalMessageDialog(
-                      Desktop.desktop,
+      JOptionPane.showInternalMessageDialog(Desktop.desktop,
 
-                      MessageManager.getString("label.couldnt_create_groovy_shell"),
-                      MessageManager.getString("label.groovy_support_failed"),
-                      JOptionPane.ERROR_MESSAGE);
+      MessageManager.getString("label.couldnt_create_groovy_shell"),
+              MessageManager.getString("label.groovy_support_failed"),
+              JOptionPane.ERROR_MESSAGE);
     }
   }
 
@@ -2476,7 +2515,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
     {
-      throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
+      throw new Error(
+              MessageManager
+                      .getString("error.call_setprogressbar_before_registering_handler"));
     }
     progressBarHandlers.put(new Long(id), handler);
     final JPanel progressPanel = progressBars.get(new Long(id));
@@ -2491,7 +2532,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         public void actionPerformed(ActionEvent e)
         {
           handler.cancelActivity(id);
-          us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
+          us.setProgressBar(MessageManager.formatMessage(
+                  "label.cancelled_params", new Object[]
+                  { ((JLabel) progressPanel.getComponent(0)).getText() }),
+                  id);
         }
       });
       progressPanel.add(cancel, BorderLayout.EAST);
@@ -2513,20 +2557,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   }
 
   /**
-   * This will return the first AlignFrame viewing AlignViewport av. It will
-   * break if there are more than one AlignFrames viewing a particular av. This
+   * This will return the first AlignFrame holding the given viewport instance. It
+   * will break if there are more than one AlignFrames viewing a particular av.
    * 
-   * @param av
-   * @return alignFrame for av
+   * @param viewport
+   * @return alignFrame for viewport
    */
-  public static AlignFrame getAlignFrameFor(AlignViewport av)
+  public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
   {
     if (desktop != null)
     {
-      AlignmentPanel[] aps = getAlignmentPanels(av.getSequenceSetId());
+      AlignmentPanel[] aps = getAlignmentPanels(viewport
+              .getSequenceSetId());
       for (int panel = 0; aps != null && panel < aps.length; panel++)
       {
-        if (aps[panel] != null && aps[panel].av == av)
+        if (aps[panel] != null && aps[panel].av == viewport)
         {
           return aps[panel].alignFrame;
         }
@@ -2753,17 +2798,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         {
           if (progress != null)
           {
-            progress.setProgressBar(MessageManager.formatMessage("status.opening_params", new String[]{url}), this.hashCode());
+            progress.setProgressBar(MessageManager.formatMessage(
+                    "status.opening_params", new Object[]
+                    { url }), this.hashCode());
           }
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
-          JOptionPane
-                  .showInternalMessageDialog(
-                          Desktop.desktop,
-                          MessageManager.getString("label.web_browser_not_found_unix"),
-                          MessageManager.getString("label.web_browser_not_found"),
-                          JOptionPane.WARNING_MESSAGE);
+          JOptionPane.showInternalMessageDialog(Desktop.desktop,
+                  MessageManager
+                          .getString("label.web_browser_not_found_unix"),
+                  MessageManager.getString("label.web_browser_not_found"),
+                  JOptionPane.WARNING_MESSAGE);
 
           ex.printStackTrace();
         }
@@ -2878,6 +2924,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     dialogPause = false;
     block.release();
   }
+
   @Override
   protected void snapShotWindow_actionPerformed(ActionEvent e)
   {
@@ -2887,14 +2934,139 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             "View of Desktop", getWidth(), getHeight(), of = new File(
                     "Jalview_snapshot" + System.currentTimeMillis()
                             + ".eps"), "View of desktop");
-    try {
+    try
+    {
       paintAll(im.getGraphics());
       im.writeImage();
     } catch (Exception q)
     {
-      Cache.log.error("Couldn't write snapshot to "+of.getAbsolutePath(),q);
+      Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
+              q);
+      return;
+    }
+    Cache.log.info("Successfully written snapshot to file "
+            + of.getAbsolutePath());
+  }
+
+  /**
+   * Explode the views in the given frame into separate AlignFrame windows.
+   * 
+   * @param sf
+   */
+  public void explodeViews(SplitFrame sf)
+  {
+    AlignFrame oldTopFrame = (AlignFrame) sf.getTopFrame();
+    AlignFrame oldBottomFrame = (AlignFrame) sf.getBottomFrame();
+    List<? extends AlignmentViewPanel> topPanels = oldTopFrame
+            .getAlignPanels();
+    List<? extends AlignmentViewPanel> bottomPanels = oldBottomFrame
+            .getAlignPanels();
+    int viewCount = topPanels.size();
+    if (viewCount < 2)
+    {
       return;
     }
-    Cache.log.info("Successfully written snapshot to file "+of.getAbsolutePath());
+
+    /*
+     * Processing in reverse order works, forwards order leaves the first panels
+     * not visible. I don't know why!
+     */
+    for (int i = viewCount - 1; i >= 0; i--)
+    {
+      /*
+       * Make new top and bottom frames. These take over the respective
+       * AlignmentPanel objects, including their AlignmentViewports, so the
+       * cdna/protein relationships between the viewports is carried over to the
+       * new split frames.
+       */
+      AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
+      AlignFrame newTopFrame = new AlignFrame(topPanel);
+      newTopFrame.setVisible(true);
+      AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
+      AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
+      newBottomFrame.setVisible(true);
+      topPanel.av.setGatherViewsHere(false);
+      bottomPanel.av.setGatherViewsHere(false);
+      JInternalFrame splitFrame = new SplitFrame(newTopFrame,
+              newBottomFrame);
+      // either panel may hold previous exploded frame geometry
+      Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
+              .getExplodedGeometry();
+      if (geometry != null)
+      {
+        splitFrame.setBounds(geometry);
+      }
+      Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
+    }
+
+    /*
+     * Clear references to the panels (now relocated in the new SplitFrames)
+     * before closing the old SplitFrame.
+     */
+    topPanels.clear();
+    bottomPanels.clear();
+    sf.close();
+  }
+
+  /**
+   * Gather expanded split frames, sharing the same pairs of sequence set ids,
+   * back into the given SplitFrame as additional views. Note that the gathered
+   * frames may themselves have multiple views.
+   * 
+   * @param source
+   */
+  public void gatherViews(GSplitFrame source)
+  {
+    AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
+    AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
+    myTopFrame.viewport.setExplodedGeometry(source.getBounds());
+    myBottomFrame.viewport.setExplodedGeometry(source.getBounds());
+    myTopFrame.viewport.setGatherViewsHere(true);
+    myBottomFrame.viewport.setGatherViewsHere(true);
+    String topViewId = myTopFrame.viewport.getSequenceSetId();
+    String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
+  
+    JInternalFrame[] frames = desktop.getAllFrames();
+    for (JInternalFrame frame : frames)
+    {
+      if (frame instanceof SplitFrame && frame != source)
+      {
+        SplitFrame sf = (SplitFrame) frame;
+        AlignFrame topFrame = (AlignFrame) sf.getTopFrame();
+        AlignFrame bottomFrame = (AlignFrame) sf.getBottomFrame();
+        boolean gatherThis = false;
+        for (int a = 0; a < topFrame.alignPanels.size(); a++)
+        {
+          AlignmentPanel topPanel = topFrame.alignPanels.get(a);
+          AlignmentPanel bottomPanel = bottomFrame.alignPanels.get(a);
+          if (topViewId.equals(topPanel.av.getSequenceSetId())
+                  && bottomViewId.equals(bottomPanel.av.getSequenceSetId()))
+          {
+            gatherThis = true;
+            topPanel.av.setGatherViewsHere(false);
+            bottomPanel.av.setGatherViewsHere(false);
+            // both panels refer to the same split frame geometry
+            Rectangle position = sf.getBounds();
+            topPanel.av.setExplodedGeometry(position);
+            bottomPanel.av.setExplodedGeometry(position);
+            myTopFrame.addAlignmentPanel(topPanel, false);
+            myBottomFrame.addAlignmentPanel(bottomPanel, false);
+          }
+        }
+  
+        if (gatherThis)
+        {
+          topFrame.getAlignPanels().clear();
+          bottomFrame.getAlignPanels().clear();
+          sf.close();
+        }
+      }
+    }
+
+    /*
+     * The dust settles...give focus to the tab we did this from.
+     */
+    myTopFrame.setDisplayedView(myTopFrame.alignPanel);
+
   }
 }
index 6078377..9a71770 100644 (file)
@@ -50,7 +50,7 @@ public class RestInputParamEditDialog extends GRestInputParamEditDialog
     try
     {
       return (InputType) (typeclass.get(name).getConstructor()
-              .newInstance(null));
+              .newInstance());
     } catch (Throwable x)
     {
       System.err
@@ -187,7 +187,7 @@ public class RestInputParamEditDialog extends GRestInputParamEditDialog
       {
         JPanel inopts = new JPanel(new MigLayout());
         ArrayList<JPanel> opts = new ArrayList<JPanel>(), prms = new ArrayList<JPanel>();
-        jtype = (InputType) (type.getConstructor().newInstance(null));
+        jtype = (InputType) (type.getConstructor().newInstance());
         typeclass.put(jtype.getURLtokenPrefix(), type);
         // and populate parameters from this type
         OptsAndParamsPage opanp = new OptsAndParamsPage(this, true);
index 177ebb8..e7c861f 100644 (file)
  */
 package jalview.ws.rest;
 
-import jalview.datamodel.SequenceI;
-import jalview.io.packed.DataProvider.JvDataType;
-import jalview.ws.rest.params.Alignment;
-import jalview.ws.rest.params.AnnotationFile;
-import jalview.ws.rest.params.SeqGroupIndexVector;
-
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -37,8 +31,17 @@ import java.util.StringTokenizer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import jalview.datamodel.SequenceI;
+import jalview.io.packed.DataProvider.JvDataType;
+import jalview.util.StringUtils;
+import jalview.ws.rest.params.Alignment;
+import jalview.ws.rest.params.AnnotationFile;
+import jalview.ws.rest.params.SeqGroupIndexVector;
+
 public class RestServiceDescription
 {
+  private static final Pattern PARAM_ENCODED_URL_PATTERN = Pattern.compile("([?&])([A-Za-z0-9_]+)=\\$([^$]+)\\$");
+
   /**
    * create a new rest service description ready to be configured
    */
@@ -77,6 +80,7 @@ public class RestServiceDescription
     this.gapCharacter = gapCharacter;
   }
 
+  @Override
   public boolean equals(Object o)
   {
     if (o == null || !(o instanceof RestServiceDescription))
@@ -87,7 +91,8 @@ public class RestServiceDescription
     boolean diff = (gapCharacter != other.gapCharacter);
     diff |= vseparable != other.vseparable;
     diff |= hseparable != other.hseparable;
-    diff |= !(urlSuffix.equals(other.urlSuffix));
+    diff |= !(urlSuffix == null && other.urlSuffix == null || (urlSuffix != null
+            && other.urlSuffix != null && urlSuffix.equals(other.urlSuffix)));
     // TODO - robust diff that includes constants and reordering of URL
     // diff |= !(postUrl.equals(other.postUrl));
     // diff |= !inputParams.equals(other.inputParams);
@@ -356,131 +361,6 @@ public class RestServiceDescription
     return invalidMessage == null;
   }
 
-  private static boolean debug = false;
-
-  /**
-   * parse the string into a list
-   * 
-   * @param list
-   * @param separator
-   * @return elements separated by separator
-   */
-  public static String[] separatorListToArray(String list, String separator)
-  {
-    int seplen = separator.length();
-    if (list == null || list.equals("") || list.equals(separator))
-      return null;
-    java.util.ArrayList<String> jv = new ArrayList<String>();
-    int cp = 0, pos, escape;
-    boolean wasescaped = false, wasquoted = false;
-    String lstitem = null;
-    while ((pos = list.indexOf(separator, cp)) >= cp)
-    {
-
-      escape = (pos > 0 && list.charAt(pos - 1) == '\\') ? -1 : 0;
-      if (wasescaped || wasquoted)
-      {
-        // append to previous pos
-        jv.set(jv.size() - 1,
-                lstitem = lstitem + separator
-                        + list.substring(cp, pos + escape));
-
-      }
-      else
-      {
-        jv.add(lstitem = list.substring(cp, pos + escape));
-      }
-      cp = pos + seplen;
-      wasescaped = escape == -1;
-      if (!wasescaped)
-      {
-        // last separator may be in an unmatched quote
-        if (java.util.regex.Pattern.matches("('[^']*')*[^']*'", lstitem))
-        {
-          wasquoted = true;
-        }
-      }
-
-    }
-    if (cp < list.length())
-    {
-      String c = list.substring(cp);
-      if (wasescaped || wasquoted)
-      {
-        // append final separator
-        jv.set(jv.size() - 1, lstitem + separator + c);
-      }
-      else
-      {
-        if (!c.equals(separator))
-        {
-          jv.add(c);
-        }
-      }
-    }
-    if (jv.size() > 0)
-    {
-      String[] v = jv.toArray(new String[jv.size()]);
-      jv.clear();
-      if (debug)
-      {
-        System.err.println("Array from '" + separator
-                + "' separated List:\n" + v.length);
-        for (int i = 0; i < v.length; i++)
-        {
-          System.err.println("item " + i + " '" + v[i] + "'");
-        }
-      }
-      return v;
-    }
-    if (debug)
-    {
-      System.err.println("Empty Array from '" + separator
-              + "' separated List");
-    }
-    return null;
-  }
-
-  /**
-   * concatenate the list with separator
-   * 
-   * @param list
-   * @param separator
-   * @return concatenated string
-   */
-  public static String arrayToSeparatorList(String[] list, String separator)
-  {
-    StringBuffer v = new StringBuffer();
-    if (list != null && list.length > 0)
-    {
-      for (int i = 0, iSize = list.length; i < iSize; i++)
-      {
-        if (list[i] != null)
-        {
-          if (v.length() > 0)
-          {
-            v.append(separator);
-          }
-          // TODO - escape any separator values in list[i]
-          v.append(list[i]);
-        }
-      }
-      if (debug)
-      {
-        System.err.println("Returning '" + separator
-                + "' separated List:\n");
-        System.err.println(v);
-      }
-      return v.toString();
-    }
-    if (debug)
-    {
-      System.err.println("Returning empty '" + separator
-              + "' separated List\n");
-    }
-    return "" + separator;
-  }
-
   /**
    * parse a string containing a list of service properties and configure the
    * service description
@@ -492,7 +372,7 @@ public class RestServiceDescription
   private boolean configureFromServiceInputProperties(String propList,
           StringBuffer warnings)
   {
-    String[] props = separatorListToArray(propList, ",");
+    String[] props = StringUtils.separatorListToArray(propList, ",");
     if (props == null)
     {
       return true;
@@ -610,7 +490,7 @@ public class RestServiceDescription
     ;
     vls.add(new String("gapCharacter='" + gapCharacter + "'"));
     vls.add(new String("returns='" + _genOutputFormatString() + "'"));
-    return arrayToSeparatorList(vls.toArray(new String[0]), ",");
+    return StringUtils.arrayToSeparatorList(vls.toArray(new String[0]), ",");
   }
 
   public String toString()
@@ -653,7 +533,7 @@ public class RestServiceDescription
   public boolean configureFromEncodedString(String encoding,
           StringBuffer warnings)
   {
-    String[] list = separatorListToArray(encoding, "|");
+    String[] list = StringUtils.separatorListToArray(encoding, "|");
 
     int nextpos = parseServiceList(list, warnings, 0);
     if (nextpos > 0)
@@ -754,7 +634,7 @@ public class RestServiceDescription
             url.append("$");
             url.append(param.getValue().getURLtokenPrefix());
             url.append(":");
-            url.append(arrayToSeparatorList(vals.toArray(new String[0]),
+            url.append(StringUtils.arrayToSeparatorList(vals.toArray(new String[0]),
                     ","));
             url.append("$");
           }
@@ -781,7 +661,7 @@ public class RestServiceDescription
     boolean valid = true;
     int lastp = 0;
     String url = new String();
-    Matcher prms = Pattern.compile("([?&])([A-Za-z0-9_]+)=\\$([^$]+)\\$")
+    Matcher prms = PARAM_ENCODED_URL_PATTERN
             .matcher(ipurl);
     Map<String, InputType> iparams = new Hashtable<String, InputType>();
     InputType jinput;
@@ -843,11 +723,11 @@ public class RestServiceDescription
     {
       try
       {
-        jinput = (InputType) (type.getConstructor().newInstance(null));
+        jinput = (InputType) (type.getConstructor().newInstance());
         if (iprm.equalsIgnoreCase(jinput.getURLtokenPrefix()))
         {
           ArrayList<String> al = new ArrayList<String>();
-          for (String prprm : separatorListToArray(iprmparams, ","))
+          for (String prprm : StringUtils.separatorListToArray(iprmparams, ","))
           {
             // hack to ensure that strings like "sep=','" containing unescaped
             // commas as values are concatenated
@@ -998,7 +878,7 @@ public class RestServiceDescription
   public static List<RestServiceDescription> parseDescriptions(
           String services) throws Exception
   {
-    String[] list = separatorListToArray(services, "|");
+    String[] list = StringUtils.separatorListToArray(services, "|");
     List<RestServiceDescription> svcparsed = new ArrayList<RestServiceDescription>();
     int p = 0, lastp = 0;
     StringBuffer warnings = new StringBuffer();
index 7dbda90..a8a3904 100644 (file)
  */
 package jalview.ws.seqfetcher;
 
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefEntry;
-import jalview.datamodel.SequenceI;
-import jalview.util.DBRefUtils;
-import jalview.util.MessageManager;
-
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -36,6 +30,12 @@ import java.util.Map;
 import java.util.Stack;
 import java.util.Vector;
 
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.SequenceI;
+import jalview.util.DBRefUtils;
+import jalview.util.MessageManager;
+
 public class ASequenceFetcher
 {
 
@@ -58,7 +58,9 @@ public class ASequenceFetcher
   public String[] getSupportedDb()
   {
     if (FETCHABLEDBS == null)
+    {
       return null;
+    }
     String[] sf = new String[FETCHABLEDBS.size()];
     Enumeration e = FETCHABLEDBS.keys();
     int i = 0;
@@ -77,7 +79,9 @@ public class ASequenceFetcher
     {
       String db = (String) e.nextElement();
       if (source.compareToIgnoreCase(db) == 0)
+      {
         return true;
+      }
     }
     jalview.bin.Cache.log.warn("isFetchable doesn't know about '" + source
             + "'");
@@ -198,7 +202,9 @@ public class ASequenceFetcher
                    */
                   System.out.println(hdr);
                   if (rrb != null)
+                  {
                     System.out.println(rrb);
+                  }
                   System.out.println("# end of " + hdr);
                 }
 
@@ -303,24 +309,16 @@ public class ASequenceFetcher
    * @param dbSourceProxy
    *          reference for class implementing
    *          jalview.ws.seqfetcher.DbSourceProxy
-   * @throws java.lang.IllegalArgumentException
-   *           if class does not implement jalview.ws.seqfetcher.DbSourceProxy
    */
-  protected void addDBRefSourceImpl(Class dbSourceProxy)
+  protected void addDBRefSourceImpl(
+          Class<? extends DbSourceProxy> dbSourceProxy)
           throws java.lang.IllegalArgumentException
   {
     DbSourceProxy proxy = null;
     try
     {
-      Object proxyObj = dbSourceProxy.getConstructor(null)
-              .newInstance(null);
-      if (!DbSourceProxy.class.isInstance(proxyObj))
-      {
-        throw new IllegalArgumentException(
-                dbSourceProxy.toString()
-                        + " does not implement the jalview.ws.seqfetcher.DbSourceProxy");
-      }
-      proxy = (DbSourceProxy) proxyObj;
+      DbSourceProxy proxyObj = dbSourceProxy.getConstructor().newInstance();
+      proxy = proxyObj;
     } catch (IllegalArgumentException e)
     {
       throw e;
@@ -426,6 +424,7 @@ public class ASequenceFetcher
   {
     ArrayList<DbSourceProxy> prlist = new ArrayList<DbSourceProxy>();
     for (String fetchable : getSupportedDb())
+    {
       for (DbSourceProxy pr : getSourceProxy(fetchable))
       {
         if (class1.isInstance(pr))
@@ -433,6 +432,7 @@ public class ASequenceFetcher
           prlist.add(pr);
         }
       }
+    }
     if (prlist.size() == 0)
     {
       return null;