MOA 12.03
Real Time Analytics for Data Streams
MultiChoiceOptionEditComponent.java
Go to the documentation of this file.
00001 /*
00002  *    MultiChoiceOptionEditComponent.java
00003  *    Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
00004  *    @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
00005  *
00006  *    This program is free software; you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation; either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    This program is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  *    
00019  */
00020 package moa.gui;
00021 
00022 import javax.swing.JComboBox;
00023 
00024 import moa.options.MultiChoiceOption;
00025 import moa.options.Option;
00026 
00033 public class MultiChoiceOptionEditComponent extends JComboBox implements
00034         OptionEditComponent {
00035 
00036     private static final long serialVersionUID = 1L;
00037 
00038     protected MultiChoiceOption editedOption;
00039 
00040     public MultiChoiceOptionEditComponent(MultiChoiceOption option) {
00041         super(option.getOptionLabels());
00042         this.editedOption = option;
00043         setSelectedIndex(option.getChosenIndex());
00044     }
00045 
00046     @Override
00047     public void applyState() {
00048         this.editedOption.setChosenIndex(getSelectedIndex());
00049     }
00050 
00051     @Override
00052     public Option getEditedOption() {
00053         return this.editedOption;
00054     }
00055 
00056     @Override
00057     public void setEditState(String cliString) {
00058         MultiChoiceOption tempOpt = (MultiChoiceOption) this.editedOption.copy();
00059         tempOpt.setValueViaCLIString(cliString);
00060         setSelectedIndex(tempOpt.getChosenIndex());
00061     }
00062 }
 All Classes Namespaces Files Functions Variables Enumerations