package es.dalocar.facturamas.swt.list;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

import es.dalocar.facturamas.swt.SWTUtils;
import es.dalocar.facturamas.swt.components.NumElementosComposite;
import es.dalocar.facturamas.swt.components.ThreeButtonsComposite;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.FormAttachment;
     

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ListaComposite extends Composite {

	 
	private Table tabla;
	private NumElementosComposite numElementosComposite;
	private ThreeButtonsComposite threeButtonsComposite;

	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public ListaComposite(Composite parent, int style) {
		super(parent, style);
		setLayout(new FormLayout());
		
		tabla = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);
		FormData tablaLData = new FormData();
		tablaLData.top =  new FormAttachment(0, 1000, 12);
		tablaLData.left =  new FormAttachment(0, 100, 10);
		tabla.setLayoutData(tablaLData);
		tabla.setHeaderVisible(true);
		tabla.setLinesVisible(true);
		
		TableColumn tblclmnID = new TableColumn(tabla, SWT.NONE);
		tblclmnID.setWidth(40);
		tblclmnID.setText("ID");
		
		TableColumn tblclmnDescripcion = new TableColumn(tabla, SWT.NONE);
		tblclmnDescripcion.setWidth(228);
		tblclmnDescripcion.setText("Descripcion");
		
		TableColumn tblclmnFecha = new TableColumn(tabla, SWT.NONE);
		tblclmnFecha.setWidth(100);
		tblclmnFecha.setText("Fecha");
		
		threeButtonsComposite = new ThreeButtonsComposite(this, SWT.NONE);
		FormData formData = new FormData();
		formData.top = new FormAttachment(0);
		formData.right = new FormAttachment(100);
		threeButtonsComposite.setLayoutData(formData);
		
		numElementosComposite = new NumElementosComposite(this, SWT.NONE);
		tablaLData.width = 340;
		tablaLData.height = 289;
		tablaLData.right =  new FormAttachment(1000, 1000, -255);
		tablaLData.bottom =  new FormAttachment(1000, 1000, -116);
		FormData formData_1 = new FormData();
		formData_1.right =  new FormAttachment(1000, 1000, -201);
		formData_1.left =  new FormAttachment(0, 1000, 11);
		formData_1.bottom =  new FormAttachment(1000, 1000, -46);
		formData_1.width = 414;
		formData_1.height = 62;
		numElementosComposite.setLayoutData(formData_1);
		numElementosComposite.setLayout(new FormLayout());

		
	}

	/**
	 * Metodo que abre deja el nuevo composite en el bucle de espera
	 * de eventos
	 */
	public void open(){
		final Display display = Display.getCurrent();
		Shell shell = this.getShell();
		Point size = this.getSize();
		shell.setLayout(new FillLayout());
		shell.layout();
		if(size.x == 0 && size.y == 0) {
			this.pack();
			shell.pack();
		} else {
			Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
			shell.setSize(shellBounds.width, shellBounds.height);
		}
		SWTUtils.openCentered(shell);
	}
	/**
	 * @return the tabla
	 */
	public Table getTabla() {
		return tabla;
	}

	/**
	 * @param tabla the tabla to set
	 */
	public void setTabla(Table tabla) {
		this.tabla = tabla;
	}

	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
	
	public NumElementosComposite getNumElementosComposite() {
		return numElementosComposite;
	}
	
	public ThreeButtonsComposite getThreeButtonsComposite() {
		return threeButtonsComposite;
	}
}
