/*
 * Wind2ConfigMySQL.java
 *
 * Created on October 20, 2006, 8:33 PM
 */

/**
 *
 * @author  davarus
 */
import java.awt.*;

public class Wind2ConfigMySQL extends javax.swing.JPanel {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/** Creates new form Wind2ConfigMain */
    public Wind2ConfigMySQL(IniFile ini) {
        initComponents(ini);
    }

    public void saveIni (IniFile ini) {
    	if (checkEnable.isSelected())
		ini.setValue("MYSQL", "useMySQL", "true");
	else
		ini.setValue("MYSQL", "useMySQL", "false");
	ini.setValue("MYSQL", "username", textUsername.getText());
	ini.setValue("MYSQL", "password", textPassword.getText());
	ini.setValue("MYSQL", "hostname", textHostname.getText());
	ini.setValue("MYSQL", "database", textDatabase.getText());
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents(IniFile ini) {//GEN-BEGIN:initComponents
        labelUsername = new javax.swing.JLabel();
        textUsername  = new javax.swing.JTextField(10);
        labelPassword = new javax.swing.JLabel();
        textPassword = new javax.swing.JTextField(10);
        labelHostname = new javax.swing.JLabel();
        textHostname = new javax.swing.JTextField(10);
        labelDatabase = new javax.swing.JLabel();
        textDatabase  = new javax.swing.JTextField(10);
	checkEnable = new javax.swing.JCheckBox();

	GridBagLayout grid = new GridBagLayout();
	GridBagConstraints cons = new GridBagConstraints();
        setLayout(grid);

	cons.gridx = 0;
	cons.gridy = 0;
	cons.insets = new Insets(8, 8, 0, 8);
	grid.setConstraints(labelUsername, cons);
        labelUsername.setText("Username:");
        add(labelUsername);

	cons.gridx = 1;
	cons.gridy = 0;
	grid.setConstraints(textUsername, cons);
        textUsername.setText(ini.getValue("MYSQL", "username"));
        add(textUsername);

	cons.gridx = 0;
	cons.gridy = 1;
	cons.insets = new Insets(0, 8, 0, 8);
	grid.setConstraints(labelPassword, cons);
        labelPassword.setText("Password:");
        add(labelPassword);

	cons.gridx = 1;
	cons.gridy = 1;
	grid.setConstraints(textPassword, cons);
	textPassword.setText(ini.getValue("MYSQL", "password"));
        add(textPassword);
	
	cons.gridx = 0;
	cons.gridy = 2;
	cons.insets = new Insets(0, 8, 0, 8);
	grid.setConstraints(labelHostname, cons);
        labelHostname.setText("Hostname:");
        add(labelHostname);

	cons.gridx = 1;
	cons.gridy = 2;
	grid.setConstraints(textHostname, cons);
	textHostname.setText(ini.getValue("MYSQL", "hostname"));
        add(textHostname);

	cons.gridx = 0;
	cons.gridy = 3;
	cons.insets = new Insets(0, 8, 0, 8);
	grid.setConstraints(labelDatabase, cons);
        labelDatabase.setText("Database:");
        add(labelDatabase);

	cons.gridx = 1;
	cons.gridy = 3;
	grid.setConstraints(textDatabase, cons);
	textDatabase.setText(ini.getValue("MYSQL", "database"));
        add(textDatabase);

	cons.gridx = 0;
	cons.gridy = 4;
	cons.weighty = 0.6;
	cons.anchor = GridBagConstraints.PAGE_START;
	grid.setConstraints(checkEnable, cons);
	checkEnable.setText("Enable");
	checkEnable.setSelected(ini.isTrue("MYSQL", "useMySQL"));
	add(checkEnable);
    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel labelUsername;
    private javax.swing.JLabel labelPassword;
    private javax.swing.JLabel labelHostname;
    private javax.swing.JLabel labelDatabase;
    private javax.swing.JTextField textUsername;
    private javax.swing.JTextField textPassword;
    private javax.swing.JTextField textHostname;
    private javax.swing.JTextField textDatabase;
    private javax.swing.JCheckBox checkEnable;
    // End of variables declaration//GEN-END:variables
    
}
