package org.richfaces.realworld.slideshow;

import java.io.Serializable;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.richfaces.realworld.tree.TreeSelectionManager;
import org.richfaces.realworld.util.SlideshowHelper;

@Name("slideshow")
@Scope(ScopeType.CONVERSATION)
public class SlideshowBean implements Serializable{

	@In(required=false) @Out(required=false)
	SlideshowHelper slideshowHelper;
	
	@In
	TreeSelectionManager treeSelectionManager;
	
	private boolean active;
	
	private int interval = 10000;

	public int getInterval() {
		return interval;
	}

	public void setInterval(int interval) {
		this.interval = interval;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}
	
	public void startSlideshow(){
		active = true;
	}
	
	public void stopSlideshow(){
		active = false;
	}

	public void updateInterval(){
		this.setInterval((int)(1000 * Long.valueOf(slideshowHelper.getInputSlider().getValue().toString())));
	}
	
	public void incrementSlide(){
		treeSelectionManager.incrementSlideshowIndex();
	}
}
