/**
 * THE TabbedBox.java WRITEME...
 */
package com.tootsville.tootsbook.client.panel;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Widget;
import com.tootsville.tootsbook.client.pages.StoreInventoryPanel;

/**
 * WRITEME: Document this type. twheys@gmail.com Feb 23, 2010
 * 
 * @author <a href="mailto:twheys@gmail.com@resinteractive.com">Tim
 *         Heys</a>
 * 
 */
public class TabbedBox extends Box {

	/**
	 * Same as #content, but overridden in child class for better
	 * reference
	 */
	private final PrettyTabPanel tabbedContent;

	/**
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * A TabbedBox WRITEME...
	 * 
	 */
	public TabbedBox () {
		this (new PrettyTabPanel ());
	}

	/**
	 * 
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * A TabbedBox WRITEME...
	 * 
	 * @param header
	 */
	public TabbedBox (final String header) {
		this (new PrettyTabPanel (), header);
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * A TabbedBox WRITEME...
	 * 
	 * @param header
	 * @param footer
	 * @param click
	 */
	public TabbedBox (final String header, final String footer,
			final ClickHandler click) {
		this (new PrettyTabPanel (), header, footer, click);
	}

	/**
	 * 
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * A TabbedBox WRITEME...
	 * 
	 * @param header
	 * @param footer
	 * @param url
	 */
	public TabbedBox (final String header, final String footer,
			final String url) {
		this (new PrettyTabPanel (), header, footer, url);
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * A TabbedBox WRITEME...
	 * 
	 * @param w
	 */
	private TabbedBox (final Widget w) {
		super (w);
		tabbedContent = (PrettyTabPanel) content;
	}

	/**
	 * Create a box with a header.
	 * 
	 * You MUST call {@link Box#pack()} after creating this instance.
	 * 
	 * @param w Widget to be added
	 * @param header String for text on header
	 */
	private TabbedBox (final Widget w, final String header) {
		super (w, header);
		tabbedContent = (PrettyTabPanel) content;
	}

	/**
	 * Create a box with a header and a link in the footer.
	 * 
	 * You MUST call {@link Box#pack()} after creating this instance.
	 * 
	 * @param w Widget to be added
	 * @param header String for text on header
	 * @param footer String for link on footer
	 * @param click ClickHandler for footer instead of using a URL
	 */
	private TabbedBox (final Widget w, final String header,
			final String footer, final ClickHandler click) {
		super (w, header, footer, click);
		tabbedContent = (PrettyTabPanel) content;
	}

	/**
	 * Create a box with a header and a link in the footer.
	 * 
	 * You MUST call {@link Box#pack()} after creating this instance.
	 * 
	 * @param w Widget to be added
	 * @param header String for text on header
	 * @param footer String for link on footer
	 * @param url URL for link on footer
	 */
	private TabbedBox (final Widget w, final String header,
			final String footer, final String url) {
		super (w, header, footer, url);
		tabbedContent = (PrettyTabPanel) content;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * TO addTab WRITEME...
	 * 
	 * @param w
	 * @param tabTitle
	 */
	public void addTab (final Widget w, final String tabTitle) {
		tabbedContent.addTab (w, tabTitle);
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 23, 2010
	 * </pre>
	 * 
	 * TO selectTab WRITEME...
	 * 
	 * @param index
	 */
	public void selectTab (final int index) {
		tabbedContent.selectTab (index);
		final StoreInventoryPanel storePanel = (StoreInventoryPanel) tabbedContent
				.getWidget (index);
		storePanel.loadItems ();
	}
}
