import se.datadosen.component.*;
import se.datadosen.util.*;

// Read localized strings to use in user interface
pluginDirectory = new File(skinDirectory + "/plugins", "Example plugin");
SmartResourceBundle texts = SmartResourceBundle.getBundle(new File(pluginDirectory, "texts"), "texts");
String pluginName = texts.getString("pluginName");

// Get JAlbum's skin tab component
ControlPanel ui = window.getSkinUI();

// Get skin's tab component so we can add a tab
Component[] comps = ui.getComponents();
JTabbedPane tabs = null;
for(int i = 0; i < comps.length; i++) {
	if (comps[i].getName().equals("XPTabs") && comps[i] instanceof JTabbedPane) {
		tabs = comps[i];
		break;
	}
}
if (tabs == null) {
	window.messageBox("Error: The example plugin could not find the XPTabs");
}


// Declare all of the UI elements
ControlPanel exampleUI = new ControlPanel() {
	JLabel Label1 = new JLabel(texts.getString("ui.Label1"));
	JCheckBox CheckBox1 = new JCheckBox(texts.getString("ui.CheckBox_1"), true);
};

// Make control variables available to the skin and other scripts
application.put("exampleUI", exampleUI);

// Add UI elements to examplePanel pane
ControlPanel examplePanel = new ControlPanel(pluginName);
RiverLayout layout = (RiverLayout)examplePanel.getLayout();
layout.setHgap(0);
layout.setVgap(5);

RiverLayout layout = (RiverLayout)exampleUI.getLayout();
layout.setVgap(1);
examplePanel.add("p hfill", exampleUI.Label1);
examplePanel.add("p", exampleUI.CheckBox1);


// Consolidate the examplePanel into a JScrollPane
JScrollPane exampleScrollPane = new JScrollPane();
exampleScrollPane.getViewport().add(examplePanel, null);

// Add search1 UI into skin tabs
tabs.add(exampleScrollPane, pluginName = texts.getString("pluginName"));
window.setSkinUI(exampleUI);

