
// Project: webCDwriter - Network CD Writing
// Author: Jörg Haeger, 15.05.2001

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

public class SaveDialog extends Dialog
{
	public SaveDialog()
	{
		super("SDTitle");

		JPanel panel = new JPanel()
		{
			public Insets getInsets() {
				return new Insets(10, 10, 10, 10);
			}
		};
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

		ListProjects lp = new ListProjects();
		try {
			lp.exec();
		} catch (CommandError e) {}
		list = new JList(lp.getStrings());
		list.addListSelectionListener(new ListSelectionListener()
		{
			public void valueChanged(ListSelectionEvent e)
			{
				String value = (String)list.getSelectedValue();
				if (value != null)
					nameField.setText(value);
			}
		});
		list.setAlignmentX(LEFT_ALIGNMENT);
		panel.add(list);

		nameField = new JTextField(State.sessionID);
		nameField.setColumns(10);
		panel.add(createLabelItemBox(
			new JLabel(i18n("SDName")),
			nameField));

		storeBox = new JCheckBox(i18n("SDStoreSession"));
		panel.add(storeBox);

		getContentPane().add(panel, BorderLayout.CENTER);
		getContentPane().add(createControlPanel("SDSave"),
			BorderLayout.SOUTH);
		pack();
	}

	protected boolean apply()
	{
		if (nameField.getText().equals(""))
			return false;
		State.sessionID = nameField.getText();
		return true;
	}

	boolean isStoreSet()
	{
		return storeBox.isSelected();
	}

	JCheckBox storeBox;
	JList list;
	JTextField nameField;
}
