import java.util.Map;
import java.util.Vector;
+import javax.swing.InputVerifier;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
* @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);
}
}
}
-
private void _deleteUserPreset(String lastParmSet2)
{
paramStore.deletePreset(lastParmSet2);
{ // 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)
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))
{
{
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)
{
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();
{
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.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());
-
+ paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(),
+ getJobParams());
+
}
/**
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;