FIXED: XCC Preferences Coherency

This patch fixes various UX weirdness with preferences and makes everything aligned.
This commit is contained in:
Antoine Mercadal
2014-04-21 16:59:06 -07:00
parent eaa607b48d
commit 14cb6d21a9
7 changed files with 259 additions and 705 deletions
+1 -5
View File
@@ -144,19 +144,15 @@ AppController *SharedAppControllerInstance = nil;
kDefaultXCCAPIMode: [NSNumber numberWithInt:kXCCAPIModeAuto],
kDefaultXCCReactToInodeMod: @YES,
kDefaultXCCReopenLastProject: @YES,
kDefaultXCCAutoOpenErrorsPanelOnWarnings: @YES,
kDefaultXCCAutoOpenErrorsPanelOnErrors: @YES,
kDefaultXCCAutoOpenErrorsPanelOnCappLint: @YES,
kDefaultXCCAutoShowNotificationOnWarnings: @YES,
kDefaultXCCAutoShowNotificationOnErrors: @YES,
kDefaultXCCAutoShowNotificationOnCappLint: @NO,
kDefaultXCCProjectHistory: [NSArray new],
kDefaultMaxRecentProjects: @20,
kDefaultLogLevel: [NSNumber numberWithInt:LOG_LEVEL_WARN],
kDefaultAutoOpenXcodeProject: @YES,
kDefaultShowProcessingNotices: @YES,
kDefaultUseSymlinkWhenCreatingProject: @YES,
KDefaultUsesCappLintForEveryNotifications: @NO
kDefaultUseSymlinkWhenCreatingProject: @YES
};
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@@ -153,12 +153,23 @@
}
}
if ((status == XCCStatusCodeError && [self.xcc shouldShowErrorNotification]) || (status != XCCStatusCodeError && [self.xcc shouldShowWarningNotification]))
if ([self.xcc shouldShowErrorNotification])
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
}
else if (!self.xcc.isLoadingProject)
{
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
BOOL showFinalNotification = YES;
if ([self.xcc shouldProcessWithCappLint])
{
showFinalNotification = [self.xcc checkCappLintForPath:self.sourcePath];
if (!showFinalNotification)
[self.xcc showCappLintErrors];
}
if (showFinalNotification)
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
}
}
@@ -179,7 +190,7 @@
nil];
info[@"projectId"] = self.projectId;
info[@"message"] = [NSString stringWithFormat:@"%@, line %d\n%@", [self.sourcePath lastPathComponent], 0, message];
info[@"message"] = [NSString stringWithFormat:@"Compilation issue: %@, line %d\n%@", [self.sourcePath lastPathComponent], 0, message];
if (self.isCancelled)
return;
-4
View File
@@ -17,10 +17,8 @@ extern NSString * const kDefaultFirstLaunchVersion;
extern NSString * const kDefaultXCCAPIMode;
extern NSString * const kDefaultXCCReactToInodeMod;
extern NSString * const kDefaultXCCReopenLastProject;
extern NSString * const kDefaultXCCAutoOpenErrorsPanelOnWarnings;
extern NSString * const kDefaultXCCAutoOpenErrorsPanelOnErrors;
extern NSString * const kDefaultXCCAutoOpenErrorsPanelOnCappLint;
extern NSString * const kDefaultXCCAutoShowNotificationOnWarnings;
extern NSString * const kDefaultXCCAutoShowNotificationOnErrors;
extern NSString * const kDefaultXCCAutoShowNotificationOnCappLint;
extern NSString * const kDefaultXCCProjectHistory;
@@ -29,8 +27,6 @@ extern NSString * const kDefaultPathModificationDates;
extern NSString * const kDefaultMaxRecentProjects;
extern NSString * const kDefaultLogLevel;
extern NSString * const kDefaultAutoOpenXcodeProject;
extern NSString * const kDefaultShowProcessingNotices;
extern NSString * const kDefaultUseSymlinkWhenCreatingProject;
extern NSString * const KDefaultUsesCappLintForEveryNotifications;
#endif
-4
View File
@@ -15,10 +15,8 @@ NSString * const kDefaultFirstLaunchVersion = @"firstLaunchVersion";
NSString * const kDefaultXCCAPIMode = @"XCCAPIMode";
NSString * const kDefaultXCCReactToInodeMod = @"XCCReactMode";
NSString * const kDefaultXCCReopenLastProject = @"XCCReopenLastProject";
NSString * const kDefaultXCCAutoOpenErrorsPanelOnWarnings = @"XCCAutoOpenErrorsPanelOnWarnings";
NSString * const kDefaultXCCAutoOpenErrorsPanelOnErrors = @"XCCAutoOpenErrorsPanelOnErrors";
NSString * const kDefaultXCCAutoOpenErrorsPanelOnCappLint = @"XCCAutoOpenErrorsPanelOnCappLint";
NSString * const kDefaultXCCAutoShowNotificationOnWarnings = @"XCCAutoShowNotificationOnWarnings";
NSString * const kDefaultXCCAutoShowNotificationOnErrors = @"XCCAutoOpenShowNotificationErrors";
NSString * const kDefaultXCCAutoShowNotificationOnCappLint = @"XCCAutoShowNotificationOnCappLint";
NSString * const kDefaultXCCProjectHistory = @"XCCProjectHistory";
@@ -27,6 +25,4 @@ NSString * const kDefaultPathModificationDates = @"pathModificationDates";
NSString * const kDefaultMaxRecentProjects = @"maxRecentProjects";
NSString * const kDefaultLogLevel = @"logLevel";
NSString * const kDefaultAutoOpenXcodeProject = @"autoOpenXcodeProject";
NSString * const kDefaultShowProcessingNotices = @"showProcessingNotices";
NSString * const kDefaultUseSymlinkWhenCreatingProject = @"useSymlinkWhenCreatingProject";
NSString * const KDefaultUsesCappLintForEveryNotifications = @"usesCappLintForEveryNotifications";
+4 -1
View File
@@ -132,7 +132,6 @@ extern NSString * const XCCProjectDidFinishLoadingNotification;
- (BOOL)isXibFile:(NSString *)path;
- (BOOL)isXCCIgnoreFile:(NSString *)path;
- (BOOL)shouldShowWarningNotification;
- (BOOL)shouldShowErrorNotification;
- (NSString *)shadowBasePathForProjectSourcePath:(NSString *)path;
@@ -146,6 +145,10 @@ extern NSString * const XCCProjectDidFinishLoadingNotification;
- (NSDictionary*)createProject:(NSString*)aPath;
- (BOOL)shouldProcessWithCappLint;
- (BOOL)checkCappLintForPath:(NSString*)aPath;
- (void)showCappLintErrors;
@end
@interface XcodeCapp (SnowLeopard)
+21 -25
View File
@@ -730,11 +730,6 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
}
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:KDefaultUsesCappLintForEveryNotifications])
[self checkCappLintForPath:path];
DDLogVerbose(@"%@ %@", NSStringFromSelector(_cmd), path);
}
@@ -1641,22 +1636,24 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
[self runTaskWithLaunchPath:executablePath arguments:args returnType:kTaskReturnTypeNone];
}
- (BOOL)shouldShowWarningNotification
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kDefaultXCCAutoShowNotificationOnWarnings];
}
- (BOOL)shouldShowErrorNotification
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kDefaultXCCAutoShowNotificationOnErrors];
}
- (BOOL)shouldProcessWithCappLint
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnCappLint]
|| [defaults boolForKey:kDefaultXCCAutoShowNotificationOnCappLint];
}
- (void)showErrors
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnErrors] && self.hasErrors) ||
([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnWarnings] && self.errorList.count))
if ([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnErrors] && self.errorList.count)
{
[self openErrorsPanel:self];
}
@@ -1672,15 +1669,16 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
if ([defaults boolForKey:kDefaultXCCAutoShowNotificationOnCappLint])
{
NSUInteger numberError = [self.errorList count];
int i = 0;
for (i = 0; i < numberError; i++)
if (numberError)
{
NSDictionary *error = [self.errorList objectAtIndex:i];
NSDictionary *error = [self.errorList objectAtIndex:0];
NSString *filename = [error objectForKey:@"path"];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:self.projectId] , @"projectId",
@"Capp_lint error", @"title",
[error objectForKey:@"message"] , @"message",
@"Code Style Issues", @"title",
filename.lastPathComponent , @"message",
nil];
[self wantUserNotificationWithInfo:dict];
@@ -1754,8 +1752,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
if ([info[@"projectId"] intValue] != self.projectId)
return;
if ([[NSUserDefaults standardUserDefaults] boolForKey:kDefaultShowProcessingNotices])
[self notifyUserWithTitle:info[@"title"] message:info[@"message"]];
[self notifyUserWithTitle:info[@"title"] message:info[@"message"]];
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
@@ -1770,7 +1767,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
[self performSelectorInBackground:@selector(checkCappLintForPath:) withObject:self.projectPath];
}
- (void)checkCappLintForPath:(NSString*)aPath
- (BOOL)checkCappLintForPath:(NSString*)aPath
{
DDLogVerbose(@"Checking path %@ with capp_lint", aPath);
@@ -1787,7 +1784,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
NSInteger status = [taskResult[@"status"] intValue];
if (status == 0)
return;
return YES;
NSString *response = taskResult[@"response"];
NSMutableArray *errors = [NSMutableArray arrayWithArray:[response componentsSeparatedByString:@"\n\n"]];
@@ -1816,7 +1813,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
NSInteger positionOfSecondColon = [errorWithoutPath rangeOfString:@":"].location;
line = [errorWithoutPath substringToIndex:positionOfSecondColon];
NSString *messageError = [NSString stringWithFormat:@"capp_lint error in %@ \n%@", path, errorWithoutPath];
NSString *messageError = [NSString stringWithFormat:@"Code style issue: %@ \n%@", path.lastPathComponent, errorWithoutPath];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:[line intValue]], @"line",
@@ -1827,11 +1824,10 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
[self.errorListController addObject:dict];
}
[self showCappLintErrors];
self.isProcessing = NO;
[[NSNotificationCenter defaultCenter] postNotificationName:XCCBatchDidEndNotification object:self];
return NO;
}
@end
File diff suppressed because it is too large Load Diff