JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / gui / WsJobParameters.java
index 918724c..b3e40c1 100644 (file)
@@ -1,68 +1,76 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 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.gui;
 
+import jalview.gui.OptsAndParamsPage.OptionBox;
+import jalview.gui.OptsAndParamsPage.ParamBox;
+import jalview.util.MessageManager;
+import jalview.ws.jws2.JabaParamStore;
+import jalview.ws.jws2.JabaPreset;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.OptionI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.ParameterI;
+import jalview.ws.params.WsParamSetI;
+
 import java.awt.BorderLayout;
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
 import java.awt.GridLayout;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.ContainerEvent;
-import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
-import java.awt.event.WindowStateListener;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Vector;
 
-import javax.swing.InputVerifier;
 import javax.swing.JButton;
-import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
-import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
-import javax.swing.JSlider;
 import javax.swing.JSplitPane;
-import javax.swing.JTabbedPane;
-import javax.swing.JTable;
 import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.ListSelectionModel;
-import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
 import javax.swing.border.TitledBorder;
-import javax.swing.event.CellEditorListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
-import javax.swing.table.*;
+
+import net.miginfocom.swing.MigLayout;
 
 import compbio.metadata.Argument;
 import compbio.metadata.Option;
@@ -70,24 +78,6 @@ import compbio.metadata.Parameter;
 import compbio.metadata.Preset;
 import compbio.metadata.PresetManager;
 import compbio.metadata.RunnerConfig;
-import compbio.metadata.ValueConstrain;
-import compbio.metadata.WrongParameterException;
-import compbio.metadata.ValueConstrain.Type;
-
-import jalview.util.jarInputStreamProvider;
-import jalview.ws.jws2.JabaParamStore;
-import jalview.ws.jws2.JabaPreset;
-import jalview.ws.jws2.Jws2Discoverer;
-import jalview.ws.jws2.ParameterUtils;
-import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
-import jalview.ws.jws2.dm.JabaOption;
-import jalview.ws.jws2.dm.JabaParameter;
-import jalview.ws.params.ArgumentI;
-import jalview.ws.params.OptionI;
-import jalview.ws.params.ParamDatastoreI;
-import jalview.ws.params.ParameterI;
-import jalview.ws.params.ValueConstrainI;
-import jalview.ws.params.WsParamSetI;
 
 /**
  * job parameter editing/browsing dialog box. User can browse existing settings
@@ -105,17 +95,28 @@ import jalview.ws.params.WsParamSetI;
  * 
  */
 public class WsJobParameters extends JPanel implements ItemListener,
-        ActionListener, DocumentListener
+        ActionListener, DocumentListener, OptsParametersContainerI
 {
   URL linkImageURL = getClass().getResource("/images/link.gif");
+
   private static final String SVC_DEF = "Defaults"; // this is the null
                                                     // parameter set as shown to
                                                     // user
 
-  private static final int PARAM_WIDTH = 340, PARAM_HEIGHT = 150,
-          PARAM_CLOSEDHEIGHT = 80;
+  /**
+   * manager for options and parameters.
+   */
+  OptsAndParamsPage opanp = new OptsAndParamsPage(this);
 
-  private static final int OPTSET_HEIGHT = 30;
+  /**
+   * panel containing job options
+   */
+  JPanel jobOptions = new JPanel();
+
+  /**
+   * panel containing job parameters
+   */
+  JPanel paramList = new JPanel();
 
   JPanel SetNamePanel = new JPanel();
 
@@ -123,15 +124,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
 
   JSplitPane settingsPanel = new JSplitPane();
 
-  JSplitPane jobPanel = new JSplitPane();
-  boolean split=true;
-  JTabbedPane tabpanels=new JTabbedPane();
-  JPanel jobOptions = new JPanel();
+  JPanel jobPanel = new JPanel();
 
   JScrollPane jobOptionsPane = new JScrollPane();
 
-  JPanel jobParameters = new JPanel();
-
   JButton createpref = new JButton();
 
   JButton deletepref = new JButton();
@@ -150,12 +146,15 @@ public class WsJobParameters extends JPanel implements ItemListener,
 
   JScrollPane paramPane = new JScrollPane();
 
-  JPanel paramList = new JPanel();
+  // ScrollablePanel optsAndparams = new ScrollablePanel();
+  JPanel optsAndparams = new JPanel();
 
   RunnerConfig serviceOptions;
 
   ParamDatastoreI paramStore;
 
+  private int MAX_OPTWIDTH = 200;
+
   WsJobParameters(Jws2Instance service)
   {
     this(service, null);
@@ -219,25 +218,27 @@ public class WsJobParameters extends JPanel implements ItemListener,
 
     frame = new JDialog(Desktop.instance, true);
 
-    frame.setTitle("Edit parameters for " + service.getActionText());
+    frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
+            new String[] { service.getActionText() }));
     Rectangle deskr = Desktop.instance.getBounds();
-    frame.setBounds(new Rectangle((int) (deskr.getCenterX() - 240),
-            (int) (deskr.getCenterY() - 250), 480, 500));
+    Dimension pref = this.getPreferredSize();
+    frame.setBounds(new Rectangle(
+            (int) (deskr.getCenterX() - pref.width / 2), (int) (deskr
+                    .getCenterY() - pref.height / 2), pref.width,
+            pref.height));
     frame.setContentPane(this);
-    // should recover defaults from user prefs.
-    //settingsPanel.setDividerLocation(0.4);
-    //jobPanel.setDividerLocation(0.5);
+
+    // should perhaps recover defaults from user prefs.
+
     frame.validate();
-    if (split) {
-      javax.swing.SwingUtilities.invokeLater(new Runnable() {
-        public void run() {
-          settingsPanel.setDividerLocation(0.5);
-          jobPanel.setDividerLocation(setDescr.getLineCount()>3 ? 0.35 : 0.16 );
-        }
-      });
-    } else {
-      tabpanels.setSelectedComponent(jobOptionsPane);
-    }
+    javax.swing.SwingUtilities.invokeLater(new Runnable()
+    {
+      public void run()
+      {
+        // jobPanel.setDividerLocation(0.25);
+
+      }
+    });
     frame.setVisible(true);
 
     if (response > 0)
@@ -247,10 +248,27 @@ public class WsJobParameters extends JPanel implements ItemListener,
     return false;
   }
 
-
   private void jbInit()
   {
-    updatepref = JvSwingUtils.makeButton("Update", "Update this existing user parameter set.",
+    this.addHierarchyBoundsListener(new HierarchyBoundsListener()
+    {
+
+      @Override
+      public void ancestorResized(HierarchyEvent arg0)
+      {
+        refreshParamLayout();
+      }
+
+      @Override
+      public void ancestorMoved(HierarchyEvent arg0)
+      {
+        // TODO Auto-generated method stub
+
+      }
+    });
+    updatepref = JvSwingUtils.makeButton(
+            MessageManager.getString("action.update"),
+            MessageManager.getString("label.update_user_parameter_set"),
             new ActionListener()
             {
 
@@ -259,7 +277,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 update_actionPerformed(e);
               }
             });
-    deletepref = JvSwingUtils.makeButton("Delete", "Delete the currently selected user parameter set.",
+    deletepref = JvSwingUtils.makeButton(
+            MessageManager.getString("action.delete"),
+            MessageManager.getString("label.delete_user_parameter_set"),
             new ActionListener()
             {
 
@@ -268,7 +288,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 delete_actionPerformed(e);
               }
             });
-    createpref = JvSwingUtils.makeButton("Create", "Create a new parameter set with the current settings.",
+    createpref = JvSwingUtils.makeButton(
+            MessageManager.getString("action.create"),
+            MessageManager.getString("label.create_user_parameter_set"),
             new ActionListener()
             {
 
@@ -277,8 +299,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 create_actionPerformed(e);
               }
             });
-    revertpref = JvSwingUtils.makeButton("Revert",
-            "Undo all changes to the current parameter set", new ActionListener()
+    revertpref = JvSwingUtils.makeButton(MessageManager
+            .getString("action.revert"), MessageManager
+            .getString("label.revert_changes_user_parameter_set"),
+            new ActionListener()
             {
 
               public void actionPerformed(ActionEvent e)
@@ -286,22 +310,29 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 revert_actionPerformed(e);
               }
             });
-    startjob = JvSwingUtils.makeButton("Start Job", "Start Job with current settings.",new ActionListener()
-    {
-      public void actionPerformed(ActionEvent e)
-      {
-        startjob_actionPerformed(e);
-      }
-    });
-    canceljob = JvSwingUtils.makeButton("Cancel Job", "Close this dialog and cancel job.", new ActionListener()
-    {
-      public void actionPerformed(ActionEvent e)
-      {
-        canceljob_actionPerformed(e);
-      }
-    });
+    startjob = JvSwingUtils.makeButton(
+            MessageManager.getString("action.start_job"),
+            MessageManager.getString("label.start_job_current_settings"),
+            new ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                startjob_actionPerformed(e);
+              }
+            });
+    canceljob = JvSwingUtils.makeButton(
+            MessageManager.getString("action.cancel_job"),
+            MessageManager.getString("label.cancel_job_close_dialog"),
+            new ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                canceljob_actionPerformed(e);
+              }
+            });
 
-    setDetails.setBorder(new TitledBorder("Details"));
+    setDetails.setBorder(new TitledBorder(MessageManager
+            .getString("label.details")));
     setDetails.setLayout(new BorderLayout());
     setDescr.setColumns(40);
     setDescr.setWrapStyleWord(true);
@@ -309,21 +340,24 @@ public class WsJobParameters extends JPanel implements ItemListener,
     setDescr.setBackground(getBackground());
     setDescr.setEditable(true);
     setDescr.getDocument().addDocumentListener(this);
-    setDescr.setToolTipText("Click to edit the notes for this parameter set.");
+    setDescr.setToolTipText(MessageManager
+            .getString("label.edit_notes_parameter_set"));
     JScrollPane setDescrView = new JScrollPane();
-    // setDescrView.setPreferredSize(new Dimension(350, 200));
     setDescrView.getViewport().setView(setDescr);
     setName.setEditable(true);
     setName.addItemListener(this);
     setName.getEditor().addActionListener(this);
     JPanel setNameInfo = new JPanel(new FlowLayout(FlowLayout.LEFT));
-    SetNamePanel.setLayout(new GridLayout(2, 1));
-    SetNamePanel.setMinimumSize(new Dimension(300, 40));
-    JLabel setNameLabel = new JLabel("Current parameter set name :");
+    GridBagLayout gbl = new GridBagLayout();
+    SetNamePanel.setLayout(gbl);
+
+    JLabel setNameLabel = new JLabel(
+            MessageManager.getString("label.current_parameter_set_name"));
     setNameLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
-    // setNameLabel.setHorizontalAlignment(FlowLayout.LEFT);
+
     setNameInfo.add(setNameLabel);
     setNameInfo.add(setName);
+
     // initial button visibility
     updatepref.setVisible(false);
     deletepref.setVisible(false);
@@ -333,58 +367,78 @@ public class WsJobParameters extends JPanel implements ItemListener,
     setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT)); // GridLayout(1,2));
     ((FlowLayout) setsavebuts.getLayout()).setHgap(10);
     ((FlowLayout) setsavebuts.getLayout()).setVgap(0);
+    JPanel spacer = new JPanel();
+    spacer.setPreferredSize(new Dimension(2, 30));
+    setsavebuts.add(spacer);
     setsavebuts.add(deletepref);
     setsavebuts.add(revertpref);
     setsavebuts.add(createpref);
     setsavebuts.add(updatepref);
-    setsavebuts.setSize(new Dimension(150, 20));
+    // setsavebuts.setSize(new Dimension(150, 30));
     JPanel buttonArea = new JPanel(new GridLayout(1, 1));
     buttonArea.add(setsavebuts);
     SetNamePanel.add(setNameInfo);
+    GridBagConstraints gbc = new GridBagConstraints();
+    gbc.gridheight = 2;
+    gbl.setConstraints(setNameInfo, gbc);
     SetNamePanel.add(buttonArea);
+    gbc = new GridBagConstraints();
+    gbc.gridx = 0;
+    gbc.gridy = 2;
+    gbc.gridheight = 1;
+    gbl.setConstraints(buttonArea, gbc);
     setDetails.add(setDescrView, BorderLayout.CENTER);
-    //setDetails.setPreferredSize(new Dimension(360, 100));
-    jobParameters.setBorder(new TitledBorder("Parameters"));
-    jobParameters.setLayout(new BorderLayout());
-    paramPane.setPreferredSize(new Dimension(360, 300));
-    paramPane.getVerticalScrollBar().setUnitIncrement(20);
-    // paramPanel.setPreferredSize(new Dimension(360, 300));
-    // TODO: relayout buttons nicely
-    paramPane.getViewport().setView(paramList);
-    jobParameters.add(paramPane, BorderLayout.CENTER);
-    JPanel jobOptionsPanel = new JPanel();
-    jobOptionsPanel.setLayout(new BorderLayout());
-    jobOptionsPanel.setBorder(new TitledBorder("Options"));
-    jobOptionsPane.getViewport().setView(jobOptions);
-    jobOptionsPanel.add(jobOptionsPane, BorderLayout.CENTER);
-    
+
+    // paramPane.setPreferredSize(new Dimension(360, 400));
+    // paramPane.setPreferredSize(null);
+    jobOptions.setBorder(new TitledBorder(MessageManager
+            .getString("label.options")));
+    jobOptions.setOpaque(true);
+    paramList.setBorder(new TitledBorder(MessageManager
+            .getString("label.parameters")));
+    paramList.setOpaque(true);
+    JPanel bjo = new JPanel(new BorderLayout()), bjp = new JPanel(
+            new BorderLayout());
+    bjo.add(jobOptions, BorderLayout.CENTER);
+    bjp.add(paramList, BorderLayout.CENTER);
+    bjp.setOpaque(true);
+    bjo.setOpaque(true);
+    // optsAndparams.setScrollableWidth(ScrollableSizeHint.FIT);
+    // optsAndparams.setScrollableHeight(ScrollableSizeHint.NONE);
+    // optsAndparams.setLayout(new BorderLayout());
+    optsAndparams.setLayout(new BorderLayout());
+    optsAndparams.add(jobOptions, BorderLayout.NORTH);
+    optsAndparams.add(paramList, BorderLayout.CENTER);
+    JPanel jp = new JPanel(new BorderLayout());
+    jp.add(optsAndparams, BorderLayout.CENTER);
+    paramPane.getViewport().setView(jp);
+    paramPane.setBorder(null);
     setLayout(new BorderLayout());
-    jobPanel.setLeftComponent(setDetails);
-    if (split) {
-      settingsPanel.setLeftComponent(jobOptionsPanel);
-      settingsPanel.setRightComponent(jobParameters);
-      settingsPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
-      jobPanel.setRightComponent(settingsPanel);
-    } else {
-    jobPanel.setRightComponent(tabpanels);
-    jobOptionsPane.setName("Options");
-    tabpanels.add(jobOptionsPane);
-    paramPane.setName("Parameters");
-    tabpanels.add(paramPane);
-    }
-    jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
-    add(SetNamePanel, BorderLayout.NORTH);    
+    jobPanel.setPreferredSize(null);
+    jobPanel.setLayout(new BorderLayout());
+    jobPanel.add(setDetails, BorderLayout.NORTH);
+    jobPanel.add(paramPane, BorderLayout.CENTER);
+    // jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
+
+    add(SetNamePanel, BorderLayout.NORTH);
     add(jobPanel, BorderLayout.CENTER);
+
     JPanel dialogpanel = new JPanel();
     dialogpanel.add(startjob);
     dialogpanel.add(canceljob);
+    // JAL-1580: setMaximumSize() doesn't work, so just size for the worst case:
+    // check for null is for JUnit usage
+    final int windowHeight = Desktop.instance == null ? 540
+            : Desktop.instance.getHeight();
+    setPreferredSize(new Dimension(540, windowHeight));
     add(dialogpanel, BorderLayout.SOUTH);
+    validate();
   }
 
   protected void revert_actionPerformed(ActionEvent e)
   {
     reInitDialog(lastParmSet);
-
+    updateWebServiceMenus();
   }
 
   protected void update_actionPerformed(ActionEvent e)
@@ -413,6 +467,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
       _deleteUserPreset(lastParmSet);
     }
     reInitDialog(null); // service default
+    updateWebServiceMenus();
   }
 
   protected void create_actionPerformed(ActionEvent e)
@@ -423,7 +478,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
       _storeCurrentPreset(curname);
       lastParmSet = curname;
       isUserPreset = true;
+      reInitDialog(curname);
       initArgSetModified();
+      updateWebServiceMenus();
     }
     else
     {
@@ -474,13 +531,11 @@ public class WsJobParameters extends JPanel implements ItemListener,
       p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) :
                  // null;
     }
-    // TODO: Recover window geometry prefs for this service
-    // jobPanel.setDividerLocation(proportionalLocation)
-    // settingsPanel.setDividerLocation(proportionalLocation)
+
     Hashtable exnames = new Hashtable();
     for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++)
     {
-      exnames.put((String) setName.getItemAt(i), setName.getItemAt(i));
+      exnames.put(setName.getItemAt(i), setName.getItemAt(i));
     }
     servicePresets = new Hashtable();
     // Add the default entry - if not present already.
@@ -518,7 +573,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
       if (jobArgset != null && jobArgset.size() > 0)
       {
         curSetName = "Supplied Settings";
+        isUserPreset = false;
         updateTable(p, jobArgset);
+        setName.setSelectedItem(curSetName);
+        updateButtonDisplay();
       }
       else
       {
@@ -533,25 +591,46 @@ public class WsJobParameters extends JPanel implements ItemListener,
   @SuppressWarnings("unchecked")
   private void updateTable(WsParamSetI p, List<ArgumentI> jobArgset)
   {
+    boolean setDefaultParams = false;
+    if (lastParmSet == null)
+    {
+      isUserPreset = false;
+      // First call - so provide Service default settings
+      setName.setSelectedItem(lastSetName = SVC_DEF);
+    }
+    if (p == null && SVC_DEF.equals("" + setName.getSelectedItem()))
+    {
+      // indicate that service defaults should be set if available
+      setDefaultParams = true;
+    }
     // populate table from default parameter set.
     List<ArgumentI> args = paramStore.getServiceParameters();
 
     // split to params and required arguments
     {
+      int cw = 0;
+      boolean optset = false;
       for (ArgumentI myarg : args)
       {
         // Ideally, Argument would implement isRequired !
         if (myarg instanceof ParameterI)
         {
           ParameterI parm = (ParameterI) myarg;
-          addParameter(parm);
+          opanp.addParameter(parm).validate();
         }
         else
         {
           if (myarg instanceof OptionI)
           {
             OptionI opt = (OptionI) myarg;
-            addOption(opt).resetToDefault();
+            OptionBox ob = opanp.addOption(opt);
+            ob.resetToDefault(setDefaultParams);
+            if (MAX_OPTWIDTH < ob.getPreferredSize().width)
+            {
+              MAX_OPTWIDTH = ob.getPreferredSize().width;
+            }
+            ob.validate();
+            cw += ob.getPreferredSize().width + 5;
           }
           else
           {
@@ -579,16 +658,6 @@ public class WsJobParameters extends JPanel implements ItemListener,
       // TODO: check if args should be unselected prior to resetting using the
       // preset
     }
-    else
-    {
-      if (lastParmSet == null)
-      {
-        isUserPreset = false;
-        // first call - so create a dummy name
-
-        setName.setSelectedItem(lastSetName = SVC_DEF);
-      }
-    }
 
     if (jobArgset != null)
     {
@@ -602,7 +671,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
       {
         if (arg instanceof ParameterI)
         {
-          setParameter((ParameterI) arg);
+          opanp.setParameter((ParameterI) arg);
         }
         else
         {
@@ -611,18 +680,14 @@ public class WsJobParameters extends JPanel implements ItemListener,
             // System.out.println("Setting option "
             // + System.identityHashCode(arg) + ":" + arg.getName()
             // + " with " + arg.getDefaultValue());
-            selectOption((OptionI) arg, arg.getDefaultValue());
+            opanp.selectOption((OptionI) arg, arg.getValue());
           }
         }
 
       }
     }
 
-    jobOptions.setPreferredSize(new Dimension(PARAM_WIDTH, optSet.size()
-            * OPTSET_HEIGHT));
-    jobOptions.setLayout(new GridLayout(optSet.size(), 1));
     refreshParamLayout();
-    paramPane.validate();
     revalidate();
   }
 
@@ -671,7 +736,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     validate();
   }
 
-  private void argSetModified(Object modifiedElement, boolean b)
+  public void argSetModified(Object modifiedElement, boolean b)
   {
     if (settingDialog)
     {
@@ -762,646 +827,121 @@ public class WsJobParameters extends JPanel implements ItemListener,
     settingDialog = stn;
   }
 
-  private void addParameter(ParameterI arg)
-  {
-    ParamBox pb = paramSet.get(arg.getName());
-    if (pb == null)
-    {
-      pb = new ParamBox(this, arg);
-      paramSet.put(arg.getName(), pb);
-      paramList.add(pb);
-    }
-    pb.init();
-    // take the defaults from the parameter
-    pb.updateControls(arg);
-  }
-
-  private void setParameter(ParameterI arg)
-  {
-    ParamBox pb = paramSet.get(arg.getName());
-    if (pb == null)
-    {
-      addParameter(arg);
-    }
-    else
-    {
-      pb.updateControls(arg);
-    }
-
-  }
-
-  private void selectOption(OptionI option, String string)
+  public void refreshParamLayout()
   {
-    OptionBox cb = optSet.get(option.getName());
-    if (cb == null)
-    {
-      cb = addOption(option);
-    }
-    cb.enabled.setSelected(string != null); // initial state for an option.
-    if (string != null)
-    {
-      if (option.getPossibleValues().contains(string))
+    // optsAndparams.setPreferredSize(null);
+    FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
+    int sep = fl.getVgap();
+    boolean fh = true;
+    int os = 0, s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom
+            + jobOptions.getBorder().getBorderInsets(jobOptions).top
+            + 2
+            * sep;
+    /**
+     * final height for viewport
+     */
+    int finalh = s;
+    int panewidth = paramPane.getViewport().getSize().width - 120
+            - jobOptions.getBorder().getBorderInsets(jobOptions).left
+            + jobOptions.getBorder().getBorderInsets(jobOptions).right;
+
+    int w = 2
+            * fl.getHgap()
+            + (MAX_OPTWIDTH > OptsAndParamsPage.PARAM_WIDTH ? MAX_OPTWIDTH
+                    : OptsAndParamsPage.PARAM_WIDTH);
+    int hgap = fl.getHgap(), cw = hgap;
+
+    if (opanp.getOptSet().size() > 0)
+    {
+
+      jobOptions.setLayout(new MigLayout("", "", ""));
+      jobOptions.removeAll();
+
+      for (OptionBox pbox : opanp.getOptSet().values())
       {
-        cb.val.setSelectedItem(string);
-      }
-      else
-      {
-        throw new Error("Invalid value " + string + " for option " + option);
-      }
-
-    }
-    if (option.isRequired() && !cb.enabled.isSelected())
-    {
-      // TODO: indicate paramset is not valid.. option needs to be selected!
-    }
-    cb.setInitialValue();
-  }
-
-  Map<String, ParamBox> paramSet = new Hashtable<String, ParamBox>();
-
-  public class ParamBox extends JPanel implements ChangeListener,
-          ActionListener, MouseListener
-  {
-    JButton showDesc = new JButton();
-
-    JTextArea string = new JTextArea();
-
-    JScrollPane descPanel = new JScrollPane();
-
-    JSlider slider = null;
-
-    JTextField valueField = null;
-
-    ValueConstrainI validator = null;
-
-    JPanel settingPanel = new JPanel();
-
-    JPanel controlPanel = new JPanel();
-
-    boolean integ = false;
-
-    boolean choice = false;
-
-    boolean descisvisible = false;
-
-    final WsJobParameters pmdialogbox;
-
-    final URL finfo;
-
-    public ParamBox(final WsJobParameters pmlayout, ParameterI parm)
-    {
-      pmdialogbox = pmlayout;
-      setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT));
-      setBorder(new TitledBorder(parm.getName()));
-      setLayout(null);
-      showDesc.setFont(new Font("Verdana", Font.PLAIN, 6));
-      showDesc.setText("+");
-      string.setFont(new Font("Verdana", Font.PLAIN, 11));
-      string.setBackground(getBackground());
-      // string.setSize(new Dimension(PARAM_WIDTH, 80));
-      string.setEditable(false);
-      descPanel.getViewport().setView(string);
-      // descPanel.setLocation(2,17);
-      descPanel.setVisible(false);
-      // string.setMinimumSize(new Dimension(140,80));
-      // string.setMaximumSize(new Dimension(280,80));
-      final ParamBox me = this;
-      finfo = parm.getFurtherDetails();
-      if (finfo != null)
-      {
-        showDesc.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Click to show brief description<br><img src=\"" + linkImageURL + "\"/> Right click for further information.")+"</html>");
-        showDesc.addMouseListener(this);
-      }
-      else
-      {
-        showDesc.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Click to show brief description.")+"</html>");
-      }
-      showDesc.addActionListener(new ActionListener()
-      {
-
-        public void actionPerformed(ActionEvent e)
-        {
-          descisvisible = !descisvisible;
-          descPanel.setVisible(descisvisible);
-          me.setPreferredSize(new Dimension(PARAM_WIDTH,
-                  (descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT));
-          me.validate();
-          pmlayout.refreshParamLayout();
-        }
-      });
-      string.setWrapStyleWord(true);
-      string.setLineWrap(true);
-      string.setColumns(32);
-      string.setText(parm.getDescription());
-      JPanel firstrow = new JPanel();
-      firstrow.setLayout(null);
-      controlPanel.setLayout(new BorderLayout());
-      controlPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70,
-              PARAM_CLOSEDHEIGHT - 50));
-      showDesc.setBounds(new Rectangle(10, 10, 16, 16));
-      firstrow.add(showDesc);
-      firstrow.add(controlPanel);
-      firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30,
-              PARAM_CLOSEDHEIGHT - 30));
-      add(firstrow);
-      validator = parm.getValidValue();
-      parameter = parm;
-      if (validator != null)
-      {
-        integ = validator.getType() == Type.Integer;
-      }
-      else
-      {
-        if (parameter.getPossibleValues() != null)
-        {
-          choice = true;
-        }
-      }
-      updateControls(parm);
-      descPanel.setBounds(new Rectangle(10, PARAM_CLOSEDHEIGHT,
-              PARAM_WIDTH - 20, PARAM_HEIGHT - PARAM_CLOSEDHEIGHT - 5));
-      add(descPanel);
-      validate();
-    }
-
-    public void init()
-    {
-      // reset the widget's initial value.
-      lastVal = null;
-    }
-
-    boolean adjusting = false;
-
-    ParameterI parameter;
-
-    JComboBox choicebox;
-
-    public int getBoxHeight()
-    {
-      return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT);
-    }
-
-    public void updateControls(ParameterI parm)
-    {
-      adjusting = true;
-      boolean init = (choicebox == null && valueField == null);
-      float fVal = 0f;
-      int iVal = 0;
-      if (init)
-      {
-        if (choice)
+        pbox.validate();
+        cw += pbox.getSize().width + hgap;
+        if (cw + 120 > panewidth)
         {
-          choicebox = new JComboBox();
-          choicebox.addActionListener(this);
-          controlPanel.add(choicebox, BorderLayout.CENTER);
+          jobOptions.add(pbox, "wrap");
+          // System.out.println("Wrap on "+pbox.option.getName());
+          cw = hgap + pbox.getSize().width;
+          fh = true;
         }
         else
         {
-          slider = new JSlider();
-          slider.addChangeListener(this);
-          valueField = new JTextField();
-          valueField.addActionListener(this);
-          valueField.setPreferredSize(new Dimension(60, 25));
-          controlPanel.add(slider, BorderLayout.WEST);
-          controlPanel.add(valueField, BorderLayout.EAST);
-
+          jobOptions.add(pbox);
         }
-      }
-
-      if (parm != null)
-      {
-        if (choice)
+        if (fh)
         {
-          if (init)
-          {
-            List vals = parm.getPossibleValues();
-            for (Object val : vals)
-            {
-              choicebox.addItem(val);
-            }
-          }
-
-          if (parm.getDefaultValue() != null)
-          {
-            choicebox.setSelectedItem(parm.getDefaultValue());
-          }
-        }
-        else
-        {
-          valueField.setText(parm.getDefaultValue());
+          finalh += pbox.getSize().height + fl.getVgap();
+          fh = false;
         }
       }
-      lastVal = updateSliderFromValueField();
-      adjusting = false;
+      jobOptions.revalidate();
     }
-
-    Object lastVal;
-
-    public ParameterI getParameter()
+    else
     {
-      ParameterI prm = parameter.copy();
-      if (choice)
-      {
-        prm.setDefaultValue((String) choicebox.getSelectedItem());
-      }
-      else
-      {
-        prm.setDefaultValue(valueField.getText());
-      }
-      return prm;
+      jobOptions.setVisible(false);
     }
 
-    public Object updateSliderFromValueField()
+    // Now layout the parameters assuming they occupy one column - to calculate
+    // total height of options+parameters
+    fl = new FlowLayout(FlowLayout.LEFT);
+    // helpful hint from
+    // http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout
+    fl.setAlignOnBaseline(true);
+    if (opanp.getParamSet().size() > 0)
     {
-      int iVal;
-      float fVal;
-      if (validator != null)
+      paramList.removeAll();
+      paramList.setLayout(new MigLayout("", "", ""));
+      fh = true;
+      for (ParamBox pbox : opanp.getParamSet().values())
       {
-        if (integ)
+        pbox.validate();
+        cw += pbox.getSize().width + hgap;
+        if (cw + 160 > panewidth)
         {
-          iVal = 0;
-          try
-          {
-            valueField.setText(valueField.getText().trim());
-            iVal = Integer.valueOf(valueField.getText());
-            if (validator.getMin() != null
-                    && validator.getMin().intValue() > iVal)
-            {
-              iVal = validator.getMin().intValue();
-              // TODO: provide visual indication that hard limit was reached for
-              // this parameter
-            }
-            if (validator.getMax() != null
-                    && validator.getMax().intValue() < iVal)
-            {
-              iVal = validator.getMax().intValue();
-              // TODO: provide visual indication that hard limit was reached for
-              // this parameter
-            }
-          } catch (Exception e)
-          {
-          }
-          ;
-          if (validator.getMin() != null && validator.getMax() != null)
-          {
-            slider.getModel().setRangeProperties(iVal, 1,
-                    validator.getMin().intValue(),
-                    validator.getMax().intValue(), true);
-          }
-          else
-          {
-            slider.setVisible(false);
-          }
-          return new int[]
-          { iVal };
+          paramList.add(pbox, "wrap");
+          cw = pbox.getSize().width + hgap;
+          fh = true;
         }
         else
         {
-          fVal = 0f;
-          try
-          {
-            fVal = Float.valueOf(valueField.getText());
-            if (validator.getMin() != null
-                    && validator.getMin().floatValue() > fVal)
-            {
-              fVal = validator.getMin().floatValue();
-              // TODO: provide visual indication that hard limit was reached for
-              // this parameter
-            }
-            if (validator.getMax() != null
-                    && validator.getMax().floatValue() < fVal)
-            {
-              fVal = validator.getMax().floatValue();
-              // TODO: provide visual indication that hard limit was reached for
-              // this parameter
-            }
-          } catch (Exception e)
-          {
-          }
-          ;
-          if (validator.getMin() != null && validator.getMax() != null)
-          {
-            slider.getModel().setRangeProperties((int) fVal * 1000, 1,
-                    (int) validator.getMin().floatValue() * 1000,
-                    (int) validator.getMax().floatValue() * 1000, true);
-          }
-          else
-          {
-            slider.setVisible(false);
-          }
-          return new float[]
-          { fVal };
-        }
-      }
-      else
-      {
-        if (!choice)
-        {
-          slider.setVisible(false);
-          return new String[]
-          { valueField.getText().trim() };
-        }
-        else
-        {
-          return new String[]
-          { (String) choicebox.getSelectedItem() };
-        }
-      }
-
-    }
-
-    public void stateChanged(ChangeEvent e)
-    {
-      if (!adjusting)
-      {
-        valueField.setText(""
-                + ((integ) ? ("" + (int) slider.getValue())
-                        : ("" + (float) (slider.getValue() / 1000f))));
-        checkIfModified();
-      }
-
-    }
-
-    public void actionPerformed(ActionEvent e)
-    {
-      if (adjusting)
-      {
-        return;
-      }
-      if (!choice)
-      {
-        updateSliderFromValueField();
-      }
-      checkIfModified();
-    }
-
-    private void checkIfModified()
-    {
-      Object cstate = updateSliderFromValueField();
-      boolean notmod = false;
-      if (cstate.getClass() == lastVal.getClass())
-      {
-        if (cstate instanceof int[])
-        {
-          notmod = (((int[]) cstate)[0] == ((int[]) lastVal)[0]);
-        }
-        else if (cstate instanceof float[])
-        {
-          notmod = (((float[]) cstate)[0] == ((float[]) lastVal)[0]);
-        }
-        else if (cstate instanceof String[])
-        {
-          notmod = (((String[]) cstate)[0].equals(((String[]) lastVal)[0]));
-        }
-      }
-      pmdialogbox.argSetModified(this, !notmod);
-    }
-
-    public void mouseClicked(MouseEvent e)
-    {
-      if (javax.swing.SwingUtilities.isRightMouseButton(e))
-      {
-        showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
-      }
-    }
-
-    public void mousePressed(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseReleased(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseEntered(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseExited(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-  }
-
-  Map<String, OptionBox> optSet = new Hashtable<String, OptionBox>();
-
-  public class OptionBox extends JPanel implements MouseListener,
-          ActionListener
-  {
-    JComboBox val = new JComboBox();
-
-    JCheckBox enabled = new JCheckBox();
-
-    JLabel optlabel = new JLabel();
-
-    final URL finfo;
-
-    boolean hasLink = false;
-
-    OptionI option;
-
-    public OptionBox(OptionI opt)
-    {
-      option = opt;
-      setLayout(new BorderLayout());
-      enabled.setSelected(opt.isRequired()); // TODO: lock required options
-      enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
-      enabled.setText("");
-      enabled.setText(opt.getName());
-      enabled.addActionListener(this);
-      finfo = option.getFurtherDetails();
-      if (finfo != null)
-      {
-        hasLink = true;
-        // optlabel.setToolTipText("<html><p>"+opt.getDescription()+"</p><img src=\""+linkImageURL+"\"/></html>");
-        enabled.setToolTipText("<html>" + JvSwingUtils.wrapTooltip(opt.getDescription()+"<br><img src=\"" + linkImageURL + "\"/>")
-                + "</html>");
-        // optlabel.addMouseListener(this);
-        enabled.addMouseListener(this);
-      }
-      else
-      {
-        // optlabel.setToolTipText(opt.getDescription());
-        enabled.setToolTipText("<html>"+JvSwingUtils.wrapTooltip(opt.getDescription())+"</html>");
-      }
-      add(enabled, BorderLayout.NORTH);
-      if (opt.getPossibleValues().size() > 1)
-      {
-        setLayout(new GridLayout(1, 2));
-        for (Object str : opt.getPossibleValues())
-        {
-          val.addItem((String) str);
-        }
-        val.setSelectedItem((String) opt.getDefaultValue());
-        val.addActionListener(this);
-        add(val, BorderLayout.SOUTH);
-      }
-      // TODO: add actionListeners for popup (to open further info),
-      // and to update list of parameters if an option is enabled
-      // that takes a value.
-      setInitialValue();
-    }
-
-    public void resetToDefault()
-    {
-      enabled.setSelected(false);
-      if (option.isRequired())
-      {
-        // Apply default value
-        selectOption(option, option.getDefaultValue());
-      }
-    }
-
-    boolean initEnabled = false;
-
-    String initVal = null;
-
-    public void setInitialValue()
-    {
-      initEnabled = enabled.isSelected();
-      if (option.getPossibleValues() != null
-              && option.getPossibleValues().size() > 1)
-      {
-        initVal = (String) val.getSelectedItem();
-      }
-      else
-      {
-        initVal = (initEnabled) ? option.getDefaultValue() : null;
-      }
-    }
-
-    public OptionI getOptionIfEnabled()
-    {
-      if (!enabled.isSelected())
-      {
-        return null;
-      }
-      OptionI opt = option.copy();
-
-      if (val.getSelectedItem() != null)
-      {
-        opt.setDefaultValue((String) val.getSelectedItem());
-      }
-      return opt;
-    }
-
-    public void actionPerformed(ActionEvent e)
-    {
-      if (e.getSource() != enabled)
-      {
-        enabled.setSelected(true);
-      }
-      checkIfModified();
-    }
-
-    private void checkIfModified()
-    {
-      boolean notmod = (initEnabled == enabled.isSelected());
-      if (enabled.isSelected())
-      {
-        if (initVal != null)
-        {
-          notmod &= initVal.equals(val.getSelectedItem());
+          paramList.add(pbox);
         }
-        else
+        if (fh)
         {
-          // compare against default service setting
-          notmod &= option.getDefaultValue() == null
-                  || option.getDefaultValue().equals(val.getSelectedItem());
+          finalh += pbox.getSize().height + fl.getVgap();
+          fh = false;
         }
-      }
-      else
-      {
-        notmod &= initVal == null;
-      }
-      argSetModified(this, !notmod);
-    }
 
-    public void mouseClicked(MouseEvent e)
-    {
-      if (javax.swing.SwingUtilities.isRightMouseButton(e))
-      {
-        showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
       }
+      /*
+       * s = 2 * sep; for (ParamBox pbox : opanp.getParamSet().values()) {
+       * pbox.validate(); s += sep +
+       * pbox.getPreferredSize().height+pbox.getBorder
+       * ().getBorderInsets(pbox).bottom; }
+       * 
+       * // paramList.setPreferredSize(new Dimension(w, s));
+       * os+=s+2*sep+paramList
+       * .getBorder().getBorderInsets(paramList).bottom+paramList
+       * .getBorder().getBorderInsets(paramList).top;
+       */
+      paramList.revalidate();
     }
-
-    public void mousePressed(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseReleased(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseEntered(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-    public void mouseExited(MouseEvent e)
-    {
-      // TODO Auto-generated method stub
-
-    }
-
-  }
-
-  private OptionBox addOption(OptionI opt)
-  {
-    OptionBox cb = optSet.get(opt.getName());
-    if (cb == null)
-    {
-      cb = new OptionBox(opt);
-      optSet.put(opt.getName(), cb);
-      jobOptions.add(cb);
-    }
-    return cb;
-  }
-
-  public static void showUrlPopUp(JComponent invoker, final String finfo,
-          int x, int y)
-  {
-
-    JPopupMenu mnu = new JPopupMenu();
-    JMenuItem mitem = new JMenuItem("View " + finfo);
-    mitem.addActionListener(new ActionListener()
-    {
-
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        Desktop.showUrl(finfo);
-
-      }
-    });
-    mnu.add(mitem);
-    mnu.show(invoker, x, y);
-  }
-
-  protected void refreshParamLayout()
-  {
-    FlowLayout fl = new FlowLayout();
-    paramList.setLayout(fl);
-    int s = 2 * fl.getVgap();
-    for (ParamBox pbox : paramSet.values())
+    else
     {
-      s += fl.getVgap() + pbox.getBoxHeight(); // getBoxHeight();
+      paramList.setVisible(false);
     }
-    paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s));
-    validate();
+    // TODO: waste some time trying to eliminate any unnecessary .validate calls
+    // here
+    // System.out.println("Size will be : "+w+","+os);
+    // optsAndparams.setPreferredSize(null);
+    // paramPane.getViewport().setView(optsAndparams);
+    paramPane.getViewport().setAutoscrolls(true);
+    paramPane.revalidate();
+    revalidate();
   }
 
   /**
@@ -1414,11 +954,11 @@ public class WsJobParameters extends JPanel implements ItemListener,
     jalview.ws.jws2.Jws2Discoverer disc = jalview.ws.jws2.Jws2Discoverer
             .getDiscoverer();
     int p = 0;
-    if (args.length > 3)
+    if (args.length > 0)
     {
       Vector<String> services = new Vector<String>();
       services.addElement(args[p++]);
-      Jws2Discoverer.setServiceUrls(services);
+      Jws2Discoverer.getDiscoverer().setServiceUrls(services);
     }
     try
     {
@@ -1429,8 +969,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
       e.printStackTrace();
       return;
     }
-    Jws2Discoverer.Jws2Instance lastserv = null;
-    for (Jws2Discoverer.Jws2Instance service : disc.getServices())
+    Jws2Instance lastserv = null;
+    for (Jws2Instance service : disc.getServices())
     {
       lastserv = service;
       if (p >= args.length || service.serviceType.equalsIgnoreCase(args[p]))
@@ -1559,12 +1099,16 @@ public class WsJobParameters extends JPanel implements ItemListener,
             }
             WsJobParameters pgui = new WsJobParameters(lastserv,
                     new JabaPreset(lastserv, pr));
-            JFrame jf = new JFrame("Parameters for "
-                    + lastserv.getActionText());
-            JPanel cont = new JPanel();
-            // jf.setPreferredSize(new Dimension(600, 800));
-            cont.add(pgui);
-            jf.add(cont);
+            JFrame jf = new JFrame(MessageManager.formatMessage(
+                    "label.ws_parameters_for",
+                    new String[] { lastserv.getActionText() }));
+            JPanel cont = new JPanel(new BorderLayout());
+            pgui.validate();
+            cont.setPreferredSize(pgui.getPreferredSize());
+            cont.add(pgui, BorderLayout.CENTER);
+            jf.setLayout(new BorderLayout());
+            jf.add(cont, BorderLayout.CENTER);
+            jf.validate();
             final Thread thr = Thread.currentThread();
             jf.addWindowListener(new WindowListener()
             {
@@ -1630,28 +1174,15 @@ public class WsJobParameters extends JPanel implements ItemListener,
     }
   }
 
-  public List<ArgumentI> getJobParams()
+  public boolean isServiceDefaults()
   {
-    List<ArgumentI> argSet = new ArrayList<ArgumentI>();
-    // recover options and parameters from GUI
-    for (OptionBox opts : optSet.values())
-    {
-      OptionI opt = opts.getOptionIfEnabled();
-      if (opt != null)
-      {
-        argSet.add(opt);
-      }
-    }
-    for (ParamBox parambox : paramSet.values())
-    {
-      ParameterI parm = parambox.getParameter();
-      if (parm != null)
-      {
-        argSet.add(parm);
-      }
-    }
+    return (!isModified() && (lastParmSet != null && lastParmSet
+            .equals(SVC_DEF)));
+  }
 
-    return argSet;
+  public List<ArgumentI> getJobParams()
+  {
+    return opanp.getCurrentSettings();
   }
 
   String lastParmSet = null;
@@ -1766,9 +1297,21 @@ public class WsJobParameters extends JPanel implements ItemListener,
     initArgSetModified();
     syncSetNamesWithStore();
     setName.setSelectedItem(lastParmSet);
+    SetNamePanel.validate();
     validate();
     settingDialog = false;
+  }
 
+  /**
+   * Rebuild the AlignFrame web service menus (after add/delete of a preset
+   * option).
+   */
+  protected void updateWebServiceMenus()
+  {
+    for (AlignFrame alignFrame : Desktop.getAlignFrames())
+    {
+      alignFrame.BuildWebServiceMenu();
+    }
   }
 
   String curSetName = null;
@@ -1879,21 +1422,27 @@ public class WsJobParameters extends JPanel implements ItemListener,
       if (src.getParent() == setName)
       {
         // rename any existing records we know about for this set.
-        String newname = (String) e.getActionCommand().trim();
+        String newname = e.getActionCommand().trim();
         String msg = null;
         if (isServicePreset(newname))
         {
-          final String oldname = curSetName!=null ? curSetName : lastParmSet;
-          final Component ourframe=this;
-          settingDialog=true;
+          final String oldname = curSetName != null ? curSetName
+                  : lastParmSet;
+          final Component ourframe = this;
+          settingDialog = true;
           setName.getEditor().setItem(oldname);
-          settingDialog=false;
-          javax.swing.SwingUtilities.invokeLater(new Runnable() {public void run() {
-            JOptionPane.showMessageDialog(ourframe, 
-                    "Invalid name - preset already exists.", "Invalid name",
-                    JOptionPane.WARNING_MESSAGE);
-            }});
-          
+          settingDialog = false;
+          javax.swing.SwingUtilities.invokeLater(new Runnable()
+          {
+            public void run()
+            {
+              JOptionPane.showMessageDialog(ourframe, MessageManager
+                      .getString("label.invalid_name_preset_exists"),
+                      MessageManager.getString("label.invalid_name"),
+                      JOptionPane.WARNING_MESSAGE);
+            }
+          });
+
           return;
         }
         curSetName = newname;
@@ -1957,4 +1506,4 @@ public class WsJobParameters extends JPanel implements ItemListener,
       return paramStore.getPreset(lastParmSet);
     }
   }
-}
\ No newline at end of file
+}