ProjectCenter now stores the project files under PROJECTNAME.pcproj to avoid

name clashes.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12017 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Philippe C.D. Robert 2002-01-07 09:37:19 +00:00
parent ba23332a84
commit fa7bda8926
16 changed files with 69 additions and 34 deletions

View file

@ -75,16 +75,19 @@ static PCAppProj *_creator = nil;
NSAssert(path,@"No valid project path provided!"); NSAssert(path,@"No valid project path provided!");
if ([fm createDirectoryAtPath:path attributes:nil]) { if ([fm createDirectoryAtPath:path attributes:nil])
{
NSString *_file; NSString *_file;
NSString *_resourcePath; NSString *_resourcePath;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSDictionary *infoDict; NSDictionary *infoDict;
NSString *plistFileName; NSString *plistFileName;
NSString *projectFile;
project = [[[PCAppProject alloc] init] autorelease]; project = [[[PCAppProject alloc] init] autorelease];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"]; _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC"
ofType:@"proj"];
dict = [NSMutableDictionary dictionaryWithContentsOfFile:_file]; dict = [NSMutableDictionary dictionaryWithContentsOfFile:_file];
// Customise the project // Customise the project
@ -102,16 +105,20 @@ static PCAppProj *_creator = nil;
@"",@"Authors", @"",@"Authors",
@"",@"URL", @"",@"URL",
@"Copyright (C) 200x by ...",@"Copyright", @"Copyright (C) 200x by ...",@"Copyright",
@"Released under ...",@"CopyrightDescription", nil]; @"Released under...",@"CopyrightDescription",
nil];
plistFileName = [NSString stringWithFormat:@"%@Info.plist", plistFileName = [NSString stringWithFormat:@"%@Info.plist",
[path lastPathComponent]]; [path lastPathComponent]];
[infoDict writeToFile:[path stringByAppendingPathComponent:plistFileName] atomically:YES]; [infoDict writeToFile:[path stringByAppendingPathComponent:plistFileName] atomically:YES];
[dict setObject:[NSArray arrayWithObjects:plistFileName,nil] [dict setObject:[NSArray arrayWithObjects:plistFileName,nil]
forKey:PCOtherResources]; forKey:PCOtherResources];
// Save the project to disc // Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] //projectFile = [NSString stringWithString:@"PC.project"];
projectFile = [NSString stringWithString:[path lastPathComponent]];
projectFile = [projectFile stringByAppendingPathExtension:@"pcproj"];
[dict writeToFile:[path stringByAppendingPathComponent:projectFile]
atomically:YES]; atomically:YES];
/* /*

View file

@ -64,4 +64,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -60,4 +60,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -80,6 +80,8 @@ static PCBundleProj *_creator = nil;
NSString *_file; NSString *_file;
NSString *_resourcePath; NSString *_resourcePath;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSString *projectFile;
project = [[[PCBundleProject alloc] init] autorelease]; project = [[[PCBundleProject alloc] init] autorelease];
@ -92,7 +94,9 @@ static PCBundleProj *_creator = nil;
[dict setObject:[project principalClass] forKey:PCProjType]; [dict setObject:[project principalClass] forKey:PCProjType];
// Save the project to disc // Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] projectFile = [NSString stringWithString:[path lastPathComponent]];
projectFile = [projectFile stringByAppendingPathExtension:@"pcproj"];
[dict writeToFile:[path stringByAppendingPathComponent:projectFile]
atomically:YES]; atomically:YES];
/* /*

View file

@ -60,4 +60,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -81,6 +81,7 @@ static PCGormProj *_creator = nil;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSDictionary *infoDict; NSDictionary *infoDict;
NSString *plistFileName; NSString *plistFileName;
NSString *projectFile;
project = [[[PCGormProject alloc] init] autorelease]; project = [[[PCGormProject alloc] init] autorelease];
@ -114,7 +115,10 @@ static PCGormProj *_creator = nil;
forKey:PCMainGModelFile]; forKey:PCMainGModelFile];
// Save the project to disc // Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] atomically:YES]; projectFile = [NSString stringWithString:[path lastPathComponent]];
projectFile = [projectFile stringByAppendingPathExtension:@"pcproj"];
[dict writeToFile:[path stringByAppendingPathComponent:projectFile]
atomically:YES];
/* /*
* Copy the project files to the provided path * Copy the project files to the provided path

View file

@ -64,4 +64,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -806,7 +806,8 @@
- (BOOL)save - (BOOL)save
{ {
BOOL ret = NO; BOOL ret = NO;
NSString *file = [projectPath stringByAppendingPathComponent:@"PC.project"]; //NSString *file = [projectPath stringByAppendingPathComponent:@"PC.project"];
NSString *file = [[projectPath stringByAppendingPathComponent:projectName] stringByAppendingPathExtension:@"pcproj"];
NSString *backup = [file stringByAppendingPathExtension:@"backup"]; NSString *backup = [file stringByAppendingPathExtension:@"backup"];
NSFileManager *fm = [NSFileManager defaultManager]; NSFileManager *fm = [NSFileManager defaultManager];
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];

View file

@ -315,9 +315,6 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
if (!project) if (!project)
{ {
#ifdef DEBUG
NSLog(@"Couldn't instantiate the project...");
#endif // DEBUG
return NO; return NO;
} }

View file

@ -79,7 +79,8 @@ static PCLibProj *_creator = nil;
NSString *_file; NSString *_file;
NSString *_resourcePath; NSString *_resourcePath;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSString *projectFile;
project = [[[PCLibProject alloc] init] autorelease]; project = [[[PCLibProject alloc] init] autorelease];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"]; _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"];
@ -90,8 +91,11 @@ static PCLibProj *_creator = nil;
[dict setObject:[project principalClass] forKey:PCProjType]; [dict setObject:[project principalClass] forKey:PCProjType];
// Save the project to disc // Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] atomically:YES]; projectFile = [NSString stringWithString:[path lastPathComponent]];
projectFile = [projectFile stringByAppendingPathExtension:@"pcproj"];
[dict writeToFile:[path stringByAppendingPathComponent:projectFile]
atomically:YES];
// Copy the project files to the provided path // Copy the project files to the provided path
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"]; _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:@"GNUmakefile.postamble"] handler:nil]; [fm copyPath:_file toPath:[path stringByAppendingPathComponent:@"GNUmakefile.postamble"] handler:nil];

View file

@ -61,4 +61,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -79,7 +79,8 @@ static PCToolProj *_creator = nil;
NSString *_file; NSString *_file;
NSString *_resourcePath; NSString *_resourcePath;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSString *projectFile;
project = [[[PCToolProject alloc] init] autorelease]; project = [[[PCToolProject alloc] init] autorelease];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"]; _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"];
@ -90,7 +91,10 @@ static PCToolProj *_creator = nil;
[dict setObject:[project principalClass] forKey:PCProjType]; [dict setObject:[project principalClass] forKey:PCProjType];
// Save the project to disc // Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] atomically:YES]; projectFile = [NSString stringWithString:[path lastPathComponent]];
projectFile = [projectFile stringByAppendingPathExtension:@"pcproj"];
[dict writeToFile:[path stringByAppendingPathComponent:projectFile]
atomically:YES];
// Copy the project files to the provided path // Copy the project files to the provided path
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"]; _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"];

View file

@ -62,4 +62,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -95,7 +95,7 @@
- (void)openProject:(id)sender - (void)openProject:(id)sender
{ {
NSString *projectPath; NSString *projPath;
NSOpenPanel *openPanel; NSOpenPanel *openPanel;
int retval; int retval;
@ -104,17 +104,23 @@
[openPanel setCanChooseDirectories:NO]; [openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES]; [openPanel setCanChooseFiles:YES];
retval = [openPanel runModalForDirectory:[[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenDirectory"] file:nil types:[NSArray arrayWithObjects:@"project",nil]]; retval = [openPanel runModalForDirectory:[[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenDirectory"] file:nil types:[NSArray arrayWithObjects:@"project",@"pcproj",nil]];
if (retval == NSOKButton) { if (retval == NSOKButton) {
BOOL isDir; BOOL isDir;
[[NSUserDefaults standardUserDefaults] setObject:[openPanel directory] forKey:@"LastOpenDirectory"]; [[NSUserDefaults standardUserDefaults] setObject:[openPanel directory]
projectPath = [[openPanel filenames] objectAtIndex:0]; forKey:@"LastOpenDirectory"];
projPath = [[openPanel filenames] objectAtIndex:0];
if ([[NSFileManager defaultManager] fileExistsAtPath:projectPath isDirectory:&isDir] && !isDir) { if ([[NSFileManager defaultManager] fileExistsAtPath:projPath
if (![projectManager openProjectAt:projectPath]) { isDirectory:&isDir] && !isDir){
NSRunAlertPanel(@"Attention!",@"Couldn't open %@!",@"OK",nil,nil,[projectPath stringByDeletingLastPathComponent]); if (![projectManager openProjectAt:projPath])
{
NSRunAlertPanel(@"Attention!",
@"Couldn't open %@!",
@"OK",nil,nil,
[projPath stringByDeletingLastPathComponent]);
} }
} }
} }
@ -131,12 +137,16 @@
[sp setAccessoryView:projectTypeAccessaryView]; [sp setAccessoryView:projectTypeAccessaryView];
runResult = [sp runModalForDirectory:NSHomeDirectory() file:@""]; runResult = [sp runModalForDirectory:NSHomeDirectory() file:@""];
if (runResult == NSOKButton) { if (runResult == NSOKButton)
{
NSString *projectType = [projectTypePopup titleOfSelectedItem]; NSString *projectType = [projectTypePopup titleOfSelectedItem];
NSString *className = [[appController projectTypes] objectForKey:projectType]; NSString *className = [[appController projectTypes] objectForKey:projectType];
if (![projectManager createProjectOfType:className path:[sp filename]]) { if (![projectManager createProjectOfType:className path:[sp filename]])
NSRunAlertPanel(@"Attention!",@"Failed to create %@!",@"OK",nil,nil,[sp filename]); {
NSRunAlertPanel(@"Attention!",
@"Failed to create %@!",
@"OK",nil,nil,[sp filename]);
} }
} }
} }
@ -150,7 +160,7 @@
{ {
NSString *proj; NSString *proj;
// Show save panel // Show save panel
[projectManager saveProjectAs:proj]; [projectManager saveProjectAs:proj];
} }

View file

@ -95,4 +95,4 @@
GNUmakefile, GNUmakefile,
GNUmakefile.postamble GNUmakefile.postamble
); );
} }

View file

@ -6,6 +6,10 @@
NSUnixExtensions = ( "project" ); NSUnixExtensions = ( "project" );
NSIcon = "ProjectCenter.tiff"; NSIcon = "ProjectCenter.tiff";
}, },
{
NSUnixExtensions = ( "pcproj" );
NSIcon = "ProjectCenter.tiff";
},
{ {
NSUnixExtensions = ( "m" ); NSUnixExtensions = ( "m" );
NSIcon = "FileIcon_.m.tiff"; NSIcon = "FileIcon_.m.tiff";