catch case when a service has no parameters (or the service's servicerunner does...
authorjprocter <Jim Procter>
Sun, 19 Sep 2010 16:36:25 +0000 (16:36 +0000)
committerjprocter <Jim Procter>
Sun, 19 Sep 2010 16:36:25 +0000 (16:36 +0000)
src/jalview/ws/jws2/MsaWSClient.java

index fce5178..2e5ef28 100644 (file)
@@ -151,7 +151,8 @@ public class MsaWSClient extends Jws2Client
     {
       if (sh.paramStore == null)
       {
-        sh.paramStore = new JabaParamStore(sh, Desktop.getUserParameterStore());
+        sh.paramStore = new JabaParamStore(sh,
+                Desktop.getUserParameterStore());
       }
       WsJobParameters jobParams = new WsJobParameters(sh, preset);
       if (!jobParams.showRunDialog())
@@ -270,7 +271,14 @@ public class MsaWSClient extends Jws2Client
       rmsawsmenu.add(msawsmenu);
       calcName = "";
     }
+    boolean hasparams = false;
+    try
+    {
+      hasparams = (service.getRunnerConfig().getArguments().size() > 0);
+    } catch (Exception e)
+    {
 
+    }
     do
     {
       if (submitGaps == true)
@@ -279,6 +287,7 @@ public class MsaWSClient extends Jws2Client
         rmsawsmenu.add(msawsmenu);
       }
       final boolean withGaps = submitGaps;
+
       JMenuItem method = new JMenuItem(calcName + "Defaults");
       method.setToolTipText("Align with default settings");
 
@@ -294,48 +303,54 @@ public class MsaWSClient extends Jws2Client
         }
       });
       msawsmenu.add(method);
-      method = new JMenuItem(calcName + "Edit and run ...");
-      method.setToolTipText("View and change the parameters before alignment.");
-
-      method.addActionListener(new ActionListener()
+      if (hasparams)
       {
-        public void actionPerformed(ActionEvent e)
-        {
-          AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-          new MsaWSClient(service, null, null, true, alignFrame.getTitle(),
-                  msa, withGaps, true, alignFrame.getViewport()
-                          .getAlignment().getDataset(), alignFrame);
+        // only add these menu options if the service has user-modifiable arguments
+        method = new JMenuItem(calcName + "Edit and run ...");
+        method.setToolTipText("View and change the parameters before alignment.");
 
-        }
-      });
-      msawsmenu.add(method);
-      List<WsParamSetI> presets = service.getParamStore().getPresets();
-      if (presets != null && presets.size() > 0)
-      {
-        JMenu presetlist = new JMenu(calcName + "Presets");
+        method.addActionListener(new ActionListener()
+        {
+          public void actionPerformed(ActionEvent e)
+          {
+            AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+            new MsaWSClient(service, null, null, true, alignFrame
+                    .getTitle(), msa, withGaps, true, alignFrame
+                    .getViewport().getAlignment().getDataset(), alignFrame);
 
-        for (final WsParamSetI preset : presets)
+          }
+        });
+        msawsmenu.add(method);
+        List<WsParamSetI> presets = service.getParamStore().getPresets();
+        if (presets != null && presets.size() > 0)
         {
-          final JMenuItem methodR = new JMenuItem(preset.getName());
-          methodR.setToolTipText("<html><p>"+JvSwingUtils.wrapTooltip("<strong>"
-                  + (preset.isModifiable() ? "User Preset"
-                          : "Service Preset") + "</strong><br/>"
-                  + preset.getDescription() + "</p>")+"</html>");
-          methodR.addActionListener(new ActionListener()
+          JMenu presetlist = new JMenu(calcName + "Presets");
+
+          for (final WsParamSetI preset : presets)
           {
-            public void actionPerformed(ActionEvent e)
+            final JMenuItem methodR = new JMenuItem(preset.getName());
+            methodR.setToolTipText("<html><p>"
+                    + JvSwingUtils.wrapTooltip("<strong>"
+                            + (preset.isModifiable() ? "User Preset"
+                                    : "Service Preset") + "</strong><br/>"
+                            + preset.getDescription() + "</p>") + "</html>");
+            methodR.addActionListener(new ActionListener()
             {
-              AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-              new MsaWSClient(service, preset, alignFrame.getTitle(), msa,
-                      false, true, alignFrame.getViewport().getAlignment()
-                              .getDataset(), alignFrame);
+              public void actionPerformed(ActionEvent e)
+              {
+                AlignmentView msa = alignFrame
+                        .gatherSequencesForAlignment();
+                new MsaWSClient(service, preset, alignFrame.getTitle(),
+                        msa, false, true, alignFrame.getViewport()
+                                .getAlignment().getDataset(), alignFrame);
 
-            }
+              }
 
-          });
-          presetlist.add(methodR);
+            });
+            presetlist.add(methodR);
+          }
+          msawsmenu.add(presetlist);
         }
-        msawsmenu.add(presetlist);
       }
       if (!submitGaps && canSubmitGaps())
       {