/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.web.utilerias.render;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Button;
import org.zkoss.zul.Div;
import org.zkoss.zul.Label;
import org.zkoss.zul.Radio;
import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.Textbox;

import com.rjconsultores.ventaboletos.entidad.RutaCombinacion;

/**
 * 
 * @author Rafius
 */
public class RenderCatalogoDeRutasCombinacionRow implements RowRenderer {

	public void render(Row row, java.lang.Object data) {

		RutaCombinacion rutaCombinacion = (RutaCombinacion) data;

		// the data append to each row with simple label
		Textbox text = new Textbox((rutaCombinacion.getIndventa() == Boolean.TRUE) ? "Si" : "No");
		text.setInplace(true);
		row.appendChild(text);

		Radio radio = new Radio();
		radio.setLabel("Si");
		// radio.setId("Si");
		radio.setChecked((rutaCombinacion.getIndventa() == Boolean.TRUE) ? Boolean.TRUE : Boolean.FALSE);
		Radio radio2 = new Radio();
		radio2.setLabel("No");
		// radio2.setId("No");
		radio2.setChecked((rutaCombinacion.getIndventa() == Boolean.TRUE) ? Boolean.FALSE : Boolean.TRUE);

		final Radiogroup radioGroup = new Radiogroup();
		radioGroup.setId("radioGroup" + rutaCombinacion.getTramo().getDesctramo());
		radioGroup.appendChild(radio);
		radioGroup.appendChild(radio2);
		final Div d = new Div();
		radioGroup.setParent(d);
		radioGroup.addEventListener(Events.ON_CLICK, new EventListener() {

			public void onEvent(Event event) throws Exception {

				String retorno = radioGroup.getSelectedItem().getLabel();
				d.appendChild(new Label(retorno));
			}
		});
		row.appendChild(radioGroup);
		row.appendChild(new Label(rutaCombinacion.getTramo().getDesctramo()));

		// we create a thumb up/down comment to each row
		final Div d2 = new Div();
		final Button thumbBtn = new Button(null, "/gui/img/create_doc.gif");
		thumbBtn.setParent(d2);
		thumbBtn.addEventListener(Events.ON_CLICK, new EventListener() {

			public void onEvent(Event event) throws Exception {
				d2.appendChild(new Label("Desativado!!!"));
				thumbBtn.setDisabled(true);
				// Pega o MysListBox
				// List<RutaCombinacion> rc = new ArrayList<RutaCombinacion>();
				// rutaCombinacionList = (MyListbox)
				// d2.getFellow("rutaCombinacionList");

				// Pegar o dataGrid

				d2.getFellow("demoGrid");

			}
		});
		row.appendChild(d2); // Any component could created as a child of grid
	}
}
