package smart_gs.image_search.normal.swingui;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JCheckBox;

import smart_gs.image_search.logical.SearchResult;

public class CheckActionForTranscription implements ItemListener {
	
	TranscriptionToolNo1Frame parent;
	SearchResult result;
	JCheckBox checkbox;

	public CheckActionForTranscription(TranscriptionToolNo1Frame parent,
			JCheckBox checkbox, SearchResult searchResult) {
		this.parent = parent;
		this.checkbox = checkbox;
		this.result = searchResult;
	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		if(e.getStateChange() == ItemEvent.SELECTED) {
			this.parent.getSelectedResults().add(this.result);
			this.checkbox.setSelected(true);
		} else {
			this.parent.getSelectedResults().remove(this.result);
			this.checkbox.setSelected(false);
		}
		this.checkbox.updateUI();
	}

}
