Jump to: navigation, search

Results View Control

Revision as of 10:50, 18 December 2007 by Jeremyl.sybase.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Back to SQL Development Tools page


The DTP Results View now provides a ResultsViewControl component for displaying SQL execution results. The ResultsViewControl can be consumed by other UI components such as editors, dialogs and wizards, enabling them to show SQL execution results in their own user-interface.



The control class is


which is in the plugin



To use the ResultsViewControl, you should instantiate one then make a simple sequence of function calls.

The ResultsViewControl should be instantiated using the constructor


passing null as the ResultsView parameter.

After instantiation, the ResultsViewControl should be initialized by calling:

init(IViewSite, IMemento) throws PartInitException

passing two null parameters.

The final part of ResultsViewControl creation is to call

void createPartControl(Composite parent)

passing the parent Composite as a parameter.

The client can request the ResultsViewControl to use the Preferences defined for the SQL Results View or not, using the method


If setUsePreferences(true) is called, the preferences for the SQL Results View relating to the user-interface will be used. These control, for example, whether results are shown in a single window or multiple windows, in text mode or grid mode.

If setUsePreferences(false) is called, the preferences defaults for the SQL Results View are used.

For example code, see Example Usage.

Filtering Results

Consumers of the ResultsViewControl can implement their own filters on the history section of the control by defining a class which extends org.eclipse.jface.viewers.ViewerFilter and passing an instance of the new class to


This allows the consumer to control which results are shown in the ResultsViewControl. For example, a consumer might only want to show the results for a particular Connection Profile. For an example, see Example Usage.

Example Usage

In the org.eclipse.datatools.sqltools.sqlbuilder.examples plugin, there is an example of a dialog which hosts the ResultsViewControl component. This plugin is located in CVS under


The dialog class is


and its usage of the ResultsViewControl is included below:

		 * Add the results view control
		_resultsViewControl = new ResultsViewControl(null);
		 * Tell the results view control to use preferences
		try {
			_resultsViewControl.init(null, null);
		} catch (PartInitException e) {

SQLBuilderDialog also defines a filter for the results history section of the ResultsViewControl in the class ResultsHistoryFilter. The filter is given to the ResultsViewControl by passing it to addResultHistoryFilter(ViewerFilter). ResultsHistoryFilter filters out all those results which are associated with Connection Profiles other than that for the current SQL statement, and which were created before the filter itself was created. Consequently the history section of the ResultsViewControl shows only those results which were created by running the SQL statement within the current SQLBuilderDialog instance.

For more information about the example dialog, see Example SQL Builder Dialog. The dialog is shown below, with its SQL Results tab selected. This tab hosts the ResultsViewControl: