RTEditableDataSource


Inherits From:
NSObject
Conforms To:
RTSQLDataSource
Declared In:
RTEditableDataSource.h


Class Description

An RTEditableDataSource is a subclass of RTQueryDataSource that is used when a selection of fields from a table are to be edited. Normally an instance of this class is associated with an RTRowEditor object that handles the actual INSERT and UPDATE queries.


Symbolic Constants

RTDataMode_Edit  0
RTDataMode_Find  1
RTDataMode_ReadOnly  2

Description:

Constants used for the current mode of the DataSource.


Method Types

- delegate
- setDelegate:
- session
- setSession:
- database
- setDatabase:
- table
- setTable:
- useBackgroundThread
- setUseBackgroundThread:
- rowCount
- currentRowIndex
- currentRow
- nextRow
- whereConditions
- setWhereConditions:
- sortOrder
- setSortOrder:
- deleteCurrentRow
- insertNewRow
- duplicateCurrentRow
- canMoveForward
- canMoveBackward
- canMoveToStart
- canMoveToEnd
- reloadData:
- moveForward:
- moveBackward:
- moveToStart:
- moveToEnd:
- doInsertRow:
- doDeleteCurrentRow:
- doDuplicateCurrentRow:

Instance Methods

canMoveBackward

- (BOOL)canMoveBackward

Returns YES if the currentRow can be be changed by moving backward.


canMoveForward

- (BOOL)canMoveForward

Returns YES if the currentRow can be be changed by moving forward.


canMoveToEnd

- (BOOL)canMoveToEnd

Returns YES if the currentRow can be be changed by moving to the last row.


canMoveToStart

- (BOOL)canMoveToStart

Returns YES if the currentRow can be be changed by moving to the first row.


currentRow

- (id <RTSQLRow>)currentRow

Returns the current row.


currentRowIndex

- (SInt32)currentRowIndex

Returns the 1-based index to the current row.


database

- (id <RTSQLDatabase>)database

Returns the database used by this data source.


delegate

- (id)delegate

Returns the delegate object.


deleteCurrentRow

- (BOOL)deleteCurrentRow

Deletes the current row. Returns YES on success, NO on failure.


doDeleteCurrentRow:

- (IBAction)doDeleteCurrentRow:(id)sender

Action method that calls deleteCurrentRow and ignores the result.


doDuplicateCurrentRow:

- (IBAction)doDuplicateCurrentRow:(id)sender

Action method that calls duplicateCurrentRow and ignores the result.


doInsertRow:

- (IBAction)doInsertRow:(id)sender

Action method that calls insertRow and ignores the result.


duplicateCurrentRow

- (BOOL)duplicateCurrentRow

Duplicates the current row into a new row at the end. Returns YES on success, NO on failure.


insertNewRow

- (BOOL)insertNewRow

Inserts a new row at the end. Returns YES on success, NO on failure.


moveBackward:

- (IBAction)moveBackward:(id)sender

Moves the current row backward by one row. Can fail if the delegate refuses to allow the current row to change.


moveForward:

- (IBAction)moveForward:(id)sender

Moves the current row forward by one row. Can fail if the delegate refuses to allow the current row to change.


moveToEnd:

- (IBAction)moveToEnd:(id)sender

Moves the current row to the last row. Can fail if the delegate refuses to allow the current row to change.


moveToStart:

- (IBAction)moveToStart:(id)sender

Moves the current row to the first row. Can fail if the delegate refuses to allow the current row to change.


nextRow

- (id <RTSQLRow>)nextRow

Moves to the next row and returns it. If nil is returned either the currentRow is the last row or the delegate did not allow the current row to be changed.


reloadData:

- (IBAction)reloadData:(id)sender

Builds the appropriate query and executes it.


rowCount

- (SInt32)rowCount

Returns the number of rows returned from the database. If all the rows haven't been fetched, they will all be fetched before this method returns.


session

- (id <RTSQLSession>)session

Returns the session used by this data source.


setDatabase:

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

Sets the database used by this data source.


setDelegate:

- (void)setDelegate:(id)inDelegate

Sets the delegate object.


setSession:

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

Sets the session used by this data source.


setSortOrder:

- (void)setSortOrder:(NSString*)str

Sets the sort order clause used by this data source.


setTable:

- (void)setTable:(id <RTSQLTable>)inTable

Sets the SQL table used by this data source.


setUseBackgroundThread:

- (void)setUseBackgroundThread:(BOOL)thread

Sets if this data source performs database operations in a background thread. Warning: this message will block if a background operation is in progress.


setWhereConditions:

- (void)setWhereConditions:(NSString*)str

Sets the base where conditions used by this data source.


sortOrder

- (NSString*)sortOrder

Returns the sort order clause used by this data source.


table

- (id <RTSQLTable>)table

Returns the SQL table used by this data source.


useBackgroundThread

- (BOOL)useBackgroundThread

Returns YES if this data source performs database operations in a background thread.


whereConditions

- (NSString*)whereConditions

Returns the base where conditions used by this data source.




Methods Implemented by the Delegate



editableDataSource:didInsertRow:

- (void)editableDataSource:(RTEditableDataSource *)dataSource didInsertRow:(id<RTSQLRow>)row

Sent after the editable data source adds an empty row. This message will be preceded by a call to editableDataSourceShouldChangeCurrentRow: and followed with a call to editableDataSourceDidChangeCurrentRow:.


editableDataSource:errorDuringOperation:exception:

- (void)editableDataSource:(RTEditableDataSource *)dataSource errorDuringOperation:(NSString*)operation exception:(NSException*)exception

Sent when an error happens during a database operation. The operation will be one of the following: SELECT, INSERT, UPDATE, DELETE. If possible, the requested action will be reverted.


editableDataSourceDidChangeCurrentRow:

- (void)editableDataSourceDidChangeCurrentRow:(RTEditableDataSource *)dataSource

Sent after the editable data source changes the current row.


editableDataSourceDidCompleteBackgroundFetch:

- (void)editableDataSourceDidCompleteBackgroundFetch:(RTEditableDataSource *)dataSource

Called after dataSource completes fetching data in a background thread.


editableDataSourceDidDeleteCurrentRow:

- (void)editableDataSourceDidDeleteCurrentRow:(RTEditableDataSource *)dataSource

Sent after the editable data source deletes the current row. This message will be followed with a call to editableDataSourceDidChangeCurrentRow:.


editableDataSourceShouldChangeCurrentRow:

- (BOOL)editableDataSourceShouldChangeCurrentRow:(RTEditableDataSource *)dataSource

Sent before the editable data source changes the current row. The current row will not be changed if NO is returned.


editableDataSourceShouldDeleteCurrentRow:

- (BOOL)editableDataSourceShouldDeleteCurrentRow:(RTEditableDataSource *)dataSource

Sent before the editable data source deletes the current row. The current row will not be deleted if NO is returned.


editableDataSourceWillBeginBackgroundFetch:

- (void)editableDataSourceWillBeginBackgroundFetch:(RTEditableDataSource *)dataSource

Called before dataSource beings fetching data in a background thread.


editableDataSourceWorkingOnBackgroundFetch:percentComplete:

- (void)editableDataSourceWorkingOnBackgroundFetch:(RTEditableDataSource *)dataSource percentComplete:(float)percent

Called while dataSource is fetching data in a background thread. percent will be a value from 0.0 to 1.0 suitable for use in a progress bar. If percent is less than 0.0, then the amount complete is indeterminate.




Notifications


RTEditableDataSource posts the following notifications to interested observers.

RTEditableDataSourceRowChangedNotification

This notification object contains the RTEditableDataSource as the notification object. It is posted when the currentRow of the data source has changed.

RTEditableDataSourceRowSavedNotification

This notification object contains the RTEditableDataSource as the notification object. It is posted when changes to the currentRow of the data source have been saved.

RTEditableDataSourceRowRevertedNotification

This notification object contains the RTEditableDataSource as the notification object. It is posted when changes to the currentRow of the data source have been reverted.


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