From: jprocter Date: Thu, 2 Sep 2010 15:18:01 +0000 (+0000) Subject: debugged option changed logic and layout X-Git-Tag: Release_2_6~74 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=62e1a981278168d7d2a78a80e721bbb899e14afb;p=jalview.git debugged option changed logic and layout --- diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index c64dce0..cbfa273 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -290,22 +290,32 @@ public class WsJobParameters extends JPanel implements ItemListener, setName.setEditable(true); setName.addItemListener(this); setName.getEditor().addActionListener(this); - SetNamePanel.setLayout(new BorderLayout()); - SetNamePanel.setMinimumSize(new Dimension(300, 35)); - SetNamePanel.add(setName, BorderLayout.WEST); + 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: "); + 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.setMinimumSize(new Dimension(150, 35)); - setsavebuts.setLayout(new FlowLayout()); - setsavebuts.add(createpref, BorderLayout.CENTER); - setsavebuts.add(updatepref, BorderLayout.CENTER); - setsavebuts.add(revertpref, BorderLayout.EAST); - setsavebuts.add(deletepref, BorderLayout.EAST); - SetNamePanel.add(setsavebuts, BorderLayout.EAST); + 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)); jobParameters.setBorder(new TitledBorder("Parameters")); @@ -358,6 +368,7 @@ public class WsJobParameters extends JPanel implements ItemListener, lastParmSet = curname; isUserPreset = true; initArgSetModified(); + syncSetNamesWithStore(); } } @@ -577,7 +588,7 @@ public class WsJobParameters extends JPanel implements ItemListener, jobOptions.setLayout(new GridLayout(optSet.size(), 1)); refreshParamLayout(); paramPane.validate(); - validate(); + revalidate(); } private boolean isModified() @@ -644,6 +655,7 @@ public class WsJobParameters extends JPanel implements ItemListener, if (b && modifiedElements.size() > 0) { makeSetNameValid(!isUserPreset); + SetNamePanel.revalidate(); } updateButtonDisplay(); } @@ -677,6 +689,7 @@ public class WsJobParameters extends JPanel implements ItemListener, while (_getUserPreset(tnm) != null) { tnm = nm + " (" + (++i) + ")"; + renamed=true; } if (i > 0) { @@ -697,7 +710,13 @@ public class WsJobParameters extends JPanel implements ItemListener, } if (!makeupdate) { - setName.setSelectedItem(curSetName = nm); + setName.addItem(curSetName = nm); + setName.setSelectedItem(curSetName); + } + if (renamed) + { + settingDialog=false; // we need this name change to be registered. + argSetModified(setName, renamed); } settingDialog = stn; } @@ -737,7 +756,7 @@ public class WsJobParameters extends JPanel implements ItemListener, { cb = addOption(opt); } - cb.enabled.setSelected(true); // initial state for an option. + cb.enabled.setSelected(string!=null); // initial state for an option. if (string != null) { if (opt.getPossibleValues().contains(string)) @@ -1205,9 +1224,10 @@ public class WsJobParameters extends JPanel implements ItemListener, { return null; } + Option opt=null; try { - Option opt = jalview.ws.jws2.ParameterUtils.copyOption(option); + opt = jalview.ws.jws2.ParameterUtils.copyOption(option); if (val.getSelectedItem() != null) { @@ -1218,7 +1238,7 @@ public class WsJobParameters extends JPanel implements ItemListener, e.printStackTrace(); return null; } - return option; + return opt; } public void actionPerformed(ActionEvent e) @@ -1237,14 +1257,15 @@ public class WsJobParameters extends JPanel implements ItemListener, { if (initVal != null) { - notmod |= initVal.equals(val.getSelectedItem()); + notmod &= initVal.equals(val.getSelectedItem()); } else { - notmod |= false; + // compare against default service setting + notmod &= option.getDefaultValue()==null || option.getDefaultValue().equals(val.getSelectedItem()); } } else { - notmod |= initVal == null; + notmod &= initVal == null; } argSetModified(this, !notmod); } @@ -1317,13 +1338,14 @@ public class WsJobParameters extends JPanel implements ItemListener, protected void refreshParamLayout() { - int s = 100; + FlowLayout fl = new FlowLayout(); + paramList.setLayout(fl); + int s = 2*fl.getVgap(); for (ParamBox pbox : paramSet.values()) { - s += pbox.getBoxHeight(); + s += fl.getVgap()+pbox.getBoxHeight(); // getBoxHeight(); } paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s)); - paramList.setLayout(new FlowLayout()); validate(); } @@ -1693,13 +1715,18 @@ public class WsJobParameters extends JPanel implements ItemListener, if (isModified()) { String lsetname = (curSetName != null) ? curSetName : lastParmSet; + if (lsetname.equals(setname)) { + // setname was just edited - so ignore this event. + return; + } + settingDialog=true; System.out.println("Prompting to save " + lsetname); if (javax.swing.JOptionPane.showConfirmDialog(this, - "Parameter set is modifed - save ?", "Save changes ?", + "Parameter set '"+lsetname+"' is modifed\nsave ?", "Save changes ?", javax.swing.JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { - System.out.println("Saving for " + setname); - _storeCurrentPreset(curSetName); + System.out.println("Saving for " + lsetname); + _storeCurrentPreset(lsetname); } }