<commit_before>/*
 *************************************************************************
 * Copyright (c) 2005, 2006 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *  
 *************************************************************************
 */

package org.eclipse.birt.report.data.oda.sampledb.ui.profile;

import java.util.Properties;

import org.eclipse.birt.report.data.oda.jdbc.ui.util.Constants;
import org.eclipse.birt.report.data.oda.sampledb.SampleDBConstants;
import org.eclipse.birt.report.data.oda.sampledb.SampleDBJDBCConnectionFactory;
import org.eclipse.birt.report.data.oda.sampledb.ui.i18n.Messages;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.PlatformUI;

/**
 * Helper class to create sampleDb selection page and property page
 * 
 */
public class SampleDbSelectionPageHelper
{
    private WizardPage m_wizardPage;
    private PreferencePage m_propertyPage;

	private static final String SAMPLE_DB_SCHEMA="ClassicModels";
	private final String CONEXT_ID_DATASOURCE_SAMPLEDB = "org.eclipse.birt.cshelp.Wizard_DatasourceProfile_ID";//$NON-NLS-1$
	private Label m_driverClass, m_driverURL, m_sampleUser;

    static final String DEFAULT_MESSAGE = 
        Messages.getMessage(  "datasource.page.title" ); //$NON-NLS-1$
    
    private static final String EMPTY_STRING = "";
    
    SampleDbSelectionPageHelper( WizardPage page )
    {
        m_wizardPage = page;
    }

    SampleDbSelectionPageHelper( PreferencePage page )
    {
        m_propertyPage = page;
    }

    void createCustomControl( Composite parent )
	{
		// create the composite to hold the widgets
		Composite content = new Composite( parent, SWT.NONE );

		GridLayout layout = new GridLayout( );
		layout.numColumns = 2;
		content.setLayout( layout );

		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.driver.class" ) ); //$NON-NLS-1$
		m_driverClass = new Label( content, SWT.LEFT );
		m_driverClass.setText( SampleDBConstants.DRIVER_CLASS ); //$NON-NLS-1$
		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.url" ) ); //$NON-NLS-1$
		m_driverURL = new Label( content, SWT.LEFT );
		m_driverURL.setText( SampleDBConstants.DRIVER_URL );//$NON-NLS-1$
		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.user" ) ); //$NON-NLS-1$
		m_sampleUser = new Label( content, SWT.LEFT );
		m_sampleUser.setText( SampleDBJDBCConnectionFactory.getDbUser( ) );//$NON-NLS-1$
		setMessage( DEFAULT_MESSAGE );
		
		PlatformUI.getWorkbench( ).getHelpSystem( ).setHelp( content,
				CONEXT_ID_DATASOURCE_SAMPLEDB );
	}
    
    /**
	 * collect custom properties
	 * 
	 * @param props
	 * @return
	 */
    Properties collectCustomProperties( Properties props )
    {
        if( props == null )
            props = new Properties();
        
        // set custom driver specific properties
		props.setProperty( Constants.ODADriverClass, getDriverClass( ) );
		props.setProperty( Constants.ODAURL, getDriverUrl( ) );
		props.setProperty( Constants.ODAUser, SAMPLE_DB_SCHEMA );
		props.setProperty( Constants.ODAPassword, "" );
		return props;
    }
    
    /**
     * get driver class
     * @return
     */<commit_msg>[183104] Override connection profile properties to not save reference to a conn profile, which does not match its saved identity as an oda.jdbc extension<commit_after>/*
 *************************************************************************
 * Copyright (c) 2005, 2007 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *  
 *************************************************************************
 */

package org.eclipse.birt.report.data.oda.sampledb.ui.profile;

import java.util.Properties;

import org.eclipse.birt.report.data.oda.jdbc.ui.util.Constants;
import org.eclipse.birt.report.data.oda.sampledb.SampleDBConstants;
import org.eclipse.birt.report.data.oda.sampledb.SampleDBJDBCConnectionFactory;
import org.eclipse.birt.report.data.oda.sampledb.ui.i18n.Messages;
import org.eclipse.datatools.connectivity.oda.util.manifest.ConnectionProfileProperty;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.PlatformUI;

/**
 * Helper class to create sampleDb selection page and property page
 * 
 */
public class SampleDbSelectionPageHelper
{
    private WizardPage m_wizardPage;
    private PreferencePage m_propertyPage;

	private static final String SAMPLE_DB_SCHEMA="ClassicModels";
	private final String CONEXT_ID_DATASOURCE_SAMPLEDB = "org.eclipse.birt.cshelp.Wizard_DatasourceProfile_ID";//$NON-NLS-1$
	private Label m_driverClass, m_driverURL, m_sampleUser;

    static final String DEFAULT_MESSAGE = 
        Messages.getMessage(  "datasource.page.title" ); //$NON-NLS-1$
    
    private static final String EMPTY_STRING = "";
    
    SampleDbSelectionPageHelper( WizardPage page )
    {
        m_wizardPage = page;
    }

    SampleDbSelectionPageHelper( PreferencePage page )
    {
        m_propertyPage = page;
    }

    void createCustomControl( Composite parent )
	{
		// create the composite to hold the widgets
		Composite content = new Composite( parent, SWT.NONE );

		GridLayout layout = new GridLayout( );
		layout.numColumns = 2;
		content.setLayout( layout );

		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.driver.class" ) ); //$NON-NLS-1$
		m_driverClass = new Label( content, SWT.LEFT );
		m_driverClass.setText( SampleDBConstants.DRIVER_CLASS ); //$NON-NLS-1$
		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.url" ) ); //$NON-NLS-1$
		m_driverURL = new Label( content, SWT.LEFT );
		m_driverURL.setText( SampleDBConstants.DRIVER_URL );//$NON-NLS-1$
		new Label( content, SWT.LEFT ).setText( Messages.getMessage( "datasource.page.user" ) ); //$NON-NLS-1$
		m_sampleUser = new Label( content, SWT.LEFT );
		m_sampleUser.setText( SampleDBJDBCConnectionFactory.getDbUser( ) );//$NON-NLS-1$
		setMessage( DEFAULT_MESSAGE );
		
		PlatformUI.getWorkbench( ).getHelpSystem( ).setHelp( content,
				CONEXT_ID_DATASOURCE_SAMPLEDB );
	}
    
    /**
	 * collect custom properties
	 * 
	 * @param props
	 * @return
	 */
    Properties collectCustomProperties( Properties props )
    {
        if( props == null )
            props = new Properties();
        
        // set custom driver specific properties
		props.setProperty( Constants.ODADriverClass, getDriverClass( ) );
		props.setProperty( Constants.ODAURL, getDriverUrl( ) );
		props.setProperty( Constants.ODAUser, SAMPLE_DB_SCHEMA );
		props.setProperty( Constants.ODAPassword, "" );
		
		// sampledb uses predined connection property values, and does not support
		// external reference to a connection profile
		props.setProperty( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, "" );
        props.setProperty( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, "" );
		
		return props;
    }
    
    /**
     * get driver class
     * @return
     */
{'fraction_non_alphanumeric': 0.14048129016001007, 'fraction_numerical': 0.006551593801184327, 'mean_word_length': 3.9924528301886792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3879454', 'n_tokens_mistral': 2555, 'n_tokens_neox': 2393, 'n_words': 533}