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