Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 13:01:17 GMT
  2. Package jalview.gui

File WsJobParameters.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
59% of files have more coverage

Code metrics

174
504
57
1
1,539
1,175
167
0.33
8.84
57
2.93

Classes

Class Line # Actions
WsJobParameters 95 504 167
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.gui;
22   
23    import java.awt.BorderLayout;
24    import java.awt.Component;
25    import java.awt.Dimension;
26    import java.awt.FlowLayout;
27    import java.awt.Font;
28    import java.awt.GridBagConstraints;
29    import java.awt.GridBagLayout;
30    import java.awt.GridLayout;
31    import java.awt.Rectangle;
32    import java.awt.event.ActionEvent;
33    import java.awt.event.ActionListener;
34    import java.awt.event.HierarchyBoundsListener;
35    import java.awt.event.HierarchyEvent;
36    import java.awt.event.ItemEvent;
37    import java.awt.event.ItemListener;
38    import java.awt.event.WindowEvent;
39    import java.awt.event.WindowListener;
40    import java.net.URL;
41    import java.util.Hashtable;
42    import java.util.Iterator;
43    import java.util.List;
44    import java.util.Vector;
45   
46    import javax.swing.JButton;
47    import javax.swing.JComboBox;
48    import javax.swing.JDialog;
49    import javax.swing.JFrame;
50    import javax.swing.JLabel;
51    import javax.swing.JPanel;
52    import javax.swing.JScrollPane;
53    import javax.swing.JSplitPane;
54    import javax.swing.JTextArea;
55    import javax.swing.border.TitledBorder;
56    import javax.swing.event.DocumentEvent;
57    import javax.swing.event.DocumentListener;
58   
59    import compbio.metadata.Argument;
60    import compbio.metadata.Option;
61    import compbio.metadata.Parameter;
62    import compbio.metadata.Preset;
63    import compbio.metadata.PresetManager;
64    import compbio.metadata.RunnerConfig;
65    import jalview.bin.Console;
66    import jalview.gui.OptsAndParamsPage.OptionBox;
67    import jalview.gui.OptsAndParamsPage.ParamBox;
68    import jalview.util.MessageManager;
69    import jalview.ws.jws2.JabaParamStore;
70    import jalview.ws.jws2.JabaPreset;
71    import jalview.ws.jws2.Jws2Discoverer;
72    import jalview.ws.jws2.jabaws2.Jws2Instance;
73    import jalview.ws.params.ArgumentI;
74    import jalview.ws.params.OptionI;
75    import jalview.ws.params.ParamDatastoreI;
76    import jalview.ws.params.ParameterI;
77    import jalview.ws.params.WsParamSetI;
78    import net.miginfocom.swing.MigLayout;
79   
80    /**
81    * job parameter editing/browsing dialog box. User can browse existing settings
82    * (user + presets + Defaults), and any changes to parameters creates a modified
83    * user parameter set. LOGIC: If the parameter set is modified, and its name is
84    * a valid, non-existant user parameter set, then a save button is shown. If the
85    * parameter set is modified and its name is a valid, extant user parameter set,
86    * then an update button is shown. If user parameter set's name is edited, and
87    * old name exists as a writable user parameter set, then rename button is
88    * shown. If current parameter set is associated with a user defined parameter
89    * set, then : if set is modifed, a 'revert' button is shown. if set is not
90    * modified, a 'delete' button is shown.
91    *
92    * @author JimP
93    *
94    */
 
95    public class WsJobParameters extends JPanel implements ItemListener,
96    ActionListener, DocumentListener, OptsParametersContainerI
97    {
98    URL linkImageURL = getClass().getResource("/images/link.gif");
99   
100    private static final String SVC_DEF = "Defaults"; // this is the null
101    // parameter set as shown to
102    // user
103   
104    /**
105    * manager for options and parameters.
106    */
107    OptsAndParamsPage opanp = new OptsAndParamsPage(this);
108   
109    /**
110    * panel containing job options
111    */
112    JPanel jobOptions = new JPanel();
113   
114    /**
115    * panel containing job parameters
116    */
117    JPanel paramList = new JPanel();
118   
119    JPanel SetNamePanel = new JPanel();
120   
121    JPanel setDetails = new JPanel();
122   
123    JSplitPane settingsPanel = new JSplitPane();
124   
125    JPanel jobPanel = new JPanel();
126   
127    JScrollPane jobOptionsPane = new JScrollPane();
128   
129    JButton createpref = new JButton();
130   
131    JButton deletepref = new JButton();
132   
133    JButton revertpref = new JButton();
134   
135    JButton updatepref = new JButton();
136   
137    JButton startjob = new JButton();
138   
139    JButton canceljob = new JButton();
140   
141    JComboBox setName = new JComboBox();
142   
143    JTextArea setDescr = new JTextArea();
144   
145    JScrollPane paramPane = new JScrollPane();
146   
147    // ScrollablePanel optsAndparams = new ScrollablePanel();
148    JPanel optsAndparams = new JPanel();
149   
150    RunnerConfig serviceOptions;
151   
152    ParamDatastoreI paramStore;
153   
154    private int MAX_OPTWIDTH = 200;
155   
 
156  0 toggle WsJobParameters(Jws2Instance service)
157    {
158  0 this(service, null);
159    }
160   
 
161  0 toggle public WsJobParameters(Jws2Instance service, WsParamSetI preset)
162    {
163  0 this(null, service, preset, null);
164    }
165   
166    /**
167    *
168    * @param desktop
169    * - if null, create new JFrame outside of desktop
170    * @param service
171    * @param preset
172    */
 
173  0 toggle public WsJobParameters(JFrame parent, Jws2Instance service,
174    WsParamSetI preset, List<Argument> jobArgset)
175    {
176  0 this(parent, null, service, preset, jobArgset);
177    }
178   
179    /**
180    *
181    * @param parent
182    * @param paramStorei
183    * @param service
184    * @param preset
185    * @param jobArgset
186    */
 
187  0 toggle public WsJobParameters(JFrame parent, ParamDatastoreI paramStorei,
188    Jws2Instance service, WsParamSetI preset,
189    List<Argument> jobArgset)
190    {
191  0 super();
192  0 jbInit();
193  0 this.paramStore = paramStorei;
194  0 if (paramStore == null)
195    {
196  0 paramStore = service.getParamStore();
197    }
198  0 this.service = service;
199    // argSetModified(false);
200    // populate parameter table
201  0 initForService(service, preset, jobArgset);
202    // display in new JFrame attached to parent.
203  0 validate();
204    }
205   
206    int response = -1;
207   
208    JDialog frame = null;
209   
210    /**
211    * shows a modal dialog containing the parameters.
212    *
213    * @return
214    */
 
215  0 toggle public boolean showRunDialog()
216    {
217   
218  0 frame = new JDialog(Desktop.instance, true);
219   
220  0 frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
221    new String[]
222    { service.getActionText() }));
223  0 Rectangle deskr = Desktop.instance.getBounds();
224  0 Dimension pref = this.getPreferredSize();
225  0 frame.setBounds(
226    new Rectangle((int) (deskr.getCenterX() - pref.width / 2),
227    (int) (deskr.getCenterY() - pref.height / 2),
228    pref.width, pref.height));
229  0 frame.setContentPane(this);
230   
231    // should perhaps recover defaults from user prefs.
232   
233  0 frame.validate();
234  0 javax.swing.SwingUtilities.invokeLater(new Runnable()
235    {
 
236  0 toggle @Override
237    public void run()
238    {
239    // jobPanel.setDividerLocation(0.25);
240   
241    }
242    });
243  0 frame.setVisible(true);
244   
245  0 if (response > 0)
246    {
247  0 return true;
248    }
249  0 return false;
250    }
251   
 
252  0 toggle private void jbInit()
253    {
254  0 this.addHierarchyBoundsListener(new HierarchyBoundsListener()
255    {
256   
 
257  0 toggle @Override
258    public void ancestorResized(HierarchyEvent arg0)
259    {
260  0 refreshParamLayout();
261    }
262   
 
263  0 toggle @Override
264    public void ancestorMoved(HierarchyEvent arg0)
265    {
266    // TODO Auto-generated method stub
267   
268    }
269    });
270  0 updatepref = JvSwingUtils.makeButton(
271    MessageManager.getString("action.update"),
272    MessageManager.getString("label.update_user_parameter_set"),
273    new ActionListener()
274    {
275   
 
276  0 toggle @Override
277    public void actionPerformed(ActionEvent e)
278    {
279  0 update_actionPerformed(e);
280    }
281    });
282  0 deletepref = JvSwingUtils.makeButton(
283    MessageManager.getString("action.delete"),
284    MessageManager.getString("label.delete_user_parameter_set"),
285    new ActionListener()
286    {
287   
 
288  0 toggle @Override
289    public void actionPerformed(ActionEvent e)
290    {
291  0 delete_actionPerformed(e);
292    }
293    });
294  0 createpref = JvSwingUtils.makeButton(
295    MessageManager.getString("action.create"),
296    MessageManager.getString("label.create_user_parameter_set"),
297    new ActionListener()
298    {
299   
 
300  0 toggle @Override
301    public void actionPerformed(ActionEvent e)
302    {
303  0 create_actionPerformed(e);
304    }
305    });
306  0 revertpref = JvSwingUtils.makeButton(
307    MessageManager.getString("action.revert"),
308    MessageManager
309    .getString("label.revert_changes_user_parameter_set"),
310    new ActionListener()
311    {
312   
 
313  0 toggle @Override
314    public void actionPerformed(ActionEvent e)
315    {
316  0 revert_actionPerformed(e);
317    }
318    });
319  0 startjob = JvSwingUtils.makeButton(
320    MessageManager.getString("action.start_job"),
321    MessageManager.getString("label.start_job_current_settings"),
322    new ActionListener()
323    {
 
324  0 toggle @Override
325    public void actionPerformed(ActionEvent e)
326    {
327  0 startjob_actionPerformed(e);
328    }
329    });
330  0 canceljob = JvSwingUtils.makeButton(
331    MessageManager.getString("action.cancel_job"),
332    MessageManager.getString("label.cancel_job_close_dialog"),
333    new ActionListener()
334    {
 
335  0 toggle @Override
336    public void actionPerformed(ActionEvent e)
337    {
338  0 canceljob_actionPerformed(e);
339    }
340    });
341   
342  0 setDetails.setBorder(
343    new TitledBorder(MessageManager.getString("label.details")));
344  0 setDetails.setLayout(new BorderLayout());
345  0 setDescr.setColumns(40);
346  0 setDescr.setWrapStyleWord(true);
347  0 setDescr.setLineWrap(true);
348  0 setDescr.setBackground(getBackground());
349  0 setDescr.setEditable(true);
350  0 setDescr.getDocument().addDocumentListener(this);
351  0 setDescr.setToolTipText(
352    MessageManager.getString("label.edit_notes_parameter_set"));
353  0 JScrollPane setDescrView = new JScrollPane();
354  0 setDescrView.getViewport().setView(setDescr);
355  0 setName.setEditable(true);
356  0 setName.addItemListener(this);
357  0 setName.getEditor().addActionListener(this);
358  0 JPanel setNameInfo = new JPanel(new FlowLayout(FlowLayout.LEFT));
359  0 GridBagLayout gbl = new GridBagLayout();
360  0 SetNamePanel.setLayout(gbl);
361   
362  0 JLabel setNameLabel = new JLabel(
363    MessageManager.getString("label.current_parameter_set_name"));
364  0 setNameLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
365   
366  0 setNameInfo.add(setNameLabel);
367  0 setNameInfo.add(setName);
368   
369    // initial button visibility
370  0 updatepref.setVisible(false);
371  0 deletepref.setVisible(false);
372  0 revertpref.setVisible(false);
373  0 createpref.setVisible(false);
374  0 JPanel setsavebuts = new JPanel();
375  0 setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT)); // GridLayout(1,2));
376  0 ((FlowLayout) setsavebuts.getLayout()).setHgap(10);
377  0 ((FlowLayout) setsavebuts.getLayout()).setVgap(0);
378  0 JPanel spacer = new JPanel();
379  0 spacer.setPreferredSize(new Dimension(2, 30));
380  0 setsavebuts.add(spacer);
381  0 setsavebuts.add(deletepref);
382  0 setsavebuts.add(revertpref);
383  0 setsavebuts.add(createpref);
384  0 setsavebuts.add(updatepref);
385    // setsavebuts.setSize(new Dimension(150, 30));
386  0 JPanel buttonArea = new JPanel(new GridLayout(1, 1));
387  0 buttonArea.add(setsavebuts);
388  0 SetNamePanel.add(setNameInfo);
389  0 GridBagConstraints gbc = new GridBagConstraints();
390  0 gbc.gridheight = 2;
391  0 gbl.setConstraints(setNameInfo, gbc);
392  0 SetNamePanel.add(buttonArea);
393  0 gbc = new GridBagConstraints();
394  0 gbc.gridx = 0;
395  0 gbc.gridy = 2;
396  0 gbc.gridheight = 1;
397  0 gbl.setConstraints(buttonArea, gbc);
398  0 setDetails.add(setDescrView, BorderLayout.CENTER);
399   
400    // paramPane.setPreferredSize(new Dimension(360, 400));
401    // paramPane.setPreferredSize(null);
402  0 jobOptions.setBorder(
403    new TitledBorder(MessageManager.getString("label.options")));
404  0 jobOptions.setOpaque(true);
405  0 paramList.setBorder(
406    new TitledBorder(MessageManager.getString("label.parameters")));
407  0 paramList.setOpaque(true);
408  0 JPanel bjo = new JPanel(new BorderLayout()),
409    bjp = new JPanel(new BorderLayout());
410  0 bjo.add(jobOptions, BorderLayout.CENTER);
411  0 bjp.add(paramList, BorderLayout.CENTER);
412  0 bjp.setOpaque(true);
413  0 bjo.setOpaque(true);
414    // optsAndparams.setScrollableWidth(ScrollableSizeHint.FIT);
415    // optsAndparams.setScrollableHeight(ScrollableSizeHint.NONE);
416    // optsAndparams.setLayout(new BorderLayout());
417  0 optsAndparams.setLayout(new BorderLayout());
418  0 optsAndparams.add(jobOptions, BorderLayout.NORTH);
419  0 optsAndparams.add(paramList, BorderLayout.CENTER);
420  0 JPanel jp = new JPanel(new BorderLayout());
421  0 jp.add(optsAndparams, BorderLayout.CENTER);
422  0 paramPane.getViewport().setView(jp);
423  0 paramPane.setBorder(null);
424  0 setLayout(new BorderLayout());
425  0 jobPanel.setPreferredSize(null);
426  0 jobPanel.setLayout(new BorderLayout());
427  0 jobPanel.add(setDetails, BorderLayout.NORTH);
428  0 jobPanel.add(paramPane, BorderLayout.CENTER);
429    // jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
430   
431  0 add(SetNamePanel, BorderLayout.NORTH);
432  0 add(jobPanel, BorderLayout.CENTER);
433   
434  0 JPanel dialogpanel = new JPanel();
435  0 dialogpanel.add(startjob);
436  0 dialogpanel.add(canceljob);
437    // JAL-1580: setMaximumSize() doesn't work, so just size for the worst case:
438    // check for null is for JUnit usage
439  0 final int windowHeight = Desktop.instance == null ? 540
440    : Desktop.instance.getHeight();
441  0 setPreferredSize(new Dimension(540, windowHeight));
442  0 add(dialogpanel, BorderLayout.SOUTH);
443  0 validate();
444    }
445   
 
446  0 toggle protected void revert_actionPerformed(ActionEvent e)
447    {
448  0 reInitDialog(lastParmSet);
449  0 updateWebServiceMenus();
450    }
451   
 
452  0 toggle protected void update_actionPerformed(ActionEvent e)
453    {
454  0 if (isUserPreset)
455    {
456  0 String curname = ((String) setName.getSelectedItem()).trim();
457  0 _updatePreset(lastParmSet, curname);
458  0 lastParmSet = curname;
459  0 isUserPreset = true;
460  0 initArgSetModified();
461  0 syncSetNamesWithStore();
462    }
463    }
464   
 
465  0 toggle private void _deleteUserPreset(String lastParmSet2)
466    {
467  0 paramStore.deletePreset(lastParmSet2);
468    }
469   
 
470  0 toggle protected void delete_actionPerformed(ActionEvent e)
471    {
472  0 if (isUserPreset)
473    {
474    // delete current preset's saved entry
475  0 _deleteUserPreset(lastParmSet);
476    }
477  0 reInitDialog(null); // service default
478  0 updateWebServiceMenus();
479    }
480   
 
481  0 toggle protected void create_actionPerformed(ActionEvent e)
482    {
483  0 String curname = ((String) setName.getSelectedItem()).trim();
484  0 if (curname.length() > 0)
485    {
486  0 _storeCurrentPreset(curname);
487  0 lastParmSet = curname;
488  0 isUserPreset = true;
489  0 reInitDialog(curname);
490  0 initArgSetModified();
491  0 updateWebServiceMenus();
492    }
493    else
494    {
495    // TODO: show warning
496  0 jalview.bin.Console.errPrintln("Invalid name. Not saved.");
497    }
498    }
499   
 
500  0 toggle protected void canceljob_actionPerformed(ActionEvent e)
501    {
502  0 response = 0;
503  0 if (frame != null)
504    {
505  0 frame.setVisible(false);
506    }
507    }
508   
 
509  0 toggle protected void startjob_actionPerformed(ActionEvent e)
510    {
511  0 response = 1;
512  0 if (frame != null)
513    {
514  0 frame.setVisible(false);
515    }
516    }
517   
518    Jws2Instance service;
519   
520    /**
521    * list of service presets in the gui
522    */
523    Hashtable servicePresets = null;
524   
525    /**
526    * set if dialog is being set - so handlers will avoid spurious events
527    */
528    boolean settingDialog = false;
529   
 
530  0 toggle void initForService(Jws2Instance service, WsParamSetI jabap,
531    List<Argument> jabajobArgset)
532    {
533  0 WsParamSetI p = null;
534  0 List<ArgumentI> jobArgset = null;
535  0 settingDialog = true;
536    { // instantiate the abstract proxy for Jaba objects
537  0 jobArgset = jabajobArgset == null ? null
538    : JabaParamStore.getJwsArgsfromJaba(jabajobArgset);
539  0 p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) :
540    // null;
541    }
542   
543  0 Hashtable exnames = new Hashtable();
544  0 for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++)
545    {
546  0 exnames.put(setName.getItemAt(i), setName.getItemAt(i));
547    }
548  0 servicePresets = new Hashtable();
549    // Add the default entry - if not present already.
550  0 if (!exnames.contains(SVC_DEF))
551    {
552  0 setName.addItem(SVC_DEF);
553  0 exnames.put(SVC_DEF, SVC_DEF);
554  0 servicePresets.put(SVC_DEF, SVC_DEF);
555    }
556  0 String curname = (p == null ? "" : p.getName());
557  0 for (WsParamSetI pr : paramStore.getPresets())
558    {
559  0 if (!pr.isModifiable())
560    {
561  0 servicePresets.put(pr.getName(), "preset");
562    }
563    else
564    {
565    }
566  0 if (!exnames.contains(pr.getName()))
567    {
568  0 setName.addItem(pr.getName());
569    }
570    }
571    // TODO: if initial jobArgset matches a given user setting or preset then
572    // should recover setting accordingly
573    // updateTable(p, jobArgset);
574  0 if (p != null)
575    {
576  0 reInitDialog(p.getName());
577  0 initArgSetModified();
578    }
579    else
580    {
581  0 if (jobArgset != null && jobArgset.size() > 0)
582    {
583  0 curSetName = "Supplied Settings";
584  0 isUserPreset = false;
585  0 updateTable(p, jobArgset);
586  0 setName.setSelectedItem(curSetName);
587  0 updateButtonDisplay();
588    }
589    else
590    {
591  0 curSetName = null;
592  0 reInitDialog(null);
593    }
594    }
595  0 settingDialog = false;
596   
597    }
598   
 
599  0 toggle @SuppressWarnings("unchecked")
600    private void updateTable(WsParamSetI p, List<ArgumentI> jobArgset)
601    {
602  0 boolean setDefaultParams = false;
603  0 if (lastParmSet == null)
604    {
605  0 isUserPreset = false;
606    // First call - so provide Service default settings
607  0 setName.setSelectedItem(lastSetName = SVC_DEF);
608    }
609  0 if (p == null && SVC_DEF.equals("" + setName.getSelectedItem()))
610    {
611    // indicate that service defaults should be set if available
612  0 setDefaultParams = true;
613    }
614    // populate table from default parameter set.
615  0 List<ArgumentI> args = paramStore.getServiceParameters();
616   
617    // split to params and required arguments
618    {
619  0 int cw = 0;
620  0 boolean optset = false;
621  0 for (ArgumentI myarg : args)
622    {
623    // Ideally, Argument would implement isRequired !
624  0 if (myarg instanceof ParameterI)
625    {
626  0 ParameterI parm = (ParameterI) myarg;
627  0 opanp.addParameter(parm).validate();
628    }
629    else
630    {
631  0 if (myarg instanceof OptionI)
632    {
633  0 OptionI opt = (OptionI) myarg;
634  0 OptionBox ob = opanp.addOption(opt);
635  0 ob.resetToDefault(setDefaultParams);
636  0 if (MAX_OPTWIDTH < ob.getPreferredSize().width)
637    {
638  0 MAX_OPTWIDTH = ob.getPreferredSize().width;
639    }
640  0 ob.validate();
641  0 cw += ob.getPreferredSize().width + 5;
642    }
643    else
644    {
645  0 jalview.bin.Console
646    .errPrintln("Ignoring unknown service argument type "
647    + myarg.getClass().getName());
648    }
649    }
650    }
651  0 args = null; // no more args to process.
652    }
653  0 if (p != null)
654    {
655  0 isUserPreset = false;
656    // initialise setname
657  0 setName.setSelectedItem(lastSetName = p.getName());
658  0 setDescr.setText(lastDescrText = p.getDescription());
659    // TODO - URL link
660  0 try
661    {
662  0 args = p.getArguments();
663    } catch (Exception e)
664    {
665  0 e.printStackTrace();
666    }
667    // TODO: check if args should be unselected prior to resetting using the
668    // preset
669    }
670   
671  0 if (jobArgset != null)
672    {
673  0 argSetModified(jobArgset, true);
674  0 args = jobArgset;
675    }
676    // get setargs from current object
677  0 if (args != null)
678    {
679  0 for (ArgumentI arg : args)
680    {
681  0 if (arg instanceof ParameterI)
682    {
683  0 opanp.setParameter((ParameterI) arg);
684    }
685    else
686    {
687  0 if (arg instanceof OptionI)
688    {
689    // jalview.bin.Console.outPrintln("Setting option "
690    // + System.identityHashCode(arg) + ":" + arg.getName()
691    // + " with " + arg.getDefaultValue());
692  0 opanp.selectOption((OptionI) arg, arg.getValue());
693    }
694    }
695   
696    }
697    }
698   
699  0 refreshParamLayout();
700  0 revalidate();
701    }
702   
 
703  0 toggle private boolean isModified()
704    {
705  0 return modifiedElements.size() > 0;
706    }
707   
708    private Hashtable modifiedElements = new Hashtable();
709   
710    /**
711    * reset gui and modification state settings
712    */
 
713  0 toggle private void initArgSetModified()
714    {
715  0 curSetName = null;
716  0 modifiedElements.clear();
717  0 updateButtonDisplay();
718    }
719   
 
720  0 toggle private void updateButtonDisplay()
721    {
722  0 boolean _update = false, _create = false, _delete = false,
723    _revert = false;
724  0 if (modifiedElements.size() > 0)
725    {
726    // set modified
727  0 _revert = true;
728  0 _update = isUserPreset; // can only update user presets
729  0 if (!isUserPreset || modifiedElements.containsKey(setName))
730    {
731    // name modified - can create new preset
732  0 _create = true;
733    }
734    }
735    else
736    {
737    // set unmodified
738    }
739    // can still delete a user preset
740  0 _delete = isUserPreset;
741   
742  0 createpref.setVisible(_create);
743  0 updatepref.setVisible(_update);
744  0 deletepref.setVisible(_delete);
745  0 revertpref.setVisible(_revert);
746  0 validate();
747    }
748   
 
749  0 toggle @Override
750    public void argSetModified(Object modifiedElement, boolean b)
751    {
752  0 if (settingDialog)
753    {
754  0 return;
755    }
756  0 if (!b)
757    {
758  0 modifiedElements.remove(modifiedElement);
759    }
760    else
761    {
762  0 if (b && modifiedElement == setName
763    && modifiedElements.contains(modifiedElement))
764    {
765    // HACK! prevents iteration on makeSetNameValid
766  0 b = false;
767    }
768  0 modifiedElements.put(modifiedElement, modifiedElement);
769    }
770    // set mod status based on presence of elements in table
771  0 if (b && modifiedElements.size() > 0)
772    {
773  0 makeSetNameValid(!isUserPreset);
774  0 SetNamePanel.revalidate();
775    }
776  0 updateButtonDisplay();
777    }
778   
 
779  0 toggle private boolean isServicePreset(String selectedItem)
780    {
781  0 return selectedItem.equals(SVC_DEF)
782    || servicePresets.containsKey(selectedItem);
783    }
784   
785    /**
786    * check if the current set name is a valid set name for saving, if not, then
787    * fix it.
788    */
 
789  0 toggle private void makeSetNameValid(boolean newuserset)
790    {
791  0 boolean stn = settingDialog;
792  0 boolean renamed = false;
793  0 settingDialog = true;
794  0 String nm = (curSetName != null ? curSetName
795    : (String) setName.getSelectedItem());
796    // check if the name is reserved - if it is, rename it.
797  0 if (isServicePreset(nm))
798    {
799  0 nm = "User " + nm;
800  0 renamed = true;
801    }
802  0 String tnm = nm;
803  0 if (newuserset)
804    {
805  0 int i = 0;
806  0 while (paramStore.getPreset(tnm) != null)
807    {
808  0 tnm = nm + " (" + (++i) + ")";
809  0 renamed = true;
810    }
811  0 if (i > 0)
812    {
813  0 nm = tnm;
814    }
815    }
816   
817  0 boolean makeupdate = false;
818    // sync the gui with the preset database
819  0 for (int i = 0, iS = setName.getItemCount(); i < iS; i++)
820    {
821  0 String snm = (String) setName.getItemAt(i);
822  0 if (snm.equals(nm))
823    {
824  0 makeupdate = true;
825    // setName.setSelectedIndex(i);
826    }
827    }
828  0 if (!makeupdate)
829    {
830  0 setName.addItem(curSetName = nm);
831  0 setName.setSelectedItem(curSetName);
832    }
833  0 if (renamed)
834    {
835  0 settingDialog = false; // we need this name change to be registered.
836  0 argSetModified(setName, renamed);
837    }
838  0 settingDialog = stn;
839    }
840   
 
841  0 toggle @Override
842    public void refreshParamLayout()
843    {
844    // optsAndparams.setPreferredSize(null);
845  0 FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
846  0 int sep = fl.getVgap();
847  0 boolean fh = true;
848  0 int os = 0,
849    s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom
850    + jobOptions.getBorder().getBorderInsets(jobOptions).top
851    + 2 * sep;
852    /**
853    * final height for viewport
854    */
855  0 int finalh = s;
856  0 int panewidth = paramPane.getViewport().getSize().width - 120
857    - jobOptions.getBorder().getBorderInsets(jobOptions).left
858    + jobOptions.getBorder().getBorderInsets(jobOptions).right;
859   
860  0 int w = 2 * fl.getHgap()
861  0 + (MAX_OPTWIDTH > OptsAndParamsPage.PARAM_WIDTH ? MAX_OPTWIDTH
862    : OptsAndParamsPage.PARAM_WIDTH);
863  0 int hgap = fl.getHgap(), cw = hgap;
864   
865  0 if (opanp.getOptSet().size() > 0)
866    {
867   
868  0 jobOptions.setLayout(new MigLayout("", "", ""));
869  0 jobOptions.removeAll();
870   
871  0 for (OptionBox pbox : opanp.getOptSet().values())
872    {
873  0 pbox.validate();
874  0 cw += pbox.getSize().width + hgap;
875  0 if (cw + 120 > panewidth)
876    {
877  0 jobOptions.add(pbox, "wrap");
878    // jalview.bin.Console.outPrintln("Wrap on "+pbox.option.getName());
879  0 cw = hgap + pbox.getSize().width;
880  0 fh = true;
881    }
882    else
883    {
884  0 jobOptions.add(pbox);
885    }
886  0 if (fh)
887    {
888  0 finalh += pbox.getSize().height + fl.getVgap();
889  0 fh = false;
890    }
891    }
892  0 jobOptions.revalidate();
893    }
894    else
895    {
896  0 jobOptions.setVisible(false);
897    }
898   
899    // Now layout the parameters assuming they occupy one column - to calculate
900    // total height of options+parameters
901  0 fl = new FlowLayout(FlowLayout.LEFT);
902    // helpful hint from
903    // http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout
904  0 fl.setAlignOnBaseline(true);
905  0 if (opanp.getParamSet().size() > 0)
906    {
907  0 paramList.removeAll();
908  0 paramList.setLayout(new MigLayout("", "", ""));
909  0 fh = true;
910  0 for (ParamBox pbox : opanp.getParamSet().values())
911    {
912  0 pbox.validate();
913  0 cw += pbox.getSize().width + hgap;
914  0 if (cw + 160 > panewidth)
915    {
916  0 paramList.add(pbox, "wrap");
917  0 cw = pbox.getSize().width + hgap;
918  0 fh = true;
919    }
920    else
921    {
922  0 paramList.add(pbox);
923    }
924  0 if (fh)
925    {
926  0 finalh += pbox.getSize().height + fl.getVgap();
927  0 fh = false;
928    }
929   
930    }
931    /*
932    * s = 2 * sep; for (ParamBox pbox : opanp.getParamSet().values()) {
933    * pbox.validate(); s += sep +
934    * pbox.getPreferredSize().height+pbox.getBorder
935    * ().getBorderInsets(pbox).bottom; }
936    *
937    * // paramList.setPreferredSize(new Dimension(w, s));
938    * os+=s+2*sep+paramList
939    * .getBorder().getBorderInsets(paramList).bottom+paramList
940    * .getBorder().getBorderInsets(paramList).top;
941    */
942  0 paramList.revalidate();
943    }
944    else
945    {
946  0 paramList.setVisible(false);
947    }
948    // TODO: waste some time trying to eliminate any unnecessary .validate calls
949    // here
950    // jalview.bin.Console.outPrintln("Size will be : "+w+","+os);
951    // optsAndparams.setPreferredSize(null);
952    // paramPane.getViewport().setView(optsAndparams);
953  0 paramPane.getViewport().setAutoscrolls(true);
954  0 paramPane.revalidate();
955  0 revalidate();
956    }
957   
958    /**
959    * testing method - grab a service and parameter set and show the window
960    *
961    * @param args
962    * @j2sIgnore
963    */
 
964  0 toggle public static void main(String[] args)
965    {
966  0 jalview.ws.jws2.Jws2Discoverer disc = jalview.ws.jws2.Jws2Discoverer
967    .getDiscoverer();
968  0 int p = 0;
969  0 if (args.length > 0)
970    {
971  0 Vector<String> services = new Vector<>();
972  0 services.addElement(args[p++]);
973  0 Jws2Discoverer.getDiscoverer().setServiceUrls(services);
974    }
975  0 try
976    {
977  0 disc.run();
978    } catch (Exception e)
979    {
980  0 jalview.bin.Console
981    .errPrintln("Aborting. Problem discovering services.");
982  0 e.printStackTrace();
983  0 return;
984    }
985  0 Jws2Instance lastserv = null;
986  0 for (Jws2Instance service : disc.getServices())
987    {
988  0 lastserv = service;
989  0 if (p >= args.length || service.serviceType.equalsIgnoreCase(args[p]))
990    {
991  0 if (lastserv != null)
992    {
993  0 List<Preset> prl = null;
994  0 Preset pr = null;
995  0 if (++p < args.length)
996    {
997  0 PresetManager prman = lastserv.getPresets();
998  0 if (prman != null)
999    {
1000  0 pr = prman.getPresetByName(args[p]);
1001  0 if (pr == null)
1002    {
1003    // just grab the last preset.
1004  0 prl = prman.getPresets();
1005    }
1006    }
1007    }
1008    else
1009    {
1010  0 PresetManager prman = lastserv.getPresets();
1011  0 if (prman != null)
1012    {
1013  0 prl = prman.getPresets();
1014    }
1015    }
1016  0 Iterator<Preset> en = (prl == null) ? null : prl.iterator();
1017  0 while (en != null && en.hasNext())
1018    {
1019  0 if (en != null)
1020    {
1021  0 if (!en.hasNext())
1022    {
1023  0 en = prl.iterator();
1024    }
1025  0 pr = en.next();
1026    }
1027    {
1028  0 jalview.bin.Console.outPrintln("Testing opts dupes for "
1029    + lastserv.getUri() + " : " + lastserv.getActionText()
1030    + ":" + pr.getName());
1031  0 List<Option> rg = lastserv.getRunnerConfig().getOptions();
1032  0 for (Option o : rg)
1033    {
1034  0 try
1035    {
1036  0 Option cpy = jalview.ws.jws2.ParameterUtils.copyOption(o);
1037    } catch (Exception e)
1038    {
1039  0 jalview.bin.Console
1040    .errPrintln("Failed to copy " + o.getName());
1041  0 e.printStackTrace();
1042    } catch (Error e)
1043    {
1044  0 jalview.bin.Console
1045    .errPrintln("Failed to copy " + o.getName());
1046  0 e.printStackTrace();
1047    }
1048    }
1049    }
1050    {
1051  0 jalview.bin.Console.outPrintln("Testing param dupes:");
1052  0 List<Parameter> rg = lastserv.getRunnerConfig()
1053    .getParameters();
1054  0 for (Parameter o : rg)
1055    {
1056  0 try
1057    {
1058  0 Parameter cpy = jalview.ws.jws2.ParameterUtils
1059    .copyParameter(o);
1060    } catch (Exception e)
1061    {
1062  0 jalview.bin.Console
1063    .errPrintln("Failed to copy " + o.getName());
1064  0 e.printStackTrace();
1065    } catch (Error e)
1066    {
1067  0 jalview.bin.Console
1068    .errPrintln("Failed to copy " + o.getName());
1069  0 e.printStackTrace();
1070    }
1071    }
1072    }
1073    {
1074  0 jalview.bin.Console.outPrintln("Testing param write:");
1075  0 List<String> writeparam = null, readparam = null;
1076  0 try
1077    {
1078  0 writeparam = jalview.ws.jws2.ParameterUtils
1079    .writeParameterSet(
1080    pr.getArguments(lastserv.getRunnerConfig()),
1081    " ");
1082  0 jalview.bin.Console.outPrintln("Testing param read :");
1083  0 List<Option> pset = jalview.ws.jws2.ParameterUtils
1084    .processParameters(writeparam,
1085    lastserv.getRunnerConfig(), " ");
1086  0 readparam = jalview.ws.jws2.ParameterUtils
1087    .writeParameterSet(pset, " ");
1088  0 Iterator<String> o = pr.getOptions().iterator(),
1089    s = writeparam.iterator(), t = readparam.iterator();
1090  0 boolean failed = false;
1091  0 while (s.hasNext() && t.hasNext())
1092    {
1093  0 String on = o.next(), sn = s.next(), st = t.next();
1094  0 if (!sn.equals(st))
1095    {
1096  0 jalview.bin.Console.outPrintln(
1097    "Original was " + on + " Phase 1 wrote " + sn
1098    + "\tPhase 2 wrote " + st);
1099  0 failed = true;
1100    }
1101    }
1102  0 if (failed)
1103    {
1104  0 jalview.bin.Console.outPrintln(
1105    "Original parameters:\n" + pr.getOptions());
1106  0 jalview.bin.Console.outPrintln(
1107    "Wrote parameters in first set:\n" + writeparam);
1108  0 jalview.bin.Console.outPrintln(
1109    "Wrote parameters in second set:\n" + readparam);
1110   
1111    }
1112    } catch (Exception e)
1113    {
1114  0 e.printStackTrace();
1115    }
1116    }
1117  0 WsJobParameters pgui = new WsJobParameters(lastserv,
1118    new JabaPreset(lastserv, pr));
1119  0 JFrame jf = new JFrame(MessageManager
1120    .formatMessage("label.ws_parameters_for", new String[]
1121    { lastserv.getActionText() }));
1122  0 JPanel cont = new JPanel(new BorderLayout());
1123  0 pgui.validate();
1124  0 cont.setPreferredSize(pgui.getPreferredSize());
1125  0 cont.add(pgui, BorderLayout.CENTER);
1126  0 jf.setLayout(new BorderLayout());
1127  0 jf.add(cont, BorderLayout.CENTER);
1128  0 jf.validate();
1129  0 final Thread thr = Thread.currentThread();
1130  0 jf.addWindowListener(new WindowListener()
1131    {
1132   
 
1133  0 toggle @Override
1134    public void windowActivated(WindowEvent e)
1135    {
1136    // TODO Auto-generated method stub
1137   
1138    }
1139   
 
1140  0 toggle @Override
1141    public void windowClosed(WindowEvent e)
1142    {
1143    }
1144   
 
1145  0 toggle @Override
1146    public void windowClosing(WindowEvent e)
1147    {
1148  0 thr.interrupt();
1149   
1150    }
1151   
 
1152  0 toggle @Override
1153    public void windowDeactivated(WindowEvent e)
1154    {
1155    // TODO Auto-generated method stub
1156   
1157    }
1158   
 
1159  0 toggle @Override
1160    public void windowDeiconified(WindowEvent e)
1161    {
1162    // TODO Auto-generated method stub
1163   
1164    }
1165   
 
1166  0 toggle @Override
1167    public void windowIconified(WindowEvent e)
1168    {
1169    // TODO Auto-generated method stub
1170   
1171    }
1172   
 
1173  0 toggle @Override
1174    public void windowOpened(WindowEvent e)
1175    {
1176    // TODO Auto-generated method stub
1177   
1178    }
1179   
1180    });
1181  0 jf.setVisible(true);
1182  0 boolean inter = false;
1183  0 while (!inter)
1184    {
1185  0 try
1186    {
1187  0 Thread.sleep(10000);
1188    } catch (Exception e)
1189    {
1190  0 inter = true;
1191    }
1192    }
1193  0 jf.dispose();
1194    }
1195    }
1196    }
1197    }
1198    }
1199   
 
1200  0 toggle public boolean isServiceDefaults()
1201    {
1202  0 return (!isModified()
1203    && (lastParmSet != null && lastParmSet.equals(SVC_DEF)));
1204    }
1205   
 
1206  0 toggle public List<ArgumentI> getJobParams()
1207    {
1208  0 return opanp.getCurrentSettings();
1209    }
1210   
1211    String lastParmSet = null;
1212   
1213    /*
1214    * Hashtable<String, Object[]> editedParams = new Hashtable<String,
1215    * Object[]>();
1216    *
1217    * store the given parameters in the user parameter set database.
1218    *
1219    * @param storeSetName - lastParmSet
1220    *
1221    * @param descr - setDescr.getText()
1222    *
1223    * @param jobParams - getJobParams()
1224    *
1225    * private void _storeUserPreset(String storeSetName, String descr,
1226    * List<ArgumentI> jobParams) { // this is a simple hash store. Object[] pset;
1227    * editedParams.put(storeSetName, pset = new Object[3]); pset[0] =
1228    * storeSetName; pset[1] = descr; pset[2] = jobParams; // writeParam("Saving "
1229    * + storeSetName + ": ", jobParams); }
1230    *
1231    * private void writeParam(String nm, List<ArgumentI> params) { for (ArgumentI
1232    * p : params) { jalview.bin.Console.outPrintln(nm + ":" + System.identityHashCode(p) +
1233    * " Name: " + p.getName() + " Value: " + p.getDefaultValue()); } }
1234    *
1235    * private Object[] _getUserPreset(String setName) { Object[] pset =
1236    * editedParams.get(setName); // if (pset != null) // writeParam("Retrieving "
1237    * + setName + ": ", (List<Argument>) pset[2]); return pset; }
1238    *
1239    * * remove the given user preset from the preset stash
1240    *
1241    * @param setName
1242    *
1243    * private void _deleteUserPreset(String setName) {
1244    * editedParams.remove(setName); }
1245    */
1246   
 
1247  0 toggle private void syncSetNamesWithStore()
1248    {
1249  0 int n = 0;
1250    // remove any set names in the drop down menu that aren't either a reserved
1251    // setting, or a user defined or service preset.
1252  0 Vector items = new Vector();
1253  0 while (n < setName.getItemCount())
1254    {
1255  0 String item = (String) setName.getItemAt(n);
1256  0 if (!item.equals(SVC_DEF) && !paramStore.presetExists(item))
1257    {
1258  0 setName.removeItemAt(n);
1259    }
1260    else
1261    {
1262  0 items.addElement(item);
1263  0 n++;
1264    }
1265    }
1266  0 if (!items.contains(SVC_DEF))
1267    {
1268  0 setName.addItem(SVC_DEF);
1269    }
1270  0 for (WsParamSetI upn : paramStore.getPresets())
1271    {
1272  0 if (!items.contains(upn.getName()))
1273    {
1274  0 setName.addItem(upn.getName());
1275    }
1276    }
1277    }
1278   
1279    /**
1280    * true if lastParmSet is a user preset
1281    */
1282    boolean isUserPreset = false;
1283   
 
1284  0 toggle private void reInitDialog(String nextPreset)
1285    {
1286  0 settingDialog = true;
1287    // updateTable(null,null); // first reset to defaults
1288  0 WsParamSetI pset = null;
1289  0 if (nextPreset != null && nextPreset.length() > 0)
1290    {
1291  0 pset = paramStore.getPreset(nextPreset);
1292    }
1293  0 if (pset != null)
1294    {
1295  0 if (pset.isModifiable())
1296    {
1297  0 isUserPreset = true;
1298  0 setDescr.setText(pset.getDescription());
1299  0 updateTable(null, pset.getArguments());
1300  0 lastParmSet = nextPreset;
1301    }
1302    else
1303    {
1304  0 isUserPreset = false;
1305  0 setDescr.setText("");
1306    // must be a default preset from service
1307  0 updateTable(pset, null);
1308  0 lastParmSet = nextPreset;
1309    }
1310    }
1311    else
1312    {
1313  0 isUserPreset = false;
1314    // Service defaults
1315  0 setDescr.setText("");
1316  0 updateTable(null, null);
1317  0 lastParmSet = SVC_DEF;
1318    }
1319   
1320  0 initArgSetModified();
1321  0 syncSetNamesWithStore();
1322  0 setName.setSelectedItem(lastParmSet);
1323  0 SetNamePanel.validate();
1324  0 validate();
1325  0 settingDialog = false;
1326    }
1327   
1328    /**
1329    * Rebuild the AlignFrame web service menus (after add/delete of a preset
1330    * option).
1331    */
 
1332  0 toggle protected void updateWebServiceMenus()
1333    {
1334  0 for (AlignFrame alignFrame : Desktop.getDesktopAlignFrames())
1335    {
1336  0 alignFrame.BuildWebServiceMenu();
1337    }
1338    }
1339   
1340    String curSetName = null;
1341   
 
1342  0 toggle @Override
1343    public void itemStateChanged(ItemEvent e)
1344    {
1345  0 if (e.getSource() == setName && e.getStateChange() == e.SELECTED)
1346    {
1347  0 final String setname = (String) setName.getSelectedItem();
1348  0 if (Console.isDebugEnabled())
1349    {
1350  0 Console.debug("Item state changed for " + setname + " (handling ? "
1351    + !settingDialog + ")");
1352    }
1353  0 if (settingDialog)
1354    {
1355    // ignore event
1356  0 return;
1357    }
1358  0 if (setname == null)
1359    {
1360  0 return;
1361    }
1362  0 javax.swing.SwingUtilities.invokeLater(new Runnable()
1363    {
 
1364  0 toggle @Override
1365    public void run()
1366    {
1367  0 doPreferenceComboStateChange(setname);
1368    }
1369    });
1370    }
1371    }
1372   
 
1373  0 toggle private void doPreferenceComboStateChange(String setname)
1374    {
1375    // user has selected a different item from combo-box
1376  0 if (isModified())
1377    {
1378  0 String lsetname = (curSetName != null) ? curSetName : lastParmSet;
1379  0 if (lsetname.equals(setname))
1380    {
1381    // setname was just edited - so ignore this event.
1382  0 return;
1383    }
1384  0 settingDialog = true;
1385  0 jalview.bin.Console.outPrintln("Prompting to save " + lsetname);
1386  0 if (JvOptionPane.showConfirmDialog(this, "Parameter set '" + lsetname
1387    + "' is modifed, and your changes will be lost.\nReally change preset ?",
1388    "Warning: Unsaved Changes",
1389    JvOptionPane.OK_CANCEL_OPTION) != JvOptionPane.OK_OPTION)
1390    {
1391    // revert the combobox to the current item
1392  0 settingDialog = true;
1393  0 setName.setSelectedItem(lsetname);
1394  0 settingDialog = false;
1395    // and leave.
1396  0 return;
1397    // jalview.bin.Console.outPrintln("Saving for " + lsetname);
1398    // _storeCurrentPreset(lsetname);
1399   
1400    }
1401    }
1402  0 settingDialog = true;
1403  0 reInitDialog(setname);
1404  0 settingDialog = false;
1405   
1406    }
1407   
 
1408  0 toggle private void _renameExistingPreset(String oldName, String curSetName2)
1409    {
1410  0 paramStore.updatePreset(oldName, curSetName2, setDescr.getText(),
1411    getJobParams());
1412    }
1413   
1414    /**
1415    * store current settings as given name. You should then reset gui.
1416    *
1417    * @param curSetName2
1418    */
 
1419  0 toggle private void _storeCurrentPreset(String curSetName2)
1420    {
1421  0 paramStore.storePreset(curSetName2, setDescr.getText(), getJobParams());
1422    }
1423   
 
1424  0 toggle private void _updatePreset(String lastParmSet2, String curname)
1425    {
1426  0 paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(),
1427    getJobParams());
1428   
1429    }
1430   
1431    /**
1432    * last saved name for this user preset
1433    */
1434    String lastSetName = null;
1435   
1436    /**
1437    * last saved value of the description text for this user preset
1438    */
1439    String lastDescrText = null;
1440   
 
1441  0 toggle @Override
1442    public void actionPerformed(ActionEvent e)
1443    {
1444  0 if (e.getSource() instanceof Component)
1445    {
1446  0 Component src = (Component) e.getSource();
1447  0 if (src.getParent() == setName)
1448    {
1449    // rename any existing records we know about for this set.
1450  0 String newname = e.getActionCommand().trim();
1451  0 String msg = null;
1452  0 if (isServicePreset(newname))
1453    {
1454  0 final String oldname = curSetName != null ? curSetName
1455    : lastParmSet;
1456  0 final Component ourframe = this;
1457  0 settingDialog = true;
1458  0 setName.getEditor().setItem(oldname);
1459  0 settingDialog = false;
1460  0 javax.swing.SwingUtilities.invokeLater(new Runnable()
1461    {
 
1462  0 toggle @Override
1463    public void run()
1464    {
1465  0 JvOptionPane.showMessageDialog(ourframe,
1466    MessageManager.getString(
1467    "label.invalid_name_preset_exists"),
1468    MessageManager.getString("label.invalid_name"),
1469    JvOptionPane.WARNING_MESSAGE);
1470    }
1471    });
1472   
1473  0 return;
1474    }
1475  0 curSetName = newname;
1476  0 jalview.bin.Console.errPrintln("New name for user setting "
1477    + curSetName + " (was " + setName.getSelectedItem() + ")");
1478  0 if (curSetName.equals(setName.getSelectedItem()))
1479    {
1480  0 curSetName = null;
1481    }
1482  0 if (curSetName != null)
1483    {
1484  0 argSetModified(setName, true);
1485  0 return;
1486    }
1487   
1488    }
1489    }
1490    }
1491   
 
1492  0 toggle private void checkDescrModified()
1493    {
1494  0 if (!settingDialog)
1495    {
1496   
1497  0 argSetModified(setDescr,
1498  0 (lastDescrText == null
1499    ? setDescr.getText().trim().length() > 0
1500    : !setDescr.getText().equals(lastDescrText)));
1501   
1502    }
1503    }
1504   
 
1505  0 toggle @Override
1506    public void insertUpdate(DocumentEvent e)
1507    {
1508  0 checkDescrModified();
1509    }
1510   
 
1511  0 toggle @Override
1512    public void removeUpdate(DocumentEvent e)
1513    {
1514  0 checkDescrModified();
1515    }
1516   
 
1517  0 toggle @Override
1518    public void changedUpdate(DocumentEvent e)
1519    {
1520  0 checkDescrModified();
1521    }
1522   
1523    /**
1524    *
1525    * @return null or the service preset selected by the user
1526    */
 
1527  0 toggle public WsParamSetI getPreset()
1528    {
1529  0 if (isUserPreset || isModified()
1530    || (lastParmSet != null && lastParmSet.equals(SVC_DEF)))
1531    {
1532  0 return null;
1533    }
1534    else
1535    {
1536  0 return paramStore.getPreset(lastParmSet);
1537    }
1538    }
1539    }