/** 
 * This script is being run when a skin is selected
 * The script produces a user interface that lets the user select transition effects
 * between slide show images.
 * This script currently only has UI controls for optional transition attributes
 * for the "Barn" and "Blinds" transitions, but it is easy to add more. Please see
 * http://msdn.microsoft.com/workshop/author/filter/reference/reference.asp
 * for a full reference if you care to continue adding cool filter attributes.
 * Author David Ekholm
 */
 
import se.datadosen.component.*;
import se.datadosen.util.*;

Map transitionUIs = new HashMap(); // Container for transition-specific controls

// Controls that are to be imported into JAlbum as variables
ControlPanel ui = new ControlPanel() {

	JComboBox transition = new JComboBox(new Object[]
	 {"None", "Barn", "Blinds", "CheckerBoard", "Fade", "GradientWipe", "Inset", "Iris", "Pixelate", "RadialWipe", "RandomBars", "RandomDissolve", "Slide", "Spiral", "Stretch", "Strips", "Wheel", "Zigzag" }
	);
	Attributizer attrs = new Attributizer();
	ControlPanel transitionUI;
};

// Install listener that handles swapping transition UIs
ui.transition.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
	ControlPanel newUI = (ControlPanel)transitionUIs.get(ui.transition.getSelectedItem());
	if (ui.transitionUI != null) {
		ui.remove(ui.transitionUI);
		ui.transitionUI = null;
		
	}
	ui.attrs.setTarget(null);
	if (newUI != null) {
		ui.transitionUI = newUI;
		ui.add("p hfill", ui.transitionUI);
		ui.attrs.setTarget(newUI);
		ui.validate();
	}
    }
});


// Install custom user interfaces for selected transitions

/**
 * Barn
 */
ControlPanel barnUI = new ControlPanel() {
	JTextField duration = new JTextField(3);
	JComboBox motion = new JComboBox(new Object[] { "out", "in" });
	JComboBox orientation = new JComboBox(new Object[] { "horizontal", "vertical" });
};
barnUI.setTitle("Barn properties");
barnUI.duration.setText("2");
barnUI.add(new JLabel("Duration"));
barnUI.add("tab", barnUI.duration);
barnUI.add("br", new JLabel("Motion"));
barnUI.add("tab", barnUI.motion);
barnUI.add("br", new JLabel("Orientation"));
barnUI.add("tab", barnUI.orientation);
transitionUIs.put("Barn", barnUI);

/**
 * Blinds
 */
ControlPanel blindsUI = new ControlPanel() {
	JTextField duration = new JTextField(3);
	JTextField bands = new JTextField(3);
	JComboBox direction = new JComboBox(new Object[] { "up", "down", "right", "left" });
};
blindsUI.setTitle("Blinds properties");
blindsUI.duration.setText("2");
blindsUI.bands.setText("10");
blindsUI.add(new JLabel("Duration"));
blindsUI.add("tab", blindsUI.duration);
blindsUI.add("br", new JLabel("Bands"));
blindsUI.add("tab", blindsUI.bands);
blindsUI.add("br", new JLabel("Direction"));
blindsUI.add("tab", blindsUI.direction);
transitionUIs.put("Blinds", blindsUI);


// Layout controls easily similar to how text is added in a word processor
ui.add("p", new JLabel("Transition effect"));
ui.add("tab", ui.transition);
ui.add(new JLabel("(Requires Internet Explorer 5.5)"));

// Finally install components into JAlbum
window.setSkinUI(ui);
