X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FWsJobParameters.java;h=09499ffde6168f132075c695b71a35262ce3d90e;hb=153dd62dc91da13ae732600e6ea55ddbe15eab39;hp=36f416cff8433506c20e14a5c8fc7cf1159564f1;hpb=0a55443b38dc5fe8718ce1e101ae603ee4d3c5c7;p=jalview.git
diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java
index 36f416c..09499ff 100644
--- a/src/jalview/gui/WsJobParameters.java
+++ b/src/jalview/gui/WsJobParameters.java
@@ -1,3 +1,20 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * 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 .
+ */
package jalview.gui;
import java.awt.BorderLayout;
@@ -23,6 +40,7 @@ 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;
@@ -32,17 +50,23 @@ 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;
@@ -53,6 +77,8 @@ 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 compbio.metadata.Argument;
@@ -65,71 +91,96 @@ 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
+ * (user + presets + Defaults), and any changes to parameters creates a modified
+ * user parameter set. LOGIC: If the parameter set is modified, and its name is
+ * a valid, non-existant user parameter set, then a save button is shown. If the
+ * parameter set is modified and its name is a valid, extant user parameter set,
+ * then an update button is shown. If user parameter set's name is edited, and
+ * old name exists as a writable user parameter set, then rename button is
+ * shown. If current parameter set is associated with a user defined parameter
+ * set, then : if set is modifed, a 'revert' button is shown. if set is not
+ * modified, a 'delete' button is shown.
+ *
+ * @author JimP
+ *
+ */
public class WsJobParameters extends JPanel implements ItemListener,
- ActionListener
+ ActionListener, DocumentListener
{
- private static final int PARAM_WIDTH = 340, PARAM_HEIGHT = 150,PARAM_CLOSEDHEIGHT=80;
+ 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;
private static final int OPTSET_HEIGHT = 30;
+ JPanel SetNamePanel = new JPanel();
+
JPanel setDetails = new JPanel();
- JPanel settingsPanel = new JPanel();
+ JSplitPane settingsPanel = new JSplitPane();
+ JSplitPane jobPanel = new JSplitPane();
+ boolean split=true;
+ JTabbedPane tabpanels=new JTabbedPane();
JPanel jobOptions = new JPanel();
JScrollPane jobOptionsPane = new JScrollPane();
JPanel jobParameters = new JPanel();
- JPanel paramButtons = new JPanel();
+ JButton createpref = new JButton();
+
+ JButton deletepref = new JButton();
- JPanel paramPanel = new JPanel();
+ JButton revertpref = new JButton();
- JLabel modified = new JLabel();
+ JButton updatepref = new JButton();
JButton startjob = new JButton();
JButton canceljob = new JButton();
- JButton exportParams = new JButton();
-
- JButton importParams = new JButton();
-
- JButton resetParams = new JButton();
-
- JButton addParam = new JButton();
-
- JButton removeParam = new JButton();
-
- JButton editParam = new JButton();
-
JComboBox setName = new JComboBox();
JTextArea setDescr = new JTextArea();
JScrollPane paramPane = new JScrollPane();
- // JList paramList = new JList();
JPanel paramList = new JPanel();
RunnerConfig serviceOptions;
- List availableParameters;
-
- private BorderLayout jparamLayout;
+ ParamDatastoreI paramStore;
WsJobParameters(Jws2Instance service)
{
this(service, null);
}
- public WsJobParameters(Jws2Instance service, Preset p)
+ public WsJobParameters(Jws2Instance service, WsParamSetI preset)
{
- this(null, service, p, null);
+ this(null, service, preset, null);
}
/**
@@ -137,16 +188,36 @@ public class WsJobParameters extends JPanel implements ItemListener,
* @param desktop
* - if null, create new JFrame outside of desktop
* @param service
- * @param p
+ * @param preset
+ */
+ public WsJobParameters(JFrame parent, Jws2Instance service,
+ WsParamSetI preset, List jobArgset)
+ {
+ this(parent, null, service, preset, jobArgset);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param paramStorei
+ * @param service
+ * @param preset
+ * @param jobArgset
*/
- public WsJobParameters(JFrame parent, Jws2Instance service, Preset p,
- List jobArgset)
+ public WsJobParameters(JFrame parent, ParamDatastoreI paramStorei,
+ Jws2Instance service, WsParamSetI preset, List jobArgset)
{
super();
jbInit();
- argSetModified(false);
+ this.paramStore = paramStorei;
+ if (paramStore == null)
+ {
+ paramStore = service.getParamStore();
+ }
+ this.service = service;
+ // argSetModified(false);
// populate parameter table
- initForService(service, p, jobArgset);
+ initForService(service, preset, jobArgset);
// display in new JFrame attached to parent.
validate();
}
@@ -155,6 +226,11 @@ public class WsJobParameters extends JPanel implements ItemListener,
JDialog frame = null;
+ /**
+ * shows a modal dialog containing the parameters.
+ *
+ * @return
+ */
public boolean showRunDialog()
{
@@ -163,9 +239,22 @@ public class WsJobParameters extends JPanel implements ItemListener,
frame.setTitle("Edit parameters for " + service.getActionText());
Rectangle deskr = Desktop.instance.getBounds();
frame.setBounds(new Rectangle((int) (deskr.getCenterX() - 240),
- (int) (deskr.getCenterY() - 92), 380, 385));
+ (int) (deskr.getCenterY() - 250), 480, 500));
frame.setContentPane(this);
-
+ // should recover defaults from user prefs.
+ //settingsPanel.setDividerLocation(0.4);
+ //jobPanel.setDividerLocation(0.5);
+ 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);
+ }
frame.setVisible(true);
if (response > 0)
@@ -175,87 +264,53 @@ public class WsJobParameters extends JPanel implements ItemListener,
return false;
}
+
private void jbInit()
{
- modified.setText("*");
- modified.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- modified.setForeground(Color.red);
- modified.setHorizontalAlignment(SwingConstants.RIGHT);
+ updatepref = JvSwingUtils.makeButton("Update", "Update this existing user parameter set.",
+ new ActionListener()
+ {
- exportParams.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- exportParams.setText("Export");
- exportParams.setToolTipText("Export parameters to a file");
- exportParams.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- exportParams_actionPerformed(e);
- }
- });
- importParams.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- importParams.setText("Import");
- importParams.setToolTipText("Import parameters from a file");
- importParams.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- importParams_actionPerformed(e);
- }
- });
- resetParams.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- resetParams.setText("Defaults");
- resetParams.setToolTipText("Reset to defaults");
- resetParams.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- resetParams_actionPerformed(e);
- }
- });
- addParam.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- addParam.setText("Add");
- addParam.setToolTipText("Add new parameter");
- addParam.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- addParam_actionPerformed(e);
- }
- });
- removeParam.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- removeParam.setText("Remove");
- removeParam.setToolTipText("Remove selected parameter");
- removeParam.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- removeParam_actionPerformed(e);
- }
- });
- editParam.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- editParam.setText("Edit");
- editParam.setToolTipText("Edit selected parameter");
- editParam.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- editParam_actionPerformed(e);
- }
- });
- startjob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- startjob.setText("Start");
- startjob.setToolTipText("Start Job");
- startjob.addActionListener(new ActionListener()
+ public void actionPerformed(ActionEvent e)
+ {
+ update_actionPerformed(e);
+ }
+ });
+ deletepref = JvSwingUtils.makeButton("Delete", "Delete the currently selected user parameter set.",
+ new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ delete_actionPerformed(e);
+ }
+ });
+ createpref = JvSwingUtils.makeButton("Create", "Create a new parameter set with the current settings.",
+ new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ create_actionPerformed(e);
+ }
+ });
+ revertpref = JvSwingUtils.makeButton("Revert",
+ "Undo all changes to the current parameter set", new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ revert_actionPerformed(e);
+ }
+ });
+ startjob = JvSwingUtils.makeButton("Start Job", "Start Job with current settings.",new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startjob_actionPerformed(e);
}
});
- canceljob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- canceljob.setText("Cancel");
- canceljob.setToolTipText("Cancel Job");
- canceljob.addActionListener(new ActionListener()
+ canceljob = JvSwingUtils.makeButton("Cancel Job", "Close this dialog and cancel job.", new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
@@ -269,180 +324,256 @@ public class WsJobParameters extends JPanel implements ItemListener,
setDescr.setWrapStyleWord(true);
setDescr.setLineWrap(true);
setDescr.setBackground(getBackground());
- setDescr.setEditable(false);
+ setDescr.setEditable(true);
+ setDescr.getDocument().addDocumentListener(this);
+ setDescr.setToolTipText("Click to edit the notes for this 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);
- modified.setPreferredSize(new Dimension(15, 15));
- JPanel SetNamePanel = new JPanel();
- SetNamePanel.setLayout(new BorderLayout());
- SetNamePanel.add(setName, BorderLayout.WEST);
- SetNamePanel.add(modified, BorderLayout.EAST);
- setDetails.add(SetNamePanel, BorderLayout.NORTH);
+ 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 :");
+ 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);
+ revertpref.setVisible(false);
+ createpref.setVisible(false);
+ JPanel setsavebuts = new JPanel();
+ setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT)); // GridLayout(1,2));
+ ((FlowLayout) setsavebuts.getLayout()).setHgap(10);
+ ((FlowLayout) setsavebuts.getLayout()).setVgap(0);
+ setsavebuts.add(deletepref);
+ setsavebuts.add(revertpref);
+ setsavebuts.add(createpref);
+ setsavebuts.add(updatepref);
+ setsavebuts.setSize(new Dimension(150, 20));
+ JPanel buttonArea = new JPanel(new GridLayout(1, 1));
+ buttonArea.add(setsavebuts);
+ SetNamePanel.add(setNameInfo);
+ SetNamePanel.add(buttonArea);
setDetails.add(setDescrView, BorderLayout.CENTER);
- // setDetails.setPreferredSize(new Dimension(360, 100));
+ //setDetails.setPreferredSize(new Dimension(360, 100));
jobParameters.setBorder(new TitledBorder("Parameters"));
- jobParameters.setLayout(jparamLayout = new BorderLayout());
+ jobParameters.setLayout(new BorderLayout());
paramPane.setPreferredSize(new Dimension(360, 300));
paramPane.getVerticalScrollBar().setUnitIncrement(20);
// paramPanel.setPreferredSize(new Dimension(360, 300));
- paramButtons.setLayout(new GridLayout(2, 3));
- paramButtons.add(addParam);
- paramButtons.add(editParam);
- paramButtons.add(removeParam);
// TODO: relayout buttons nicely
- paramButtons.add(exportParams);
- paramButtons.add(importParams);
- paramButtons.add(resetParams);
paramPane.getViewport().setView(paramList);
- jobParameters.add(paramPane, BorderLayout.NORTH);
- // jobParameters.add(paramButtons, BorderLayout.SOUTH);
- settingsPanel.setLayout(new GridLayout(2,1));
- // settingsPanel.add(modified, BorderLayout.NORTH);
+ 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);
- settingsPanel.add(jobOptionsPanel);
- settingsPanel.add(jobParameters);
-
+
setLayout(new BorderLayout());
- // setPreferredSize(new Dimension(400, 600));
- // setSize(new Dimension(400, 600));
- add(setDetails, BorderLayout.NORTH);
- add(settingsPanel, BorderLayout.CENTER);
+ 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);
+ add(jobPanel, BorderLayout.CENTER);
JPanel dialogpanel = new JPanel();
dialogpanel.add(startjob);
dialogpanel.add(canceljob);
add(dialogpanel, BorderLayout.SOUTH);
}
- protected void canceljob_actionPerformed(ActionEvent e)
+ protected void revert_actionPerformed(ActionEvent e)
{
- response = 0;
- if (frame != null)
- {
- frame.setVisible(false);
- }
+ reInitDialog(lastParmSet);
+
}
- protected void startjob_actionPerformed(ActionEvent e)
+ protected void update_actionPerformed(ActionEvent e)
{
- response = 1;
- if (frame != null)
+ if (isUserPreset)
{
- frame.setVisible(false);
+ String curname = ((String) setName.getSelectedItem()).trim();
+ _updatePreset(lastParmSet, curname);
+ lastParmSet = curname;
+ isUserPreset = true;
+ initArgSetModified();
+ syncSetNamesWithStore();
}
}
- protected void editParam_actionPerformed(ActionEvent e)
+ private void _deleteUserPreset(String lastParmSet2)
{
- // TODO Auto-generated method stub
-
+ paramStore.deletePreset(lastParmSet2);
}
- protected void removeParam_actionPerformed(ActionEvent e)
+ protected void delete_actionPerformed(ActionEvent e)
{
- // TODO Auto-generated method stub
-
+ if (isUserPreset)
+ {
+ // delete current preset's saved entry
+ _deleteUserPreset(lastParmSet);
+ }
+ reInitDialog(null); // service default
}
- protected void addParam_actionPerformed(ActionEvent e)
+ protected void create_actionPerformed(ActionEvent e)
{
- // TODO Auto-generated method stub
-
+ String curname = ((String) setName.getSelectedItem()).trim();
+ if (curname.length() > 0)
+ {
+ _storeCurrentPreset(curname);
+ lastParmSet = curname;
+ isUserPreset = true;
+ initArgSetModified();
+ }
+ else
+ {
+ // TODO: show warning
+ System.err.println("Invalid name. Not saved.");
+ }
}
- protected void resetParams_actionPerformed(ActionEvent e)
+ protected void canceljob_actionPerformed(ActionEvent e)
{
- // TODO Auto-generated method stub
-
+ response = 0;
+ if (frame != null)
+ {
+ frame.setVisible(false);
+ }
}
- protected void importParams_actionPerformed(ActionEvent e)
+ protected void startjob_actionPerformed(ActionEvent e)
{
- // TODO Auto-generated method stub
-
+ response = 1;
+ if (frame != null)
+ {
+ frame.setVisible(false);
+ }
}
- protected void exportParams_actionPerformed(ActionEvent e)
- {
- // TODO Auto-generated method stub
+ Jws2Instance service;
- }
+ /**
+ * list of service presets in the gui
+ */
+ Hashtable servicePresets = null;
- Jws2Instance service;
+ /**
+ * set if dialog is being set - so handlers will avoid spurious events
+ */
+ boolean settingDialog = false;
- void initForService(Jws2Instance service, Preset p,
- List jobArgset)
+ void initForService(Jws2Instance service, WsParamSetI jabap,
+ List jabajobArgset)
{
- this.service = service;
- serviceOptions = service.getRunnerConfig();
- // add any presets not already added.
+ WsParamSetI p = null;
+ List jobArgset = null;
+ settingDialog = true;
+ { // instantiate the abstract proxy for Jaba objects
+ jobArgset = jabajobArgset == null ? null : JabaParamStore
+ .getJwsArgsfromJaba(jabajobArgset);
+ 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));
+ }
+ servicePresets = new Hashtable();
+ // Add the default entry - if not present already.
+ if (!exnames.contains(SVC_DEF))
+ {
+ setName.addItem(SVC_DEF);
+ exnames.put(SVC_DEF, SVC_DEF);
+ servicePresets.put(SVC_DEF, SVC_DEF);
+ }
String curname = (p == null ? "" : p.getName());
- PresetManager prman = service.getPresets();
- if (prman != null)
+ for (WsParamSetI pr : paramStore.getPresets())
{
- List prList = service.getPresets().getPresets();
- if (prList != null)
+ if (!pr.isModifiable())
{
- for (Object pr : prList)
- {
- if (p == null || !curname.equals(((Preset) pr).getName()))
- {
- setName.addItem(((Preset) pr).getName());
- }
- }
+ servicePresets.put(pr.getName(), "preset");
+ }
+ else
+ {
+ }
+ if (!exnames.contains(pr.getName()))
+ {
+ setName.addItem(pr.getName());
+ }
+ }
+ // TODO: if initial jobArgset matches a given user setting or preset then
+ // should recover setting accordingly
+ // updateTable(p, jobArgset);
+ if (p != null)
+ {
+ reInitDialog(p.getName());
+ initArgSetModified();
+ }
+ else
+ {
+ if (jobArgset != null && jobArgset.size() > 0)
+ {
+ curSetName = "Supplied Settings";
+ updateTable(p, jobArgset);
+ }
+ else
+ {
+ curSetName = null;
+ reInitDialog(null);
}
}
- updateTable(p, jobArgset);
+ settingDialog = false;
+
}
@SuppressWarnings("unchecked")
- private void updateTable(Preset p, List jobArgset)
+ private void updateTable(WsParamSetI p, List jobArgset)
{
- availableParameters = new ArrayList();
- List setargs = new ArrayList();
// populate table from default parameter set.
- List args = serviceOptions.getArguments();
+ List args = paramStore.getServiceParameters();
// split to params and required arguments
{
- for (Argument arg : args)
+ for (ArgumentI myarg : args)
{
- Argument myarg = (Argument) arg;
// Ideally, Argument would implement isRequired !
- if (myarg instanceof Parameter)
+ if (myarg instanceof ParameterI)
{
- Parameter parm = (Parameter) myarg;
- if (true) // parm.isRequired())
- {
- addParameter(parm);
- }
- else
- {
- availableParameters.add(parm);
- }
+ ParameterI parm = (ParameterI) myarg;
+ addParameter(parm);
}
else
{
- if (myarg instanceof Option)
+ if (myarg instanceof OptionI)
{
- Option opt = (Option) myarg;
- addOption(opt);
- if (opt.isRequired())
- {
- selectOption(opt, opt.getDefaultValue());
- }
+ OptionI opt = (OptionI) myarg;
+ addOption(opt).resetToDefault();
}
else
{
System.err.println("Ignoring unknown service argument type "
- + arg.getClass().getName());
+ + myarg.getClass().getName());
}
}
}
@@ -450,187 +581,327 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
if (p != null)
{
- if (lastParmSet == null)
- {
- // initialise setname
- setName.addItem(p.getName());
- }
- setDescr.setText(p.getDescription());
+ isUserPreset = false;
+ // initialise setname
+ setName.setSelectedItem(lastSetName = p.getName());
+ setDescr.setText(lastDescrText = p.getDescription());
// TODO - URL link
try
{
- args = p.getArguments(serviceOptions);
+ args = p.getArguments();
} catch (Exception e)
{
e.printStackTrace();
}
// TODO: check if args should be unselected prior to resetting using the
// preset
- setargs.clear();
}
else
{
if (lastParmSet == null)
{
+ isUserPreset = false;
// first call - so create a dummy name
- setName.addItem("Defaults *");
+
+ setName.setSelectedItem(lastSetName = SVC_DEF);
}
}
+
if (jobArgset != null)
{
- argSetModified(true);
+ argSetModified(jobArgset, true);
args = jobArgset;
}
// get setargs from current object
if (args != null)
{
- for (Argument arg : args)
+ for (ArgumentI arg : args)
{
- if (arg instanceof Parameter)
+ if (arg instanceof ParameterI)
{
- setargs.add((Parameter) arg);
+ setParameter((ParameterI) arg);
}
else
{
- if (arg instanceof Option)
+ if (arg instanceof OptionI)
{
- selectOption((Option) arg, arg.getDefaultValue());
+ // System.out.println("Setting option "
+ // + System.identityHashCode(arg) + ":" + arg.getName()
+ // + " with " + arg.getDefaultValue());
+ selectOption((OptionI) arg, arg.getDefaultValue());
}
}
}
}
- // mdl.setData(setargs);
- // jobOptions.setLayout(new GridLayout(optSet.size() / 2 + 1, 2));
jobOptions.setPreferredSize(new Dimension(PARAM_WIDTH, optSet.size()
* OPTSET_HEIGHT));
jobOptions.setLayout(new GridLayout(optSet.size(), 1));
refreshParamLayout();
- // paramPanel.setLayout(new GridLayout(paramSet.size(), 1));
- // paramList.va
- // paramPane.getViewport().validate();
paramPane.validate();
- validate();
+ revalidate();
}
private boolean isModified()
{
- return modified.isVisible();
+ return modifiedElements.size() > 0;
+ }
+
+ private Hashtable modifiedElements = new Hashtable();
+
+ /**
+ * reset gui and modification state settings
+ */
+ private void initArgSetModified()
+ {
+ curSetName = null;
+ modifiedElements.clear();
+ updateButtonDisplay();
}
- private void argSetModified(boolean b)
+ private void updateButtonDisplay()
{
- modified.setVisible(b);
- /*
- * String setn = (String)setName.getSelectedItem(); if (setn==null) return;
- * int p = setName.getSelectedIndex(); if (b) { if (setn.length()<2 ||
- * setn.lastIndexOf(" *")!=setn.length()-2) { setn = setn+" *"; } } else {
- * if (setn.lastIndexOf(" *")==setn.length()-2) { setn =
- * setn.substring(0,setn.length()-2); } } // edit the list
- *
- * Object[] objects = new Object[setName.getItemCount()]; for (int
- * i=0;i 0)
+ {
+ // set modified
+ _revert = true;
+ _update = isUserPreset; // can only update user presets
+ if (!isUserPreset || modifiedElements.containsKey(setName))
+ {
+ // name modified - can create new preset
+ _create = true;
+ }
+ }
+ else
+ {
+ // set unmodified
+ }
+ // can still delete a user preset
+ _delete = isUserPreset;
+
+ createpref.setVisible(_create);
+ updatepref.setVisible(_update);
+ deletepref.setVisible(_delete);
+ revertpref.setVisible(_revert);
validate();
}
- private void addParameter(Parameter parm)
+ private void argSetModified(Object modifiedElement, boolean b)
{
- ParamBox pb = paramSet.get(parm.getName());
- if (pb == null)
+ if (settingDialog)
{
- pb = new ParamBox(this, parm);
- paramSet.put(parm.getName(), pb);
- paramList.add(pb);
+ return;
+ }
+ if (!b)
+ {
+ modifiedElements.remove(modifiedElement);
+ }
+ else
+ {
+ if (b && modifiedElement == setName
+ && modifiedElements.contains(modifiedElement))
+ {
+ // HACK! prevents iteration on makeSetNameValid
+ b = false;
+ }
+ modifiedElements.put(modifiedElement, modifiedElement);
+ }
+ // set mod status based on presence of elements in table
+ if (b && modifiedElements.size() > 0)
+ {
+ makeSetNameValid(!isUserPreset);
+ SetNamePanel.revalidate();
}
+ updateButtonDisplay();
}
- private void selectOption(Option opt, String string)
+ private boolean isServicePreset(String selectedItem)
{
- OptionBox cb = optSet.get(opt.getName());
- if (cb == null)
+ return selectedItem.equals(SVC_DEF)
+ || servicePresets.containsKey(selectedItem);
+ }
+
+ /**
+ * check if the current set name is a valid set name for saving, if not, then
+ * fix it.
+ */
+ private void makeSetNameValid(boolean newuserset)
+ {
+ boolean stn = settingDialog;
+ boolean renamed = false;
+ settingDialog = true;
+ String nm = (curSetName != null ? curSetName : (String) setName
+ .getSelectedItem());
+ // check if the name is reserved - if it is, rename it.
+ if (isServicePreset(nm))
{
- cb = addOption(opt);
+ nm = "User " + nm;
+ renamed = true;
}
- if (string == null)
+ String tnm = nm;
+ if (newuserset)
{
- // no value specified.
- if (opt.isRequired())
+ int i = 0;
+ while (paramStore.getPreset(tnm) != null)
{
- // indicate option needs to be selected!
+ tnm = nm + " (" + (++i) + ")";
+ renamed = true;
}
- else
+ if (i > 0)
+ {
+ nm = tnm;
+ }
+ }
+
+ boolean makeupdate = false;
+ // sync the gui with the preset database
+ for (int i = 0, iS = setName.getItemCount(); i < iS; i++)
+ {
+ String snm = (String) setName.getItemAt(i);
+ if (snm.equals(nm))
{
- cb.enabled.setSelected(false);
+ makeupdate = true;
+ // setName.setSelectedIndex(i);
}
}
+ if (!makeupdate)
+ {
+ setName.addItem(curSetName = nm);
+ setName.setSelectedItem(curSetName);
+ }
+ if (renamed)
+ {
+ settingDialog = false; // we need this name change to be registered.
+ argSetModified(setName, renamed);
+ }
+ 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
{
- cb.enabled.setSelected(true);
+ pb.updateControls(arg);
+ }
- if (opt.getPossibleValues().contains(string))
+ }
+
+ private void selectOption(OptionI option, String string)
+ {
+ 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))
{
cb.val.setSelectedItem(string);
}
else
{
- throw new Error("Invalid value " + string + " for option " + opt);
+ 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 paramSet = new Hashtable();
public class ParamBox extends JPanel implements ChangeListener,
- ActionListener
+ ActionListener, MouseListener
{
JButton showDesc = new JButton();
JTextArea string = new JTextArea();
+
JScrollPane descPanel = new JScrollPane();
JSlider slider = null;
JTextField valueField = null;
- ValueConstrain validator = null;
+ ValueConstrainI validator = null;
+
JPanel settingPanel = new JPanel();
- JPanel controlPanel=new JPanel();
+
+ JPanel controlPanel = new JPanel();
boolean integ = false;
boolean choice = false;
- boolean descisvisible=false;
- public ParamBox(final WsJobParameters pmlayout, Parameter parm)
+
+ 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, 11));
- showDesc.setText("?");
+ 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.setLocation(2,17);
descPanel.setVisible(false);
// string.setMinimumSize(new Dimension(140,80));
// string.setMaximumSize(new Dimension(280,80));
- final ParamBox me=this;
- showDesc.addActionListener(new ActionListener() {
+ final ParamBox me = this;
+ finfo = parm.getFurtherDetails();
+ if (finfo != null)
+ {
+ showDesc.setToolTipText(""+JvSwingUtils.wrapTooltip("Click to show brief description
Right click for further information.")+"");
+ showDesc.addMouseListener(this);
+ }
+ else
+ {
+ showDesc.setToolTipText(""+JvSwingUtils.wrapTooltip("Click to show brief description.")+"");
+ }
+ showDesc.addActionListener(new ActionListener()
+ {
- @Override
public void actionPerformed(ActionEvent e)
{
- descisvisible=!descisvisible;
+ descisvisible = !descisvisible;
descPanel.setVisible(descisvisible);
- me.setPreferredSize(new Dimension(PARAM_WIDTH, (descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT));
+ me.setPreferredSize(new Dimension(PARAM_WIDTH,
+ (descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT));
me.validate();
pmlayout.refreshParamLayout();
}
@@ -639,15 +910,16 @@ public class WsJobParameters extends JPanel implements ItemListener,
string.setLineWrap(true);
string.setColumns(32);
string.setText(parm.getDescription());
- // name.setToolTipText(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));
+ 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));
+ firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30,
+ PARAM_CLOSEDHEIGHT - 30));
add(firstrow);
validator = parm.getValidValue();
parameter = parm;
@@ -663,25 +935,33 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
}
updateControls(parm);
- descPanel.setBounds(new Rectangle(10,PARAM_CLOSEDHEIGHT+10, PARAM_WIDTH-20, PARAM_HEIGHT-PARAM_CLOSEDHEIGHT-30));
+ 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;
- Parameter parameter;
+ ParameterI parameter;
JComboBox choicebox;
+
public int getBoxHeight()
{
return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT);
}
- public void updateControls(Parameter parm)
+
+ public void updateControls(ParameterI parm)
{
adjusting = true;
- boolean init = valueField == null;
+ boolean init = (choicebox == null && valueField == null);
float fVal = 0f;
int iVal = 0;
if (init)
@@ -690,7 +970,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
choicebox = new JComboBox();
choicebox.addActionListener(this);
- controlPanel.add(choicebox,BorderLayout.CENTER);
+ controlPanel.add(choicebox, BorderLayout.CENTER);
}
else
{
@@ -699,7 +979,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
valueField = new JTextField();
valueField.addActionListener(this);
valueField.setPreferredSize(new Dimension(60, 25));
- controlPanel.add(slider,BorderLayout.WEST);
+ controlPanel.add(slider, BorderLayout.WEST);
controlPanel.add(valueField, BorderLayout.EAST);
}
@@ -709,11 +989,15 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
if (choice)
{
- List vals = parm.getPossibleValues();
- for (Object val : vals)
+ if (init)
{
- choicebox.addItem(val);
+ List vals = parm.getPossibleValues();
+ for (Object val : vals)
+ {
+ choicebox.addItem(val);
+ }
}
+
if (parm.getDefaultValue() != null)
{
choicebox.setSelectedItem(parm.getDefaultValue());
@@ -724,28 +1008,24 @@ public class WsJobParameters extends JPanel implements ItemListener,
valueField.setText(parm.getDefaultValue());
}
}
- updateSliderFromValueField();
+ lastVal = updateSliderFromValueField();
adjusting = false;
}
- public Parameter getParameter()
+ Object lastVal;
+
+ public ParameterI getParameter()
{
- try
+ ParameterI prm = parameter.copy();
+ if (choice)
{
- if (choice)
- {
- parameter.setDefaultValue((String) choicebox.getSelectedItem());
- }
- else
- {
- parameter.setDefaultValue(valueField.getText());
- }
- } catch (WrongParameterException e)
+ prm.setDefaultValue((String) choicebox.getSelectedItem());
+ }
+ else
{
- e.printStackTrace();
- return null;
+ prm.setDefaultValue(valueField.getText());
}
- return parameter;
+ return prm;
}
public Object updateSliderFromValueField()
@@ -761,6 +1041,20 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
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)
{
}
@@ -784,7 +1078,21 @@ public class WsJobParameters extends JPanel implements ItemListener,
try
{
fVal = Float.valueOf(valueField.getText());
- } catch (Exception e)
+ 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)
{
}
;
@@ -819,7 +1127,6 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
- @Override
public void stateChanged(ChangeEvent e)
{
if (!adjusting)
@@ -827,42 +1134,121 @@ public class WsJobParameters extends JPanel implements ItemListener,
valueField.setText(""
+ ((integ) ? ("" + (int) slider.getValue())
: ("" + (float) (slider.getValue() / 1000f))));
+ checkIfModified();
}
+
}
- @Override
public void actionPerformed(ActionEvent e)
{
- if (choice)
+ if (adjusting)
{
+ return;
}
- else if (!adjusting)
+ if (!choice)
{
updateSliderFromValueField();
}
- argSetModified(true);
+ 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 optSet = new Hashtable();
- public class OptionBox extends JPanel implements ActionListener
+ public class OptionBox extends JPanel implements MouseListener,
+ ActionListener
{
JComboBox val = new JComboBox();
JCheckBox enabled = new JCheckBox();
- Option option;
+ JLabel optlabel = new JLabel();
- public OptionBox(Option opt)
+ final URL finfo;
+
+ boolean hasLink = false;
+
+ OptionI option;
+
+ public OptionBox(OptionI opt)
{
option = opt;
setLayout(new BorderLayout());
- enabled.setSelected(opt.isRequired());
+ enabled.setSelected(opt.isRequired()); // TODO: lock required options
enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
+ enabled.setText("");
enabled.setText(opt.getName());
- enabled.setToolTipText(opt.getDescription());
+ enabled.addActionListener(this);
+ finfo = option.getFurtherDetails();
+ if (finfo != null)
+ {
+ hasLink = true;
+ // optlabel.setToolTipText(""+opt.getDescription()+"
");
+ enabled.setToolTipText("" + JvSwingUtils.wrapTooltip(opt.getDescription()+"
")
+ + "");
+ // optlabel.addMouseListener(this);
+ enabled.addMouseListener(this);
+ }
+ else
+ {
+ // optlabel.setToolTipText(opt.getDescription());
+ enabled.setToolTipText(""+JvSwingUtils.wrapTooltip(opt.getDescription())+"");
+ }
add(enabled, BorderLayout.NORTH);
if (opt.getPossibleValues().size() > 1)
{
@@ -878,37 +1264,119 @@ public class WsJobParameters extends JPanel implements ItemListener,
// 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 Option getOptionIfEnabled()
+ 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;
}
- try
+ OptionI opt = option.copy();
+
+ if (val.getSelectedItem() != null)
{
- 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());
+ }
+ else
{
- option.setDefaultValue((String) val.getSelectedItem());
+ // compare against default service setting
+ notmod &= option.getDefaultValue() == null
+ || option.getDefaultValue().equals(val.getSelectedItem());
}
- } catch (WrongParameterException e)
+ }
+ else
{
- e.printStackTrace();
- return null;
+ notmod &= initVal == null;
}
- return option;
+ argSetModified(this, !notmod);
}
- @Override
- public void actionPerformed(ActionEvent e)
+ public void mouseClicked(MouseEvent e)
{
- argSetModified(true);
- enabled.setSelected(true);
+ 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
+
+ }
+
}
- private OptionBox addOption(Option opt)
+ private OptionBox addOption(OptionI opt)
{
OptionBox cb = optSet.get(opt.getName());
if (cb == null)
@@ -920,14 +1388,36 @@ public class WsJobParameters extends JPanel implements ItemListener,
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()
{
- int s=100;
- for (ParamBox pbox : paramSet.values()){
- s+=pbox.getBoxHeight();
+ FlowLayout fl = new FlowLayout();
+ paramList.setLayout(fl);
+ int s = 2 * fl.getVgap();
+ for (ParamBox pbox : paramSet.values())
+ {
+ s += fl.getVgap() + pbox.getBoxHeight(); // getBoxHeight();
}
paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s));
- paramList.setLayout(new FlowLayout());
validate();
}
@@ -960,122 +1450,210 @@ public class WsJobParameters extends JPanel implements ItemListener,
for (Jws2Discoverer.Jws2Instance service : disc.getServices())
{
lastserv = service;
- if (p < args.length && service.serviceType.equalsIgnoreCase(args[p]))
- {
- break;
- }
- }
- if (lastserv != null)
- {
- List prl = null;
- Preset pr = null;
- if (++p < args.length)
+ if (p >= args.length || service.serviceType.equalsIgnoreCase(args[p]))
{
- PresetManager prman = lastserv.getPresets();
- if (prman != null)
+ if (lastserv != null)
{
- pr = prman.getPresetByName(args[p]);
- if (pr == null)
+ List prl = null;
+ Preset pr = null;
+ if (++p < args.length)
{
- // just grab the last preset.
- prl = prman.getPresets();
+ PresetManager prman = lastserv.getPresets();
+ if (prman != null)
+ {
+ pr = prman.getPresetByName(args[p]);
+ if (pr == null)
+ {
+ // just grab the last preset.
+ prl = prman.getPresets();
+ }
+ }
}
- }
- }
- Iterator en = (prl == null) ? null : prl.iterator();
- while (true)
- {
- if (en != null)
- {
- if (!en.hasNext())
+ else
{
- en = prl.iterator();
+ PresetManager prman = lastserv.getPresets();
+ if (prman != null)
+ {
+ prl = prman.getPresets();
+ }
}
- pr = en.next();
- }
- WsJobParameters pgui = new WsJobParameters(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);
- final Thread thr = Thread.currentThread();
- jf.addWindowListener(new WindowListener()
- {
-
- @Override
- public void windowActivated(WindowEvent e)
+ Iterator en = (prl == null) ? null : prl.iterator();
+ while (en != null && en.hasNext())
{
- // TODO Auto-generated method stub
+ if (en != null)
+ {
+ if (!en.hasNext())
+ {
+ en = prl.iterator();
+ }
+ pr = en.next();
+ }
+ {
+ System.out.println("Testing opts dupes for "
+ + lastserv.getUri() + " : "
+ + lastserv.getActionText() + ":" + pr.getName());
+ List