New: Added menu Create Project... in xCodeCapp

Previously it wasn't possible to create a capp project from xCodeCapp.
Now you can create one from the menu item Create Project, xCodeCapp will load the project as the same time is no error occurs.
When choosing an existing project, xCodeCapp removes the old one (this is asked to the user, would you like to replace the files...).
In case of errors, the errors panel appears.
This commit is contained in:
Alexandre Wilhelm
2013-08-06 00:41:38 -07:00
parent 3c9435ed21
commit ceb22a47c5
5 changed files with 494 additions and 2332 deletions
@@ -40,6 +40,7 @@
+ (AppController *)sharedAppController;
- (IBAction)createProject:(id)sender;
- (IBAction)loadProject:(id)aSender;
- (IBAction)openHelp:(id)aSender;
- (IBAction)openAbout:(id)aSender;
+20
View File
@@ -401,6 +401,25 @@ AppController *SharedAppControllerInstance = nil;
[self openWindow:self.preferencesWindow];
}
- (IBAction)createProject:(id)sender
{
NSSavePanel *savePanel = [NSSavePanel savePanel];
savePanel.title = @"Create a new Cappuccino Project";
savePanel.canCreateDirectories = YES;
if ([savePanel runModal] != NSFileHandlingPanelOKButton)
return;
NSString *projectPath = [[savePanel.URL path] stringByStandardizingPath];
NSDictionary *taskResult = [self.xcc createProject:projectPath];
if ([taskResult[@"status"] intValue])
return;
[self loadProjectAtPath:projectPath reopening:YES];
}
#pragma mark - Delegates
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app
@@ -439,6 +458,7 @@ AppController *SharedAppControllerInstance = nil;
#pragma mark - Private Helpers
- (BOOL)loadProjectAtPath:(NSString *)path reopening:(BOOL)reopen
{
if (!reopen && [self.xcc.projectPath isEqualToString:path])
+2
View File
@@ -134,6 +134,8 @@ extern NSString * const XCCProjectDidFinishLoadingNotification;
- (void)wantUserNotificationWithInfo:(NSDictionary *)info;
- (NSDictionary *)runTaskWithLaunchPath:(NSString *)launchPath arguments:(NSArray *)arguments returnType:(XCCTaskReturnType)returnType;
- (NSDictionary*)createProject:(NSString*)aPath;
@end
@interface XcodeCapp (SnowLeopard)
+32 -1
View File
@@ -239,7 +239,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
// Make sure we are using jsc as the narwhal engine!
self.environment[@"NARWHAL_ENGINE"] = @"jsc";
self.executables = @[@"python", @"narwhal-jsc", @"objj", @"nib2cib"];
self.executables = @[@"python", @"narwhal-jsc", @"objj", @"nib2cib", @"capp"];
}
- (void)initObservers
@@ -574,6 +574,37 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
[self openXcodeProject:self];
}
- (NSDictionary*)createProject:(NSString*)aPath
{
// This is used when an user wants to replace an existing project
NSArray *argumentsRemove = [NSArray arrayWithObjects:@"-rf", aPath, nil];
[self runTaskWithLaunchPath:@"/bin/rm" arguments:argumentsRemove returnType:kTaskReturnTypeAny];
// Don't know if we have to use the argument -l or not. In this case we should add $CAPP_BUILD in the taskEnv
NSArray *arguments = [NSArray arrayWithObjects:@"gen", aPath ,@"-t", @"NibApplication", nil];
NSDictionary *taskResult = [self runTaskWithLaunchPath:self.executablePaths[@"capp"]
arguments:arguments
returnType:kTaskReturnTypeStdOut];
NSInteger status = [taskResult[@"status"] intValue];
NSString *response = taskResult[@"response"];
if (!status)
{
DDLogVerbose(@"Created Xcode project: [%ld, %@]", status, status ? response : @"");
[self notifyUserWithTitle:@"Project created" message:aPath.lastPathComponent];
}
else
{
DDLogVerbose(@"Created Xcode project failed: [%ld, %@]", status, status ? response : @"");
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:response forKey:@"message"];
[self.errorListController addObject:dictionary];
[self showErrors];
}
return taskResult;
}
#pragma mark - Notification handlers
/*
File diff suppressed because it is too large Load Diff