JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / gui / OptsAndParamsPage.java
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 jalview.util.MessageManager;
24 import jalview.ws.params.ArgumentI;
25 import jalview.ws.params.OptionI;
26 import jalview.ws.params.ParameterI;
27 import jalview.ws.params.ValueConstrainI;
28 import jalview.ws.params.ValueConstrainI.ValueType;
29
30 import java.awt.BorderLayout;
31 import java.awt.Component;
32 import java.awt.Dimension;
33 import java.awt.Font;
34 import java.awt.GridLayout;
35 import java.awt.Rectangle;
36 import java.awt.event.ActionEvent;
37 import java.awt.event.ActionListener;
38 import java.awt.event.KeyEvent;
39 import java.awt.event.KeyListener;
40 import java.awt.event.MouseEvent;
41 import java.awt.event.MouseListener;
42 import java.net.URL;
43 import java.util.ArrayList;
44 import java.util.List;
45 import java.util.Map;
46
47 import javax.swing.JButton;
48 import javax.swing.JCheckBox;
49 import javax.swing.JComboBox;
50 import javax.swing.JComponent;
51 import javax.swing.JLabel;
52 import javax.swing.JMenuItem;
53 import javax.swing.JPanel;
54 import javax.swing.JPopupMenu;
55 import javax.swing.JScrollPane;
56 import javax.swing.JSlider;
57 import javax.swing.JTextArea;
58 import javax.swing.JTextField;
59 import javax.swing.border.TitledBorder;
60 import javax.swing.event.ChangeEvent;
61 import javax.swing.event.ChangeListener;
62
63 import net.miginfocom.swing.MigLayout;
64
65 /**
66  * GUI generator/manager for options and parameters. Originally abstracted from
67  * the WsJobParameters dialog box.
68  * 
69  * @author jprocter
70  * 
71  */
72 public class OptsAndParamsPage
73 {
74   /**
75    * compact or verbose style parameters
76    */
77   boolean compact = false;
78
79   public class OptionBox extends JPanel implements MouseListener,
80           ActionListener
81   {
82     JCheckBox enabled = new JCheckBox();
83
84     final URL finfo;
85
86     boolean hasLink = false;
87
88     boolean initEnabled = false;
89
90     String initVal = null;
91
92     OptionI option;
93
94     JLabel optlabel = new JLabel();
95
96     JComboBox val = new JComboBox();
97
98     public OptionBox(OptionI opt)
99     {
100       option = opt;
101       setLayout(new BorderLayout());
102       enabled.setSelected(opt.isRequired()); // TODO: lock required options
103       enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
104       enabled.setText("");
105       enabled.setText(opt.getName());
106       enabled.addActionListener(this);
107       finfo = option.getFurtherDetails();
108       String desc = opt.getDescription();
109       if (finfo != null)
110       {
111         hasLink = true;
112
113         enabled.setToolTipText(JvSwingUtils
114                 .wrapTooltip(
115                         true,
116                         ((desc == null || desc.trim().length() == 0) ? MessageManager
117                                 .getString("label.opt_and_params_further_details")
118                                 : desc)
119                                 + "<br><img src=\"" + linkImageURL + "\"/>"));
120         enabled.addMouseListener(this);
121       }
122       else
123       {
124         if (desc != null && desc.trim().length() > 0)
125         {
126           enabled.setToolTipText(JvSwingUtils.wrapTooltip(true,
127                   opt.getDescription()));
128         }
129       }
130       add(enabled, BorderLayout.NORTH);
131       for (Object str : opt.getPossibleValues())
132       {
133         val.addItem(str);
134       }
135       val.setSelectedItem(opt.getValue());
136       if (opt.getPossibleValues().size() > 1)
137       {
138         setLayout(new GridLayout(1, 2));
139         val.addActionListener(this);
140         add(val, BorderLayout.SOUTH);
141       }
142       // TODO: add actionListeners for popup (to open further info),
143       // and to update list of parameters if an option is enabled
144       // that takes a value. JBPNote: is this TODO still valid ?
145       setInitialValue();
146     }
147
148     @Override
149     public void actionPerformed(ActionEvent e)
150     {
151       if (e.getSource() != enabled)
152       {
153         enabled.setSelected(true);
154       }
155       checkIfModified();
156     }
157
158     private void checkIfModified()
159     {
160       boolean notmod = (initEnabled == enabled.isSelected());
161       if (enabled.isSelected())
162       {
163         if (initVal != null)
164         {
165           notmod &= initVal.equals(val.getSelectedItem());
166         }
167         else
168         {
169           // compare against default service setting
170           notmod &= option.getValue() == null
171                   || option.getValue().equals(val.getSelectedItem());
172         }
173       }
174       else
175       {
176         notmod &= (initVal != null) ? initVal.equals(val.getSelectedItem())
177                 : val.getSelectedItem() != initVal;
178       }
179       poparent.argSetModified(this, !notmod);
180     }
181
182     public OptionI getOptionIfEnabled()
183     {
184       if (!enabled.isSelected())
185       {
186         return null;
187       }
188       OptionI opt = option.copy();
189       if (opt.getPossibleValues() != null
190               && opt.getPossibleValues().size() == 1)
191       {
192         // Hack to make sure the default value for an enabled option with only
193         // one value is actually returned
194         opt.setValue(opt.getPossibleValues().get(0));
195       }
196       if (val.getSelectedItem() != null)
197       {
198         opt.setValue((String) val.getSelectedItem());
199       }
200       else
201       {
202         if (option.getValue() != null)
203         {
204           opt.setValue(option.getValue());
205         }
206       }
207       return opt;
208     }
209
210     @Override
211     public void mouseClicked(MouseEvent e)
212     {
213       if (e.isPopupTrigger()) // for Windows
214       {
215         showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
216       }
217     }
218
219     @Override
220     public void mouseEntered(MouseEvent e)
221     {
222       // TODO Auto-generated method stub
223
224     }
225
226     @Override
227     public void mouseExited(MouseEvent e)
228     {
229       // TODO Auto-generated method stub
230
231     }
232
233     @Override
234     public void mousePressed(MouseEvent e)
235     {
236       if (e.isPopupTrigger()) // Mac
237       {
238         showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
239       }
240     }
241
242     @Override
243     public void mouseReleased(MouseEvent e)
244     {
245     }
246
247     public void resetToDefault(boolean setDefaultParams)
248     {
249       enabled.setSelected(false);
250       if (option.isRequired()
251               || (setDefaultParams && option.getValue() != null))
252       {
253         // Apply default value
254         selectOption(option, option.getValue());
255       }
256     }
257
258     public void setInitialValue()
259     {
260       initEnabled = enabled.isSelected();
261       if (option.getPossibleValues() != null
262               && option.getPossibleValues().size() > 1)
263       {
264         initVal = (String) val.getSelectedItem();
265       }
266       else
267       {
268         initVal = (initEnabled) ? (String) val.getSelectedItem() : null;
269       }
270     }
271
272   }
273
274   public class ParamBox extends JPanel implements ChangeListener,
275           ActionListener, MouseListener
276   {
277     boolean adjusting = false;
278
279     boolean choice = false;
280
281     JComboBox choicebox;
282
283     JPanel controlPanel = new JPanel();
284
285     boolean descisvisible = false;
286
287     JScrollPane descPanel = new JScrollPane();
288
289     final URL finfo;
290
291     boolean integ = false;
292
293     Object lastVal;
294
295     ParameterI parameter;
296
297     final OptsParametersContainerI pmdialogbox;
298
299     JPanel settingPanel = new JPanel();
300
301     JButton showDesc = new JButton();
302
303     JSlider slider = null;
304
305     JTextArea string = new JTextArea();
306
307     ValueConstrainI validator = null;
308
309     JTextField valueField = null;
310
311     public ParamBox(final OptsParametersContainerI pmlayout, ParameterI parm)
312     {
313       pmdialogbox = pmlayout;
314       finfo = parm.getFurtherDetails();
315       validator = parm.getValidValue();
316       parameter = parm;
317       if (validator != null)
318       {
319         integ = validator.getType() == ValueType.Integer;
320       }
321       else
322       {
323         if (parameter.getPossibleValues() != null)
324         {
325           choice = true;
326         }
327       }
328
329       if (!compact)
330       {
331         makeExpanderParam(parm);
332       }
333       else
334       {
335         makeCompactParam(parm);
336
337       }
338     }
339
340     private void makeCompactParam(ParameterI parm)
341     {
342       setLayout(new MigLayout("", "[][grow]"));
343
344       String ttipText = null;
345
346       controlPanel.setLayout(new BorderLayout());
347
348       if (parm.getDescription() != null
349               && parm.getDescription().trim().length() > 0)
350       {
351         // Only create description boxes if there actually is a description.
352         ttipText = (JvSwingUtils
353                 .wrapTooltip(
354                         true,
355                         parm.getDescription()
356                                 + (finfo != null ? "<br><img src=\""
357                                         + linkImageURL
358                                         + "\"/>"
359                                         + MessageManager
360                                                 .getString("label.opt_and_params_further_details")
361                                         : "")));
362       }
363
364       JvSwingUtils.mgAddtoLayout(this, ttipText,
365               new JLabel(parm.getName()), controlPanel, "");
366       updateControls(parm);
367       validate();
368     }
369
370     private void makeExpanderParam(ParameterI parm)
371     {
372       setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT));
373       setBorder(new TitledBorder(parm.getName()));
374       setLayout(null);
375       showDesc.setFont(new Font("Verdana", Font.PLAIN, 6));
376       showDesc.setText("+");
377       string.setFont(new Font("Verdana", Font.PLAIN, 11));
378       string.setBackground(getBackground());
379
380       string.setEditable(false);
381       descPanel.getViewport().setView(string);
382
383       descPanel.setVisible(false);
384
385       JPanel firstrow = new JPanel();
386       firstrow.setLayout(null);
387       controlPanel.setLayout(new BorderLayout());
388       controlPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70,
389               PARAM_CLOSEDHEIGHT - 50));
390       firstrow.add(controlPanel);
391       firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30,
392               PARAM_CLOSEDHEIGHT - 30));
393
394       final ParamBox me = this;
395
396       if (parm.getDescription() != null
397               && parm.getDescription().trim().length() > 0)
398       {
399         // Only create description boxes if there actually is a description.
400         if (finfo != null)
401         {
402           showDesc.setToolTipText(JvSwingUtils.wrapTooltip(
403                   true,
404                   MessageManager
405                           .formatMessage(
406                                   "label.opt_and_params_show_brief_desc_image_link",
407                                   new String[] { linkImageURL
408                                           .toExternalForm() })));
409           showDesc.addMouseListener(this);
410         }
411         else
412         {
413           showDesc.setToolTipText(JvSwingUtils.wrapTooltip(
414                   true,
415                   MessageManager
416                           .getString("label.opt_and_params_show_brief_desc")));
417         }
418         showDesc.addActionListener(new ActionListener()
419         {
420
421           @Override
422           public void actionPerformed(ActionEvent e)
423           {
424             descisvisible = !descisvisible;
425             descPanel.setVisible(descisvisible);
426             descPanel.getVerticalScrollBar().setValue(0);
427             me.setPreferredSize(new Dimension(PARAM_WIDTH,
428                     (descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT));
429             me.validate();
430             pmdialogbox.refreshParamLayout();
431           }
432         });
433         string.setWrapStyleWord(true);
434         string.setLineWrap(true);
435         string.setColumns(32);
436         string.setText(parm.getDescription());
437         showDesc.setBounds(new Rectangle(10, 10, 16, 16));
438         firstrow.add(showDesc);
439       }
440       add(firstrow);
441       validator = parm.getValidValue();
442       parameter = parm;
443       if (validator != null)
444       {
445         integ = validator.getType() == ValueType.Integer;
446       }
447       else
448       {
449         if (parameter.getPossibleValues() != null)
450         {
451           choice = true;
452         }
453       }
454       updateControls(parm);
455       descPanel.setBounds(new Rectangle(10, PARAM_CLOSEDHEIGHT,
456               PARAM_WIDTH - 20, PARAM_HEIGHT - PARAM_CLOSEDHEIGHT - 5));
457       add(descPanel);
458       validate();
459     }
460
461     @Override
462     public void actionPerformed(ActionEvent e)
463     {
464       if (adjusting)
465       {
466         return;
467       }
468       if (!choice)
469       {
470         updateSliderFromValueField();
471       }
472       checkIfModified();
473     }
474
475     private void checkIfModified()
476     {
477       Object cstate = updateSliderFromValueField();
478       boolean notmod = false;
479       if (cstate.getClass() == lastVal.getClass())
480       {
481         if (cstate instanceof int[])
482         {
483           notmod = (((int[]) cstate)[0] == ((int[]) lastVal)[0]);
484         }
485         else if (cstate instanceof float[])
486         {
487           notmod = (((float[]) cstate)[0] == ((float[]) lastVal)[0]);
488         }
489         else if (cstate instanceof String[])
490         {
491           notmod = (((String[]) cstate)[0].equals(((String[]) lastVal)[0]));
492         }
493       }
494       pmdialogbox.argSetModified(this, !notmod);
495     }
496
497     @Override
498     public int getBaseline(int width, int height)
499     {
500       return 0;
501     }
502
503     // from
504     // http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout
505     // helpful hint of using the Java 1.6 alignBaseLine property of FlowLayout
506     @Override
507     public Component.BaselineResizeBehavior getBaselineResizeBehavior()
508     {
509       return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
510     }
511
512     public int getBoxHeight()
513     {
514       return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT);
515     }
516
517     public ParameterI getParameter()
518     {
519       ParameterI prm = parameter.copy();
520       if (choice)
521       {
522         prm.setValue((String) choicebox.getSelectedItem());
523       }
524       else
525       {
526         prm.setValue(valueField.getText());
527       }
528       return prm;
529     }
530
531     public void init()
532     {
533       // reset the widget's initial value.
534       lastVal = null;
535     }
536
537     @Override
538     public void mouseClicked(MouseEvent e)
539     {
540       if (e.isPopupTrigger()) // for Windows
541       {
542         showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
543       }
544     }
545
546     @Override
547     public void mouseEntered(MouseEvent e)
548     {
549       // TODO Auto-generated method stub
550
551     }
552
553     @Override
554     public void mouseExited(MouseEvent e)
555     {
556       // TODO Auto-generated method stub
557
558     }
559
560     @Override
561     public void mousePressed(MouseEvent e)
562     {
563       if (e.isPopupTrigger()) // for Mac
564       {
565         showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
566       }
567     }
568
569     @Override
570     public void mouseReleased(MouseEvent e)
571     {
572       // TODO Auto-generated method stub
573
574     }
575
576     @Override
577     public void stateChanged(ChangeEvent e)
578     {
579       if (!adjusting)
580       {
581         valueField.setText(""
582                 + ((integ) ? ("" + slider.getValue()) : ("" + slider
583                         .getValue() / 1000f)));
584         checkIfModified();
585       }
586
587     }
588
589     public void updateControls(ParameterI parm)
590     {
591       adjusting = true;
592       boolean init = (choicebox == null && valueField == null);
593       if (init)
594       {
595         if (choice)
596         {
597           choicebox = new JComboBox();
598           choicebox.addActionListener(this);
599           controlPanel.add(choicebox, BorderLayout.CENTER);
600         }
601         else
602         {
603           slider = new JSlider();
604           slider.addChangeListener(this);
605           valueField = new JTextField();
606           valueField.addActionListener(this);
607           valueField.addKeyListener(new KeyListener()
608           {
609
610             @Override
611             public void keyTyped(KeyEvent e)
612             {
613             }
614
615             @Override
616             public void keyReleased(KeyEvent e)
617             {
618               if (e.isActionKey())
619               {
620                 if (valueField.getText().trim().length() > 0)
621                 {
622                   actionPerformed(null);
623                 }
624               }
625             }
626
627             @Override
628             public void keyPressed(KeyEvent e)
629             {
630             }
631           });
632           valueField.setPreferredSize(new Dimension(60, 25));
633           controlPanel.add(slider, BorderLayout.WEST);
634           controlPanel.add(valueField, BorderLayout.EAST);
635
636         }
637       }
638
639       if (parm != null)
640       {
641         if (choice)
642         {
643           if (init)
644           {
645             List vals = parm.getPossibleValues();
646             for (Object val : vals)
647             {
648               choicebox.addItem(val);
649             }
650           }
651
652           if (parm.getValue() != null)
653           {
654             choicebox.setSelectedItem(parm.getValue());
655           }
656         }
657         else
658         {
659           valueField.setText(parm.getValue());
660         }
661       }
662       lastVal = updateSliderFromValueField();
663       adjusting = false;
664     }
665
666     public Object updateSliderFromValueField()
667     {
668       int iVal;
669       float fVal;
670       if (validator != null)
671       {
672         if (integ)
673         {
674           iVal = 0;
675           try
676           {
677             valueField.setText(valueField.getText().trim());
678             iVal = Integer.valueOf(valueField.getText());
679             if (validator.getMin() != null
680                     && validator.getMin().intValue() > iVal)
681             {
682               iVal = validator.getMin().intValue();
683               // TODO: provide visual indication that hard limit was reached for
684               // this parameter
685             }
686             if (validator.getMax() != null
687                     && validator.getMax().intValue() < iVal)
688             {
689               iVal = validator.getMax().intValue();
690               // TODO: provide visual indication that hard limit was reached for
691               // this parameter
692             }
693           } catch (Exception e)
694           {
695           }
696           ;
697           // update value field to reflect any bound checking we performed.
698           valueField.setText("" + iVal);
699           if (validator.getMin() != null && validator.getMax() != null)
700           {
701             slider.getModel().setRangeProperties(iVal, 1,
702                     validator.getMin().intValue(),
703                     validator.getMax().intValue() + 1, true);
704           }
705           else
706           {
707             slider.setVisible(false);
708           }
709           return new int[] { iVal };
710         }
711         else
712         {
713           fVal = 0f;
714           try
715           {
716             valueField.setText(valueField.getText().trim());
717             fVal = Float.valueOf(valueField.getText());
718             if (validator.getMin() != null
719                     && validator.getMin().floatValue() > fVal)
720             {
721               fVal = validator.getMin().floatValue();
722               // TODO: provide visual indication that hard limit was reached for
723               // this parameter
724               // update value field to reflect any bound checking we performed.
725               valueField.setText("" + fVal);
726             }
727             if (validator.getMax() != null
728                     && validator.getMax().floatValue() < fVal)
729             {
730               fVal = validator.getMax().floatValue();
731               // TODO: provide visual indication that hard limit was reached for
732               // this parameter
733               // update value field to reflect any bound checking we performed.
734               valueField.setText("" + fVal);
735             }
736           } catch (Exception e)
737           {
738           }
739           ;
740           if (validator.getMin() != null && validator.getMax() != null)
741           {
742             slider.getModel().setRangeProperties((int) (fVal * 1000f), 1,
743                     (int) (validator.getMin().floatValue() * 1000f),
744                     1 + (int) (validator.getMax().floatValue() * 1000f),
745                     true);
746           }
747           else
748           {
749             slider.setVisible(false);
750           }
751           return new float[] { fVal };
752         }
753       }
754       else
755       {
756         if (!choice)
757         {
758           slider.setVisible(false);
759           return new String[] { valueField.getText().trim() };
760         }
761         else
762         {
763           return new String[] { (String) choicebox.getSelectedItem() };
764         }
765       }
766
767     }
768   }
769
770   public static final int PARAM_WIDTH = 340;
771
772   public static final int PARAM_HEIGHT = 150;
773
774   public static final int PARAM_CLOSEDHEIGHT = 80;
775
776   public OptsAndParamsPage(OptsParametersContainerI paramContainer)
777   {
778     this(paramContainer, false);
779   }
780
781   public OptsAndParamsPage(OptsParametersContainerI paramContainer,
782           boolean compact)
783   {
784     poparent = paramContainer;
785     this.compact = compact;
786   }
787
788   public static void showUrlPopUp(JComponent invoker, final String finfo,
789           int x, int y)
790   {
791
792     JPopupMenu mnu = new JPopupMenu();
793     JMenuItem mitem = new JMenuItem(MessageManager.formatMessage(
794             "label.view_params", new String[] { finfo }));
795     mitem.addActionListener(new ActionListener()
796     {
797
798       @Override
799       public void actionPerformed(ActionEvent e)
800       {
801         Desktop.showUrl(finfo);
802
803       }
804     });
805     mnu.add(mitem);
806     mnu.show(invoker, x, y);
807   }
808
809   URL linkImageURL = getClass().getResource("/images/link.gif");
810
811   Map<String, OptionBox> optSet = new java.util.LinkedHashMap<String, OptionBox>();
812
813   Map<String, ParamBox> paramSet = new java.util.LinkedHashMap<String, ParamBox>();
814
815   public Map<String, OptionBox> getOptSet()
816   {
817     return optSet;
818   }
819
820   public void setOptSet(Map<String, OptionBox> optSet)
821   {
822     this.optSet = optSet;
823   }
824
825   public Map<String, ParamBox> getParamSet()
826   {
827     return paramSet;
828   }
829
830   public void setParamSet(Map<String, ParamBox> paramSet)
831   {
832     this.paramSet = paramSet;
833   }
834
835   OptsParametersContainerI poparent;
836
837   OptionBox addOption(OptionI opt)
838   {
839     OptionBox cb = optSet.get(opt.getName());
840     if (cb == null)
841     {
842       cb = new OptionBox(opt);
843       optSet.put(opt.getName(), cb);
844       // jobOptions.add(cb, FlowLayout.LEFT);
845     }
846     return cb;
847   }
848
849   ParamBox addParameter(ParameterI arg)
850   {
851     ParamBox pb = paramSet.get(arg.getName());
852     if (pb == null)
853     {
854       pb = new ParamBox(poparent, arg);
855       paramSet.put(arg.getName(), pb);
856       // paramList.add(pb);
857     }
858     pb.init();
859     // take the defaults from the parameter
860     pb.updateControls(arg);
861     return pb;
862   }
863
864   void selectOption(OptionI option, String string)
865   {
866     OptionBox cb = optSet.get(option.getName());
867     if (cb == null)
868     {
869       cb = addOption(option);
870     }
871     cb.enabled.setSelected(string != null); // initial state for an option.
872     if (string != null)
873     {
874       if (option.getPossibleValues().contains(string))
875       {
876         cb.val.setSelectedItem(string);
877       }
878       else
879       {
880         throw new Error(MessageManager.formatMessage(
881                 "error.invalid_value_for_option", new String[] { string,
882                     option.getName() }));
883       }
884
885     }
886     if (option.isRequired() && !cb.enabled.isSelected())
887     {
888       // TODO: indicate paramset is not valid.. option needs to be selected!
889     }
890     cb.setInitialValue();
891   }
892
893   void setParameter(ParameterI arg)
894   {
895     ParamBox pb = paramSet.get(arg.getName());
896     if (pb == null)
897     {
898       addParameter(arg);
899     }
900     else
901     {
902       pb.updateControls(arg);
903     }
904
905   }
906
907   /**
908    * recover options and parameters from GUI
909    * 
910    * @return
911    */
912   public List<ArgumentI> getCurrentSettings()
913   {
914     List<ArgumentI> argSet = new ArrayList<ArgumentI>();
915     for (OptionBox opts : getOptSet().values())
916     {
917       OptionI opt = opts.getOptionIfEnabled();
918       if (opt != null)
919       {
920         argSet.add(opt);
921       }
922     }
923     for (ParamBox parambox : getParamSet().values())
924     {
925       ParameterI parm = parambox.getParameter();
926       if (parm != null)
927       {
928         argSet.add(parm);
929       }
930     }
931
932     return argSet;
933   }
934
935 }