RTQueryDataSource


Inherits From:
NSObject
Conforms To:
RTSQLDataSource
NSCoding
Declared In:
RTQueryDataSource.h


Class Description

This class exists to serve as an NSTableDataSource based on a SQL query. To use it, the following should be done:
  1. Specify it as the dataSource for the table

  2. If you want column sorting, specify it as the delegate for the table (or have your delegate call tableView:didClickTableColumn: on it)

  3. Specify a queryString

  4. Specify a the RTArchivedSession encapsulating the session to use.

  5. Specify the name of the database to use (if none is specified, the first (database in the session will be used)

  6. Set any options (updateColumnTitles, addRemoveColumns, displayErrors, autoPerformQuery, sortingEnabled)

  7. If autoPerformQuery isn't enabled, send the message performQuery:


Method Types

- updateColumnTitles
- setUpdateColumnTitles:
- addRemoveColumns
- setAddRemoveColumns:
- displayErrors
- setDisplayErrors:
- autoPerformQuery
- setAutoPerformQuery:
- sortingEnabled
- setSortingEnabled:
- loadDataOnAwake
- setLoadDataOnAwake:
- queryString
- setQueryString:
- setQueryStringNoExecute:
- tableView
- setTableView:
- database
- setDatabase:
- databaseName
- setDatabaseName:
- session
- setSession:
- initializeSession:
- performQuery:
- resultSet

Instance Methods

addRemoveColumns

- (BOOL)addRemoveColumns

If YES, the columns in the tableView will be removed when the query is performed and replaced with a new column for each column in the result set.


autoPerformQuery

- (BOOL)autoPerformQuery

If YES, the query will be performed when the tableView asks for data.


database

- (id <RTSQLDatabase>)database

Returns the database queried by this data source.


databaseName

- (NSString*)databaseName

Returns the name of the database queried by this data source.


displayErrors

- (BOOL)displayErrors

If YES, the user will be shown a sheet or alert with any error messages returned from the server.


initializeSession:

- (IBAction)initializeSession:(id)sender

If the session is not already open, asks the archived session to open a session.


loadDataOnAwake

- (BOOL)loadDataOnAwake

If YES, the query will be performed when the awakeFromNib message is received.


performQuery:

- (IBAction)performQuery:(id)sender

Performs the query in queryString and sends a reloadData message to the tableView.


queryString

- (NSString*)queryString

Returns the query used to populate this data source.


resultSet

- (id <RTSQLResultSet>)resultSet

Allows other interested parties to access the result set


session

- (id <RTSQLSession>)session

Returns the session used by this data source.


setAddRemoveColumns:

- (void)setAddRemoveColumns:(BOOL)val

If YES, the columns in the tableView will be removed when the query is performed and replaced with a new column for each column in the result set.


setAutoPerformQuery:

- (void)setAutoPerformQuery:(BOOL)val

If YES, the query will be performed when the tableView asks for data.


setDatabase:

- (void)setDatabase:(id <RTSQLDatabase>)inDatabase

Sets the database queried by this data source.


setDatabaseName:

- (void)setDatabaseName:(NSString*)inName

Sets the name of the database queried by this data source.


setDisplayErrors:

- (void)setDisplayErrors:(BOOL)display

If YES, the user will be shown a sheet or alert with any error messages returned from the server.


setLoadDataOnAwake:

- (void)setLoadDataOnAwake:(BOOL)val

If YES, the query will be performed when the awakeFromNib message is received.


setQueryString:

- (void)setQueryString:(NSString*)inQuery

Sets the query used to populate this data source.


setQueryStringNoExecute:

- (void)setQueryStringNoExecute:(NSString*)inQuery

Sets the query used to populate this data source without executing the query.


setSession:

- (void)setSession:(id <RTSQLSession>)inSession

Sets the session used by this data source.


setSortingEnabled:

- (void)setSortingEnabled:(BOOL)val

If YES, the user can click on column titles to sort the data by that column.


setTableView:

- (void)setTableView:(NSTableView*)inView

Sets the NSTableView managed by this data source.


setUpdateColumnTitles:

- (void)setUpdateColumnTitles:(BOOL)val

If set to YES, the titles of the tableView's columns will be updated with the names of the columns in the database.


sortingEnabled

- (BOOL)sortingEnabled

If YES, the user can click on column titles to sort the data by that column.


tableView

- (NSTableView*)tableView

Returns the NSTableView managed by this data source.


updateColumnTitles

- (BOOL)updateColumnTitles

Returns YES if the titles of the tableView's columns will be updated with the names of the columns in the database.




Notifications


RTQueryDataSource posts the following notifications to interested observers.

RTQueryDataSourceErrorNotification

This notification object contains the RTQueryDataSource as the notification object. It is posted when an error happens while performing the query. The userInfo dictionary will have the actual reason under the key "Reason".


Copyright ©2006 by Runtime Labs, Inc.. All Rights Reserved.