JAL-1432 updated copyright notices
[jalview.git] / src / jalview / ws / jws2 / MsaWSClient.java
index f3c385a..4e3f81c 100644 (file)
@@ -1,25 +1,25 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.ws.jws2;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.swing.*;
@@ -28,11 +28,7 @@ import jalview.datamodel.*;
 import jalview.gui.*;
 import compbio.data.msa.MsaWS;
 import compbio.metadata.Argument;
-import compbio.metadata.Option;
-import compbio.metadata.Preset;
-import compbio.metadata.PresetManager;
-import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
-import jalview.ws.jws2.dm.JabaWsParamSet;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
 
 /**
@@ -48,13 +44,7 @@ public class MsaWSClient extends Jws2Client
    */
   MsaWS server;
 
-  AlignFrame alignFrame;
-
-  private Preset preset;
-
-  private List<Argument> paramset;
-
-  public MsaWSClient(Jws2Discoverer.Jws2Instance sh, String altitle,
+  public MsaWSClient(Jws2Instance sh, String altitle,
           jalview.datamodel.AlignmentView msa, boolean submitGaps,
           boolean preserveOrder, Alignment seqdataset,
           AlignFrame _alignFrame)
@@ -64,9 +54,9 @@ public class MsaWSClient extends Jws2Client
     // TODO Auto-generated constructor stub
   }
 
-  public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
-          String altitle, jalview.datamodel.AlignmentView msa,
-          boolean submitGaps, boolean preserveOrder, Alignment seqdataset,
+  public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
+          jalview.datamodel.AlignmentView msa, boolean submitGaps,
+          boolean preserveOrder, Alignment seqdataset,
           AlignFrame _alignFrame)
   {
     this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
@@ -90,14 +80,18 @@ public class MsaWSClient extends Jws2Client
    *          DOCUMENT ME!
    */
 
-  public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
+  public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
           List<Argument> arguments, boolean editParams, String altitle,
           jalview.datamodel.AlignmentView msa, boolean submitGaps,
           boolean preserveOrder, Alignment seqdataset,
           AlignFrame _alignFrame)
   {
-    super();
-    alignFrame = _alignFrame;
+    super(_alignFrame, preset, arguments);
+    if (!processParams(sh, editParams))
+    {
+      return;
+    }
+
     if (!(sh.service instanceof MsaWS))
     {
       // redundant at mo - but may change
@@ -111,67 +105,7 @@ public class MsaWSClient extends Jws2Client
 
       return;
     }
-    server = sh.service;
-    if (preset != null)
-    {
-      if (preset instanceof JabaPreset)
-      {
-        this.preset = ((JabaPreset) preset).p;
-      }
-      else if (preset instanceof JabaWsParamSet)
-      {
-        List<Argument> newargs = new ArrayList<Argument>();
-        JabaWsParamSet pset = ((JabaWsParamSet) preset);
-        for (Option opt : pset.getjabaArguments())
-        {
-          newargs.add(opt);
-        }
-        if (arguments != null && arguments.size() > 0)
-        {
-          // merge arguments with preset's own arguments.
-          for (Argument opt : arguments)
-          {
-            newargs.add(opt);
-          }
-        }
-        paramset = newargs;
-      }
-      else
-      {
-        throw new Error(
-                "Implementation error: Can only instantiate Jaba parameter sets.");
-      }
-    }
-    else
-    {
-      // just provided with a bunch of arguments
-      this.paramset = arguments;
-    }
-    if (editParams)
-    {
-      if (sh.paramStore == null)
-      {
-        sh.paramStore = new JabaParamStore(sh,
-                Desktop.getUserParameterStore());
-      }
-      WsJobParameters jobParams = new WsJobParameters(sh, preset);
-      if (!jobParams.showRunDialog())
-      {
-        return;
-      }
-      WsParamSetI prset = jobParams.getPreset();
-      if (prset == null)
-      {
-        paramset = JabaParamStore.getJabafromJwsArgs(jobParams
-                .getJobParams());
-      }
-      else
-      {
-        this.preset = ((JabaPreset) prset).p;
-        paramset = null; // no user supplied parameters.
-      }
-    }
-
+    server = (MsaWS) sh.service;
     if ((wsInfo = setWebService(sh, false)) == null)
     {
       JOptionPane.showMessageDialog(Desktop.desktop,
@@ -274,18 +208,19 @@ public class MsaWSClient extends Jws2Client
     boolean hasparams = service.hasParameters();
     do
     {
-      String action="Align ";
+      String action = "Align ";
       if (submitGaps == true)
       {
-        action="Realign ";
+        action = "Realign ";
         msawsmenu = new JMenu("Realign with " + svcname);
-        msawsmenu.setToolTipText("Align sequences to an existing alignment");
+        msawsmenu
+                .setToolTipText("Align sequences to an existing alignment");
         rmsawsmenu.add(msawsmenu);
       }
       final boolean withGaps = submitGaps;
 
-      JMenuItem method = new JMenuItem(calcName + "Defaults");
-      method.setToolTipText(action+"with default settings");
+      JMenuItem method = new JMenuItem(calcName + "with Defaults");
+      method.setToolTipText(action + "with default settings");
 
       method.addActionListener(new ActionListener()
       {
@@ -301,8 +236,9 @@ public class MsaWSClient extends Jws2Client
       msawsmenu.add(method);
       if (hasparams)
       {
-        // only add these menu options if the service has user-modifiable arguments
-        method = new JMenuItem(calcName + "Edit and run ...");
+        // only add these menu options if the service has user-modifiable
+        // arguments
+        method = new JMenuItem("Edit settings and run ...");
         method.setToolTipText("View and change the parameters before alignment.");
 
         method.addActionListener(new ActionListener()
@@ -320,7 +256,7 @@ public class MsaWSClient extends Jws2Client
         List<WsParamSetI> presets = service.getParamStore().getPresets();
         if (presets != null && presets.size() > 0)
         {
-          JMenu presetlist = new JMenu(calcName + "Presets");
+          JMenu presetlist = new JMenu("Run " + calcName + "with preset");
 
           for (final WsParamSetI preset : presets)
           {