SourceForge: bina/bina_plugin_bnppmysqldriver: changeset 4:1e012fef8c72
Help added default tip
authorgerasch
Wed Nov 04 14:58:41 2009 +0100 (6 weeks ago)
changeset 41e012fef8c72
parent 3 af709273a653
Help added
build.xml
src/org/bnplusplus/driver/sql/mysql/BNPlusPlusMySQLDataSource.java
src/org/bnplusplus/driver/sql/mysql/resources/files/mysql-help.html
src/org/bnplusplus/driver/sql/mysql/wizards/DatabaseWizardPage.java
src/org/bnplusplus/driver/sql/mysql/wizards/MySQLDatabaseWizardPage.java
     1.1 --- a/build.xml	Fri Oct 02 13:45:16 2009 +0200
     1.2 +++ b/build.xml	Wed Nov 04 14:58:41 2009 +0100
     1.3 @@ -1,12 +1,9 @@
     1.4 -<project name="BiNA BN++ MySQL Driver Plugin" default="publish" basedir=".">
     1.5 +<project name="BiNA BN++ MySQL Database Driver Plugin" default="publish" basedir=".">
     1.6  	<description>
     1.7 -        Ant build script for BiNA Core
     1.8 +        Ant build script for BiNAs MySQL Database Driver Plugin
     1.9      </description>
    1.10  
    1.11 -
    1.12 -	<import file="../bina_platform/global.xml"/>
    1.13 -			
    1.14 -	<target name="init" depends="base_init">
    1.15 +	<target name="init">
    1.16  		<tstamp/>
    1.17  		<property name="plugin_id" value="bnpp_mysql_driver"/>
    1.18  		
    1.19 @@ -23,7 +20,6 @@
    1.20  		<property name="lib_dir" value="lib/"/>
    1.21  		<property name="bin_dir" value="bin/"/>
    1.22  				
    1.23 -		<property name="resources_path" value="org/bnplusplus/driver/sql/mysql/resources" />
    1.24  		<property name="api" value="doc/"/>
    1.25  		
    1.26  		
    1.27 @@ -31,11 +27,10 @@
    1.28  		<property name="bnpp_model_jar" value="${platform_dir}plugins/org.bnplusplus.model/bnpp_model.jar"/>
    1.29  		<property name="bcp_jar" value="${platform_dir}plugins/org.bina.bcp/bcp.jar"/>
    1.30  		<property name="bnpp_sql_driver_jar" value="${platform_dir}plugins/org.bnplusplus.driver.sql/bnpp_sql_driver.jar"/>
    1.31 -				
    1.32 -		
    1.33 +
    1.34  		<property name="lib_mysql_connector" 	value="lib/mysql-connector-java-5.1.7-bin.jar"/>
    1.35  		
    1.36 -		<property name="bina_jar" value="${platform_dir}${platform_jar}" />
    1.37 +		<property name="bina_jar" value="${platform_dir}BiNA.jar" />
    1.38  		<property name="classpath" value="${bina_jar}:${bnpp_model_jar}:${bcp_jar}:${bnpp_sql_driver_jar}:${lib_mysql_connector}" />
    1.39  		
    1.40  		
    1.41 @@ -98,10 +93,6 @@
    1.42  		</copy>
    1.43  	</target>
    1.44  	
    1.45 -	<target name="Upload Plugin" depends="plugin">
    1.46 -		<antcall target="upload_plugin" />
    1.47 -	</target>
    1.48 -	
    1.49  	<!-- ====================================================== -->
    1.50  	<!-- JavaDocs -->
    1.51  	<!-- ====================================================== -->
    1.52 @@ -132,9 +123,5 @@
    1.53  		</javadoc>
    1.54  	</target>
    1.55  	
    1.56 -	<target name="Upload API" depends="docs">
    1.57 -		<antcall target="upload_api" />
    1.58 -	</target>
    1.59 -	
    1.60  </project>
    1.61  
     2.1 --- a/src/org/bnplusplus/driver/sql/mysql/BNPlusPlusMySQLDataSource.java	Fri Oct 02 13:45:16 2009 +0200
     2.2 +++ b/src/org/bnplusplus/driver/sql/mysql/BNPlusPlusMySQLDataSource.java	Wed Nov 04 14:58:41 2009 +0100
     2.3 @@ -22,7 +22,7 @@
     2.4  import org.bina.platform.gui.wizards.WizardPage;
     2.5  import org.bnplusplus.driver.sql.BNPlusPlusBasicSQLDataSource;
     2.6  import org.bnplusplus.driver.sql.SQLSelectStatement;
     2.7 -import org.bnplusplus.driver.sql.mysql.wizards.DatabaseWizardPage;
     2.8 +import org.bnplusplus.driver.sql.mysql.wizards.MySQLDatabaseWizardPage;
     2.9  
    2.10  /**
    2.11   * @author Andreas Gerasch
    2.12 @@ -90,7 +90,7 @@
    2.13      }
    2.14      
    2.15      public WizardPage getWizardPage() {
    2.16 -    	return new DatabaseWizardPage(null, this);
    2.17 +    	return new MySQLDatabaseWizardPage(null, this);
    2.18      }
    2.19      
    2.20      @Override
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/org/bnplusplus/driver/sql/mysql/resources/files/mysql-help.html	Wed Nov 04 14:58:41 2009 +0100
     3.3 @@ -0,0 +1,9 @@
     3.4 +<html>
     3.5 +<body>
     3.6 +If you want to use a <b>BN++ MySQL</b> database for main data source, you have 
     3.7 +to provide the hostname, database name, user login and password.<br/>
     3.8 +<br/>
     3.9 +If you like to use one of our <b>public</b> databases, please, get the current settings from our website
    3.10 +<a href="http://www.bnplusplus.org/">http://www.bnplusplus.org/</a>.
    3.11 +</body>
    3.12 +</html>
    3.13 \ No newline at end of file
     4.1 --- a/src/org/bnplusplus/driver/sql/mysql/wizards/DatabaseWizardPage.java	Fri Oct 02 13:45:16 2009 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,215 +0,0 @@
     4.4 -package org.bnplusplus.driver.sql.mysql.wizards;
     4.5 -
     4.6 -import java.awt.Color;
     4.7 -import java.awt.event.ActionEvent;
     4.8 -import java.awt.event.ActionListener;
     4.9 -import java.awt.event.KeyAdapter;
    4.10 -import java.awt.event.KeyEvent;
    4.11 -import java.sql.Connection;
    4.12 -import java.sql.DriverManager;
    4.13 -import java.sql.SQLException;
    4.14 -
    4.15 -import javax.swing.JButton;
    4.16 -import javax.swing.JLabel;
    4.17 -import javax.swing.JOptionPane;
    4.18 -import javax.swing.JPanel;
    4.19 -import javax.swing.JPasswordField;
    4.20 -import javax.swing.JTextField;
    4.21 -
    4.22 -import org.bina.platform.Arguments;
    4.23 -import org.bina.platform.Core;
    4.24 -import org.bina.platform.Arguments.PluginArgument;
    4.25 -import org.bina.platform.environment.Preferences;
    4.26 -import org.bina.platform.gui.wizards.Wizard;
    4.27 -import org.bina.platform.gui.wizards.WizardPage;
    4.28 -import org.bnplusplus.driver.sql.mysql.BNPlusPlusMySQLDataSource;
    4.29 -import org.bnplusplus.driver.sql.mysql.Plugin;
    4.30 -
    4.31 -import com.jgoodies.forms.layout.CellConstraints;
    4.32 -import com.jgoodies.forms.layout.FormLayout;
    4.33 -
    4.34 -public class DatabaseWizardPage extends WizardPage {
    4.35 -	private JPanel page = null;
    4.36 -    
    4.37 -    private JTextField host_field, port_field, database_field, login_field;
    4.38 -    private JPasswordField password_field;
    4.39 -    
    4.40 -    private boolean dbOkay = false;
    4.41 -
    4.42 -	private BNPlusPlusMySQLDataSource dataSource = null;
    4.43 -    
    4.44 -    public DatabaseWizardPage(Wizard wizard, BNPlusPlusMySQLDataSource dataSource) {
    4.45 -        super(wizard, "MySQL Database Settings");
    4.46 -		this.dataSource = dataSource;
    4.47 -
    4.48 -    }
    4.49 -    
    4.50 -    @Override
    4.51 -    public boolean canNext() {
    4.52 -        return dbOkay;
    4.53 -    }
    4.54 -
    4.55 -    @Override
    4.56 -    public boolean canBack() {
    4.57 -        return true;
    4.58 -    }
    4.59 -    
    4.60 -    /* (non-Javadoc)
    4.61 -     * @see org.bina.platformx.wizards.WizardPage2#canBeSkipped()
    4.62 -     */
    4.63 -    @Override
    4.64 -    public boolean canBeSkipped() {
    4.65 -    	getPage();
    4.66 -    	
    4.67 -    	Arguments args = Core.getInstance().getArguments();
    4.68 -    	
    4.69 -    	PluginArgument hostArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "host");
    4.70 -		PluginArgument databaseArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "database");
    4.71 -		PluginArgument loginArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "login");
    4.72 -		
    4.73 -		if (hostArg != null && loginArg != null && databaseArg != null) {
    4.74 -			return true;
    4.75 -		}
    4.76 -		
    4.77 -		return false;
    4.78 -    }
    4.79 -
    4.80 -    @Override
    4.81 -    public JPanel getPage() {
    4.82 -        if (page == null) {
    4.83 -            FormLayout layout = new FormLayout(
    4.84 -                    "5dlu, left:default, 5dlu, 6px:grow, 2dlu, default, 2dlu, left:default, 5dlu",   
    4.85 -                    "5dlu, default, 10dlu, default, 5dlu, default, 5dlu, default, default:grow"); 
    4.86 -            
    4.87 -            
    4.88 -            page = new JPanel();
    4.89 -            page.setLayout(layout);
    4.90 -            
    4.91 -            CellConstraints cc = new CellConstraints();
    4.92 -            
    4.93 -            page.add(new JLabel("Host"), cc.xy(2, 2));
    4.94 -            page.add(host_field = new JTextField(), cc.xy(4, 2));
    4.95 -            page.add(new JLabel(":"), cc.xy(6, 2));
    4.96 -            page.add(port_field = new JTextField(5), cc.xy(8, 2));
    4.97 -            page.add(new JLabel("Database"), cc.xy(2, 4));
    4.98 -            page.add(database_field = new JTextField(20), cc.xy(4, 4));
    4.99 -            page.add(new JLabel("Login"), cc.xy(2, 6));
   4.100 -            page.add(login_field = new JTextField(), cc.xy(4, 6));
   4.101 -            page.add(new JLabel("Password"), cc.xy(2, 8));
   4.102 -            page.add(password_field = new JPasswordField(), cc.xy(4, 8));
   4.103 -            
   4.104 -            if (wizard.getPreferences() != null) {
   4.105 -            	Preferences prefs = wizard.getPreferences().getPluginData(Plugin.PLUGIN_NAME);
   4.106 -            	host_field.setText(prefs.getProperty("database.host", ""));
   4.107 -            	port_field.setText(prefs.getProperty("database.port", ""));
   4.108 -            	database_field.setText(prefs.getProperty("database.database", ""));
   4.109 -            	login_field.setText(prefs.getProperty("database.login", ""));
   4.110 -            	password_field.setText(prefs.getProperty("database.password", "", true));
   4.111 -            }
   4.112 -            final JButton check = new JButton("Verify Connection");
   4.113 -            page.add(check, cc.xyw(2, 9, 7, CellConstraints.CENTER, CellConstraints.CENTER));
   4.114 -            
   4.115 -            KeyAdapter k = new KeyAdapter() {
   4.116 -            	@Override
   4.117 -            	public void keyReleased(KeyEvent e) {
   4.118 -            		boolean enable = true;
   4.119 -            		if (host_field.getText().trim().equals("")) {
   4.120 -            			host_field.setBackground(new Color(255, 190, 190));
   4.121 -            			enable = false;
   4.122 -            		} else {
   4.123 -            			host_field.setBackground(Color.WHITE);
   4.124 -            		}
   4.125 -            		
   4.126 -            		if (port_field.getText().trim().equals("")) {
   4.127 -            			port_field.setBackground(new Color(255, 190, 190));
   4.128 -            			enable = false;
   4.129 -            		} else {
   4.130 -            			port_field.setBackground(Color.WHITE);
   4.131 -            		}
   4.132 -            		
   4.133 -            		if (database_field.getText().trim().equals("")) {
   4.134 -            			database_field.setBackground(new Color(255, 190, 190));
   4.135 -            			enable = false;
   4.136 -            		} else {
   4.137 -            			database_field.setBackground(Color.WHITE);
   4.138 -            		}
   4.139 -            		
   4.140 -            		if (login_field.getText().trim().equals("")) {
   4.141 -            			login_field.setBackground(new Color(255, 190, 190));
   4.142 -            			enable = false;
   4.143 -            		} else {
   4.144 -            			login_field.setBackground(Color.WHITE);
   4.145 -            		}
   4.146 -            		check.setEnabled(enable);
   4.147 -            	}
   4.148 -            };
   4.149 -            
   4.150 -            host_field.addKeyListener(k);
   4.151 -            port_field.addKeyListener(k);
   4.152 -            database_field.addKeyListener(k);
   4.153 -            login_field.addKeyListener(k);
   4.154 -            
   4.155 -            check.addActionListener(new ActionListener() {
   4.156 -
   4.157 -				public void actionPerformed(ActionEvent e) {
   4.158 -					try {
   4.159 -						Class.forName( "com.mysql.jdbc.Driver" );
   4.160 -					} catch( Exception e1 ) {
   4.161 -						JOptionPane.showMessageDialog(page, "MySQL driver not found!", "Error", JOptionPane.ERROR_MESSAGE);
   4.162 -						dbOkay = false;
   4.163 -						fireStateChanged();
   4.164 -						return;
   4.165 -					}
   4.166 -					
   4.167 -					String db = "jdbc:mysql://"+ host_field.getText() + ":" + port_field.getText() + "/"+  database_field.getText() ;
   4.168 -					try {
   4.169 -						Connection connection = DriverManager.getConnection(db, login_field.getText(), new String(password_field.getPassword()));
   4.170 -						connection.close();
   4.171 -					} catch (SQLException e1 ) {
   4.172 -						String s = e1.getMessage();
   4.173 -						if (s.length() > 200)
   4.174 -							s = s.substring(0, 200) + "...";
   4.175 -						JOptionPane.showMessageDialog(page, "Exception occured: " + s, "Error", JOptionPane.ERROR_MESSAGE);
   4.176 -						dbOkay = false;
   4.177 -						fireStateChanged();
   4.178 -						return;
   4.179 -					}
   4.180 -					JOptionPane.showMessageDialog(page, "Everything looks fine.", "Test successful", JOptionPane.INFORMATION_MESSAGE);
   4.181 -					dbOkay = true;
   4.182 -					fireStateChanged();
   4.183 -				}
   4.184 -            });
   4.185 -
   4.186 -        }
   4.187 -        return page;
   4.188 -    }
   4.189 -
   4.190 -    @Override
   4.191 -    public void finished() {
   4.192 -    	
   4.193 -    	if (wizard.getPreferences() != null) {
   4.194 -    		Preferences prefs = wizard.getPreferences().getPluginData(Plugin.PLUGIN_NAME);
   4.195 -
   4.196 -    		prefs.setProperty("database.host", host_field.getText());
   4.197 -    		prefs.setProperty("database.port", port_field.getText());
   4.198 -    		prefs.setProperty("database.database", database_field.getText());
   4.199 -    		prefs.setProperty("database.login", login_field.getText());
   4.200 -    		prefs.setProperty("database.password", new String(password_field.getPassword()), true);
   4.201 -
   4.202 -    		prefs.flush();
   4.203 -    	}
   4.204 -    	
   4.205 -    	dataSource.setHost(host_field.getText());
   4.206 -    	dataSource.setPort(port_field.getText());
   4.207 -    	dataSource.setDatabase(database_field.getText());
   4.208 -    	dataSource.setLogin(login_field.getText());
   4.209 -    	dataSource.setPassword(new String(password_field.getPassword()));
   4.210 -
   4.211 -    }
   4.212 -
   4.213 -    @Override
   4.214 -    public void canceled() {
   4.215 -
   4.216 -    }
   4.217 -    
   4.218 -}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/org/bnplusplus/driver/sql/mysql/wizards/MySQLDatabaseWizardPage.java	Wed Nov 04 14:58:41 2009 +0100
     5.3 @@ -0,0 +1,233 @@
     5.4 +package org.bnplusplus.driver.sql.mysql.wizards;
     5.5 +
     5.6 +import java.awt.Color;
     5.7 +import java.awt.event.ActionEvent;
     5.8 +import java.awt.event.ActionListener;
     5.9 +import java.awt.event.KeyAdapter;
    5.10 +import java.awt.event.KeyEvent;
    5.11 +import java.sql.Connection;
    5.12 +import java.sql.DriverManager;
    5.13 +import java.sql.SQLException;
    5.14 +
    5.15 +import javax.swing.JButton;
    5.16 +import javax.swing.JComboBox;
    5.17 +import javax.swing.JLabel;
    5.18 +import javax.swing.JOptionPane;
    5.19 +import javax.swing.JPanel;
    5.20 +import javax.swing.JPasswordField;
    5.21 +import javax.swing.JTextField;
    5.22 +import javax.swing.JTextPane;
    5.23 +
    5.24 +import org.bina.platform.Arguments;
    5.25 +import org.bina.platform.Core;
    5.26 +import org.bina.platform.Arguments.PluginArgument;
    5.27 +import org.bina.platform.environment.Preferences;
    5.28 +import org.bina.platform.gui.wizards.Wizard;
    5.29 +import org.bina.platform.gui.wizards.WizardPage;
    5.30 +import org.bina.platform.utils.swing.ComponentUtilities;
    5.31 +import org.bnplusplus.driver.sql.mysql.BNPlusPlusMySQLDataSource;
    5.32 +import org.bnplusplus.driver.sql.mysql.Plugin;
    5.33 +import org.bnplusplus.driver.sql.mysql.resources.Resources;
    5.34 +
    5.35 +import com.jgoodies.forms.layout.CellConstraints;
    5.36 +import com.jgoodies.forms.layout.FormLayout;
    5.37 +
    5.38 +public class MySQLDatabaseWizardPage extends WizardPage {
    5.39 +	private JPanel page = null;
    5.40 +    
    5.41 +    private JTextField host_field, port_field, database_field, login_field;
    5.42 +    private JComboBox presets;
    5.43 +    private JPasswordField password_field;
    5.44 +    
    5.45 +    private boolean dbOkay = false;
    5.46 +
    5.47 +	private BNPlusPlusMySQLDataSource dataSource = null;
    5.48 +    
    5.49 +    public MySQLDatabaseWizardPage(Wizard wizard, BNPlusPlusMySQLDataSource dataSource) {
    5.50 +        super(wizard, "MySQL database settings");
    5.51 +		this.dataSource = dataSource;
    5.52 +
    5.53 +    }
    5.54 +    
    5.55 +    @Override
    5.56 +    public boolean hasHelp() {
    5.57 +    	return true;
    5.58 +    }
    5.59 +    
    5.60 +    @Override
    5.61 +    public boolean canNext() {
    5.62 +        return dbOkay;
    5.63 +    }
    5.64 +
    5.65 +    @Override
    5.66 +    public boolean canBack() {
    5.67 +        return true;
    5.68 +    }
    5.69 +    
    5.70 +    /* (non-Javadoc)
    5.71 +     * @see org.bina.platformx.wizards.WizardPage2#canBeSkipped()
    5.72 +     */
    5.73 +    @Override
    5.74 +    public boolean canBeSkipped() {
    5.75 +    	getPage();
    5.76 +    	
    5.77 +    	Arguments args = Core.getInstance().getArguments();
    5.78 +    	
    5.79 +    	PluginArgument hostArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "host");
    5.80 +		PluginArgument databaseArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "database");
    5.81 +		PluginArgument loginArg = args.getPluginArgument(Plugin.PLUGIN_NAME, "login");
    5.82 +		
    5.83 +		if (hostArg != null && loginArg != null && databaseArg != null) {
    5.84 +			return true;
    5.85 +		}
    5.86 +		
    5.87 +		return false;
    5.88 +    }
    5.89 +
    5.90 +    @Override
    5.91 +    public JPanel getPage() {
    5.92 +        if (page == null) {
    5.93 +            FormLayout layout = new FormLayout(
    5.94 +                    "5dlu, left:default, 5dlu, 6px:grow, 2dlu, default, 2dlu, left:default, 5dlu",   
    5.95 +                    "5dlu, default, 5dlu, default, 10dlu, default, 5dlu, default, 5dlu, default, default:grow"); 
    5.96 +            
    5.97 +            
    5.98 +            page = new JPanel();
    5.99 +            page.setLayout(layout);
   5.100 +            page.setBackground(Color.WHITE);
   5.101 +            
   5.102 +            CellConstraints cc = new CellConstraints();
   5.103 +            
   5.104 +            JTextPane pane = ComponentUtilities.createHTMLTextPane(Resources.class.getResource("files/mysql-help.html"));
   5.105 +            page.add(ComponentUtilities.createPlainEditorScrollPane(pane, 100), cc.xyw(2, 2, 7, CellConstraints.FILL, CellConstraints.FILL));
   5.106 +            
   5.107 +            
   5.108 +//            page.add(presets = new JComboBox(), cc.xy(2, 4, ))
   5.109 +            
   5.110 +            
   5.111 +            page.add(new JLabel("Hostname"), cc.xy(2, 4));
   5.112 +            page.add(host_field = new JTextField(), cc.xy(4, 4));
   5.113 +            page.add(new JLabel(":"), cc.xy(6, 4));
   5.114 +            page.add(port_field = new JTextField(5), cc.xy(8, 4));
   5.115 +            page.add(new JLabel("Database name"), cc.xy(2, 6));
   5.116 +            page.add(database_field = new JTextField(20), cc.xyw(4, 6, 5));
   5.117 +            page.add(new JLabel("User login"), cc.xy(2, 8));
   5.118 +            page.add(login_field = new JTextField(), cc.xyw(4, 8, 5));
   5.119 +            page.add(new JLabel("User password"), cc.xy(2, 10));
   5.120 +            page.add(password_field = new JPasswordField(), cc.xyw(4, 10, 5));
   5.121 +            
   5.122 +            if (wizard.getPreferences() != null) {
   5.123 +            	Preferences prefs = wizard.getPreferences().getPluginData(Plugin.PLUGIN_NAME);
   5.124 +            	host_field.setText(prefs.getProperty("database.host", ""));
   5.125 +            	port_field.setText(prefs.getProperty("database.port", "3306"));
   5.126 +            	database_field.setText(prefs.getProperty("database.database", ""));
   5.127 +            	login_field.setText(prefs.getProperty("database.login", ""));
   5.128 +            	password_field.setText(prefs.getProperty("database.password", "", true));
   5.129 +            }
   5.130 +            final JButton check = new JButton("Verify Connection");
   5.131 +            page.add(check, cc.xyw(2, 11, 7, CellConstraints.CENTER, CellConstraints.CENTER));
   5.132 +            
   5.133 +            KeyAdapter k = new KeyAdapter() {
   5.134 +            	@Override
   5.135 +            	public void keyReleased(KeyEvent e) {
   5.136 +            		boolean enable = true;
   5.137 +            		if (host_field.getText().trim().equals("")) {
   5.138 +            			host_field.setBackground(new Color(255, 190, 190));
   5.139 +            			enable = false;
   5.140 +            		} else {
   5.141 +            			host_field.setBackground(Color.WHITE);
   5.142 +            		}
   5.143 +            		
   5.144 +            		if (port_field.getText().trim().equals("")) {
   5.145 +            			port_field.setBackground(new Color(255, 190, 190));
   5.146 +            			enable = false;
   5.147 +            		} else {
   5.148 +            			port_field.setBackground(Color.WHITE);
   5.149 +            		}
   5.150 +            		
   5.151 +            		if (database_field.getText().trim().equals("")) {
   5.152 +            			database_field.setBackground(new Color(255, 190, 190));
   5.153 +            			enable = false;
   5.154 +            		} else {
   5.155 +            			database_field.setBackground(Color.WHITE);
   5.156 +            		}
   5.157 +            		
   5.158 +            		if (login_field.getText().trim().equals("")) {
   5.159 +            			login_field.setBackground(new Color(255, 190, 190));
   5.160 +            			enable = false;
   5.161 +            		} else {
   5.162 +            			login_field.setBackground(Color.WHITE);
   5.163 +            		}
   5.164 +            		check.setEnabled(enable);
   5.165 +            	}
   5.166 +            };
   5.167 +            
   5.168 +            host_field.addKeyListener(k);
   5.169 +            port_field.addKeyListener(k);
   5.170 +            database_field.addKeyListener(k);
   5.171 +            login_field.addKeyListener(k);
   5.172 +            
   5.173 +            check.addActionListener(new ActionListener() {
   5.174 +
   5.175 +				public void actionPerformed(ActionEvent e) {
   5.176 +					try {
   5.177 +						Class.forName( "com.mysql.jdbc.Driver" );
   5.178 +					} catch( Exception e1 ) {
   5.179 +						JOptionPane.showMessageDialog(page, "MySQL driver not found!", "Error", JOptionPane.ERROR_MESSAGE);
   5.180 +						dbOkay = false;
   5.181 +						fireStateChanged();
   5.182 +						return;
   5.183 +					}
   5.184 +					
   5.185 +					String db = "jdbc:mysql://"+ host_field.getText() + ":" + port_field.getText() + "/"+  database_field.getText() ;
   5.186 +					try {
   5.187 +						Connection connection = DriverManager.getConnection(db, login_field.getText(), new String(password_field.getPassword()));
   5.188 +						connection.close();
   5.189 +					} catch (SQLException e1 ) {
   5.190 +						String s = e1.getMessage();
   5.191 +						if (s.length() > 200)
   5.192 +							s = s.substring(0, 200) + "...";
   5.193 +						JOptionPane.showMessageDialog(page, "Exception occured: " + s, "Error", JOptionPane.ERROR_MESSAGE);
   5.194 +						dbOkay = false;
   5.195 +						fireStateChanged();
   5.196 +						return;
   5.197 +					}
   5.198 +					JOptionPane.showMessageDialog(page, "Everything looks fine.", "Test successful", JOptionPane.INFORMATION_MESSAGE);
   5.199 +					dbOkay = true;
   5.200 +					fireStateChanged();
   5.201 +				}
   5.202 +            });
   5.203 +
   5.204 +        }
   5.205 +        return page;
   5.206 +    }
   5.207 +
   5.208 +    @Override
   5.209 +    public void finished() {
   5.210 +    	
   5.211 +    	if (wizard.getPreferences() != null) {
   5.212 +    		Preferences prefs = wizard.getPreferences().getPluginData(Plugin.PLUGIN_NAME);
   5.213 +
   5.214 +    		prefs.setProperty("database.host", host_field.getText());
   5.215 +    		prefs.setProperty("database.port", port_field.getText());
   5.216 +    		prefs.setProperty("database.database", database_field.getText());
   5.217 +    		prefs.setProperty("database.login", login_field.getText());
   5.218 +    		prefs.setProperty("database.password", new String(password_field.getPassword()), true);
   5.219 +
   5.220 +    		prefs.flush();
   5.221 +    	}
   5.222 +    	
   5.223 +    	dataSource.setHost(host_field.getText());
   5.224 +    	dataSource.setPort(port_field.getText());
   5.225 +    	dataSource.setDatabase(database_field.getText());
   5.226 +    	dataSource.setLogin(login_field.getText());
   5.227 +    	dataSource.setPassword(new String(password_field.getPassword()));
   5.228 +
   5.229 +    }
   5.230 +
   5.231 +    @Override
   5.232 +    public void canceled() {
   5.233 +
   5.234 +    }
   5.235 +    
   5.236 +}