001package fi.jyu.mit.fxgui;
002
003import java.util.ArrayList;
004
005import javafx.beans.value.ChangeListener;
006import javafx.scene.control.CheckBox;
007
008/**
009 * Simple CheckBoxchooser
010 * @author terop
011 *@version 13.1.2017
012 * @param <T> type of objects to save
013 */
014public class CheckBoxChooser<T> extends BaseBoxChooser<T, CheckBox> {
015
016        @Override
017        protected void removeListener(CheckBox node, ArrayList<ChangeListener<Boolean>> list) {
018                for (ChangeListener<Boolean> changeListener : list) {
019                        node.selectedProperty().removeListener(changeListener);
020                }
021                
022        }
023
024
025        @Override
026        protected CheckBox addCorrectComponent(String name, T object) {
027                CheckBox box = new CheckBox(name);
028                box.setMnemonicParsing(true);
029                return box;
030        }
031
032        
033        @Override
034        protected void addChangeListener(CheckBox box, ChangeListener<Boolean> listener) {
035                box.selectedProperty().addListener(listener);
036        }
037
038
039        @Override
040        protected boolean isComponentSelected(CheckBox component) {
041                return component.selectedProperty().get();
042        }
043
044
045    @Override
046    protected boolean setComponentSelected(CheckBox component, boolean value) {
047        boolean oldSelect = isComponentSelected(component);
048        component.selectedProperty().set(value);
049        return oldSelect;
050    }
051
052}