package dnd;


import java.util.ArrayList;
import java.util.List;

import javax.faces.event.ActionEvent;

import org.richfaces.component.html.HtmlDragIndicator;
import org.richfaces.component.html.HtmlDragSupport;
import org.richfaces.component.html.HtmlDropSupport;
import org.richfaces.event.DragEvent;
import org.richfaces.event.DropEvent;

import util.componentInfo.ComponentInfo;



public class DndBean {

	private List types = new ArrayList();
	private Object dragValue;
	private Object testParam;
	private String actionDrop;
	private String actionListenerDrop;
	private String actionDrag;
	private String actionListenerDrag;
	private HtmlDropSupport htmlDropSupport = null;
	private HtmlDragSupport htmlDragSupport = null;
	private HtmlDragIndicator htmlDragIndicator = null;

	public void addHtmlDnD(){
		ComponentInfo info = ComponentInfo.getInstance();
		info.addField(htmlDropSupport);
		info.addField(htmlDragSupport);
		info.addField(htmlDragIndicator);
	}
	
	public HtmlDropSupport getHtmlDropSupport() {
		return htmlDropSupport;
	}

	public void setHtmlDropSupport(HtmlDropSupport htmlDropSupport) {
		this.htmlDropSupport = htmlDropSupport;
	}

	public HtmlDragSupport getHtmlDragSupport() {
		return htmlDragSupport;
	}

	public void setHtmlDragSupport(HtmlDragSupport htmlDragSupport) {
		this.htmlDragSupport = htmlDragSupport;
	}

	public HtmlDragIndicator getHtmlDragIndicator() {
		return htmlDragIndicator;
	}

	public void setHtmlDragIndicator(HtmlDragIndicator htmlDragIndicator) {
		this.htmlDragIndicator = htmlDragIndicator;
	}

	public DndBean() {
		super();

		types.add("One");
		types.add("Two");
		
		actionDrag = "---";
		actionListenerDrag = "---";
		actionDrop = "---";
		actionListenerDrop = "---";
	}
	
	public void actListenerDrag(ActionEvent e) {
		actionListenerDrag = "actionListenerDrag work!";
	}

	public void actListenerDrop(ActionEvent e) {
		actionListenerDrop = "actionListenerDrop work!";
	}

	public void processDrop(DropEvent event) {
		System.out.println("Bean.processDrop()" + event.getDropValue());
		this.dragValue = event.getDragValue();
	}

	public void processDrag(DragEvent event) {
		System.out.println("Bean.processDrag()"+ event.getDropValue());
	}

	public List getTypes() {
		return types;
	}

	public String dragAction() {
		System.out.println("Bean.dragAction()");
		actionDrag = "actionDtag work!";
		return null;
	}

	public String dropAction() {
		System.out.println("Bean.dropAction()");
		actionDrop = "actionDrop work!";
		return null;
	}

	public Object getDragValue() {
		return dragValue;
	}

	public Object getTestParam() {
		return testParam;
	}

	public void setTestParam(Object testParam) {
		this.testParam = testParam;
		System.out.println("Bean.setTestParam()" + testParam);
	}

	public String getActionDrop() {
		return actionDrop;
	}

	public void setActionDrop(String actionDrop) {
		this.actionDrop = actionDrop;
	}

	public String getActionListenerDrop() {
		return actionListenerDrop;
	}

	public void setActionListenerDrop(String actionListenerDrop) {
		this.actionListenerDrop = actionListenerDrop;
	}

	public String getActionDrag() {
		return actionDrag;
	}

	public void setActionDrag(String actionDrag) {
		this.actionDrag = actionDrag;
	}

	public String getActionListenerDrag() {
		return actionListenerDrag;
	}

	public void setActionListenerDrag(String actionListenerDrag) {
		this.actionListenerDrag = actionListenerDrag;
	}
}