From 0ce916eb0583ec6b062786f91bee0133906671ce Mon Sep 17 00:00:00 2001 From: sqlprodev Date: Mon, 11 Apr 2011 20:29:49 +0000 Subject: initial commit of SP_REFACTOR ifdefs, the start of a long quest to separate UI code from functional code --- Source/SPCustomQuery.m | 164 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 146 insertions(+), 18 deletions(-) (limited to 'Source/SPCustomQuery.m') diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 2c9e890e..732ed5db 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -25,7 +25,9 @@ #import "SPCustomQuery.h" #import "SPSQLParser.h" +#ifndef SP_REFACTOR /* headers */ #import "SPGrowlController.h" +#endif #import "SPDataCellFormatter.h" #import "SPDatabaseDocument.h" #import "SPTablesList.h" @@ -43,7 +45,9 @@ #import "SPAppController.h" #import "SPBundleHTMLOutputController.h" +#ifndef SP_REFACTOR /* headers */ #import +#endif @implementation SPCustomQuery @@ -212,7 +216,9 @@ return; } +#ifndef SP_REFACTOR /* ui manip for query favorites */ if ([tableDocumentInstance isUntitled]) [saveQueryFavoriteGlobal setState:NSOnState]; +#endif [NSApp beginSheet:queryFavoritesSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self @@ -230,7 +236,9 @@ return; } +#ifndef SP_REFACTOR /* ui manip for query favorites */ if ([tableDocumentInstance isUntitled]) [saveQueryFavoriteGlobal setState:NSOnState]; +#endif [NSApp beginSheet:queryFavoritesSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self @@ -240,7 +248,9 @@ else if ([queryFavoritesButton indexOfSelectedItem] == 3) { // init query favorites controller +#ifndef SP_REFACTOR [prefs synchronize]; +#endif if(favoritesManager) [favoritesManager release]; favoritesManager = [[SPQueryFavoriteManager alloc] initWithDelegate:self]; @@ -253,7 +263,11 @@ } else if ([queryFavoritesButton indexOfSelectedItem] > 5) { // Choose favorite +#ifndef SP_REFACTOR BOOL replaceContent = [prefs boolForKey:SPQueryFavoriteReplacesContent]; +#else + BOOL replaceContent = YES; +#endif if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) replaceContent = !replaceContent; @@ -274,12 +288,18 @@ - (IBAction)chooseQueryHistory:(id)sender { +#ifndef SP_REFACTOR [prefs synchronize]; +#endif // Choose history item if ([queryHistoryButton indexOfSelectedItem] > 6) { +#ifndef SP_REFACTOR BOOL replaceContent = [prefs boolForKey:SPQueryHistoryReplacesContent]; +#else + BOOL replaceContent = YES; +#endif [textView breakUndoCoalescing]; if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) replaceContent = !replaceContent; @@ -382,8 +402,10 @@ // "Indent new lines" toggle if (sender == autoindentMenuItem) { BOOL enableAutoindent = !([autoindentMenuItem state] == NSOffState); +#ifndef SP_REFACTOR /* prefs access */ [prefs setBool:enableAutoindent forKey:SPCustomQueryAutoIndent]; [prefs synchronize]; +#endif [autoindentMenuItem setState:enableAutoindent?NSOnState:NSOffState]; [textView setAutoindent:enableAutoindent]; } @@ -391,12 +413,15 @@ // "Auto-pair characters" toggle if (sender == autopairMenuItem) { BOOL enableAutopair = !([autopairMenuItem state] == NSOffState); +#ifndef SP_REFACTOR /* prefs access */ [prefs setBool:enableAutopair forKey:SPCustomQueryAutoPairCharacters]; [prefs synchronize]; +#endif [autopairMenuItem setState:enableAutopair?NSOnState:NSOffState]; [textView setAutopair:enableAutopair]; } +#ifndef SP_REFACTOR /* prefs access */ // "Auto-help" toggle if (sender == autohelpMenuItem) { BOOL enableAutohelp = !([autohelpMenuItem state] == NSOffState); @@ -405,12 +430,15 @@ [autohelpMenuItem setState:enableAutohelp?NSOnState:NSOffState]; [textView setAutohelp:enableAutohelp]; } +#endif // "Auto-uppercase keywords" toggle if (sender == autouppercaseKeywordsMenuItem) { BOOL enableAutouppercaseKeywords = !([autouppercaseKeywordsMenuItem state] == NSOffState); +#ifndef SP_REFACTOR /* prefs access */ [prefs setBool:enableAutouppercaseKeywords forKey:SPCustomQueryAutoUppercaseKeywords]; [prefs synchronize]; +#endif [autouppercaseKeywordsMenuItem setState:enableAutouppercaseKeywords?NSOnState:NSOffState]; [textView setAutouppercaseKeywords:enableAutouppercaseKeywords]; } @@ -418,6 +446,7 @@ - (IBAction)saveQueryHistory:(id)sender { +#ifndef SP_REFACTOR NSSavePanel *panel = [NSSavePanel savePanel]; [panel setRequiredFileType:SPFileExtensionSQL]; @@ -432,6 +461,7 @@ [encodingPopUp setEnabled:YES]; [panel beginSheetForDirectory:nil file:@"history" modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"saveHistory"]; +#endif } - (IBAction)copyQueryHistory:(id)sender @@ -450,10 +480,14 @@ NSString *infoString; +#ifndef SP_REFACTOR /* if ([tableDocumentInstance isUntitled]) */ if ([tableDocumentInstance isUntitled]) +#endif infoString = NSLocalizedString(@"Are you sure you want to clear the global history list? This action cannot be undone.", @"clear global history list informative message"); +#ifndef SP_REFACTOR /* if ([tableDocumentInstance isUntitled]) */ else infoString = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to clear the history list for “%@”? This action cannot be undone.", @"clear history list for “%@” informative message"), [tableDocumentInstance displayName]]; +#endif NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Clear History?", @"clear history message") defaultButton:NSLocalizedString(@"Clear", @"clear button") @@ -545,13 +579,17 @@ // BOOL queriesSeparatedByDelimiter = NO; NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; +#ifndef SP_REFACTOR /* [tableDocumentInstance setQueryMode:] */ [tableDocumentInstance setQueryMode:SPCustomQueryQueryMode]; +#endif // Notify listeners that a query has started [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; +#ifndef SP_REFACTOR /* growl */ // Start the notification timer to allow notifications to be shown even if frontmost for long queries [[SPGrowlController sharedGrowlController] setVisibilityForNotificationName:@"Query Finished"]; +#endif // Reset the current table view as necessary to avoid redraw and reload issues. // Restore the view position to the top left to be within the results for all datasets. @@ -804,7 +842,9 @@ // Restore automatic query retries [mySQLConnection setAllowQueryRetries:YES]; +#ifndef SP_REFACTOR /* [tableDocumentInstance setQueryMode:] */ [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; +#endif // If no results were returned, redraw the empty table and post notifications before returning. if ( !resultDataCount ) { @@ -813,11 +853,13 @@ // Notify any listeners that the query has completed [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; +#ifndef SP_REFACTOR /* growl */ // Perform the Growl notification for query completion [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText string]] document:tableDocumentInstance notificationName:@"Query Finished"]; +#endif // Set up the callback if present if ([taskArguments objectForKey:@"callback"]) { @@ -844,11 +886,13 @@ //query finished [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; +#ifndef SP_REFACTOR /* growl */ // Query finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText string]] document:tableDocumentInstance notificationName:@"Query Finished"]; +#endif // Set up the callback if present if ([taskArguments objectForKey:@"callback"]) { @@ -1112,7 +1156,7 @@ } /* - * Add or remove "⁄* *⁄" for each line in the current query + * Add or remove "‚ÅÑ* *‚ÅÑ" for each line in the current query * a given selection */ - (void)commentOutCurrentQueryTakingSelection:(BOOL)takeSelection @@ -1165,8 +1209,8 @@ /* * Add or remove "-- " for each line in the current query or selection, - * if the selection is in-line wrap selection into ⁄* block comments and - * place the caret after ⁄* to allow to enter !xxxxxx e.g. + * if the selection is in-line wrap selection into ‚ÅÑ* block comments and + * place the caret after ‚ÅÑ* to allow to enter !xxxxxx e.g. */ - (void)commentOut { @@ -1297,6 +1341,7 @@ [errorText setString:NSLocalizedString(@"There were no errors.", @"text shown when query was successfull")]; } +#ifndef SP_REFACTOR /* show/hide errror view */ // Show or hide the error area if necessary if ([errorsString length] && [queryInfoPaneSplitView collapsibleSubviewCollapsed]) { [queryInfoButton setState:NSOnState]; @@ -1305,6 +1350,7 @@ [queryInfoButton setState:NSOffState]; [self toggleQueryInfoPaneCollapse:queryInfoButton]; } +#endif } #pragma mark - @@ -1429,16 +1475,25 @@ // Set up the interface [customQueryView setVerticalMotionCanBeginDrag:NO]; +#ifndef SP_REFACTOR [autoindentMenuItem setState:([prefs boolForKey:SPCustomQueryAutoIndent]?NSOnState:NSOffState)]; [autopairMenuItem setState:([prefs boolForKey:SPCustomQueryAutoPairCharacters]?NSOnState:NSOffState)]; [autohelpMenuItem setState:([prefs boolForKey:SPCustomQueryUpdateAutoHelp]?NSOnState:NSOffState)]; [autouppercaseKeywordsMenuItem setState:([prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]?NSOnState:NSOffState)]; +#else + [autoindentMenuItem setState:(YES?NSOnState:NSOffState)]; + [autopairMenuItem setState:(YES?NSOnState:NSOffState)]; + [autohelpMenuItem setState:(YES?NSOnState:NSOffState)]; + [autouppercaseKeywordsMenuItem setState:(YES?NSOnState:NSOffState)]; +#endif if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] ) [self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:YES]; // Populate query favorites +#ifndef SP_REFACTOR [self queryFavoritesHaveBeenUpdated:nil]; +#endif // Disable runSelectionMenuItem in the gear menu [runSelectionMenuItem setEnabled:NO]; @@ -1487,7 +1542,11 @@ } // Update font size on the table +#ifndef SP_REFACTOR NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; +#else + NSFont *tableFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; +#endif [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; // If there are no table columns to add, return @@ -1523,8 +1582,9 @@ [[dataCell formatter] setFieldType:[columnDefinition objectForKey:@"type"]]; [theCol setDataCell:dataCell]; [[theCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; - [theCol setHeaderToolTip:[NSString stringWithFormat:@"%@ – %@%@", [columnDefinition objectForKey:@"name"], [columnDefinition objectForKey:@"type"], ([columnDefinition objectForKey:@"char_length"]) ? [NSString stringWithFormat:@"(%@)", [columnDefinition objectForKey:@"char_length"]] : @""]]; + [theCol setHeaderToolTip:[NSString stringWithFormat:@"%@ ‚Äì %@%@", [columnDefinition objectForKey:@"name"], [columnDefinition objectForKey:@"type"], ([columnDefinition objectForKey:@"char_length"]) ? [NSString stringWithFormat:@"(%@)", [columnDefinition objectForKey:@"char_length"]] : @""]]; +#ifndef SP_REFACTOR // Set the width of this column to saved value if exists and maps to a real column if ([columnDefinition objectForKey:@"org_name"] && [(NSString *)[columnDefinition objectForKey:@"org_name"] length]) { NSNumber *colWidth = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [columnDefinition objectForKey:@"db"], [tableDocumentInstance host]]] objectForKey:[columnDefinition objectForKey:@"org_table"]] objectForKey:[columnDefinition objectForKey:@"org_name"]]; @@ -1532,6 +1592,7 @@ [theCol setWidth:[colWidth floatValue]]; } } +#endif [customQueryView addTableColumn:theCol]; [theCol release]; @@ -1619,8 +1680,10 @@ [customQueryView setDelegate:nil]; for (NSDictionary *columnDefinition in cqColumnDefinition) { +#ifndef SP_REFACTOR // Skip columns with saved widths if ([[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]] objectForKey:[tablesListInstance tableName]] objectForKey:[columnDefinition objectForKey:@"name"]]) continue; +#endif // Otherwise set the column width NSTableColumn *aTableColumn = [customQueryView tableColumnWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; @@ -1888,7 +1951,11 @@ return [theValue shortStringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]; if ([theValue isNSNull]) +#ifndef SP_REFACTOR return [prefs objectForKey:SPNullValue]; +#else + return @"NULL"; +#endif if ([theValue isKindOfClass:[MCPGeometryData class]]) return [theValue wktString]; @@ -1943,7 +2010,13 @@ } else { if ( [[anObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) { newObject = @"CURRENT_TIMESTAMP"; - } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) { + } else if([anObject isEqualToString: +#ifndef SP_REFACTOR + [prefs stringForKey:SPNullValue] +#else + @"NULL" +#endif + ]) { newObject = @"NULL"; } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) { newObject = [(NSString*)anObject getGeomFromTextString]; @@ -1970,26 +2043,32 @@ return; } - // This shouldn't happen – for safety reasons + // This shouldn't happen ‚Äì for safety reasons if ( ![mySQLConnection affectedRows] ) { +#ifndef SP_REFACTOR if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); } else { NSBeep(); } +#endif return; } // On success reload table data by executing the last query if reloading is enabled +#ifndef SP_REFACTOR if ([prefs boolForKey:SPReloadAfterEditingRow]) { reloadingExistingResult = YES; [self storeCurrentResultViewForRestoration]; [self performQueries:[NSArray arrayWithObject:lastExecutedQuery] withCallback:NULL]; } else { +#endif // otherwise, just update the data in the data storage SPDataStorageReplaceObjectAtRowAndColumn(resultData, rowIndex, [[aTableColumn identifier] intValue], anObject); +#ifndef SP_REFACTOR } +#endif } else { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Updating field content failed. Couldn't identify field origin unambiguously (%ld match%@). It's very likely that while editing this field of table `%@` was changed.", @"message of panel when error while updating field to db after enabling it"), @@ -2362,7 +2441,11 @@ id originalData = [resultData cellDataAtRow:rowIndex column:[[aTableColumn identifier] integerValue]]; if ([originalData isNSNull]) +#ifndef SP_REFACTOR originalData = [NSString stringWithString:[prefs objectForKey:SPNullValue]]; +#else + originalData = [NSString stringWithString:@"NULL"]; +#endif [fieldEditor editWithObject:originalData fieldName:[columnDefinition objectForKey:@"name"] @@ -2407,6 +2490,7 @@ // Check our notification object is our table content view if ([aNotification object] != customQueryView) return; +#ifndef SP_REFACTOR /* triggered commands */ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableRowChanged]; for(NSString* cmdPath in triggeredCommands) { NSArray *data = [cmdPath componentsSeparatedByString:@"|"]; @@ -2443,7 +2527,7 @@ } } } - +#endif } /** @@ -2468,11 +2552,15 @@ NSString *col = [columnDefinition objectForKey:@"org_name"]; // Retrieve or instantiate the tableColumnWidths object +#ifndef SP_REFACTOR if ([prefs objectForKey:SPTableColumnWidths] != nil) { tableColumnWidths = [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPTableColumnWidths]]; } else { +#endif tableColumnWidths = [NSMutableDictionary dictionary]; +#ifndef SP_REFACTOR } +#endif // Edit or create database object if ([tableColumnWidths objectForKey:host_db] == nil) { @@ -2490,7 +2578,9 @@ // Save the column size [[[tableColumnWidths objectForKey:host_db] objectForKey:table] setObject:[NSNumber numberWithDouble:[(NSTableColumn *)[[aNotification userInfo] objectForKey:@"NSTableColumn"] width]] forKey:col]; +#ifndef SP_REFACTOR [prefs setObject:tableColumnWidths forKey:SPTableColumnWidths]; +#endif } /** @@ -2505,6 +2595,7 @@ NSUInteger targetWidth = [customQueryView autodetectWidthForColumnDefinition:columnDefinition maxRows:500]; // Clear any saved widths for the column +#ifndef SP_REFACTOR NSString *dbKey = [NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]; NSString *tableKey = [tablesListInstance tableName]; NSMutableDictionary *savedWidths = [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPTableColumnWidths]]; @@ -2524,6 +2615,7 @@ } [prefs setObject:[NSDictionary dictionaryWithDictionary:savedWidths] forKey:SPTableColumnWidths]; } +#endif // Return the width, while the delegate is empty to prevent column resize notifications [customQueryView setDelegate:nil]; @@ -2671,6 +2763,8 @@ #pragma mark - #pragma mark SplitView delegate methods +#ifndef SP_REFACTOR /* splitview delegate methods */ + /* * Tells the splitView that it can collapse views */ @@ -2705,6 +2799,8 @@ return (splitView == queryInfoPaneSplitView ? NSZeroRect : proposedEffectiveRect); } +#endif + #pragma mark - #pragma mark MySQL Help @@ -2718,6 +2814,7 @@ } +#ifndef SP_REFACTOR /* * Return the Help window. */ @@ -2912,6 +3009,7 @@ helpTarget = [helpTargetSelector selectedSegment]; [self helpTargetValidation]; } +#endif - (IBAction)showCompletionList:(id)sender { @@ -2928,6 +3026,8 @@ break; } } + +#ifndef SP_REFACTOR /* * Show the data for "HELP 'currentWord' invoked by autohelp" */ @@ -3047,7 +3147,7 @@ aRange = [desc rangeOfRegex:@"\\[HELP ([^ ]*?)\\]" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length+53, [desc length]-53-aRange.location-aRange.length) capture:1 error:&err1]; if(aRange.location != NSNotFound) { aUrl = [[desc substringWithRange:aRange] stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; - [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"%@", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]]; + [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"%@", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]]; } else break; @@ -3062,7 +3162,7 @@ // aRange = [desc rangeOfRegex:@"(?%@", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]]; + // [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"%@", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]]; // } // else // break; @@ -3086,16 +3186,16 @@ if (r) [theResult dataSeek:0]; // check if HELP 'contents' is called if(![searchString isEqualToString:SP_HELP_TOC_SEARCH_STRING]) - [theHelp appendFormat:@"
%@ “%@”
", NSLocalizedString(@"Help topics for", @"help topics for"), searchString]; + [theHelp appendFormat:@"
%@ “%@”
", NSLocalizedString(@"Help topics for", @"help topics for"), searchString]; else - [theHelp appendFormat:@"
%@:
", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories"), searchString]; + [theHelp appendFormat:@"
%@:
", NSLocalizedString(@"MySQL Help ‚Äì Categories", @"mysql help categories"), searchString]; // iterate through all found rows and print them as HTML ul/li list [theHelp appendString:@""]; @@ -3236,6 +3336,8 @@ return YES; } +#endif + #pragma mark - #pragma mark Query favorites manager delegate methods @@ -3275,7 +3377,7 @@ [[[[tableDocumentInstance fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] lastPathComponent] action:NULL keyEquivalent:@""]; [headerMenuItem setTag:SP_FAVORITE_HEADER_MENUITEM_TAG]; - [headerMenuItem setToolTip:[NSString stringWithFormat:@"‘%@’ based favorites", + [headerMenuItem setToolTip:[NSString stringWithFormat:@"‚Äò%@‚Äô based favorites", [[[[tableDocumentInstance fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] lastPathComponent]]]; [headerMenuItem setIndentationLevel:0]; [menu addItem:headerMenuItem]; @@ -3287,7 +3389,7 @@ [paraStyle addTabStop:[[[NSTextTab alloc] initWithType:NSRightTabStopType location:190.0f] autorelease]]; NSDictionary *attributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:paraStyle, [NSFont systemFontOfSize:11], nil] forKeys:[NSArray arrayWithObjects:NSParagraphStyleAttributeName, NSFontAttributeName, nil]]; NSAttributedString *titleString = [[[NSAttributedString alloc] - initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"] + initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@‚á•", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"] attributes:attributes] autorelease]; NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""]; [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]]; @@ -3304,6 +3406,7 @@ [headerMenuItem setIndentationLevel:0]; [menu addItem:headerMenuItem]; [headerMenuItem release]; +#ifndef SP_REFACTOR for (NSDictionary *favorite in [prefs objectForKey:SPQueryFavorites]) { if (![favorite isKindOfClass:[NSDictionary class]] || ![favorite objectForKey:@"name"]) continue; NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; @@ -3311,7 +3414,7 @@ [paraStyle addTabStop:[[[NSTextTab alloc] initWithType:NSRightTabStopType location:190.0f] autorelease]]; NSDictionary *attributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:paraStyle, [NSFont systemFontOfSize:11], nil] forKeys:[NSArray arrayWithObjects:NSParagraphStyleAttributeName, NSFontAttributeName, nil]]; NSAttributedString *titleString = [[[NSAttributedString alloc] - initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"] + initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@‚á•", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"] attributes:attributes] autorelease]; NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""]; [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]]; @@ -3320,6 +3423,7 @@ [menu addItem:item]; [item release]; } +#endif } #pragma mark - @@ -3332,9 +3436,11 @@ { isWorking = YES; +#ifndef SP_REFACTOR /* check selected view */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]) return; +#endif tableRowsSelectable = NO; [runSelectionButton setEnabled:NO]; @@ -3350,9 +3456,11 @@ { isWorking = NO; +#ifndef SP_REFACTOR /* check active tab */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]) return; +#endif if (selectionButtonCanBeEnabled) { [runSelectionButton setEnabled:YES]; @@ -3408,7 +3516,7 @@ // Result Table Font preference changed else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; - [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{«û·π∂·∏π√ú‚àëzgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; [customQueryView setFont:tableFont]; [customQueryView reloadData]; } @@ -3435,6 +3543,7 @@ if ([contextInfo isEqualToString:@"addAllToNewQueryFavorite"] || [contextInfo isEqualToString:@"addSelectionToNewQueryFavorite"]) { if (returnCode == NSOKButton) { +#ifndef SP_REFACTOR // Add the new query favorite directly the user's preferences here instead of asking the manager to do it // as it may not have been fully initialized yet. @@ -3472,6 +3581,7 @@ [saveQueryFavoriteGlobal setState:NSOffState]; [self queryFavoritesHaveBeenUpdated:nil]; +#endif } } @@ -3485,8 +3595,10 @@ if (returnCode == NSOKButton) { NSError *error = nil; +#ifndef SP_REFACTOR [prefs setInteger:[[encodingPopUp selectedItem] tag] forKey:SPLastSQLFileEncoding]; [prefs synchronize]; +#endif [[self buildHistoryString] writeToFile:[panel filename] atomically:YES @@ -3524,13 +3636,17 @@ } // Control Clear History menu item title according to isUntitled else if ( [menuItem tag] == SP_HISTORY_CLEAR_MENUITEM_TAG ) { +#ifndef SP_REFACTOR /* if ( [tableDocumentInstance isUntitled] ) */ if ( [tableDocumentInstance isUntitled] ) { +#endif [menuItem setTitle:NSLocalizedString(@"Clear Global History", @"clear global history menu item title")]; [menuItem setToolTip:NSLocalizedString(@"Clear the global history list", @"clear the global history list tooltip message")]; +#ifndef SP_REFACTOR /* if ( [tableDocumentInstance isUntitled] ) */ } else { - [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Clear History for “%@”", @"clear history for “%@” menu title"), [tableDocumentInstance displayName]]]; + [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Clear History for ‚Äú%@‚Äù", @"clear history for ‚Äú%@‚Äù menu title"), [tableDocumentInstance displayName]]]; [menuItem setToolTip:NSLocalizedString(@"Clear the document-based history list", @"clear the document-based history list tooltip message")]; } +#endif } // Check for History items else if ( [menuItem tag] >= SP_HISTORY_COPY_MENUITEM_TAG && [menuItem tag] <= SP_HISTORY_CLEAR_MENUITEM_TAG ) { @@ -3601,6 +3717,7 @@ selectionIndexToRestore = nil; selectionViewportToRestore = NSZeroRect; +#ifndef SP_REFACTOR // init helpHTMLTemplate NSError *error; @@ -3611,13 +3728,14 @@ // an error occurred while reading if (helpHTMLTemplate == nil) { - NSLog(@"%@", [NSString stringWithFormat:@"Error reading “%@.html”!
%@", SPHTMLHelpTemplate, [error localizedFailureReason]]); + NSLog(@"%@", [NSString stringWithFormat:@"Error reading “%@.html”!
%@", SPHTMLHelpTemplate, [error localizedFailureReason]]); NSBeep(); } // init search history [helpWebView setMaintainsBackForwardList:YES]; [[helpWebView backForwardList] setCapacity:20]; +#endif // init tableView's data source resultDataCount = 0; @@ -3629,7 +3747,9 @@ queryLoadTimer = nil; +#ifndef SP_REFACTOR prefs = [NSUserDefaults standardUserDefaults]; +#endif kCellEditorErrorNoMatch = NSLocalizedString(@"Field is not editable. No matching record found.\nReload data, check encoding, or try to add\na primary key field or more fields\nin your SELECT statement for table '%@'\nto identify field origin unambiguously.", @"Custom Query result editing error - could not identify original row"); kCellEditorErrorNoMultiTabDb = NSLocalizedString(@"Field is not editable. Field has no or multiple table or database origin(s).",@"field is not editable due to no table/database"); @@ -3834,8 +3954,10 @@ [queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG]; [queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG]; +#ifndef SP_REFACTOR // Set the structure and index view's vertical gridlines if required [customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; +#endif // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self @@ -3847,7 +3969,9 @@ name:SPDocumentTaskEndNotification object:tableDocumentInstance]; +#ifndef SP_REFACTOR [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; +#endif // Collapse the query information pane if ([queryInfoPaneSplitView collapsibleSubview]) { @@ -3870,7 +3994,9 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; +#ifndef SP_REFACTOR [prefs removeObserver:self forKeyPath:SPGlobalResultTableFont]; +#endif [NSObject cancelPreviousPerformRequestsWithTarget:customQueryView]; [self clearQueryLoadTimer]; @@ -3880,7 +4006,9 @@ if(fieldEditor) [fieldEditor release], fieldEditor = nil; +#ifndef SP_REFACTOR if (helpHTMLTemplate) [helpHTMLTemplate release]; +#endif if (mySQLversion) [mySQLversion release]; if (sortField) [sortField release]; if (cqColumnDefinition) [cqColumnDefinition release]; -- cgit v1.2.3