<commit_before> /**********************************************************************
 **                                                                   **
 **               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                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/


package org.pentaho.di.core.database.wizard;

import java.util.TreeMap;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.Props;
import org.pentaho.di.core.database.DatabaseMeta;



/**
 * 
 * On page one we select the database connection name, the database type and the access type.
 * 
 * @author Matt
 * @since  04-apr-2005
 */
public class CreateDatabaseWizardPage1 extends WizardPage
{
	private Label    wlName;
	private Text     wName;
	private FormData fdlName, fdName;
	
	private Label    wlDBType;
	private List     wDBType;
	private FormData fdlDBType, fdDBType;
	
	private Label    wlAccType;
	private List     wAccType;
	private FormData fdlAccType, fdAccType;

	private Props props;
	private DatabaseMeta info;
	private java.util.List<DatabaseMeta> databases;
	
	public CreateDatabaseWizardPage1(String arg, Props props, DatabaseMeta info, java.util.List<DatabaseMeta> databases)
	{
		super(arg);
		this.props=props;
		this.info = info;
		this.databases = databases;
		
		setTitle(Messages.getString("CreateDatabaseWizardPage1.DialogTitle")); //$NON-NLS-1$
		setDescription(Messages.getString("CreateDatabaseWizardPage1.DialogMessage")); //$NON-NLS-1$
		
		setPageComplete(false);
	}
	
	public void createControl(Composite parent)
	{
		int margin = Const.MARGIN;
		int middle = props.getMiddlePct();
		
		// create the composite to hold the widgets
		Composite composite = new Composite(parent, SWT.NONE);
 		props.setLook(composite);
	    
	    FormLayout compLayout = new FormLayout();
	    compLayout.marginHeight = Const.FORM_MARGIN;
	    compLayout.marginWidth  = Const.FORM_MARGIN;
		composite.setLayout(compLayout);

		wlName = new Label(composite, SWT.RIGHT);
		wlName.setText(Messages.getString("CreateDatabaseWizardPage1.DBName.Label")); //$NON-NLS-1$
 		props.setLook(wlName);
		fdlName = new FormData();
		fdlName.left   = new FormAttachment(0,0);
		fdlName.top    = new FormAttachment(0,0);
		fdlName.right  = new FormAttachment(middle,0);
		wlName.setLayoutData(fdlName);
		wName = new Text(composite, SWT.SINGLE | SWT.BORDER);
 		props.setLook(wName);
		fdName = new FormData();
		fdName.left    = new FormAttachment(middle, margin);
		fdName.right   = new FormAttachment(100, 0);
		wName.setLayoutData(fdName);
		wName.addModifyListener(new ModifyListener()
			{
				public void modifyText(ModifyEvent e)
				{
					setPageComplete(false);
				}
			}
		);
		
		wlDBType = new Label(composite, SWT.RIGHT);
		wlDBType.setText(Messages.getString("CreateDatabaseWizardPage1.DBType.Label")); //$NON-NLS-1$
 		props.setLook(wlDBType);
		fdlDBType = new FormData();
		fdlDBType.left   = new FormAttachment(0, 0);
		fdlDBType.top    = new FormAttachment(wName, margin);
		fdlDBType.right  = new FormAttachment(middle, 0);
		wlDBType.setLayoutData(fdlDBType);
		wDBType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
 		props.setLook(wDBType);
    
    // PMD-101: Sort the connection types, as a convenience (this could be pushed lower) 
    Object[] dbtypes = DatabaseMeta.getDBTypeDescLongList();
    TreeMap sortTypes = new TreeMap();
    for (int i = 0; i < dbtypes.length; i++)
    {
        sortTypes.put(dbtypes[i], dbtypes[i]);
    }
    dbtypes = sortTypes.keySet().toArray();
 
		for (int i=0;i< dbtypes.length;i++)
		{
			wDBType.add((String)dbtypes[i]);
		}
    
		// Select a default: the first
		if (info.getDatabaseType()==DatabaseMeta.TYPE_DATABASE_NONE) 
		{
			wDBType.select(0);
		}
		else
		{
			int idx = wDBType.indexOf(info.getDatabaseTypeDesc());
			if (idx>=0)
			{<commit_msg>Type checking<commit_after> /**********************************************************************
 **                                                                   **
 **               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                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/


package org.pentaho.di.core.database.wizard;

import java.util.Set;
import java.util.TreeMap;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.Props;
import org.pentaho.di.core.database.DatabaseMeta;



/**
 * 
 * On page one we select the database connection name, the database type and the access type.
 * 
 * @author Matt
 * @since  04-apr-2005
 */
public class CreateDatabaseWizardPage1 extends WizardPage
{
	private Label    wlName;
	private Text     wName;
	private FormData fdlName, fdName;
	
	private Label    wlDBType;
	private List     wDBType;
	private FormData fdlDBType, fdDBType;
	
	private Label    wlAccType;
	private List     wAccType;
	private FormData fdlAccType, fdAccType;

	private Props props;
	private DatabaseMeta info;
	private java.util.List<DatabaseMeta> databases;
	
	public CreateDatabaseWizardPage1(String arg, Props props, DatabaseMeta info, java.util.List<DatabaseMeta> databases)
	{
		super(arg);
		this.props=props;
		this.info = info;
		this.databases = databases;
		
		setTitle(Messages.getString("CreateDatabaseWizardPage1.DialogTitle")); //$NON-NLS-1$
		setDescription(Messages.getString("CreateDatabaseWizardPage1.DialogMessage")); //$NON-NLS-1$
		
		setPageComplete(false);
	}
	
	public void createControl(Composite parent)
	{
		int margin = Const.MARGIN;
		int middle = props.getMiddlePct();
		
		// create the composite to hold the widgets
		Composite composite = new Composite(parent, SWT.NONE);
 		props.setLook(composite);
	    
	    FormLayout compLayout = new FormLayout();
	    compLayout.marginHeight = Const.FORM_MARGIN;
	    compLayout.marginWidth  = Const.FORM_MARGIN;
		composite.setLayout(compLayout);

		wlName = new Label(composite, SWT.RIGHT);
		wlName.setText(Messages.getString("CreateDatabaseWizardPage1.DBName.Label")); //$NON-NLS-1$
 		props.setLook(wlName);
		fdlName = new FormData();
		fdlName.left   = new FormAttachment(0,0);
		fdlName.top    = new FormAttachment(0,0);
		fdlName.right  = new FormAttachment(middle,0);
		wlName.setLayoutData(fdlName);
		wName = new Text(composite, SWT.SINGLE | SWT.BORDER);
 		props.setLook(wName);
		fdName = new FormData();
		fdName.left    = new FormAttachment(middle, margin);
		fdName.right   = new FormAttachment(100, 0);
		wName.setLayoutData(fdName);
		wName.addModifyListener(new ModifyListener()
			{
				public void modifyText(ModifyEvent e)
				{
					setPageComplete(false);
				}
			}
		);
		
		wlDBType = new Label(composite, SWT.RIGHT);
		wlDBType.setText(Messages.getString("CreateDatabaseWizardPage1.DBType.Label")); //$NON-NLS-1$
 		props.setLook(wlDBType);
		fdlDBType = new FormData();
		fdlDBType.left   = new FormAttachment(0, 0);
		fdlDBType.top    = new FormAttachment(wName, margin);
		fdlDBType.right  = new FormAttachment(middle, 0);
		wlDBType.setLayoutData(fdlDBType);
		wDBType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
 		props.setLook(wDBType);
    
    // PMD-101: Sort the connection types, as a convenience (this could be pushed lower) 
 	    String[] dbtypes = DatabaseMeta.getDBTypeDescLongList();
        TreeMap<String,String> sortTypes = new TreeMap<String,String>();
        for (int i = 0; i < dbtypes.length; i++)
        {
            sortTypes.put(dbtypes[i], dbtypes[i]);
        }
        Set<String> keys = sortTypes.keySet();
        dbtypes = keys.toArray( new String[keys.size()] );
 
		for (int i=0;i< dbtypes.length;i++)
		{
			wDBType.add((String)dbtypes[i]);
		}
    
		// Select a default: the first
		if (info.getDatabaseType()==DatabaseMeta.TYPE_DATABASE_NONE) 
		{
			wDBType.select(0);
		}
		else
		{
			int idx = wDBType.indexOf(info.getDatabaseTypeDesc());
			if (idx>=0)
			{
{'fraction_non_alphanumeric': 0.13499716392512762, 'fraction_numerical': 0.0069956513518623555, 'mean_word_length': 2.6353951890034364, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '983322', 'n_tokens_mistral': 3419, 'n_tokens_neox': 3150, 'n_words': 652}