From ee085902c3312eb623fbafaca2d59b3260385e72 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 19 Oct 2010 20:39:35 +0000 Subject: Replace use of hardcoded strings with constants when working with trigger data. --- Interfaces/English.lproj/DBView.xib | 18 ++++++------- Source/SPTableTriggers.h | 11 ++++++++ Source/SPTableTriggers.m | 54 ++++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 3d816896..fc0c5510 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,8 +23,8 @@ YES + - YES @@ -5763,7 +5763,7 @@ YES - table + TriggerTableName 116 8 1000 @@ -5793,7 +5793,7 @@ - trigger + TriggerName 100 10 3.4028230607370965e+38 @@ -5820,7 +5820,7 @@ - event + TriggerEvent 85 10 3.4028230607370965e+38 @@ -5847,7 +5847,7 @@ - timing + TriggerActionTime 121 10 3.4028230607370965e+38 @@ -5874,7 +5874,7 @@ - statement + TriggerStatement 68 10 3.4028230607370965e+38 @@ -5901,7 +5901,7 @@ - definer + TriggerDefiner 71 10 3.4028230607370965e+38 @@ -5928,7 +5928,7 @@ - created + TriggerCreated 49 10 3.4028234663852886e+38 @@ -5955,7 +5955,7 @@ - sql_mode + TriggerSQLMode 60 10 3.4028234663852886e+38 diff --git a/Source/SPTableTriggers.h b/Source/SPTableTriggers.h index b7bd61fd..c6178310 100644 --- a/Source/SPTableTriggers.h +++ b/Source/SPTableTriggers.h @@ -25,6 +25,16 @@ #import +// Constants +/*extern NSString *SPTriggerName; +extern NSString *SPTriggerTableName; +extern NSString *SPTriggerEvent; +extern NSString *SPTriggerActionTime; +extern NSString *SPTriggerStatement; +extern NSString *SPTriggerDefiner; +extern NSString *SPTriggerCreated; +extern NSString *SPTriggerSQLMode;*/ + @interface SPTableTriggers : NSObject { IBOutlet id tableDocumentInstance; @@ -54,6 +64,7 @@ BOOL isEdit; + // Cache vars NSString *editTriggerName; NSString *editTriggerEvent; NSString *editTriggerTableName; diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index a934f450..329b0f8c 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -32,6 +32,16 @@ #import "SPAlertSheets.h" #import "SPServerSupport.h" +// Constants +static const NSString *SPTriggerName = @"TriggerName"; +static const NSString *SPTriggerTableName = @"TriggerTableName"; +static const NSString *SPTriggerEvent = @"TriggerEvent"; +static const NSString *SPTriggerActionTime = @"TriggerActionTime"; +static const NSString *SPTriggerStatement = @"TriggerStatement"; +static const NSString *SPTriggerDefiner = @"TriggerDefiner"; +static const NSString *SPTriggerCreated = @"TriggerCreated"; +static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; + @interface SPTableTriggers (PrivateAPI) - (void)_editTriggerAtIndex:(NSInteger)index; @@ -48,7 +58,7 @@ #pragma mark Initialization /** - * init + * Init */ - (id)init { @@ -493,13 +503,13 @@ { NSMutableArray *temp = [[NSMutableArray alloc] init]; - [temp addObject:[trigger objectForKey:@"trigger"]]; - [temp addObject:[trigger objectForKey:@"event"]]; - [temp addObject:[trigger objectForKey:@"timing"]]; - [temp addObject:[trigger objectForKey:@"statement"]]; - [temp addObject:[trigger objectForKey:@"definer"]]; - [temp addObject:([trigger objectForKey:@"created"]) ? [trigger objectForKey:@"created"] : @""]; - [temp addObject:[trigger objectForKey:@"sql_mode"]]; + [temp addObject:[trigger objectForKey:SPTriggerName]]; + [temp addObject:[trigger objectForKey:SPTriggerEvent]]; + [temp addObject:[trigger objectForKey:SPTriggerActionTime]]; + [temp addObject:[trigger objectForKey:SPTriggerStatement]]; + [temp addObject:[trigger objectForKey:SPTriggerDefiner]]; + [temp addObject:([trigger objectForKey:SPTriggerCreated]) ? [trigger objectForKey:SPTriggerCreated] : @""]; + [temp addObject:[trigger objectForKey:SPTriggerSQLMode]]; [data addObject:temp]; @@ -534,11 +544,11 @@ // Cache the original trigger's name and statement in the event that the editing process fails and // we need to recreate it. - editTriggerName = [trigger objectForKey:@"trigger"]; - editTriggerStatement = [trigger objectForKey:@"statement"]; - editTriggerTableName = [trigger objectForKey:@"table"]; - editTriggerEvent = [trigger objectForKey:@"event"]; - editTriggerActionTime = [trigger objectForKey:@"timing"]; + editTriggerName = [trigger objectForKey:SPTriggerName]; + editTriggerStatement = [trigger objectForKey:SPTriggerStatement]; + editTriggerTableName = [trigger objectForKey:SPTriggerTableName]; + editTriggerEvent = [trigger objectForKey:SPTriggerEvent]; + editTriggerActionTime = [trigger objectForKey:SPTriggerActionTime]; [triggerNameTextField setStringValue:editTriggerName]; [triggerStatementTextView setString:editTriggerStatement]; @@ -584,6 +594,8 @@ /** * Refresh the displayed trigger, optionally forcing a refresh of the underlying cache. + * + * @param classAllCaches Indicates whether all the caches should be refreshed */ - (void)_refreshTriggerDataForcingCacheRefresh:(BOOL)clearAllCaches { @@ -601,14 +613,14 @@ for (NSDictionary *trigger in triggers) { [triggerData addObject:[NSDictionary dictionaryWithObjectsAndKeys: - [trigger objectForKey:@"Table"], @"table", - [trigger objectForKey:@"Trigger"], @"trigger", - [trigger objectForKey:@"Event"], @"event", - [trigger objectForKey:@"Timing"], @"timing", - [trigger objectForKey:@"Statement"], @"statement", - [trigger objectForKey:@"Definer"], @"definer", - [trigger objectForKey:@"Created"], @"created", - [trigger objectForKey:@"sql_mode"], @"sql_mode", + [trigger objectForKey:@"Table"], SPTriggerTableName, + [trigger objectForKey:@"Trigger"], SPTriggerName, + [trigger objectForKey:@"Event"], SPTriggerEvent, + [trigger objectForKey:@"Timing"], SPTriggerActionTime, + [trigger objectForKey:@"Statement"], SPTriggerStatement, + [trigger objectForKey:@"Definer"], SPTriggerDefiner, + [trigger objectForKey:@"Created"], SPTriggerCreated, + [trigger objectForKey:@"sql_mode"], SPTriggerSQLMode, nil]]; } -- cgit v1.2.3