Update of /cvsroot/pgsqlformac/QueryTool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7303 Modified Files: ChangeLog MyOutlineView.m MyResultsView.m PreferenceController.h PreferenceController.m SqlDocument.h SqlDocument.m TODO.txt Log Message: Add remember multiple connections. Index: TODO.txt =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/TODO.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TODO.txt 17 Sep 2006 15:41:48 -0000 1.10 --- TODO.txt 2 Dec 2006 14:51:43 -0000 1.11 *************** *** 4,7 **** --- 4,9 ---- TODO - Features, Functions and Warnings (in rough priority order) ======================================= + - 2006-11-10 Move threading to library. + - 2006-09-17 Error message not reset at the beginning of a query. *************** *** 27,31 **** FIXME (Known Errors) ==================== ! - 2006-08-26 Function return parameters not correctly determined, see below: CREATE or REPLACE FUNCTION pgcocoa_test_schema.create_time_stamp AS $$ --- 29,56 ---- FIXME (Known Errors) ==================== ! ! - 2006-09-01 "Save As" always saves the query window, should save the log window if the log window is front most. ! ! - 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] -[NSBigMutableString characterAtIndex:] called with out-of-bounds index. For apps linked on Tiger this will raise an exception. For earlier apps it will produce this one-time warning and continue with existing behavior (which is undefined). ! 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] Exception raised during posting of notification. Ignored. exception: *** -[NSBigMutableString characterAtIndex:]: Range or index out of bounds ! ! ! Completed ! ========= ! - 2006-11-10 Need to be able to save multiple connections in preferences. (12/02/2006) ! ! - 2006-08-26 Function return parameters not correctly determined, see below: (10/30/2006) ! ! SOURCE: ! ! sql = [NSString stringWithFormat:@"%s%@.%@.%s", "CREATE or REPLACE FUNCTION ", PGCocoaTestDatabase, PGCocoaTestSchema, ! "create_time_stamp() RETURNS trigger AS $time_stamp$\n\ ! BEGIN\n\ ! NEW.create_time := current_timestamp;\n\ ! RETURN NEW;\n\ ! END;\n\ ! $time_stamp$ LANGUAGE plpgsql;\n"]; ! ! RESULT: CREATE or REPLACE FUNCTION pgcocoa_test_schema.create_time_stamp AS $$ *************** *** 36,47 **** $$ LANGUAGE plpgsql; - - 2006-09-01 "Save As" always saves the query window, should save the log window if the log window is front most. - - - 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] -[NSBigMutableString characterAtIndex:] called with out-of-bounds index. For apps linked on Tiger this will raise an exception. For earlier apps it will produce this one-time warning and continue with existing behavior (which is undefined). - 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] Exception raised during posting of notification. Ignored. exception: *** -[NSBigMutableString characterAtIndex:]: Range or index out of bounds - Completed - ========= - 2006-09-17 Data columns in the results table are not resizing. --- 61,86 ---- $$ LANGUAGE plpgsql; + -- psql SQL result of \df + SELECT n.nspname as "Schema", + p.proname as "Name", + CASE WHEN p.proretset THEN 'setof ' ELSE '' END || pg_catalog.format_type(p.prorettype, NULL) as "Result data type", + pg_catalog.oidvectortypes(p.proargtypes) as "Argument data types", + r.rolname as "Owner", + l.lanname as "Language", + p.prosrc as "Source code", + pg_catalog.obj_description(p.oid, 'pg_proc') as "Description" + FROM pg_catalog.pg_proc p + LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang + JOIN pg_catalog.pg_roles r ON r.oid = p.proowner + WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype + AND (p.proargtypes[0] IS NULL + OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype) + AND NOT p.proisagg + AND p.proname ~ '^create_time_stamp$' + AND n.nspname ~ '^pgcocoa_test_schema$' + ORDER BY 1, 2, 3, 4; - 2006-09-17 Data columns in the results table are not resizing. Index: MyOutlineView.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/MyOutlineView.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MyOutlineView.m 30 Aug 2006 21:25:49 -0000 1.8 --- MyOutlineView.m 2 Dec 2006 14:51:43 -0000 1.9 *************** *** 1,3 **** --- 1,4 ---- #import "MyOutlineView.h" + #import "PreferenceController.h" @implementation MyOutlineView *************** *** 156,159 **** --- 157,166 ---- newItem = [[NSMenuItem alloc] init]; + [newItem setTitle:@"SELECT function()"]; + [newItem setTarget: menuActionTarget]; + [newItem setAction: @selector(onSelectExecuteFunctionMenuItem:)]; + [functionMenu addItem: newItem]; + + newItem = [[NSMenuItem alloc] init]; [newItem setTitle:@"CREATE OR REPLACE FUNCTION template ()"]; [newItem setTarget: menuActionTarget]; *************** *** 239,244 **** [self setRowHeight:[[[theCols objectAtIndex:0] dataCell] cellSize].height]; ! [[NSUserDefaults standardUserDefaults] setObject:[currentFont fontName] forKey:@"PGSqlForMac_QueryTool_SchemaTableFontName"]; ! [[NSUserDefaults standardUserDefaults] setFloat:[currentFont pointSize] forKey:@"PGSqlForMac_QueryTool_SchemaTableFontSize"]; } --- 246,251 ---- [self setRowHeight:[[[theCols objectAtIndex:0] dataCell] cellSize].height]; ! [[NSUserDefaults standardUserDefaults] setObject:[currentFont fontName] forKey:UDSchemaTableFontName]; ! [[NSUserDefaults standardUserDefaults] setFloat:[currentFont pointSize] forKey:UDSchemaTableFontSize]; } Index: ChangeLog =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/ChangeLog,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ChangeLog 4 Sep 2006 14:51:13 -0000 1.18 --- ChangeLog 2 Dec 2006 14:51:43 -0000 1.19 *************** *** 1,2 **** --- 1,21 ---- + 2006-09-17 10:41 ntiffin + + * QueryTool.h, SqlDocument.m, TODO.txt, + English.lproj/SqlDocument.nib/keyedobjects.nib, + QueryToolForPostgresN.xcodeproj/ntiffin.mode1, + QueryToolForPostgresN.xcodeproj/ntiffin.pbxuser: Add automatic + result column resizing. + + 2006-09-13 18:13 ntiffin + + * QueryTool.h: Add missing global definition. + + 2006-09-04 09:51 ntiffin + + * ChangeLog, QueryToolForPostgresN.xcodeproj/ntiffin.mode1, + QueryToolForPostgresN.xcodeproj/ntiffin.pbxuser, + QueryToolForPostgresN.xcodeproj/project.pbxproj: Add fink based + XCode project file. + 2006-09-04 09:22 ntiffin *************** *** 7,10 **** --- 26,35 ---- and refactor preferences. + 2006-08-31 19:56 ntiffin + + * ChangeLog, SqlDocument.m, Help/.DS_Store, Help/index.html: Fix + for PGconn not being thread safe. Migrate to new PQconnectdb API. + Add help text. + 2006-08-30 16:25 ntiffin Index: PreferenceController.h =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/PreferenceController.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PreferenceController.h 4 Sep 2006 14:22:07 -0000 1.3 --- PreferenceController.h 2 Dec 2006 14:51:43 -0000 1.4 *************** *** 10,13 **** --- 10,41 ---- #import "QueryTool.h" + /* Active NSUserDefaults Key Strings */ + NSString * const UDUserDefaultsVersion = @"PGSqlForMac_QueryTool_UserDefaultsVersion"; + NSString * const UDShowInformationSchema = @"PGSqlForMac_QueryTool_ShowInformationSchema"; + NSString * const UDShowPGCatalogSchema = @"PGSqlForMac_QueryTool_ShowPGCatalogSchema"; + NSString * const UDShowPGToastSchema = @"PGSqlForMac_QueryTool_ShowPGToastSchema"; + NSString * const UDShowPGTempsSchema = @"PGSqlForMac_QueryTool_ShowPGTempsSchema"; + NSString * const UDShowPGPublicSchema = @"PGSqlForMac_QueryTool_ShowPGPublicSchema"; + NSString * const UDLogSQL = @"PGSqlForMac_QueryTool_LogSQL"; + NSString * const UDLogQueryInfo = @"PGSqlForMac_QueryTool_LogQueryInfo"; + NSString * const UDShowPostgreSQLHelp = @"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"; + NSString * const UDShowSQLCommandHelp = @"PGSqlForMac_QueryTool_ShowSQLCommandHelp"; + NSString * const UDResultsTableFontName = @"PGSqlForMac_QueryTool_ResultsTableFontName"; + NSString * const UDResultsTableFontSize = @"PGSqlForMac_QueryTool_ResultsTableFontSize"; + NSString * const UDHighlight_Keywords = @"PGSqlForMac_QueryTool_Highlight_Keywords"; + NSString * const UDSchemaTableFontName = @"PGSqlForMac_QueryTool_SchemaTableFontName"; + NSString * const UDSchemaTableFontSize = @"PGSqlForMac_QueryTool_SchemaTableFontSize"; + + // New connection key names for connection dictionary + NSString * const UDConnArrayName = @"ConnArray"; + NSString * const UDConnName = @"Name"; + NSString * const UDConnUserName = @"UserName"; + NSString * const UDConnHost = @"Host"; + NSString * const UDConnPort = @"Port"; + NSString * const UDConnDatabaseName = @"DatabaseName"; + + // Last Connection Name + NSString * const UDLastConn = @"LastConnection"; + @interface PreferenceController : NSWindowController { IBOutlet NSButton *prefShowPGInfoSchema; *************** *** 22,25 **** --- 50,59 ---- IBOutlet NSTextField *prefPostgresqlHelpURL; IBOutlet NSTextField *prefPostgresqlSQLURL; + + IBOutlet NSTextField *prefConnUserName; + IBOutlet NSTextField *prefConnPassword; + IBOutlet NSTextField *prefConnDBName; + IBOutlet NSTextField *prefConnServer; + IBOutlet NSTextField *prefConnPort; } *************** *** 27,32 **** --- 61,74 ---- -(IBAction)savePreferences:(id)sender; -(IBAction)cancelPreferences:(id)sender; + -(IBAction)deleteConnection:(id)sender; + -(IBAction)newConnection:(id)sender; + -(IBAction)selectConnection:(id)sender; -(void)createApplicationDefaultPreferences; @end + + /* Userdefaults History */ + /* Version */ + /* 1 = Prior to correct UDUserDefaultsVersion value */ + /* 2 = current */ Index: PreferenceController.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/PreferenceController.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PreferenceController.m 4 Sep 2006 14:22:07 -0000 1.2 --- PreferenceController.m 2 Dec 2006 14:51:43 -0000 1.3 *************** *** 24,28 **** NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"]) { [prefShowPGInfoSchema setState:NSOnState]; --- 24,28 ---- NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! if ([userDefaults boolForKey:UDShowInformationSchema]) { [prefShowPGInfoSchema setState:NSOnState]; *************** *** 32,36 **** [prefShowPGInfoSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"]) { [prefShowPGCatalogSchema setState:NSOnState]; --- 32,36 ---- [prefShowPGInfoSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:UDShowPGCatalogSchema]) { [prefShowPGCatalogSchema setState:NSOnState]; *************** *** 40,44 **** [prefShowPGCatalogSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"]) { [prefShowPGToastSchema setState:NSOnState]; --- 40,44 ---- [prefShowPGCatalogSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:UDShowPGToastSchema]) { [prefShowPGToastSchema setState:NSOnState]; *************** *** 48,52 **** [prefShowPGToastSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"]) { [prefShowPGTempSchema setState:NSOnState]; --- 48,52 ---- [prefShowPGToastSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:UDShowPGTempsSchema]) { [prefShowPGTempSchema setState:NSOnState]; *************** *** 56,60 **** [prefShowPGTempSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"]) { [prefShowPGPublicSchema setState:NSOnState]; --- 56,60 ---- [prefShowPGTempSchema setState:NSOffState]; } ! if ([userDefaults boolForKey:UDShowPGPublicSchema]) { [prefShowPGPublicSchema setState:NSOnState]; *************** *** 65,69 **** } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_LogSQL"]) { [prefLogAllSQL setState:NSOnState]; --- 65,69 ---- } ! if ([userDefaults boolForKey:UDLogSQL]) { [prefLogAllSQL setState:NSOnState]; *************** *** 73,77 **** [prefLogAllSQL setState:NSOffState]; } ! if ([userDefaults boolForKey:@"PGSqlForMac_QueryTool_LogQueryInfo"]) { [prefLogInfoMessages setState:NSOnState]; --- 73,77 ---- [prefLogAllSQL setState:NSOffState]; } ! if ([userDefaults boolForKey:UDLogQueryInfo]) { [prefLogInfoMessages setState:NSOnState]; *************** *** 82,87 **** } ! [prefPostgresqlHelpURL setStringValue:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"]]; ! [prefPostgresqlSQLURL setStringValue:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowSQLCommandHelp"]]; } --- 82,87 ---- } ! [prefPostgresqlHelpURL setStringValue:[userDefaults stringForKey:UDShowPostgreSQLHelp]]; ! [prefPostgresqlSQLURL setStringValue:[userDefaults stringForKey:UDShowSQLCommandHelp]]; } *************** *** 105,110 **** [prefLogInfoMessages setState:NSOnState]; ! [prefPostgresqlHelpURL setStringValue:@"file:///sw/share/doc/postgresql81/html/index.html"]; ! [prefPostgresqlSQLURL setStringValue:@"file:///sw/share/doc/postgresql81/html/sql-commands.html"]; } --- 105,125 ---- [prefLogInfoMessages setState:NSOnState]; ! NSFileManager *fileManager = [NSFileManager defaultManager]; ! if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/index.html"]) ! { ! [prefPostgresqlHelpURL setStringValue:@"file:///sw/share/doc/postgresql81/html/index.html"]; ! } ! else ! { ! [prefPostgresqlHelpURL setStringValue:@""]; ! } ! if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/sql-commands.html"]) ! { ! [prefPostgresqlSQLURL setStringValue:@"file:///sw/share/doc/postgresql81/html/sql-commands.html"]; ! } ! else ! { ! [prefPostgresqlSQLURL setStringValue:@""]; ! } } *************** *** 116,177 **** if ([prefShowPGInfoSchema state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"]; } if ([prefShowPGCatalogSchema state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"]; } if ([prefShowPGToastSchema state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"]; } if ([prefShowPGTempSchema state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"]; } if ([prefShowPGPublicSchema state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"]; } if ([prefLogAllSQL state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_LogSQL"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_LogSQL"]; } if ([prefLogInfoMessages state]) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_LogQueryInfo"]; } else { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_LogQueryInfo"]; } ! [userDefaults setObject:[prefPostgresqlHelpURL stringValue] forKey:@"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"]; ! [userDefaults setObject:[prefPostgresqlSQLURL stringValue] forKey:@"PGSqlForMac_QueryTool_ShowSQLCommandHelp"]; [[NSUserDefaults standardUserDefaults] synchronize]; [[self window] close]; --- 131,192 ---- if ([prefShowPGInfoSchema state]) { ! [userDefaults setObject:@"yes" forKey:UDShowInformationSchema]; } else { ! [userDefaults setObject:@"no" forKey:UDShowInformationSchema]; } if ([prefShowPGCatalogSchema state]) { ! [userDefaults setObject:@"yes" forKey:UDShowPGCatalogSchema]; } else { ! [userDefaults setObject:@"no" forKey:UDShowPGCatalogSchema]; } if ([prefShowPGToastSchema state]) { ! [userDefaults setObject:@"yes" forKey:UDShowPGToastSchema]; } else { ! [userDefaults setObject:@"no" forKey:UDShowPGToastSchema]; } if ([prefShowPGTempSchema state]) { ! [userDefaults setObject:@"yes" forKey:UDShowPGTempsSchema]; } else { ! [userDefaults setObject:@"no" forKey:UDShowPGTempsSchema]; } if ([prefShowPGPublicSchema state]) { ! [userDefaults setObject:@"yes" forKey:UDShowPGPublicSchema]; } else { ! [userDefaults setObject:@"no" forKey:UDShowPGPublicSchema]; } if ([prefLogAllSQL state]) { ! [userDefaults setObject:@"yes" forKey:UDLogSQL]; } else { ! [userDefaults setObject:@"no" forKey:UDLogSQL]; } if ([prefLogInfoMessages state]) { ! [userDefaults setObject:@"yes" forKey:UDLogQueryInfo]; } else { ! [userDefaults setObject:@"no" forKey:UDLogQueryInfo]; } ! [userDefaults setObject:[prefPostgresqlHelpURL stringValue] forKey:UDShowPostgreSQLHelp]; ! [userDefaults setObject:[prefPostgresqlSQLURL stringValue] forKey:UDShowSQLCommandHelp]; [[NSUserDefaults standardUserDefaults] synchronize]; [[self window] close]; *************** *** 187,190 **** --- 202,237 ---- } + /* + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + host, @"host", + port, @"port", + dbName, @"dbname", + userName, @"user", + nil]; + return dict; + */ + + -(IBAction)deleteConnection:(id)sender; + { + UNUSED_PARAMETER(sender); + NSLog(@"%s: deleteConnection not implemented.", __FILE__); + // TODO + } + + -(IBAction)newConnection:(id)sender; + { + UNUSED_PARAMETER(sender); + NSLog(@"%s: newConnection not implemented.", __FILE__); + // TODO + } + + -(IBAction)selectConnection:(id)sender; + { + UNUSED_PARAMETER(sender); + NSLog(@"%s: selectConnection not implemented.", __FILE__); + // TODO + } + + -(void)createApplicationDefaultPreferences { *************** *** 192,274 **** // does not track application version numbering, for future use should we need to ! // drastically change the prefs we will be able to determine what version of prefs // the user has. ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_User_Defaults_Version"] == nil) { ! [userDefaults setObject:@"1.0.0" forKey:@"PGSqlForMac_QueryTool_Pref_Version"]; } ! ! ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"] == nil) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"] == nil) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"] == nil) { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"] == nil) { ! [userDefaults setObject:@"no" forKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"] == nil) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_LogSQL"] == nil) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_LogSQL"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_LogQueryInfo"] == nil) { ! [userDefaults setObject:@"yes" forKey:@"PGSqlForMac_QueryTool_LogQueryInfo"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_SchemaTableFontName"] == nil) { ! [userDefaults setObject:@"Lucida Grande" forKey:@"PGSqlForMac_QueryTool_SchemaTableFontName"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_SchemaTableFontSize"] == nil) { ! [userDefaults setFloat:12.0 forKey:@"PGSqlForMac_QueryTool_SchemaTableFontSize"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ResultsTableFontName"] == nil) { ! [userDefaults setObject:@"Lucida Grande" forKey:@"PGSqlForMac_QueryTool_ResultsTableFontName"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ResultsTableFontSize"] == nil) { ! [userDefaults setFloat:12.0 forKey:@"PGSqlForMac_QueryTool_ResultsTableFontSize"]; } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_Highlight_Keywords"] == nil) { [userDefaults setObject:@"select from where order group by asc desc insert into delete drop create alter table procedure view function" ! forKey:@"PGSqlForMac_QueryTool_Highlight_Keywords"]; } NSFileManager *fileManager = [NSFileManager defaultManager]; ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"] == nil) { if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/index.html"]) { [userDefaults setObject:@"file:///sw/share/doc/postgresql81/html/index.html" ! forKey:@"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"]; } } ! if ([userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowSQLCommandHelp"] == nil) { if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/sql-commands.html"]) { [userDefaults setObject:@"file:///sw/share/doc/postgresql81/html/sql-commands.html" ! forKey:@"PGSqlForMac_QueryTool_ShowSQLCommandHelp"]; } ! } } --- 239,376 ---- // does not track application version numbering, for future use should we need to ! // drastically change the prefs we will be able to quickly determine what version of prefs // the user has. ! if ([userDefaults stringForKey:UDUserDefaultsVersion] == nil) { ! [userDefaults setObject:@"2" forKey:UDUserDefaultsVersion]; } ! if ([userDefaults stringForKey:UDShowInformationSchema] == nil) { ! [userDefaults setObject:@"yes" forKey:UDShowInformationSchema]; } ! if ([userDefaults stringForKey:UDShowPGCatalogSchema] == nil) { ! [userDefaults setObject:@"yes" forKey:UDShowPGCatalogSchema]; } ! if ([userDefaults stringForKey:UDShowPGToastSchema] == nil) { ! [userDefaults setObject:@"no" forKey:UDShowPGToastSchema]; } ! if ([userDefaults stringForKey:UDShowPGTempsSchema] == nil) { ! [userDefaults setObject:@"no" forKey:UDShowPGTempsSchema]; } ! if ([userDefaults stringForKey:UDShowPGPublicSchema] == nil) { ! [userDefaults setObject:@"yes" forKey:UDShowPGPublicSchema]; } ! if ([userDefaults stringForKey:UDLogSQL] == nil) { ! [userDefaults setObject:@"yes" forKey:UDLogSQL]; } ! if ([userDefaults stringForKey:UDLogQueryInfo] == nil) { ! [userDefaults setObject:@"yes" forKey:UDLogQueryInfo]; } ! if ([userDefaults stringForKey:UDSchemaTableFontName] == nil) { ! [userDefaults setObject:@"Lucida Grande" forKey:UDSchemaTableFontName]; } ! if ([userDefaults stringForKey:UDSchemaTableFontSize] == nil) { ! [userDefaults setFloat:12.0 forKey:UDSchemaTableFontSize]; } ! if ([userDefaults stringForKey:UDResultsTableFontName] == nil) { ! [userDefaults setObject:@"Lucida Grande" forKey:UDResultsTableFontName]; } ! if ([userDefaults stringForKey:UDResultsTableFontSize] == nil) { ! [userDefaults setFloat:12.0 forKey:UDResultsTableFontSize]; } ! if ([userDefaults stringForKey:UDHighlight_Keywords] == nil) { [userDefaults setObject:@"select from where order group by asc desc insert into delete drop create alter table procedure view function" ! forKey:UDHighlight_Keywords]; } NSFileManager *fileManager = [NSFileManager defaultManager]; ! if ([userDefaults stringForKey:UDShowPostgreSQLHelp] == nil) { if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/index.html"]) { [userDefaults setObject:@"file:///sw/share/doc/postgresql81/html/index.html" ! forKey:UDShowPostgreSQLHelp]; } } ! if ([userDefaults stringForKey:UDShowSQLCommandHelp] == nil) { if ([fileManager fileExistsAtPath:@"/sw/share/doc/postgresql81/html/sql-commands.html"]) { [userDefaults setObject:@"file:///sw/share/doc/postgresql81/html/sql-commands.html" ! forKey:UDShowSQLCommandHelp]; } ! } ! if ([userDefaults arrayForKey:UDConnArrayName] == nil) ! { ! // Create dictionary with connection details. ! NSMutableDictionary *aConnDict = [NSMutableDictionary dictionaryWithCapacity:6]; ! ! [aConnDict setObject:@"" forKey:UDConnUserName]; ! [aConnDict setObject:@"localhost" forKey:UDConnHost]; ! [aConnDict setObject:@"5432" forKey:UDConnPort]; ! [aConnDict setObject:@"" forKey:UDConnDatabaseName]; ! [aConnDict setObject:@"Default" forKey:UDConnName]; ! ! // Update UserDefaults. ! NSMutableArray *connArray = [NSMutableArray arrayWithCapacity:1]; ! [connArray addObject:aConnDict]; ! [userDefaults setObject:connArray forKey:UDConnArrayName]; ! NSLog(@"Adding new Connection Array: %s, Line %d", __FILE__, __LINE__); ! ! [userDefaults setObject:@"None" forKey:UDLastConn]; ! } ! ! /* remove old user defaults */ ! ! /* Added 2006_11_11 */ ! NSString * const UDUserDefaultsVersionOLD1 = @"PGSqlForMac_QueryTool_User_Defaults_Version"; ! NSString * const UDUserDefaultsVersionOLD2 = @"PGSqlForMac_QueryTool_Pref_Version"; ! if ([userDefaults stringForKey:UDUserDefaultsVersionOLD1] != nil) ! { ! [userDefaults removeObjectForKey:UDUserDefaultsVersionOLD1]; ! } ! if ([userDefaults stringForKey:UDUserDefaultsVersionOLD2] != nil) ! { ! [userDefaults removeObjectForKey:UDUserDefaultsVersionOLD2]; ! } ! ! /* Added 2006_12_01 */ ! NSString * const UDDefaultUserName = @"PGSqlForMac_QueryTool_DefaultUserName"; ! NSString * const UDDefaultHost = @"PGSqlForMac_QueryTool_DefaultHost"; ! NSString * const UDDefaultPort = @"PGSqlForMac_QueryTool_DefaultPort"; ! NSString * const UDDefaultDatabaseName = @"PGSqlForMac_QueryTool_DefaultDatabaseName"; ! if ([userDefaults stringForKey:UDDefaultUserName] != nil) ! { ! [userDefaults removeObjectForKey:UDDefaultUserName]; ! } ! if ([userDefaults stringForKey:UDDefaultHost] != nil) ! { ! [userDefaults removeObjectForKey:UDDefaultHost]; ! } ! if ([userDefaults stringForKey:UDDefaultPort] != nil) ! { ! [userDefaults removeObjectForKey:UDDefaultPort]; ! } ! if ([userDefaults stringForKey:UDDefaultDatabaseName] != nil) ! { ! [userDefaults removeObjectForKey:UDDefaultDatabaseName]; ! } ! ! } Index: MyResultsView.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/MyResultsView.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MyResultsView.m 16 Jul 2006 23:17:39 -0000 1.1 --- MyResultsView.m 2 Dec 2006 14:51:43 -0000 1.2 *************** *** 8,12 **** #import "MyResultsView.h" ! @implementation MyResultsView --- 8,12 ---- #import "MyResultsView.h" ! #import "PreferenceController.h" @implementation MyResultsView *************** *** 25,30 **** [self setRowHeight:[[[theCols objectAtIndex:0] dataCell] cellSize].height]; ! [[NSUserDefaults standardUserDefaults] setObject:[currentFont fontName] forKey:@"PGSqlForMac_QueryTool_ResultsTableFontName"]; ! [[NSUserDefaults standardUserDefaults] setFloat:[currentFont pointSize] forKey:@"PGSqlForMac_QueryTool_ResultsTableFontSize"]; } --- 25,30 ---- [self setRowHeight:[[[theCols objectAtIndex:0] dataCell] cellSize].height]; ! [[NSUserDefaults standardUserDefaults] setObject:[currentFont fontName] forKey:UDResultsTableFontName]; ! [[NSUserDefaults standardUserDefaults] setFloat:[currentFont pointSize] forKey:UDResultsTableFontSize]; } Index: SqlDocument.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/SqlDocument.m,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SqlDocument.m 17 Sep 2006 15:41:48 -0000 1.24 --- SqlDocument.m 2 Dec 2006 14:51:43 -0000 1.25 *************** *** 9,12 **** --- 9,13 ---- #import "SqlDocument.h" #import "SqlToolbarCategory.h" + #import "PreferenceController.h" @implementation SqlDocument *************** *** 27,30 **** --- 28,66 ---- } + + - (void)connectionNameChanged:(id)sender + { + UNUSED_PARAMETER(sender); + NSArray * connArray = [[NSUserDefaults standardUserDefaults] arrayForKey:UDConnArrayName]; + unsigned int i; + NSDictionary *connDict; + + // NSLog(@"Connection Name Changed."); + + // Fill the text boxes with the data from the new connection name. + if (connArray) + { + for (i = 0; i < [connArray count]; i++) + { + connDict = [connArray objectAtIndex:i]; + NSString *aConnectionName = [NSString stringWithString:[connDict objectForKey:UDConnName]]; + if ([aConnectionName compare:[connectionName stringValue]] == NSOrderedSame) + { + [host setStringValue:@""]; + [userName setStringValue:@""]; + [databaseName setStringValue:@""]; + [port setStringValue:@""]; + + [host setStringValue:[connDict objectForKey:UDConnHost]]; + [userName setStringValue:[connDict objectForKey:UDConnUserName]]; + [databaseName setStringValue:[connDict objectForKey:UDConnDatabaseName]]; + [port setStringValue:[connDict objectForKey:UDConnPort]]; + break; + } + } + } + } + + - (void)windowControllerDidLoadNib:(NSWindowController *) aController { *************** *** 58,63 **** // set the font for the schema view ! font = [NSFont fontWithName:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_SchemaTableFontName"] ! size:[userDefaults floatForKey:@"PGSqlForMac_QueryTool_SchemaTableFontSize"]]; [schemaView setCurrentFont:font]; NSEnumerator* columns = [[schemaView tableColumns] objectEnumerator]; --- 94,99 ---- // set the font for the schema view ! font = [NSFont fontWithName:[userDefaults stringForKey:UDSchemaTableFontName] ! size:[userDefaults floatForKey:UDSchemaTableFontSize]]; [schemaView setCurrentFont:font]; NSEnumerator* columns = [[schemaView tableColumns] objectEnumerator]; *************** *** 71,76 **** //set the font for the results view ! font = [NSFont fontWithName:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_ResultsTableFontName"] ! size:[userDefaults floatForKey:@"PGSqlForMac_QueryTool_ResultsTableFontSize"]]; [dataOutput setCurrentFont:font]; columns = [[dataOutput tableColumns] objectEnumerator]; --- 107,112 ---- //set the font for the results view ! font = [NSFont fontWithName:[userDefaults stringForKey:UDResultsTableFontName] ! size:[userDefaults floatForKey:UDResultsTableFontSize]]; [dataOutput setCurrentFont:font]; columns = [[dataOutput tableColumns] objectEnumerator]; *************** *** 85,89 **** // init the keyword arrays NSString *temp = [[NSString alloc] ! initWithString:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_Highlight_Keywords"]]; keywords = [[NSArray alloc] initWithArray:[temp componentsSeparatedByString:@" "]]; --- 121,125 ---- // init the keyword arrays NSString *temp = [[NSString alloc] ! initWithString:[userDefaults stringForKey:UDHighlight_Keywords]]; keywords = [[NSArray alloc] initWithArray:[temp componentsSeparatedByString:@" "]]; *************** *** 107,111 **** [query setSelectedRange:NSMakeRange(0,0)]; [self performSelector:@selector(onConnect:) withObject:self afterDelay:0.0]; ! } --- 143,151 ---- [query setSelectedRange:NSMakeRange(0,0)]; [self performSelector:@selector(onConnect:) withObject:self afterDelay:0.0]; ! ! // Set the connection delegate for when the connection name changes. ! [connectionName setAction:@selector(connectionNameChanged:)]; ! [connectionName setTarget:self]; ! } *************** *** 135,143 **** // set explorer display defaults from NSUserDefaults NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [explorer setShowInformationSchema:[userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowInformationSchema"]]; ! [explorer setShowPGCatalog:[userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGCatalogSchema"]]; ! [explorer setShowPGToast:[userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGToastSchema"]]; ! [explorer setShowPGTemps:[userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGTempsSchema"]]; ! [explorer setShowPublic:[userDefaults boolForKey:@"PGSqlForMac_QueryTool_ShowPGPublicSchema"]]; [NSThread detachNewThreadSelector:@selector(buildSchema:) toTarget:explorer withObject:schemaView]; --- 175,183 ---- // set explorer display defaults from NSUserDefaults NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [explorer setShowInformationSchema:[userDefaults boolForKey:UDShowInformationSchema]]; ! [explorer setShowPGCatalog:[userDefaults boolForKey:UDShowPGCatalogSchema]]; ! [explorer setShowPGToast:[userDefaults boolForKey:UDShowPGToastSchema]]; ! [explorer setShowPGTemps:[userDefaults boolForKey:UDShowPGTempsSchema]]; ! [explorer setShowPublic:[userDefaults boolForKey:UDShowPGPublicSchema]]; [NSThread detachNewThreadSelector:@selector(buildSchema:) toTarget:explorer withObject:schemaView]; *************** *** 145,187 **** [schemaView setDataSource:explorer]; // explorer does the work. [schemaView setMenuActionTarget:self]; ! } - (IBAction)onConnect:(id)sender { - /* read the preferences and add them to the drop downs */ - NSString * aDefault; UNUSED_PARAMETER(sender); [status setStringValue:[NSString stringWithString:@"Waiting for connection information"]]; ! aDefault = [[NSUserDefaults standardUserDefaults] stringForKey:@"PGSqlForMac_QueryTool_DefaultHost"]; ! if (aDefault) ! { ! [host setStringValue:aDefault]; ! } ! else ! { ! [host setStringValue:@"localhost"]; ! } ! aDefault = [[NSUserDefaults standardUserDefaults] stringForKey:@"PGSqlForMac_QueryTool_DefaultUserName"]; ! if (aDefault) ! { ! [userName setStringValue:aDefault]; ! } ! aDefault = [[NSUserDefaults standardUserDefaults] stringForKey:@"PGSqlForMac_QueryTool_DefaultDatabaseName"]; ! if (aDefault) ! { ! [databaseName setStringValue:aDefault]; ! } ! aDefault = [[NSUserDefaults standardUserDefaults] stringForKey:@"PGSqlForMac_QueryTool_DefaultPort"]; ! if (aDefault) { ! [port setStringValue:aDefault]; } else { ! [port setStringValue:@"5432"]; } ! [NSApp beginSheet:panelConnect modalForWindow:window --- 185,246 ---- [schemaView setDataSource:explorer]; // explorer does the work. [schemaView setMenuActionTarget:self]; ! } ! - (IBAction)onConnect:(id)sender { UNUSED_PARAMETER(sender); [status setStringValue:[NSString stringWithString:@"Waiting for connection information"]]; ! // Create the connection drop down box. ! NSArray * connArray = [[NSUserDefaults standardUserDefaults] arrayForKey:UDConnArrayName]; ! unsigned int i; ! NSDictionary *connDict; ! ! [connectionRemember setState:0]; ! if (connArray) { ! i = 0; ! connDict = [connArray objectAtIndex:i]; ! ! // add names to drop down list ! [connectionName removeAllItems]; ! for (i = 0; i < [connArray count]; i++) ! { ! connDict = [connArray objectAtIndex:i]; ! [connectionName addItemWithObjectValue:[connDict objectForKey:UDConnName]]; ! } ! ! // Select the last used connection ! NSString *lastConnectionName = [[NSUserDefaults standardUserDefaults] stringForKey:UDLastConn]; ! for (i = 0; i < [connArray count]; i++) ! { ! connDict = [connArray objectAtIndex:i]; ! NSString *connDictName = [connDict objectForKey:UDConnName]; ! if ([connDictName compare:lastConnectionName] == NSOrderedSame) ! { ! [connectionName setStringValue:[connDict objectForKey:UDConnName]]; ! [connectionName selectItemWithObjectValue:[connDict objectForKey:UDConnName]]; ! break; ! } ! } ! if (i >= [connArray count]) ! { ! // Use first entry in array if last used is not found. ! i = 0; ! connDict = [connArray objectAtIndex:i]; ! } ! // connDict contains the dict to use for defaults. ! [host setStringValue:[connDict objectForKey:UDConnHost]]; ! [userName setStringValue:[connDict objectForKey:UDConnUserName]]; ! [databaseName setStringValue:[connDict objectForKey:UDConnDatabaseName]]; ! [port setStringValue:[connDict objectForKey:UDConnPort]]; } else { ! NSLog(@"Count not find connArray: %s, line %d", __FILE__, __LINE__); } ! [NSApp beginSheet:panelConnect modalForWindow:window *************** *** 191,194 **** --- 250,286 ---- } + - (IBAction)onConnectDelete:(id)sender; + { + // Make sure combobox has selection + UNUSED_PARAMETER(sender); + if ([[connectionName stringValue] length] == 0) + { + return; + } + NSMutableArray * connArray = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:UDConnArrayName]]; + unsigned int i; + NSDictionary *connDict; + // Remove from user defaults. + for (i = 0; i < [connArray count]; i++) + { + connDict = [connArray objectAtIndex:i]; + NSString *aConnectionName = [NSString stringWithString:[connDict objectForKey:UDConnName]]; + if ([aConnectionName compare:[connectionName stringValue]] == NSOrderedSame) + { + // If found remove from list. + [connArray removeObjectAtIndex:i]; + + // Save the result. + [[NSUserDefaults standardUserDefaults] setObject:connArray forKey:UDConnArrayName]; + break; + } + } + // Atempt to remove from comboBox. + [connectionName removeItemWithObjectValue:[connectionName stringValue]]; + + // Clear out selection. + [connectionName setStringValue:@""]; + } + - (IBAction)onConnectOK:(id)sender { *************** *** 210,220 **** [conn setPort:[port stringValue]]; - // update user defaults - [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithString:[userName stringValue]] forKey:@"PGSqlForMac_QueryTool_DefaultUserName"]; - [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithString:[host stringValue]] forKey:@"PGSqlForMac_QueryTool_DefaultHost"]; - [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithString:[port stringValue]] forKey:@"PGSqlForMac_QueryTool_DefaultPort"]; - [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithString:[databaseName stringValue]] forKey:@"PGSqlForMac_QueryTool_DefaultDatabaseName"]; - [[NSUserDefaults standardUserDefaults] synchronize]; - // close the sheet [NSApp stopModal]; --- 302,305 ---- *************** *** 247,254 **** } ! // create the schema explorer ! [self setNewExplorerConn]; ! } else { [status setStringValue:@"Connection failed:"]; } --- 332,413 ---- } ! // Create the schema explorer. ! [self setNewExplorerConn]; ! // update last connection name ! if ([[connectionName stringValue] length] != 0) ! { ! [[NSUserDefaults standardUserDefaults] setObject:[connectionName stringValue] forKey:UDLastConn]; ! } ! ! // Save connection details in userDefaults. ! if ([connectionRemember state]) ! { ! unsigned int potentialConnNum = 0; ! bool foundInComboBox = NO; ! // If no name then create a name. ! if ([[connectionName stringValue] length] == 0) ! { ! for (potentialConnNum = 1; potentialConnNum < 50; potentialConnNum++) ! { ! foundInComboBox = NO; ! NSString *potentialConnectionName = [NSString stringWithFormat:@"Connection %d", potentialConnNum]; ! for (i = 0; i < [connectionName numberOfItems]; i++) ! { ! if ([potentialConnectionName compare:[[connectionName itemObjectValueAtIndex:i] stringValue]] == NSOrderedSame) ! { ! foundInComboBox = YES; ! break; ! } ! } ! if (foundInComboBox == YES) ! { ! continue; ! } ! // Use the name created. ! [connectionName setStringValue: potentialConnectionName]; ! break; ! } ! } ! if (potentialConnNum < 50) // if loop ran-out without finding a good name skip this code. ! { ! // figure out if connectionName is already in list, if not add it ! foundInComboBox = NO; ! for (i = 0; i < [connectionName numberOfItems]; i++) ! { ! if ([[connectionName stringValue] compare:[connectionName itemObjectValueAtIndex:i]] == NSOrderedSame) ! { ! foundInComboBox = YES; ! break; ! } ! } ! if (foundInComboBox == NO) ! { ! // Add to combo box. ! [connectionName addItemWithObjectValue: [connectionName stringValue]]; ! [connectionName selectItemWithObjectValue: [connectionName stringValue]]; ! ! // Create dictionary with connection details. ! NSMutableDictionary *aConnDict = [NSMutableDictionary dictionaryWithCapacity:6]; ! ! [aConnDict setObject:[userName stringValue] forKey:UDConnUserName]; ! [aConnDict setObject:[host stringValue] forKey:UDConnHost]; ! [aConnDict setObject:[port stringValue] forKey:UDConnPort]; ! [aConnDict setObject:[databaseName stringValue] forKey:UDConnDatabaseName]; ! [aConnDict setObject:[connectionName stringValue] forKey:UDConnName]; ! ! // TODO remove all other last connections ! ! // Update UserDefaults. ! NSMutableArray *connArray = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:UDConnArrayName]]; ! [connArray addObject:aConnDict]; ! [[NSUserDefaults standardUserDefaults] setObject:connArray forKey:UDConnArrayName]; ! [[NSUserDefaults standardUserDefaults] synchronize]; ! } ! } ! } ! } ! else ! { [status setStringValue:@"Connection failed:"]; } *************** *** 265,269 **** UNUSED_PARAMETER(sender); NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowPostgreSQLHelp"]]]; } --- 424,428 ---- UNUSED_PARAMETER(sender); NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[userDefaults stringForKey:UDShowPostgreSQLHelp]]]; } *************** *** 273,277 **** UNUSED_PARAMETER(sender); NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[userDefaults stringForKey:@"PGSqlForMac_QueryTool_ShowSQLCommandHelp"]]]; } --- 432,436 ---- UNUSED_PARAMETER(sender); NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; ! [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[userDefaults stringForKey:UDShowSQLCommandHelp]]]; } *************** *** 369,391 **** toBeRun = [query string]; } ! ! /* FIXME does not correctly handle quoted queries */ ! /* For example: ! CREATE or REPLACE FUNCTION pgcocoa_test_schema.sum_n_product ! (IN x integer, IN y integer, OUT sum integer, OUT prod integer) AS $$ ! BEGIN ! sum := x + y; ! prod := x * y; ! END; $$ LANGUAGE plpgsql; ! */ ! ! //NSArray *arrQuery = [toBeRun componentsSeparatedByString:@";"]; ! int xx; - //for (x = 0; x < [arrQuery count]; x++) for (xx = 0; xx < 1; xx++) { - //NSString *sql = [arrQuery objectAtIndex:x]; - //RecordSet *rs = [conn execQuery:sql]; RecordSet *rs = [conn execQueryLogInfoLogSQL:toBeRun]; if ([conn sqlLog] != nil) --- 528,535 ---- toBeRun = [query string]; } ! int xx; for (xx = 0; xx < 1; xx++) { RecordSet *rs = [conn execQueryLogInfoLogSQL:toBeRun]; if ([conn sqlLog] != nil) *************** *** 671,675 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendString:@"SELECT "]; ! while (currentIndex != NSNotFound) { if (!first) { --- 815,820 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendString:@"SELECT "]; ! while (currentIndex != NSNotFound) ! { if (!first) { *************** *** 692,696 **** unsigned currentIndex = [theRows firstIndex]; NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; ! while (currentIndex != NSNotFound) { if (!first) { --- 837,842 ---- unsigned currentIndex = [theRows firstIndex]; NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; ! while (currentIndex != NSNotFound) ! { if (!first) { *************** *** 718,722 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE UNIQUE INDEX %@_idx%d ON %@.%@ (", tableName, indexCount, schemaName, tableName]; ! while (currentIndex != NSNotFound) { if (!first) { --- 864,869 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE UNIQUE INDEX %@_idx%d ON %@.%@ (", tableName, indexCount, schemaName, tableName]; ! while (currentIndex != NSNotFound) ! { if (!first) { *************** *** 745,749 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE UNIQUE INDEX %@_idx%d ON %@.%@ (", tableName, indexCount, schemaName, tableName]; ! while (currentIndex != NSNotFound) { if (!first) { --- 892,897 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE UNIQUE INDEX %@_idx%d ON %@.%@ (", tableName, indexCount, schemaName, tableName]; ! while (currentIndex != NSNotFound) ! { if (!first) { *************** *** 774,778 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { if (!first) { --- 922,927 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) ! { if (!first) { *************** *** 801,805 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { if (!first) { --- 950,955 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) ! { if (!first) { *************** *** 828,832 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { if (!first) { --- 978,983 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) ! { if (!first) { *************** *** 855,859 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE TABLE %@.%@ (\n", schemaName, tableName]; ! while (currentIndex != NSNotFound) { if (!first) { --- 1006,1011 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"CREATE TABLE %@.%@ (\n", schemaName, tableName]; ! while (currentIndex != NSNotFound) ! { if (!first) { *************** *** 882,886 **** NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { if (!first) { --- 1034,1039 ---- NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) ! { if (!first) { *************** *** 974,977 **** --- 1127,1144 ---- } + - (void)onSelectExecuteFunctionMenuItem:(id)sender + { + UNUSED_PARAMETER(sender); + NSIndexSet *theRows =[schemaView selectedRowIndexes]; + unsigned int currentRow =[theRows firstIndex]; + NSString *functionName = [[schemaView itemAtRow:currentRow] name]; + NSString *schemaName = [[schemaView itemAtRow:currentRow] baseSchema]; + NSAssert(functionName,@"onSelectCreateFunctionTemplateMenuItem: no function name."); + NSAssert(schemaName, @"onSelectCreateFunctionTemplateMenuItem: no schema name."); + + NSString *sql = [NSString stringWithFormat:@"SELECT %@.%@();\n", schemaName, functionName]; + [query insertText:sql]; + } + - (void)onSelectDropFunctionMenuItem:(id)sender { *************** *** 1069,1076 **** ! if (rangeOfEdit.length == 0) { return; } ! if (rangeOfEdit.length > 1) { [self colorRange:rangeOfEdit]; return; --- 1236,1245 ---- ! if (rangeOfEdit.length == 0) ! { return; } ! if (rangeOfEdit.length > 1) ! { [self colorRange:rangeOfEdit]; return; *************** *** 1079,1083 **** // if the edited range contains no delimiters... unsigned long i = rangeOfEdit.location; ! if (i >= [[ts string] length]) { i = [[ts string] length] - 1; } while ([[ts string] characterAtIndex:i] != ' ') --- 1248,1255 ---- // if the edited range contains no delimiters... unsigned long i = rangeOfEdit.location; ! if (i >= [[ts string] length]) ! { ! i = [[ts string] length] - 1; ! } while ([[ts string] characterAtIndex:i] != ' ') *************** *** 1093,1097 **** i = rangeOfEdit.location; ! if (i >= [[ts string] length]) { i = [[ts string] length] - 1; } while ([[ts string] characterAtIndex:i] != ' ') { --- 1265,1272 ---- i = rangeOfEdit.location; ! if (i >= [[ts string] length]) ! { ! i = [[ts string] length] - 1; ! } while ([[ts string] characterAtIndex:i] != ' ') { *************** *** 1108,1113 **** { // TODO implement the system return nil; ! } --- 1283,1301 ---- { // TODO implement the system + NSLog(@"%s: textView not implemented.", __FILE__); return nil; ! } ! ! - (NSString *)currentQuery ! { ! // TODO ! NSLog(@"%s: currentQuery not implemented.", __FILE__); ! return nil; ! } ! ! - (void)threadComplete ! { ! // TODO ! NSLog(@"%s: threadComplete not implemented.", __FILE__); } Index: SqlDocument.h =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/SqlDocument.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SqlDocument.h 30 Aug 2006 15:51:15 -0000 1.14 --- SqlDocument.h 2 Dec 2006 14:51:43 -0000 1.15 *************** *** 15,18 **** --- 15,19 ---- #import "MyResultsView.h" #import "QueryTool.h" + #import "ExecuteQueryThread.h" @class PreferenceController; *************** *** 31,39 **** //connect dialog IBOutlet NSPanel *panelConnect; IBOutlet NSTextField *userName; IBOutlet NSTextField *password; IBOutlet NSTextField *databaseName; ! IBOutlet NSComboBox *host; ! IBOutlet NSComboBox *port; IBOutlet NSPopUpButton *dbName; --- 32,42 ---- //connect dialog IBOutlet NSPanel *panelConnect; + IBOutlet NSComboBox *connectionName; + IBOutlet NSButton *connectionRemember; IBOutlet NSTextField *userName; IBOutlet NSTextField *password; IBOutlet NSTextField *databaseName; ! IBOutlet NSTextField *host; ! IBOutlet NSTextField *port; IBOutlet NSPopUpButton *dbName; *************** *** 51,54 **** --- 54,60 ---- ExplorerModel *explorer; // ref to schema outline view data source + //threads + ExecuteQueryThread *theThread; + // Non-Gui NSString *fileContent; *************** *** 75,78 **** --- 81,85 ---- - (IBAction)onConnectOK:(id)sender; - (IBAction)onConnectCancel:(id)sender; + - (IBAction)onConnectDelete:(id)sender; - (IBAction)onDisconnect:(id)sender; - (IBAction)onSetDatabase:(id)sender; *************** *** 116,119 **** --- 123,127 ---- - (void)onSelectCreateFunctionTemplateMenuItem:(id)sender; - (void)onSelectDropFunctionMenuItem:(id)sender; + - (void)onSelectExecuteFunctionMenuItem:(id)sender; // Indexes *************** *** 122,124 **** --- 130,136 ---- - (void)colorRange:(NSRange)rangeToColor; + // Other + - (NSString *)currentQuery; + - (void)threadComplete; + @end |