The CSV ODA user interface extension described in this section illustrates how to create an ODA user interface plug-in using the Eclipse PDE. The following section describes the code-based extensions a developer must make to complete the development of the CSV ODA user interface extension, after defining the plug-in framework in the Eclipse PDE.
The CSV ODA user interface plug-in contains the following packages:
org.eclipse.birt.report.data.oda.csv.ui
Contains the UiPlugin class, which is automatically generated by the PDE Manifest Editor when you create the plug-in project.
org.eclipse.birt.report.data.oda.csv.ui.i18n
Contains the Messages class and the messages.properties properties file to generate the messages displayed in the user interface. Localized versions of these messages are in files that use the following naming syntax:
messages_<locale>.msg
org.eclipse.birt.report.data.oda.csv.ui.impl
Contains the CustomDataSetWizardPage class, an automatically generated implementation of an ODA data set designer page, which supports creating or editing an ODA data set.
org.eclipse.birt.report.data.oda.csv.ui.wizards
The wizards package contains the classes that create the user interface pages used to choose a data source and data set in BIRT Report Designer.
Implementing the ODA data source and data set wizards
BIRT Report Designer uses the Eclipse Data Tools Platform (DTP) ODA design‑time framework and offers wizards that automatically generate customizable implementations. The DTP ODA framework defines two of the three extension points used in the CSV ODA user interface plug‑in:
Connection profile
Defined in org.eclipse.datatools.connectivity.connectionProfile
Data source and data set wizards
Defined in org.eclipse.datatools.connectivity.oda.design.ui.dataSource
The CSV ODA user interface plug-in also must implement the extension point for property pages defined in org.eclipse.ui.propertyPages.
The CSV ODA user interface plug-in uses the following abstract base classes in the org.eclipse.datatools.connectivity.oda.design.ui.wizards package to create the wizards that specify the data source and data set pages. An ODA user interface plug-in must extend these classes to provide the wizard pages with page control and related behavior:
DataSourceEditorPage
Provides the framework to implement an ODA data source property page
DataSourceWizardPage
Provides the framework to implement an ODA data source wizard page
DataSetWizardPage
Provides the framework to implement an ODA data set wizard page
This customizable page provides a simple Query Text control for user input. The page extends org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage in the DTP ODA design-time framework to support updating an ODA data set design instance using query metadata.
The org.eclipse.birt.report.data.oda.csv.ui.wizards package in the CSV ODA user interface extension example implements the following classes:
Constants
Defines the constants for the data source connection properties defined in the run-time drive implementation, org.eclipse.birt.report.data.oda.csv.
CSVFilePropertyPage
Extends DataSourceEditorPage to create and initialize the editor controls for the property page used to specify the ODA data source. The class updates connection profile properties with values collected from the page.
CSVFileSelectionPageHelper
Specifies the page layout and sets up the control that listens for user input and verifies the location of the CSV data source file.
CSVFileSelectionWizardPage
Extends DataSourceWizardPage. This class creates and initializes the controls for the data source wizard page. The class sets the select file message and collects the property values.
FileSelectionWizardPage
Extends DataSetWizardPage. This class creates and initializes the controls for the data set wizard page and specifies the page layout. The class connects to the data source, executes a query, retrieves the metadata and result set, and updates the data set design.
Constants class
The Constants class defines the following variables for the data source connection properties defined in org.eclipse.birt.report.data.oda.csv:
ODAHOME specifies the CSV ODA file path constant, HOME.
ODA_DEFAULT_CHARSET specifies the default character set as 8-bit Unicode Transformation Format (UTF-8).
DEFAULT_MAX_ROWS sets the default maximum number of rows that can be retrieved from the data source.
Listing 25‑18 shows the code for the Constants class.
Listing 25‑18 The Constants class
public class Constants {
public static String ODAHOME="HOME";
public static String ODA_DEFAULT_CHARSET = "UTF-8";
public static int DEFAULT_MAX_ROWS = 1000;
}
CSVFilePropertyPage class
CSVFilePropertyPage extends the DataSourceEditorPage class, implementing the following methods to provide page editing functionality for the CSV ODA data source property page:
The createAndInitCustomControl( ) method performs the following tasks:
Instantiates a CSVFileSelectionPageHelper object
Specifies the page layout and sets up the editing control by calling the CSVFileSelectionPageHelper.createCustomControl( ) and initCustomControl( ) methods
Listing 25‑19 shows the code for createAndInitCustomControl( ).
Listing 25‑19 The createAndInitCustomControl( ) method
m_pageHelper = new CSVFileSelectionPageHelper( this );
}
m_pageHelper.createCustomControl( parent );
m_pageHelper.initCustomControl( profileProps );
if( ! isSessionEditable( ) )
{
getControl( ).setEnabled( false );
}
}
collectCustomProperties( ) updates the connection profile properties with the values collected from the page by calling CSVFileSelectionPageHelper.collectCustomProperties( ) method, as shown in Listing 25‑20.
Listing 25‑20 The collectCustomProperties( ) method
public Properties collectCustomProperties( Properties profileProps )
The CSVFileSelectionWizardPage class extends the DataSourceWizardPage class, implementing the following methods to provide the functionality for the CSV ODA data source wizard page:
The createPageCustomControl( ) method performs the following tasks:
Instantiates a CSVFileSelectionPageHelper object
Specifies the page layout and sets up the wizard page control by calling CSVFileSelectionPageHelper.createCustomControl( ) method
Calls CSVFileSelectionPageHelper.initCustomControl( ) to initialize the control to the location of the data source file
Listing 25‑25 shows the code for the createPageCustomControl( ) method.
Listing 25‑25 The createPageCustomControl( ) method
public void createPageCustomControl( Composite parent )
{
if( m_pageHelper == null )
{
m_pageHelper = new CSVFileSelectionPageHelper( this );
The collectCustomProperties( ) method instantiates a Properties object to contain the CSV data source properties information, as shown in Listing 25‑26.
Listing 25‑26 The collectCustomProperties( ) method
The FileSelectionWizardPage class extends the DataSetWizardPage class, implementing the following methods to provide the functionality for the CSV ODA data set wizard page:
The createPageControl( ) method performs the following tasks:
Specifies the page layout and sets up the wizard page control
Gets the data source properties
Calls populateAvailableList( ) to update the data set design
Listing 25‑27 shows the code for the createPageControl( ) method.
Listing 25‑27 The createPageControl( ) method
private Control createPageControl( Composite parent )
{
Composite composite = new Composite( parent, SWT.NULL );