package ${package};

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import static hibergui.HiberGUI.*;
import hibergui.hibernate.HibernateForm;
import hibergui.property.StringEdit;

import ${form.class};

public class ${form.name} extends HibernateForm<${form.class}>{
	String title;
	public ${form.name} (Composite cptParent, int mode){
		title=${form.title};
		super(cptParent, mode);
		setWindowTitle(${form.title});
	}
	
	@Override
    protected Composite createFields(Composite cptParent) {
		Composite cptFields = new Composite(cptParent, SWT.BORDER);
        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        cptFields.setLayout(gridLayout);        
        GridData data;
        
               
        <#list form?children as f>        
        <#if f?node_name ='label'>         
           new Label(cptFields, SWT.NONE).setText("${f.@name}");
        <#elseif f?node_name='edit'>          
           ${f.@type} ${f.@name};                      
           ${f.name} = new ${f.type}(this, cptFields, NONE 
        		   
        		   /*itt kell vizsgálni majd a par. létezését*/        		   
        		   , "${f.@property}"
        		   , "${f.@name}"
        		   );
           
           data = new GridData(GridData.FILL_HORIZONTAL);        
           ${f.[i].name}.setLayoutData(data);           
        </#if>         
        </#list>
        return cptFields;
        
        <#list form.label as label>
        new Label(cptFields, SWT.NONE).setText("${label.name}");
        </#list>
        
        eNev = new StringEdit(this, cptFields, NONE, "${form.edit.property}", "${form.edit.name}");
        data = new GridData(GridData.FILL_HORIZONTAL);        
        eNev.setLayoutData(data);
        
        return cptFields;
	}
	
	 @Override
	    protected void createColumnsForTable() {
	        addColumn(SWT.LEFT, "${form.edit.property}", "${form.edit.name}", 200);
	    }
}
