package dataScroller;

import java.util.ArrayList;

import javax.faces.event.ActionEvent;

import org.richfaces.event.DataScrollerEvent;

public class DataScroller {
	
	private ArrayList dataTable;
	public Data tD;
	public String align;
	public String fastControls;
	public boolean render;
	public boolean renderIfSinglePage;
	public boolean limitToList; 
	public boolean renderTable;
	public int maxPages;
    private String action;
    private String actionListener;

    public String act() {
		action = "action work!";
		return null;
	}

	public String actListener(ActionEvent e) {
		actionListener = "actionListener work!";
		return null;
	}
    
	public String getAction() {
		return action;
	}

	public String getActionListener() {
		return actionListener;
	}

	public boolean isRenderTable() {
		return renderTable;
	}

	public void setRenderTable(boolean renderTable) {
		this.renderTable = renderTable;
	}

	public String getFastControls() {
		return fastControls;
	}

	public void setFastControls(String fastControls) {
		this.fastControls = fastControls;
	}

	public int getMaxPages() {
		return maxPages;
	}

	public void setMaxPages(int maxPages) {
		this.maxPages = maxPages;
	}

	public DataScroller() {
		action = "---";
		actionListener = "---";
		fastControls = "auto";
		render = true;
		renderIfSinglePage = true;
		align = "left";
		maxPages = 20;
		limitToList = false;
		
		
		dataTable = new ArrayList();
		
		for(int i=0;i<1000;i++)
		{
			dataTable.add(new Data("Random",i));
		}	
				
	}
	
	public void CutArray(){
		int k = dataTable.size()-1;
		for(int i = k ;i > (k+1)/2; i--)
		{
			dataTable.remove(i);						
		}
	}
	
	public void RestoreArray(){
		
		int k = dataTable.size()-1;
		for(int i = k;i < (k+1)*2;i++)
		{
			dataTable.add(new Data("Random",i));
		}	
	}
	
	public ArrayList getDataTable() {
		return dataTable;
	}

	public void setDataTable(ArrayList dataTable) {
		this.dataTable = dataTable;
	}
	
	public void ScrollerListener(DataScrollerEvent e){
		
		System.out.println("NewScrollValue: "+e.getNewScrolVal());
		System.out.println("OldScrollValue: "+e.getOldScrolVal());
	}

	public Data getTD() {
		return tD;
	}

	public void setTD(Data td) {
		tD = td;
	}

	public boolean isRender() {
		return render;
	}

	public void setRender(boolean render) {
		this.render = render;
	}

	public boolean isRenderIfSinglePage() {
		return renderIfSinglePage;
	}

	public void setRenderIfSinglePage(boolean renderIfSinglePage) {
		this.renderIfSinglePage = renderIfSinglePage;
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
	}

	public boolean isLimitToList() {
		return limitToList;
	}

	public void setLimitToList(boolean limitToList) {
		this.limitToList = limitToList;
	}

	public void bTest1(){
		setAlign("left");
		setFastControls("auto");
		setLimitToList(false);
		setMaxPages(20);
		setRenderIfSinglePage(true);
	}
	
	public void bTest2(){
		setAlign("right");
		setFastControls("show");
		setLimitToList(false);
		setMaxPages(30);
		setRenderIfSinglePage(false);
	}
	
	public void bTest3(){
		setAlign("center");
		setFastControls("hide");
		setLimitToList(false);
		setMaxPages(10);
		setRenderIfSinglePage(true);
	}
	
	public void bTest4(){
		setAlign("center");
		setFastControls("auto");
		setLimitToList(true);
		setMaxPages(30);
		setRenderIfSinglePage(false);
	}
	
	public void bTest5(){
		setAlign("left");
		setFastControls("show");
		setLimitToList(false);
		setMaxPages(40);
		setRenderIfSinglePage(true);
	}
}
