
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.Properties;
import java.text.*;

public class WOR_sh_FormFrame2 extends JInternalFrame {

    static int openFrameCount = 0;
    static final int offset = 20;

	JTextField DesPSField;

	String if_wor, irTxt = "";
	String dsgns, desStg;
	String WOR_DIR 	= "./wor";
	String des_prop_val;

    public WOR_sh_FormFrame2 ( String if_wor ){

		super("", true, true, true, true);
		openFrameCount++;
		setTitle("PRODUCT DESIGN WORK ORDER REQUEST " + openFrameCount);

		JPanel topPanel = new JPanel();
		topPanel.setBorder(new EmptyBorder(1,1,1,1));
		topPanel.setLayout(new BorderLayout());

		des_prop_val = getdesarray();

		// Designers
		JPanel DesPanel = new JPanel();
		GridBagLayout gbc2 = new GridBagLayout();
		DesPanel.setLayout(gbc2);

		JPanel DesPSPanel = new JPanel();
		JLabel DesPSLabel = new JLabel ("Designer: ");
		DesPSField = new JTextField(desStg,19);
		DesPSPanel.add(DesPSLabel);
		DesPSPanel.add(DesPSField);

		//des_prop_val[] = get_des_props();
		desStg		= des_prop_val[0];

		JPanel DesCBPanel = new JPanel();
		final JComboBox dsgnsComboBox = new JComboBox(des_prop_val);
		dsgnsComboBox.setSelectedItem(desStg);
		DesCBPanel.add(dsgnsComboBox);

		dsgnsComboBox.addItemListener(
			new ItemListener() {
				public void itemStateChanged( ItemEvent e ) {
					if( e.getStateChange() == ItemEvent.SELECTED ){
						DesPSField.setText("" + ((JComboBox)e.getSource()).getSelectedItem());
					}
				}
			}
		);

		DesPanel.add(DesPSPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
			,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 1, 0));
		DesPanel.add(DesCBPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
			,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 1, 0));

		topPanel.add(DesPanel, BorderLayout.NORTH);

		setContentPane(topPanel);
		pack();
		setLocation( offset * openFrameCount, offset * openFrameCount);
    }

	public String getdesarray() {
		// Designers
		final String des_propsfile = "ROG_Des.properties";
		String ROG_DesSTG = "ROG_Des.";

		Properties des_props = new Properties ();

		try {
			InputStream in = new FileInputStream(des_propsfile);
			des_props.load(in);
			in.close();
		}
		catch (IOException e) {}

		//des_prop_val = new String[des_props.size()];
		String[] des_prop_val = new String[des_props.size()];

		for (int n = 0; n < des_props.size(); n++) {
			des_prop_val[n] = des_props.getProperty(ROG_DesSTG + n);
			System.out.println( n + ": " + des_prop_val[n] );
		}

		return (String)des_prop_val[];
	}

    public void ExitSelected() {
		this.setVisible(false);
	}

	public String getDes() {
		dsgns = DesPSField.getText();
		return dsgns;
	}
}
