/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sample.scatterplot.jsf;

import java.util.ArrayList;
import java.util.List;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.SelectItem;
import sample.scatterplot.persistence.PlotType;

/**
 *
 * A simple JSF bean to list the plot types and can select one of them.
 *
 * @author ricky
 */
@Named(value="plotTypeBean")
@RequestScoped
public class PlotTypeBean {

    private PlotType plotType;

    /** Creates a new instance of PlotTypeBien */
    public PlotTypeBean() {
        plotType = PlotType.values()[0];
    }

    public List<SelectItem> getPlotTypes() {
        List<SelectItem> selectItems = new ArrayList<SelectItem>();
        for (PlotType pt: PlotType.values()) {
            selectItems.add(new SelectItem(pt.name(), pt.getDescription()));
        }
        return selectItems;
    }

    public PlotType getPlotType() {
        return plotType;
    }

    public void setPlotType(PlotType plotType) {
        this.plotType = plotType;
    }

    public String getPlotTypeString() {
        return plotType.name();
    }

    public void setPlotTypeString(String plotType) {
        this.plotType = PlotType.valueOf(plotType);
    }

}

