From 7b5f4d96727a505b67b7970e0b4f2ca1de0394a2 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 5 Jun 2009 17:44:48 +0000 Subject: =?UTF-8?q?=E2=80=A2=20reload=20table=20list,=20database=20pull-do?= =?UTF-8?q?wn=20menu=20according=20to=20user's=20statements=20in=20the=20C?= =?UTF-8?q?ustom=20Query=20editor=20if=20necessary=20-=20if=20statement=20?= =?UTF-8?q?begins=20with:=20use,=20create,=20alter,=20rename,=20drop=20?= =?UTF-8?q?=E2=80=A2=20reload=20table=20list,=20database=20pull-down=20men?= =?UTF-8?q?u=20according=20to=20imported=20statements=20=E2=80=A2=20sped?= =?UTF-8?q?=20up=20"Import=20MySQL=20Dump"=20=E2=80=A2=20fixed=20some=20ti?= =?UTF-8?q?ny=20issues=20of=20the=20last=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableDocument.m | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'Source/TableDocument.m') diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 192c93a5..cea86c3c 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -911,6 +911,47 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removedatabase"]; } +/* + * Reset the current selected database name + */ +- (void) refreshCurrentDatabase +{ + NSString *dbName; + + // Notify listeners that a query has started + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + + CMMCPResult *theResult = [mySQLConnection queryString:@"SELECT DATABASE()"]; + if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + int i; + int r = [theResult numOfRows]; + if (r) [theResult dataSeek:0]; + for ( i = 0 ; i < r ; i++ ) { + dbName = [[theResult fetchRowAsArray] objectAtIndex:0]; + } + if(![dbName isKindOfClass:[NSNull class]]) { + if(![dbName isEqualToString:selectedDatabase]) { + if (selectedDatabase) { + [selectedDatabase release]; + selectedDatabase = nil; + } + selectedDatabase = [dbName retain]; + [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; + [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], selectedDatabase]]; + } + } else { + [selectedDatabase release]; + selectedDatabase = nil; + [chooseDatabaseButton selectItemAtIndex:0]; + [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/", mySQLVersion, [self name]]]; + } + } + + //query finished + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + +} + #pragma mark - #pragma mark Console methods -- cgit v1.2.3