diff options
-rw-r--r-- | Interfaces/English.lproj/Console.xib | 10 | ||||
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 46 | ||||
-rw-r--r-- | Source/CustomQuery.m | 27 | ||||
-rw-r--r-- | Source/SPConstants.h | 3 | ||||
-rw-r--r-- | Source/SPConstants.m | 3 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 21 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 28 | ||||
-rw-r--r-- | Source/SPQueryController.m | 21 | ||||
-rw-r--r-- | Source/SPServerVariablesController.m | 28 | ||||
-rw-r--r-- | Source/SPTooltip.m | 2 | ||||
-rw-r--r-- | Source/TableContent.m | 32 | ||||
-rw-r--r-- | Source/TableDocument.m | 24 | ||||
-rw-r--r-- | Source/TableDump.m | 43 | ||||
-rw-r--r-- | Source/TableSource.m | 126 |
14 files changed, 212 insertions, 202 deletions
diff --git a/Interfaces/English.lproj/Console.xib b/Interfaces/English.lproj/Console.xib index d84c24b5..1afdbc3b 100644 --- a/Interfaces/English.lproj/Console.xib +++ b/Interfaces/English.lproj/Console.xib @@ -12,8 +12,8 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="7"/> <integer value="49"/> - <integer value="79"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -534,7 +534,7 @@ </object> </object> </object> - <int key="NSSelectedIndex">4</int> + <int key="NSSelectedIndex">1</int> <bool key="NSPullDown">YES</bool> <int key="NSPreferredEdge">1</int> <bool key="NSUsesItemFromMenu">YES</bool> @@ -645,10 +645,6 @@ </object> </object> <object class="NSUserDefaultsController" id="320962651"> - <object class="NSMutableArray" key="NSDeclaredKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>SPConsoleShowTimestamps</string> - </object> <bool key="NSSharedInstance">YES</bool> </object> </object> @@ -1327,7 +1323,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{255, 481}, {283, 118}}</string> + <string>{{255, 376}, {283, 223}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSMutableDictionary"> diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 37e3ae2e..c5a4bfc4 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,7 +23,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="133"/> + <integer value="287"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -871,7 +871,7 @@ <object class="NSTabViewItem" id="831053945"> <string key="NSIdentifier">source</string> <object class="NSView" key="NSView" id="461236772"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder" ref="714795046"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1964,7 +1964,7 @@ <double key="NSIntercellSpacingHeight">2</double> <reference key="NSBackgroundColor" ref="1024678221"/> <reference key="NSGridColor" ref="864903678"/> - <double key="NSRowHeight">13</double> + <double key="NSRowHeight">16</double> <int key="NSTvFlags">-222265344</int> <reference key="NSDelegate"/> <reference key="NSDataSource"/> @@ -2026,7 +2026,7 @@ <reference key="NSContentView" ref="794929378"/> <reference key="NSHeaderClipView" ref="1038672854"/> <reference key="NSCornerView" ref="476444025"/> - <bytes key="NSScrollAmts">QSAAAEEgAABBcAAAQXAAAA</bytes> + <bytes key="NSScrollAmts">QSAAAEEgAABBkAAAQZAAAA</bytes> </object> <object class="NSButton" id="988187819"> <reference key="NSNextResponder" ref="1063281455"/> @@ -2132,6 +2132,7 @@ </object> </object> <string key="NSFrame">{{10, 7}, {700, 544}}</string> + <reference key="NSSuperview" ref="714795046"/> </object> <string key="NSLabel">Structure</string> <reference key="NSColor" ref="62854682"/> @@ -2926,7 +2927,7 @@ <object class="NSTabViewItem" id="105987292"> <string key="NSIdentifier">customQuery</string> <object class="NSView" key="NSView" id="746504912"> - <reference key="NSNextResponder" ref="714795046"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -2953,29 +2954,6 @@ <object class="NSTextView" id="1055190999"> <reference key="NSNextResponder" ref="1072692119"/> <int key="NSvFlags">6418</int> - <object class="NSMutableSet" key="NSDragTypes"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="set.sortedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>Apple HTML pasteboard type</string> - <string>Apple PDF pasteboard type</string> - <string>Apple PICT pasteboard type</string> - <string>Apple PNG pasteboard type</string> - <string>Apple URL pasteboard type</string> - <string>CorePasteboardFlavorType 0x6D6F6F76</string> - <string>NSColor pasteboard type</string> - <string>NSFilenamesPboardType</string> - <string>NSStringPboardType</string> - <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> - <string>NeXT RTFD pasteboard type</string> - <string>NeXT Rich Text Format v1.0 pasteboard type</string> - <string>NeXT TIFF v4.0 pasteboard type</string> - <string>NeXT font pasteboard type</string> - <string>NeXT ruler pasteboard type</string> - <string>WebURLsWithTitlesPboardType</string> - <string>public.url</string> - </object> - </object> <string key="NSFrameSize">{688, 14}</string> <reference key="NSSuperview" ref="1072692119"/> <object class="NSTextContainer" key="NSTextContainer" id="326170846"> @@ -3798,7 +3776,6 @@ </object> </object> <string key="NSFrame">{{10, 7}, {700, 544}}</string> - <reference key="NSSuperview" ref="714795046"/> </object> <string key="NSLabel">Custom Query</string> <reference key="NSColor" ref="62854682"/> @@ -4843,14 +4820,14 @@ <reference key="NSTabView" ref="714795046"/> </object> </object> - <reference key="NSSelectedTabViewItem" ref="105987292"/> + <reference key="NSSelectedTabViewItem" ref="831053945"/> <reference key="NSFont" ref="26"/> <int key="NSTvFlags">134217731</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="746504912"/> + <reference ref="461236772"/> </object> </object> </object> @@ -24956,6 +24933,13 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <object class="IBPartialClassDescription"> <string key="className">TableDocument</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPConnectionDelegate.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">TableDocument</string> <string key="superclassName">NSDocument</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 14b8c191..f515f335 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -468,11 +468,7 @@ SPTextAndLinkCell *dataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; [dataCell setEditable:YES]; [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } else { - [dataCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + [dataCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; [theCol setDataCell:dataCell]; [[theCol headerCell] setStringValue:NSArrayObjectAtIndex(theColumns, i)]; @@ -2623,9 +2619,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [customQueryView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [customQueryView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [customQueryView reloadData]; + } } /** @@ -2761,7 +2770,6 @@ for (i=6; i< [menu numberOfItems]; i++) [[menu itemAtIndex:i] setHidden:([[menu itemAtIndex:i] tag] != SP_FAVORITE_HEADER_MENUITEM_TAG && ![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", searchPattern]])]; - } - (IBAction)filterQueryHistory:(id)sender @@ -2771,19 +2779,17 @@ NSString *searchPattern = [queryHistorySearchField stringValue]; for (i=2; i< [menu numberOfItems]; i++) [[menu itemAtIndex:i] setHidden:(![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", searchPattern]])]; - } - (void)awakeFromNib { - // Set pre-defined menu tags [queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG]; [queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG]; // Set the structure and index view's vertical gridlines if required - [customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - + [customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) @@ -2802,6 +2808,7 @@ [usedQuery release]; [fullResult release]; [favoritesManager release]; + if (helpHTMLTemplate) [helpHTMLTemplate release]; if (mySQLversion) [mySQLversion release]; if (sortField) [sortField release]; diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 3c40fc66..af884ac3 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -78,6 +78,9 @@ typedef enum { extern NSString *SPKillProcessQueryMode; extern NSString *SPKillProcessConnectionMode; +// Default monospaced font name +extern NSString *SPDefaultMonospacedFontName; + // Preference key constants // General Prefpane extern NSString *SPDefaultFavorite; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 4cafc02e..e9a87ff7 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -29,6 +29,9 @@ NSString *SPKillProcessQueryMode = @"SPKillProcessQueryMode"; NSString *SPKillProcessConnectionMode = @"SPKillProcessConnectionMode"; +// Default monospaced font name +NSString *SPDefaultMonospacedFontName = @"Courier"; + // Preference key constants // General Prefpane NSString *SPDefaultFavorite = @"DefaultFavorite"; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 96631502..43bab67c 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -131,18 +131,15 @@ - (id)editWithObject:(id)data fieldName:(NSString*)fieldName usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)tableWindow { - - if ( ![prefs objectForKey:SPFieldEditorSheetFont] ) - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [editTextView setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - } else { - [editTextView setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - // [prefs setObject:[NSArchiver archivedDataWithRootObject:[editTextView font]] forKey:@"FieldEditorSheetFont"]; - } - else + // If required, use monospaced fonts + if (![prefs objectForKey:SPFieldEditorSheetFont]) { + [editTextView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + else { [editTextView setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"FieldEditorSheetFont"]]]; + } - [hexTextView setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; + [hexTextView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; [editSheetFieldName setStringValue:[NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"Field", @"Field"), fieldName]]; @@ -153,7 +150,7 @@ [editTextView setHidden:YES]; [editTextScrollView setHidden:YES]; - if(!isEditable) { + if (!isEditable) { [editSheetOkButton setHidden:YES]; [editSheetCancelButton setHidden:YES]; [editSheetIsNotEditableCancelButton setHidden:NO]; @@ -180,7 +177,7 @@ [editSheetSegmentControl setHidden:(!isBlob)]; // Set window's min size since no segment and quicklook buttons are hidden - if(isBlob) { + if (isBlob) { [editSheet setFrameAutosaveName:@"SPFieldEditorBlobSheet"]; [editSheet setMinSize:NSMakeSize(560, 200)]; } else { diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index 864bccc3..5087ef2a 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -60,8 +60,21 @@ */ - (void)awakeFromNib { + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + // Set the process table view's vertical gridlines if required - [processListTableView setGridStyleMask:([[NSUserDefaults standardUserDefaults] boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [processListTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + + // Set the strutcture and index view's font + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + + for (NSTableColumn *column in [processListTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + // Register as an observer for the when the UseMonospacedFonts preference changes + [prefs addObserver:self forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; } #pragma mark - @@ -326,9 +339,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [processListTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [processListTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [processListTableView reloadData]; + } } #pragma mark - diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index f951e582..891f4fb5 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -153,6 +153,13 @@ static SPQueryController *sharedQueryController = nil; // Set the process table view's vertical gridlines if required [consoleTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + // Set the strutcture and index view's font + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + + for (NSTableColumn *column in [consoleTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } } #pragma mark - @@ -395,10 +402,22 @@ static SPQueryController *sharedQueryController = nil; if ([keyPath isEqualToString:SPConsoleEnableLogging]) { [loggingDisabledTextField setStringValue:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? @"" : @"Query logging is currently disabled"]; } - // Show/hide vertical grid lines in console table view + // Display table veiew vertical gridlines preference changed else if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [consoleTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [consoleTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [consoleTableView reloadData]; + } } /** diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m index 17bb5ba0..3046c2dd 100644 --- a/Source/SPServerVariablesController.m +++ b/Source/SPServerVariablesController.m @@ -59,8 +59,21 @@ */ - (void)awakeFromNib { + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + // Set the process table view's vertical gridlines if required - [variablesTableView setGridStyleMask:([[NSUserDefaults standardUserDefaults] boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [variablesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + + // Set the strutcture and index view's font + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + + for (NSTableColumn *column in [variablesTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + // Register as an observer for the when the UseMonospacedFonts preference changes + [prefs addObserver:self forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; } #pragma mark - @@ -199,9 +212,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [variablesTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [variablesTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [variablesTableView reloadData]; + } } #pragma mark - diff --git a/Source/SPTooltip.m b/Source/SPTooltip.m index 9b321005..5a0bd954 100644 --- a/Source/SPTooltip.m +++ b/Source/SPTooltip.m @@ -31,7 +31,7 @@ // // [SPTooltip showWithObject:@"<h1>Hello</h1>I am a <b>tooltip</b>" ofType:@"html" // displayOptions:[NSDictionary dictionaryWithObjectsAndKeys: -// @"Monaco", @"fontname", +// SPDefaultMonospacedFontName, @"fontname", // @"#EEEEEE", @"backgroundcolor", // @"20", @"fontsize", // @"transparent", @"transparent", nil]]; diff --git a/Source/TableContent.m b/Source/TableContent.m index d479a3a3..552fbd41 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -119,11 +119,14 @@ return self; } +/** + * Initialise various interface controls + */ - (void)awakeFromNib { // Set the table content view's vertical gridlines if required [tableContentView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) @@ -319,11 +322,7 @@ } // Set the data cell font according to the preferences - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } else { - [dataCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + [dataCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; // Assign the data cell [theCol setDataCell:dataCell]; @@ -1257,14 +1256,8 @@ [tableContentView setVerticalMotionCanBeginDrag:NO]; - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [argumentField setFont:[NSFont fontWithName:@"Monaco" size:10]]; - [limitRowsField setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - } else { - [limitRowsField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - [argumentField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } [limitRowsStepper setEnabled:NO]; + if ( ![prefs boolForKey:SPLimitResults] ) { [limitRowsField setStringValue:@""]; } @@ -2878,9 +2871,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [tableContentView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [tableContentView reloadData]; + } } /** diff --git a/Source/TableDocument.m b/Source/TableDocument.m index df856d33..69fc54d5 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -174,6 +174,12 @@ [prefs addObserver:tableRelationsInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; + // Register observers for the when the UseMonospacedFonts preference changes + [prefs addObserver:tableSourceInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:tableContentInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:customQueryInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + // Register observers for when the logging preference changes [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPConsoleEnableLogging options:NSKeyValueObservingOptionNew context:NULL]; @@ -3300,9 +3306,6 @@ [aController setShouldCascadeWindows:YES]; [super windowControllerDidLoadNib:aController]; - //NSEnumerator *theCols = [[variablesTableView tableColumns] objectEnumerator]; - //NSTableColumn *theCol; - //register for notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:) name:@"SMySQLQueryWillBePerformed" object:self]; @@ -3310,21 +3313,6 @@ name:@"SMySQLQueryHasBeenPerformed" object:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"NSApplicationWillTerminateNotification" object:nil]; - - //set up interface - /*if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [[SPQueryController sharedQueryController] setConsoleFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - - while ( (theCol = [theCols nextObject]) ) { - [[theCol dataCell] setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } - } else { - [[SPQueryController sharedQueryController] setConsoleFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - - while ( (theCol = [theCols nextObject]) ) { - [[theCol dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - }*/ } // NSWindow delegate methods diff --git a/Source/TableDump.m b/Source/TableDump.m index 02e46cd7..90c27a42 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -2525,14 +2525,14 @@ [switchButton release]; if ( [prefs boolForKey:SPUseMonospacedFonts] ) { [[[exportDumpTableView tableColumnWithIdentifier:@"tables"] dataCell] - setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; + setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; [[[exportMultipleCSVTableView tableColumnWithIdentifier:@"tables"] dataCell] - setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; + setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; [[[exportMultipleXMLTableView tableColumnWithIdentifier:@"tables"] dataCell] - setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; + setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; [[[fieldMappingTableView tableColumnWithIdentifier:@"0"] dataCell] - setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - [errorsView setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; + setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; + [errorsView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; } else { [[[exportDumpTableView tableColumnWithIdentifier:@"tables"] dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; @@ -2544,7 +2544,6 @@ setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [errorsView setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } - // [self reloadTables:self]; } #pragma mark - @@ -2552,30 +2551,15 @@ - (int)numberOfRowsInTableView:(NSTableView *)aTableView; { - if ( aTableView == fieldMappingTableView ) { - return [fieldMappingTableColumnNames count]; - } else { - return [tables count]; - } + return (aTableView == fieldMappingTableView) ? [fieldMappingTableColumnNames count] : [tables count]; } -- (void)tableView:(NSTableView *)aTableView - willDisplayCell:(id)aCell - forTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { - if ( [[NSUserDefaults standardUserDefaults] boolForKey:SPUseMonospacedFonts] ) { - [aCell setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - } - else - { - [aCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + [aCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } -- (id)tableView:(NSTableView *)aTableView -objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { id returnObject = nil; @@ -2603,15 +2587,12 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn return returnObject; } -- (void)tableView:(NSTableView *)aTableView - setObjectValue:(id)anObject - forTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { if ( aTableView == fieldMappingTableView ) { [fieldMappingArray replaceObjectAtIndex:rowIndex withObject:anObject]; - - } else { + } + else { [[tables objectAtIndex:rowIndex] replaceObjectAtIndex:0 withObject:anObject]; } } diff --git a/Source/TableSource.m b/Source/TableSource.m index 4d89ddbf..932d9cdd 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -216,28 +216,9 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab } else { [indexedColumnsField setNumberOfVisibleItems:10]; } - - // Reset font for field and index table - NSEnumerator *indexColumnsEnumerator = [[indexView tableColumns] objectEnumerator]; - NSEnumerator *fieldColumnsEnumerator = [[tableSourceView tableColumns] objectEnumerator]; - id indexColumn; - id fieldColumn; - BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; - - while ( (indexColumn = [indexColumnsEnumerator nextObject]) ) - if ( useMonospacedFont ) - [[indexColumn dataCell] setFont:[NSFont fontWithName:@"Monaco" size:10]]; - else - [[indexColumn dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - - while ( (fieldColumn = [fieldColumnsEnumerator nextObject]) ) - if ( useMonospacedFont ) - [[fieldColumn dataCell] setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - else - [[fieldColumn dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - - [tableSourceView reloadData]; + [indexView reloadData]; + [tableSourceView reloadData]; // display and *then* tile to force scroll bars to be in the correct position [[tableSourceView enclosingScrollView] display]; @@ -246,8 +227,8 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab // Enable 'Duplicate field' if at least one field is specified // if no field is selected 'Duplicate field' will copy the last field // Enable 'Duplicate field' only for tables! - if([tablesListInstance tableType] == SP_TABLETYPE_TABLE) - [copyFieldButton setEnabled:enableInteraction && ([tableSourceView numberOfRows] > 0)]; + if ([tablesListInstance tableType] == SP_TABLETYPE_TABLE) + [copyFieldButton setEnabled:enableInteraction && ([tableSourceView numberOfRows] > 0)]; else [copyFieldButton setEnabled:NO]; @@ -255,9 +236,9 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } -/* -reloads the table (performing a new mysql-query) -*/ +/** + * Reloads the table (performing a new mysql-query) + */ - (IBAction)reloadTable:(id)sender { [tableDataInstance resetAllData]; @@ -265,7 +246,6 @@ reloads the table (performing a new mysql-query) [self loadTable:selectedTable]; } - #pragma mark - #pragma mark Edit methods @@ -482,39 +462,15 @@ closes the keySheet #pragma mark - #pragma mark Additional methods -/* -sets the connection (received from TableDocument) and makes things that have to be done only once -*/ +/** + * Sets the connection (received from TableDocument) and makes things that have to be done only once + */ - (void)setConnection:(MCPConnection *)theConnection { - NSEnumerator *indexColumnsEnumerator = [[indexView tableColumns] objectEnumerator]; - NSEnumerator *fieldColumnsEnumerator = [[tableSourceView tableColumns] objectEnumerator]; - id indexColumn; - id fieldColumn; - mySQLConnection = theConnection; - //set up tableView + // Set up tableView [tableSourceView registerForDraggedTypes:[NSArray arrayWithObjects:@"SequelProPasteboard", nil]]; - - while ( (indexColumn = [indexColumnsEnumerator nextObject]) ) { - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [[indexColumn dataCell] setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } - else - { - [[indexColumn dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - } - while ( (fieldColumn = [fieldColumnsEnumerator nextObject]) ) { - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [[fieldColumn dataCell] setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - } - else - { - [[fieldColumn dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - } } /* @@ -822,10 +778,29 @@ fetches the result as an array with a dictionary for each row in it */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [tableSourceView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; [indexView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *indexColumn in [indexView tableColumns]) + { + [[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + for (NSTableColumn *fieldColumn in [tableSourceView tableColumns]) + { + [[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [tableSourceView reloadData]; + [indexView reloadData]; + } } /** @@ -1057,26 +1032,12 @@ returns a dictionary containing enum/set field names as key and possible values return (aTableView == tableSourceView) ? [tableFields count] : [indexes count]; } -- (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex -{ - id theRow, theValue; - - if ( aTableView == tableSourceView ) { - theRow = [tableFields objectAtIndex:rowIndex]; - } else { - theRow = [indexes objectAtIndex:rowIndex]; - } - theValue = [theRow objectForKey:[aTableColumn identifier]]; - - return theValue; +- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex +{ + return [(aTableView == tableSourceView) ? [tableFields objectAtIndex:rowIndex] : [indexes objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]; } -- (void)tableView:(NSTableView *)aTableView - setObjectValue:(id)anObject - forTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { // Make sure that the drag operation is for the right table view if (aTableView!=tableSourceView) return; @@ -1369,12 +1330,12 @@ would result in a position change. - (float)splitView:(NSSplitView *)sender constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)offset { - return proposedMax - 150; + return proposedMax - 150; } - (float)splitView:(NSSplitView *)sender constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)offset { - return proposedMin + 150; + return proposedMin + 150; } - (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(int)dividerIndex @@ -1409,7 +1370,20 @@ would result in a position change. // Set the structure and index view's vertical gridlines if required [tableSourceView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; [indexView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - + + // Set the strutcture and index view's font + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + + for (NSTableColumn *indexColumn in [indexView tableColumns]) + { + [[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + for (NSTableColumn *fieldColumn in [tableSourceView tableColumns]) + { + [[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) |