package hibergui.assoc;

import static hibergui.HiberGUI.MULTIPLE_SELECTION;

import java.util.Collection;

import hibergui.Form;

import org.eclipse.swt.widgets.Composite;

public abstract class M2MEdit<T, C extends Collection<T>> extends AssociationEdit<T, C> {

	public M2MEdit(Form<?> form, Composite cptParent, int style, String prop, String name) {
		super(form, cptParent, style, prop, name);
	}

    protected abstract Form<T> createForm(Composite cptParent, int style);

    protected Form<T> createForm(Composite cptParent) {
    	return createForm(cptParent, MULTIPLE_SELECTION);
    }
    
	@Override
	protected void setSelection(T[] result) {
		add(result);
		set(extract());
	}
	
	protected abstract void add(T[] objects);
	
}
