package zemplen.ui;

import hibergui.Form;
import hibergui.hibernate.HibernateM2OEdit_Combo;

import org.eclipse.swt.widgets.Composite;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import zemplen.model.Tav;
import zemplen.model.Verseny;

public class TavCombo extends HibernateM2OEdit_Combo<Tav> {
	
	private Verseny verseny;
	
    public TavCombo(Form form, Composite cptParent, int style) {
		super(form, cptParent, style, "tav", "táv", "elnevezes");

		btnAssoc.setText("Távok");
	}
    
	public void fixVerseny(Verseny verseny) {
    	this.verseny = verseny;
    	refresh();
    }
    
	@Override
    protected Form<Tav> createForm(Composite cptParent, int style) {
    	TavForm f = new TavForm(cptParent, style);
    	f.eVerseny.set(verseny);
		f.eVerseny.fix(true);
    	return f;
    }

	@Override
	protected Criteria createCriteria() {
		return super.createCriteria().add(Restrictions.eq("verseny", verseny));
	}
}
