All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swixml.examples.wizard.SetJDBCInfoPage Maven / Gradle / Ivy

The newest version!
package org.swixml.examples.wizard;


import java.awt.Component;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.swing.JComboBox;

import org.jdesktop.application.Action;
import org.netbeans.spi.wizard.ResultProgressHandle;
import org.netbeans.spi.wizard.Wizard;
import org.netbeans.spi.wizard.WizardPage;
import org.netbeans.spi.wizard.WizardPanelNavResult;

@SuppressWarnings("serial")
public class SetJDBCInfoPage extends WizardPage implements DDLWizardConstants{
    
    public static final String DESCRIPTION = "JDBC connection";
	
	private static final String SELECT_DRIVER_MESSAGE = "please select the JDBC Driver";

	static class JDBCInfo {
	
		final Class driver;
		final String connectionUrl;
		final String name ;
		
		public JDBCInfo( String name,  Class driver, String connectionUrl) {
			super();
			this.name = name;
			this.driver = driver;
			this.connectionUrl = connectionUrl;
		}

		@Override
		public String toString() {
			return name;
		}

		public final String getDriver() {
			return driver.getName();
		}

		public final String getConnectionUrl() {
			return connectionUrl;
		}
		
		
	}

        class OpenConnectionTask extends WizardPanelNavResult {

            @Override
            public void start(Map wizardData, ResultProgressHandle progress) {

                progress.setBusy("Connecting...");

                Connection conn = null;

				try {
		
					conn = DDLWizardApplication.getConnection( wizardData );
		
				} catch (Exception e) {
					//JOptionPane.showMessageDialog(SetJDBCInfoPage.this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE)
					progress.failed (e.getMessage(), true);
					return;
				}
				finally {
					DDLWizardApplication.closeConnection(conn);
				}

				progress.finished(WizardPanelNavResult.PROCEED);

            }

        }
	
    List supportedDrivers = new ArrayList(3);

    JComboBox cmbDriver;
 
    /**
     * 
     */
	public SetJDBCInfoPage() {
		super( PAGE1_STEP,DESCRIPTION);
		
		
		supportedDrivers.add( new JDBCInfo( "