package zemplen.ui;

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

import zemplen.model.Allomas;
import zemplen.model.Verseny;
import hibergui.Form;
import hibergui.hibernate.HibernateM2OEdit_Combo;

public class AllomasCombo extends HibernateM2OEdit_Combo<Allomas> {

	private Verseny verseny;
	
	public AllomasCombo(Form form, Composite cptParent, int style) {
		super(form, cptParent, style, "allomas", "állomás", "elnevezes");

		btnAssoc.setText("Állomások");
	}

    public void fixVerseny(Verseny verseny) {
    	this.verseny = verseny;
    	refresh();
    }

	@Override
    protected Form<Allomas> createForm(Composite cptParent, int style) {
		AllomasForm f = new AllomasForm(cptParent, style);
		f.eVerseny.set(verseny);
		f.eVerseny.fix(true);
		return f;
    }

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