package com.explodingpixels.macwidgets;

import java.awt.BorderLayout;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.explodingpixels.macwidgets.BottomBar;
import com.explodingpixels.macwidgets.BottomBarSize;
import com.explodingpixels.macwidgets.DBottomBar;
import com.explodingpixels.macwidgets.MacUtils;
import com.explodingpixels.macwidgets.MacWidgetFactory;
import com.explodingpixels.widgets.WindowUtils;

public class DBottomBarTest {
	private JFrame frame;
	@Before
	public void setUp() throws Exception {

	}

	@Test
	public void doTest() throws Exception {
		JButton leftButton = new JButton(
				new ImageIcon(
						DBottomBar.class
								.getResource("/com/explodingpixels/macwidgets/icons/AddItem16.png")));
		leftButton.putClientProperty("JButton.buttonType", "segmentedTextured");
		leftButton.putClientProperty("JButton.segmentPosition", "first");
		leftButton.setFocusable(false);

		JButton rightButton = new JButton(
				new ImageIcon(
						DBottomBar.class
								.getResource("/com/explodingpixels/macwidgets/icons/RemoveItem16.png")));
		rightButton
				.putClientProperty("JButton.buttonType", "segmentedTextured");
		rightButton.putClientProperty("JButton.segmentPosition", "last");
		rightButton.setFocusable(false);

		ButtonGroup group = new ButtonGroup();
		group.add(leftButton);
		group.add(rightButton);

		JButton lockButton = new JButton(new ImageIcon(DBottomBar.class
				.getResource("/com/explodingpixels/macwidgets/icons/lock.png")));
		lockButton.putClientProperty("JButton.buttonType", "textured");

		JTextArea textArea = new JTextArea();

		BottomBar bottomBar = new BottomBar(BottomBarSize.LARGE);
		bottomBar.addComponentToLeft(leftButton, 0);
		bottomBar.addComponentToLeft(rightButton);
		bottomBar.addComponentToCenter(MacWidgetFactory
				.createEmphasizedLabel("362 Items"));
		bottomBar.addComponentToRight(lockButton);

		frame = new JFrame();
		bottomBar.installWindowDraggerOnWindow(frame);
		MacUtils.makeWindowLeopardStyle(frame.getRootPane());
		WindowUtils.createAndInstallRepaintWindowFocusListener(frame);
		frame.add(bottomBar.getComponent(), BorderLayout.SOUTH);
		frame.add(textArea, BorderLayout.CENTER);
		frame.setSize(500, 350);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setVisible(true);
	}

	@After
	public void tearDown() throws Exception {
		frame.dispose();
	}
}