 /**********************************************************************
 **                                                                   **
 **               This code belongs to the KETTLE project.            **
 **                                                                   **
 ** Kettle, from version 2.2 on, is released into the public domain   **
 ** under the Lesser GNU Public License (LGPL).                       **
 **                                                                   **
 ** For more details, please read the document LICENSE.txt, included  **
 ** in this project                                                   **
 **                                                                   **
 ** http://www.kettle.be                                              **
 ** info@kettle.be                                                    **
 **                                                                   **
 **********************************************************************/

package be.ibridge.kettle.core.wizards.createdatabase;

import java.util.ArrayList;

import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;

import be.ibridge.kettle.core.Props;
import be.ibridge.kettle.core.database.DatabaseMeta;

/**
 * Shows a wizard that creates a new database connection...
 *
 * @author jb
 * @since  04-apr-2005
 *
 */
public class CreateDatabaseWizard {


	private boolean wizardFinished=false; // true when wizard finished

    /**
     * Shows a wizard that creates a new database connection...
     * @param shell
     * @param props
     * @param databases
     * @return DatabaseMeta when finished or null when canceled
     */
    public DatabaseMeta createAndRunDatabaseWizard(Shell shell, Props props, ArrayList databases)
    {

        DatabaseMeta newDBInfo = new DatabaseMeta();
        
        final CreateDatabaseWizardPage1 page1 = new CreateDatabaseWizardPage1("1", props, newDBInfo, databases);
        page1.createControl(shell);
        
        final  CreateDatabaseWizardPageInformix pageifx = new CreateDatabaseWizardPageInformix("ifx", props, newDBInfo);
        pageifx.createControl(shell);
        
        final  CreateDatabaseWizardPageJDBC pagejdbc = new CreateDatabaseWizardPageJDBC("jdbc", props, newDBInfo);
        pagejdbc.createControl(shell);
        
        final  CreateDatabaseWizardPageOCI pageoci = new CreateDatabaseWizardPageOCI("oci", props, newDBInfo);
        pageoci.createControl(shell);
        
        final CreateDatabaseWizardPageODBC pageodbc = new CreateDatabaseWizardPageODBC("odbc", props, newDBInfo);
        pageodbc.createControl(shell);
        
        final CreateDatabaseWizardPageOracle pageoracle = new CreateDatabaseWizardPageOracle("oracle", props, newDBInfo);

        final CreateDatabaseWizardPage2 page2 = new CreateDatabaseWizardPage2("2", props, newDBInfo);
        page2.createControl(shell);

    	wizardFinished=false; // set to false for safety only
    	
        Wizard wizard = new Wizard() 
        {
            /**
             * @see org.eclipse.jface.wizard.Wizard#performFinish()
             */
        	public boolean performFinish() 
            {
            	wizardFinished=true;
                return true;
            }
            
            /**
             * @see org.eclipse.jface.wizard.Wizard#canFinish()
             */
            public boolean canFinish()
            {
                return page2.canFinish();
            }
        };
                
        wizard.addPage(page1);        
        wizard.addPage(pageoci);
        wizard.addPage(pageodbc);
        wizard.addPage(pagejdbc);
        wizard.addPage(pageoracle);
        wizard.addPage(pageifx);
        wizard.addPage(page2);
                
        WizardDialog wd = new WizardDialog(shell, wizard);
        wd.setMinimumPageSize(700,400);
        wd.open();
        
        if(!wizardFinished){
        	newDBInfo=null;
        }
        return newDBInfo;
    }


	
}

@@ -1407,24 +1407,65 @@
 ction...%0D%0A *
+ (Code 'normalized' from Spoon and Chef.)
 %0D%0A * @author
@@ -1469,10 +1469,18 @@
 hor 
-jb
+Matt, Jens
 %0D%0A *
@@ -1492,19 +1492,19 @@
 ce  
-04-ap
+29-ma
 r-200
-5
+6
 %0D%0A *

'Normalize' the database wizards from spoon and chef.