aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDatabaseDocument.h1
-rw-r--r--Source/SPDatabaseDocument.m53
-rw-r--r--Source/SPSplitView.m2
-rw-r--r--Source/SPTablesList.h1
-rw-r--r--Source/SPTablesList.m41
5 files changed, 41 insertions, 57 deletions
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index f84e8826..73a322d7 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -377,7 +377,6 @@
- (IBAction)saveCreateSyntax:(id)sender;
- (IBAction)copyCreateTableSyntaxFromSheet:(id)sender;
- (IBAction)focusOnTableContentFilter:(id)sender;
-- (IBAction)focusOnTableListFilter:(id)sender;
- (IBAction)export:(id)sender;
- (IBAction)exportSelectedTablesAs:(id)sender;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index c296fba6..9bcb9733 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -535,10 +535,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
queryEditorInitString = nil;
}
- // Set focus to table list filter field if visible
- // otherwise set focus to Table List view
- [self focusOnTableListFilter:self];
-
if (spfSession != nil) {
// Restore vertical split view divider for tables' list and right view (Structure, Content, etc.)
@@ -578,6 +574,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
if ([self database]) [self detectDatabaseEncoding];
+
+ // Set focus to table list filter field if visible
+ // otherwise set focus to Table List view
+ [[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
#endif
#ifdef SP_REFACTOR /* glue */
if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentDidConnect:)] )
@@ -2298,14 +2298,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
/**
- * Makes the tables list filter field the first responder.
- */
-- (IBAction)focusOnTableListFilter:(id)sender
-{
- [[tablesListInstance onMainThread] performSelector:@selector(makeTableListFilterHaveFocus) withObject:nil afterDelay:0.25];
-}
-
-/**
* Exports the selected tables in the chosen file format.
*/
- (IBAction)exportSelectedTablesAs:(id)sender
@@ -6045,13 +6037,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
selectedDatabase = [[NSString alloc] initWithString:targetDatabaseName];
#endif
-#ifndef SP_REFACTOR /* clear SPTablesList selection */
- // If the item has changed, clear the item selection for cleaner loading
- if (![targetItemName isEqualToString:[self table]]) {
- [[tablesListInstance onMainThread] setTableListSelectability:YES];
- [[[tablesListInstance valueForKey:@"tablesListView"] onMainThread] deselectAll:self];
- [[tablesListInstance onMainThread] setTableListSelectability:NO];
- }
+#ifndef SP_REFACTOR /* update database encoding */
// Update the stored database encoding, used for views, "default" table encodings, and to allow
// or disallow use of the "View using encoding" menu
@@ -6071,25 +6057,28 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[spHistoryControllerInstance setModifyingState:NO];
[spHistoryControllerInstance updateHistoryEntries];
}
-
- // Set focus to table list filter field if visible
- // otherwise set focus to Table List view
- [self focusOnTableListFilter:self];
#endif
}
#ifndef SP_REFACTOR /* update selected table in SPTablesList */
+
+ BOOL focusOnFilter = YES;
+ if (targetItemName) focusOnFilter = NO;
+
// If a the table has changed, update the selection
- if (![targetItemName isEqualToString:[self table]]) {
- if (targetItemName) {
- [tablesListInstance selectItemWithName:targetItemName];
- }
- else {
- [[tablesListInstance onMainThread] setTableListSelectability:YES];
- [[[tablesListInstance valueForKey:@"tablesListView"] onMainThread] deselectAll:self];
- [[tablesListInstance onMainThread] setTableListSelectability:NO];
- }
+ if (![targetItemName isEqualToString:[self table]] && targetItemName) {
+ focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName];
+ }
+
+ // Ensure the window focus is on the table list or the filter as appropriate
+ [[tablesListInstance onMainThread] setTableListSelectability:YES];
+ if (focusOnFilter) {
+ [[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
+ } else {
+ [[tablesListInstance onMainThread] makeTableListHaveFocus];
}
+ [[tablesListInstance onMainThread] setTableListSelectability:NO];
+
#endif
[self endTask];
#ifndef SP_REFACTOR /* triggered commands */
diff --git a/Source/SPSplitView.m b/Source/SPSplitView.m
index 49097d41..2793fd87 100644
--- a/Source/SPSplitView.m
+++ b/Source/SPSplitView.m
@@ -1106,7 +1106,7 @@
// Restore the first responder if appropriate
if (firstResponderToRestore) {
- [[self window] makeFirstResponder:firstResponderToRestore];
+ [[wrappedView window] makeFirstResponder:firstResponderToRestore];
}
[wrappedView release], wrappedView = nil;
diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h
index 172fff67..8d267c71 100644
--- a/Source/SPTablesList.h
+++ b/Source/SPTablesList.h
@@ -162,6 +162,7 @@
#ifndef SP_REFACTOR /* method decls */
- (void)selectTableAtIndex:(NSNumber *)row;
- (void)makeTableListFilterHaveFocus;
+- (void)makeTableListHaveFocus;
#endif
// Getters
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index cbe4d4da..30e22eab 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -264,29 +264,18 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
// Check for mysql errors - if information_schema is not accessible for some reasons
// omit adding procedures and functions
- if(![mySQLConnection queryErrored] && theResult != nil && [theResult numberOfRows] ) {
+ if(![mySQLConnection queryErrored] && theResult != nil && [theResult numberOfRows] && [theResult numberOfFields] > 3) {
// Add the header row
[tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")];
[tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeNone]];
- if( [theResult numberOfFields] == 1 ) {
- for (NSArray *eachRow in theResult) {
- [tables addObject:NSArrayObjectAtIndex(eachRow, 3)];
- if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) {
- [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]];
- } else {
- [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]];
- }
- }
- } else {
- for (NSArray *eachRow in theResult) {
- [tables addObject:NSArrayObjectAtIndex(eachRow, 3)];
- if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) {
- [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]];
- } else {
- [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]];
- }
+ for (NSArray *eachRow in theResult) {
+ [tables addObject:NSArrayObjectAtIndex(eachRow, 3)];
+ if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) {
+ [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]];
+ } else {
+ [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]];
}
}
}
@@ -1830,20 +1819,26 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
}
/**
- * Set focus to table list filter search field
+ * Set focus to table list filter search field, or the table list if the filter
+ * field is not visible.
*/
- (void) makeTableListFilterHaveFocus
{
if([tables count] > 20) {
[[tableDocumentInstance parentWindow] makeFirstResponder:listFilterField];
}
- else if([tables count] > 2) {
+ else {
[[tableDocumentInstance parentWindow] makeFirstResponder:tablesListView];
- if([tablesListView numberOfSelectedRows] < 1)
- [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
-
}
}
+
+/**
+ * Set focus to the table list.
+ */
+- (void) makeTableListHaveFocus
+{
+ [[tableDocumentInstance parentWindow] makeFirstResponder:tablesListView];
+}
#endif
/**