aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTablesList.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-22 07:42:35 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-22 07:42:35 +0000
commite30cdeb6ee289fc4221d7b3fc5ec9e58be059675 (patch)
treea6b3bc9aa0d3676dd25081bc93f79631678d1cd0 /Source/SPTablesList.m
parent20c836954dce8f0d07788003b44e44990ac3a29d (diff)
downloadsequelpro-e30cdeb6ee289fc4221d7b3fc5ec9e58be059675.tar.gz
sequelpro-e30cdeb6ee289fc4221d7b3fc5ec9e58be059675.tar.bz2
sequelpro-e30cdeb6ee289fc4221d7b3fc5ec9e58be059675.zip
• renamed some shell variables for Bundle commands
• added sequelpro scheme commands: SelectTables, ReloadTablesList, ReloadContentTable
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r--Source/SPTablesList.m40
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index fc7be0f8..6fdca8c0 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -1155,6 +1155,46 @@
return YES;
}
+/**
+ * Try to select items using the provided names in theNames; returns YES if at least
+ * one item could be seleceted, otherwise NO.
+ */
+- (BOOL)selectItemsWithNames:(NSArray *)theNames
+{
+ NSInteger i, tableType;
+ NSInteger itemIndex = NSNotFound;
+ NSMutableIndexSet *selectionIndexSet = [NSMutableIndexSet indexSet];
+
+ // Loop through the unfiltered tables/views to find the desired item
+ for(NSString* theName in theNames) {
+ for (i = 0; i < [tables count]; i++) {
+ tableType = [[tableTypes objectAtIndex:i] integerValue];
+ if (tableType == SPTableTypeNone) continue;
+ if ([[tables objectAtIndex:i] isEqualToString:theName]) {
+ [selectionIndexSet addIndex:i];
+ }
+ else if ([[tables objectAtIndex:i] compare:theName options:NSCaseInsensitiveSearch|NSLiteralSearch] == NSOrderedSame)
+ [selectionIndexSet addIndex:i];
+ }
+ }
+
+ // If no match found, return failure
+ if (![selectionIndexSet count]) return NO;
+
+ if (!isTableListFiltered) {
+ [tablesListView selectRowIndexes:selectionIndexSet byExtendingSelection:NO];
+ } else {
+ [tablesListView deselectAll:nil];
+ [listFilterField setStringValue:@""];
+ [self updateFilter:self];
+ [tablesListView selectRowIndexes:selectionIndexSet byExtendingSelection:NO];
+ }
+
+ [[tablesListView onMainThread] scrollRowToVisible:[tablesListView selectedRow]];
+
+ return YES;
+}
+
#pragma mark -
#pragma mark Datasource methods