+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
package jalview.gui;
+import jalview.ws.jws2.JabaParamStore;
+import jalview.ws.jws2.JabaPreset;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.Jws2Discoverer.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.ValueConstrainI;
+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.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 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.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JSplitPane;
-import javax.swing.JTable;
+import javax.swing.JTabbedPane;
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 compbio.metadata.Argument;
import compbio.metadata.Option;
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
* (user + presets + Defaults), and any changes to parameters creates a modified
public class WsJobParameters extends JPanel implements ItemListener,
ActionListener, DocumentListener
{
+ 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 paramList = new JPanel();
+ JPanel optsAndparams = new JPanel();
+
RunnerConfig serviceOptions;
ParamDatastoreI paramStore;
+ private int MAX_OPTWIDTH = 200;
+
WsJobParameters(Jws2Instance service)
{
this(service, null);
* @param service
* @param preset
*/
- public WsJobParameters(JFrame parent, Jws2Instance service, WsParamSetI preset,
- List<Argument> jobArgset)
+ public WsJobParameters(JFrame parent, Jws2Instance service,
+ WsParamSetI preset, List<Argument> jobArgset)
{
this(parent, null, service, preset, jobArgset);
}
frame.setTitle("Edit parameters for " + 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.
+
+ // should perhaps recover defaults from user prefs.
+
frame.validate();
- settingsPanel.setDividerLocation(0.4);
- jobPanel.setDividerLocation(0.3);
- frame.setVisible(true);
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ jobPanel.setDividerLocation(0.25);
+
+ }
+ });
+ frame.setVisible(true);
if (response > 0)
{
return false;
}
- protected JButton makeButton(String label, String tooltip,
- ActionListener action)
- {
- JButton button = new JButton();
- button.setText(label);
- button.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- button.setForeground(Color.black);
- button.setHorizontalAlignment(SwingConstants.CENTER);
- button.setToolTipText(tooltip);
- button.addActionListener(action);
- return button;
- }
-
private void jbInit()
{
- updatepref = makeButton("Update", "Update the stored user preference",
+ updatepref = JvSwingUtils.makeButton("Update",
+ "Update this existing user parameter set.",
new ActionListener()
{
update_actionPerformed(e);
}
});
- deletepref = makeButton("Delete", "Delete the user preference",
+ deletepref = JvSwingUtils.makeButton("Delete",
+ "Delete the currently selected user parameter set.",
new ActionListener()
{
delete_actionPerformed(e);
}
});
- createpref = makeButton("Create", "Create a new preference",
+ createpref = JvSwingUtils.makeButton("Create",
+ "Create a new parameter set with the current settings.",
new ActionListener()
{
create_actionPerformed(e);
}
});
- revertpref = makeButton("Revert",
- "Undo all changes to the current set", new ActionListener()
+ revertpref = JvSwingUtils.makeButton("Revert",
+ "Undo all changes to the current parameter set",
+ new ActionListener()
{
public void actionPerformed(ActionEvent e)
revert_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)
- {
- startjob_actionPerformed(e);
- }
- });
- canceljob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- canceljob.setText("Cancel");
- canceljob.setToolTipText("Cancel Job");
- canceljob.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- canceljob_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);
+ }
+ });
setDetails.setBorder(new TitledBorder("Details"));
setDetails.setLayout(new BorderLayout());
setDescr.setBackground(getBackground());
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.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("Parameter set: ");
+ GridBagLayout gbl = new GridBagLayout();
+ SetNamePanel.setLayout(gbl);
+
+ 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);
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);
- settingsPanel.setLeftComponent(jobOptionsPanel);
- settingsPanel.setRightComponent(jobParameters);
- settingsPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ jobParameters.setBorder(new TitledBorder("Parameters"));
+ paramPane.setPreferredSize(new Dimension(360, 400));
+ jobOptions.setBorder(new TitledBorder("Options"));
+
+ paramList.setBorder(new TitledBorder("Parameters"));
+
+ JPanel bjo=new JPanel(new BorderLayout()),bjp=new JPanel(new BorderLayout());
+ bjo.add(jobOptions, BorderLayout.CENTER);
+ bjp.add(paramList, BorderLayout.CENTER);
+ optsAndparams.setLayout(new BorderLayout());
+
+ optsAndparams.add(bjo, BorderLayout.CENTER);
+ optsAndparams.add(bjp, BorderLayout.SOUTH);
+ paramPane.setViewportView(optsAndparams);
+
setLayout(new BorderLayout());
- // setPreferredSize(new Dimension(400, 600));
- // setSize(new Dimension(400, 600));
jobPanel.setLeftComponent(setDetails);
- jobPanel.setRightComponent(settingsPanel);
+ jobPanel.setRightComponent(paramPane);
jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
+
add(SetNamePanel, BorderLayout.NORTH);
add(jobPanel, BorderLayout.CENTER);
+
JPanel dialogpanel = new JPanel();
dialogpanel.add(startjob);
dialogpanel.add(canceljob);
if (isUserPreset)
{
String curname = ((String) setName.getSelectedItem()).trim();
- if (curname.length() > 0 && !curname.equals(lastParmSet))
- {
- _deleteUserPreset(lastParmSet);
- }
- _storeCurrentPreset(curname);
+ _updatePreset(lastParmSet, curname);
lastParmSet = curname;
isUserPreset = true;
initArgSetModified();
{ // instantiate the abstract proxy for Jaba objects
jobArgset = jabajobArgset == null ? null : JabaParamStore
.getJwsArgsfromJaba(jabajobArgset);
- p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) : null;
+ 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++)
{
if (myarg instanceof OptionI)
{
OptionI opt = (OptionI) myarg;
- addOption(opt).resetToDefault();
+ OptionBox ob = addOption(opt);
+ ob.resetToDefault();
+ if (MAX_OPTWIDTH < ob.getPreferredSize().width)
+ {
+ MAX_OPTWIDTH = ob.getPreferredSize().width;
+ }
+
}
else
{
}
}
- jobOptions.setPreferredSize(new Dimension(PARAM_WIDTH, optSet.size()
- * OPTSET_HEIGHT));
- jobOptions.setLayout(new GridLayout(optSet.size(), 1));
refreshParamLayout();
- paramPane.validate();
revalidate();
}
boolean stn = settingDialog;
boolean renamed = false;
settingDialog = true;
- String nm = (String) setName.getSelectedItem();
+ String nm = (curSetName != null ? curSetName : (String) setName
+ .getSelectedItem());
// check if the name is reserved - if it is, rename it.
if (isServicePreset(nm))
{
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><p>Click to show brief description, and right click to open link for further information.</p></html>");
+ 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><p>Click to show brief description.</p></html>");
+ showDesc.setToolTipText("<html>"
+ + JvSwingUtils
+ .wrapTooltip("Click to show brief description.")
+ + "</html>");
}
showDesc.addActionListener(new ActionListener()
{
{
descisvisible = !descisvisible;
descPanel.setVisible(descisvisible);
+ descPanel.getVerticalScrollBar().setValue(0);
me.setPreferredSize(new Dimension(PARAM_WIDTH,
(descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT));
me.validate();
{
adjusting = true;
boolean init = (choicebox == null && valueField == null);
- float fVal = 0f;
- int iVal = 0;
if (init)
{
if (choice)
{
valueField.setText(valueField.getText().trim());
iVal = Integer.valueOf(valueField.getText());
- if (validator.getMin()!=null && validator.getMin().intValue()>iVal)
+ if (validator.getMin() != null
+ && validator.getMin().intValue() > iVal)
{
iVal = validator.getMin().intValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
- if (validator.getMax()!=null && validator.getMax().intValue()<iVal)
+ if (validator.getMax() != null
+ && validator.getMax().intValue() < iVal)
{
iVal = validator.getMax().intValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
} catch (Exception e)
{
try
{
fVal = Float.valueOf(valueField.getText());
- if (validator.getMin()!=null && validator.getMin().floatValue()>fVal)
+ if (validator.getMin() != null
+ && validator.getMin().floatValue() > fVal)
{
fVal = validator.getMin().floatValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
- if (validator.getMax()!=null && validator.getMax().floatValue()<fVal)
+ if (validator.getMax() != null
+ && validator.getMax().floatValue() < fVal)
{
fVal = validator.getMax().floatValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
} catch (Exception e)
{
{
if (javax.swing.SwingUtilities.isRightMouseButton(e))
{
- Desktop.showUrl(finfo.toString());
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
}
// TODO Auto-generated method stub
}
+ // from http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout
+ // helpful hint of using the Java 1.6 alignBaseLine property of FlowLayout
+ @Override
+ public Component.BaselineResizeBehavior getBaselineResizeBehavior() {
+ return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
+ }
+ @Override
+ public int getBaseline(int width, int height) {
+ return 0;
+ }
}
Map<String, OptionBox> optSet = new Hashtable<String, OptionBox>();
JLabel optlabel = new JLabel();
- URL linkImageURL = getClass().getResource("/images/link.gif");
-
final URL finfo;
boolean hasLink = false;
if (finfo != null)
{
hasLink = true;
- // optlabel.setToolTipText("<html><p>"+opt.getDescription()+"</p><img src=\""+linkImageURL+"\"/></html>");
- enabled.setToolTipText("<html><p>" + opt.getDescription()
- + "</p><img src=\"" + linkImageURL + "\"/></html>");
- // optlabel.addMouseListener(this);
+ enabled.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip(opt.getDescription()
+ + "<br><img src=\"" + linkImageURL + "\"/>")
+ + "</html>");
enabled.addMouseListener(this);
}
else
{
- // optlabel.setToolTipText(opt.getDescription());
- enabled.setToolTipText(opt.getDescription());
+ enabled.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip(opt.getDescription())
+ + "</html>");
}
add(enabled, BorderLayout.NORTH);
if (opt.getPossibleValues().size() > 1)
}
// TODO: add actionListeners for popup (to open further info),
// and to update list of parameters if an option is enabled
- // that takes a value.
+ // that takes a value. JBPNote: is this TODO still valid ?
setInitialValue();
}
{
cb = new OptionBox(opt);
optSet.put(opt.getName(), cb);
- jobOptions.add(cb);
+ jobOptions.add(cb, FlowLayout.LEFT);
}
return cb;
}
protected void refreshParamLayout()
{
- FlowLayout fl = new FlowLayout();
- paramList.setLayout(fl);
- int s = 2 * fl.getVgap();
- for (ParamBox pbox : paramSet.values())
+ FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
+ int sep=fl.getVgap();
+ int os=0,s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom+jobOptions.getBorder().getBorderInsets(jobOptions).top+2 * sep;
+ int w = 2 * fl.getHgap() + (MAX_OPTWIDTH > PARAM_WIDTH ? MAX_OPTWIDTH : PARAM_WIDTH);
+ jobOptions.setLayout(fl);
+ if (optSet.size() > 0)
+ {
+
+ for (OptionBox pbox : optSet.values())
+ {
+ pbox.revalidate();
+ s += sep + pbox.getPreferredSize().height;
+ }
+ jobOptions.setPreferredSize(new Dimension(w, s));
+ jobOptions.setLayout(new GridLayout(optSet.size(),1));
+ os=s;
+ }
+ else
+ {
+ jobOptions.setVisible(false);
+ }
+
+ // Now layout the parameters assuming they occupy one column - to calculate total height of options+parameters
+ fl = new FlowLayout(FlowLayout.CENTER);
+ // helpful hint from http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout
+ fl.setAlignOnBaseline(true);
+ if (paramSet.size() > 0)
+ {
+ paramList.setLayout(fl);
+
+ s = 2 * sep;
+ for (ParamBox pbox : paramSet.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;
+ }
+ else
{
- s += fl.getVgap() + pbox.getBoxHeight(); // getBoxHeight();
+ paramList.setVisible(false);
}
- paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s));
+ // TODO: waste some time trying to eliminate any unnecessary .validate calls here
+ paramList.validate();
+ jobOptions.validate();
+ // System.out.println("Size will be : "+w+","+os);
+ optsAndparams.validate();
+ paramPane.getViewport().validate();
+ paramPane.getVerticalScrollBar().setBlockIncrement(PARAM_CLOSEDHEIGHT*2);
+ paramPane.validate();
validate();
}
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++]);
}
{
System.out.println("Testing opts dupes for "
- + lastserv.getHost() + " : "
+ + lastserv.getUri() + " : "
+ lastserv.getActionText() + ":" + pr.getName());
List<Option> rg = lastserv.getRunnerConfig().getOptions();
for (Option o : rg)
e.printStackTrace();
}
}
- WsJobParameters pgui = new WsJobParameters(lastserv, new JabaPreset(lastserv, pr));
+ 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);
+ 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()
{
{
isUserPreset = false;
// Service defaults
+ setDescr.setText("");
updateTable(null, null);
lastParmSet = SVC_DEF;
}
initArgSetModified();
syncSetNamesWithStore();
setName.setSelectedItem(lastParmSet);
+ SetNamePanel.validate();
validate();
settingDialog = false;
{
if (e.getSource() == setName && e.getStateChange() == e.SELECTED)
{
- String setname = (String) setName.getSelectedItem();
+ final String setname = (String) setName.getSelectedItem();
System.out.println("Item state changed for " + setname
+ " (handling ? " + !settingDialog + ")");
if (settingDialog)
{
return;
}
- // user has selected a different item from combo-box
- if (isModified())
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- String lsetname = (curSetName != null) ? curSetName : lastParmSet;
- if (lsetname.equals(setname))
+ public void run()
{
- // setname was just edited - so ignore this event.
- return;
+ doPreferenceComboStateChange(setname);
}
- settingDialog = true;
- System.out.println("Prompting to save " + lsetname);
- if (javax.swing.JOptionPane.showConfirmDialog(this,
- "Parameter set '" + lsetname + "' is modifed\nsave ?",
- "Save changes ?", javax.swing.JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
- {
- System.out.println("Saving for " + lsetname);
- _storeCurrentPreset(lsetname);
+ });
+ }
+ }
- }
+ private void doPreferenceComboStateChange(String setname)
+ {
+ // user has selected a different item from combo-box
+ if (isModified())
+ {
+ String lsetname = (curSetName != null) ? curSetName : lastParmSet;
+ if (lsetname.equals(setname))
+ {
+ // setname was just edited - so ignore this event.
+ return;
}
settingDialog = true;
- reInitDialog(setname);
- settingDialog = false;
+ System.out.println("Prompting to save " + lsetname);
+ if (javax.swing.JOptionPane
+ .showConfirmDialog(
+ this,
+ "Parameter set '"
+ + lsetname
+ + "' is modifed, and your changes will be lost.\nReally change preset ?",
+ "Warning: Unsaved Changes",
+ javax.swing.JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)
+ {
+ // revert the combobox to the current item
+ settingDialog = true;
+ setName.setSelectedItem(lsetname);
+ settingDialog = false;
+ // and leave.
+ return;
+ // System.out.println("Saving for " + lsetname);
+ // _storeCurrentPreset(lsetname);
+ }
}
+ settingDialog = true;
+ reInitDialog(setname);
+ settingDialog = false;
+
+ }
+
+ private void _renameExistingPreset(String oldName, String curSetName2)
+ {
+ paramStore.updatePreset(oldName, curSetName2, setDescr.getText(),
+ getJobParams());
}
/**
paramStore.storePreset(curSetName2, setDescr.getText(), getJobParams());
}
+ private void _updatePreset(String lastParmSet2, String curname)
+ {
+ paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(),
+ getJobParams());
+
+ }
+
/**
* last saved name for this user preset
*/
String msg = null;
if (isServicePreset(newname))
{
- JOptionPane.showConfirmDialog(this,
- "Invalid name - preset already exists.", "Invalid name",
- JOptionPane.OK_OPTION);
- // reset name
- setName.setSelectedItem(curSetName);
+ 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);
+ }
+ });
+
return;
}
curSetName = newname;
return paramStore.getPreset(lastParmSet);
}
}
-}
\ No newline at end of file
+}