diff --git a/PCBaseFileTypes/GNUmakefile b/PCBaseFileTypes/GNUmakefile index 60b285a..0a65782 100644 --- a/PCBaseFileTypes/GNUmakefile +++ b/PCBaseFileTypes/GNUmakefile @@ -38,7 +38,8 @@ PCBaseFileTypes_RESOURCE_FILES = \ cfile.template \ cheader.template \ class.template \ - header.template + header.template \ + protocol.template -include GNUmakefile.preamble @@ -46,3 +47,4 @@ include $(GNUSTEP_MAKEFILES)/bundle.make -include GNUmakefile.postamble + diff --git a/PCBaseFileTypes/PCBaseFileType.m b/PCBaseFileTypes/PCBaseFileType.m index e62d841..69dfb1d 100644 --- a/PCBaseFileTypes/PCBaseFileType.m +++ b/PCBaseFileTypes/PCBaseFileType.m @@ -31,6 +31,7 @@ #define ObjCHeader @"ObjC Header" #define CFile @"C File" #define CHeaderFile @"C Header" +#define ProtocolFile @"ObjC Protocol" @implementation PCBaseFileType @@ -40,124 +41,138 @@ static NSDictionary *dict = nil; + (id)sharedCreator { - if (!_creator) { - NSDictionary *classDict; - NSDictionary *headerDict; - NSDictionary *ccDict; - NSDictionary *chDict; - - _creator = [[[self class] alloc] init]; - - // Setting up the dictionary needed for registration! - classDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCClasses,@"ProjectKey",nil]; - headerDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCHeaders,@"ProjectKey",nil]; - ccDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCOtherSources,@"ProjectKey",nil]; - chDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCHeaders,@"ProjectKey",nil]; - - dict = [[NSDictionary alloc] initWithObjectsAndKeys:classDict,ObjCClass,headerDict,ObjCHeader,ccDict,CFile,chDict,CHeaderFile,nil]; - } - return _creator; + if (!_creator) { + NSDictionary *classDict; + NSDictionary *headerDict; + NSDictionary *ccDict; + NSDictionary *chDict; + NSDictionary *protocolDict; + + _creator = [[[self class] alloc] init]; + + // Setting up the dictionary needed for registration! + classDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCClasses,@"ProjectKey",nil]; + headerDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCHeaders,@"ProjectKey",nil]; + ccDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCOtherSources,@"ProjectKey",nil]; + chDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCHeaders,@"ProjectKey",nil]; + protocolDict = [NSDictionary dictionaryWithObjectsAndKeys:_creator,@"Creator",PCHeaders,@"ProjectKey",nil]; + + dict = [[NSDictionary alloc] initWithObjectsAndKeys:classDict,ObjCClass,headerDict,ObjCHeader,ccDict,CFile,chDict,CHeaderFile,protocolDict,ProtocolFile,nil]; + } + return _creator; } - (NSString *)name { - return _name; + return _name; } - (NSDictionary *)creatorDictionary { - return dict; + return dict; } - (NSDictionary *)createFileOfType:(NSString *)type path:(NSString *)path project:(PCProject *)aProject { - NSFileManager *fm = [NSFileManager defaultManager]; - NSString *_file; - NSString *newFile = nil; - NSMutableDictionary *files; - - // A class and possibly a header - files = [NSMutableDictionary dictionaryWithCapacity:2]; - - NSLog(@"<%@ %x>: create %@ at %@",[self class],self,type,path); - - /* - * - */ + NSFileManager *fm = [NSFileManager defaultManager]; + NSString *_file; + NSString *newFile = nil; + NSMutableDictionary *files; + + // A class and possibly a header + files = [NSMutableDictionary dictionaryWithCapacity:2]; + + NSLog(@"<%@ %x>: create %@ at %@",[self class],self,type,path); + + /* + * + */ + + if ([type isEqualToString:ObjCClass]) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"template"]; + newFile = [path stringByAppendingPathExtension:@"m"]; + [fm copyPath:_file toPath:newFile handler:nil]; + [files setObject:ObjCClass forKey:newFile]; - if ([type isEqualToString:ObjCClass]) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"template"]; - newFile = [path stringByAppendingPathExtension:@"m"]; - [fm copyPath:_file toPath:newFile handler:nil]; - [files setObject:ObjCClass forKey:newFile]; - - [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; - - // Should a header be created as well? - newFile = [path stringByAppendingPathExtension:@"h"]; - if (NSRunAlertPanel(@"Attention!",@"Should %@ be created and inserted in the project as well?",@"Yes",@"No",nil,[newFile lastPathComponent])) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"]; - [fm copyPath:_file toPath:newFile handler:nil]; - - [self replaceTagsInFileAtPath:newFile withProject:aProject type:ObjCHeader]; - [files setObject:ObjCHeader forKey:newFile]; - } + [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; + + // Should a header be created as well? + newFile = [path stringByAppendingPathExtension:@"h"]; + if (NSRunAlertPanel(@"Attention!",@"Should %@ be created and inserted in the project as well?",@"Yes",@"No",nil,[newFile lastPathComponent])) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"]; + [fm copyPath:_file toPath:newFile handler:nil]; + + [self replaceTagsInFileAtPath:newFile withProject:aProject type:ObjCHeader]; + [files setObject:ObjCHeader forKey:newFile]; + } + } + + /* + * + */ + + else if ([type isEqualToString:CFile]) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cfile" ofType:@"template"]; + newFile = [path stringByAppendingPathExtension:@"c"]; + [fm copyPath:_file toPath:newFile handler:nil]; + [files setObject:CFile forKey:newFile]; + + [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; + + // Should a header be created as well? + newFile = [path stringByAppendingPathExtension:@"h"]; + if (NSRunAlertPanel(@"Attention!",@"Should %@ be created and inserted in the project as well?",@"Yes",@"No",nil,[newFile lastPathComponent])) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"]; + [fm copyPath:_file toPath:newFile handler:nil]; + + [self replaceTagsInFileAtPath:newFile withProject:aProject type:CHeaderFile]; + [files setObject:CHeaderFile forKey:newFile]; } + } + + /* + * + */ + + else if ([type isEqualToString:ObjCHeader]) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"]; + newFile = [path stringByAppendingPathExtension:@"h"]; + [fm copyPath:_file toPath:newFile handler:nil]; + [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; + [files setObject:ObjCHeader forKey:newFile]; + } + + /* + * + */ + + else if ([type isEqualToString:CHeaderFile]) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"]; + newFile = [path stringByAppendingPathExtension:@"h"]; + [fm copyPath:_file toPath:newFile handler:nil]; + [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; + [files setObject:CHeaderFile forKey:newFile]; + } - /* - * - */ - - else if ([type isEqualToString:CFile]) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cfile" ofType:@"template"]; - newFile = [path stringByAppendingPathExtension:@"c"]; - [fm copyPath:_file toPath:newFile handler:nil]; - [files setObject:CFile forKey:newFile]; - - [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; - - // Should a header be created as well? - newFile = [path stringByAppendingPathExtension:@"h"]; - if (NSRunAlertPanel(@"Attention!",@"Should %@ be created and inserted in the project as well?",@"Yes",@"No",nil,[newFile lastPathComponent])) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"]; - [fm copyPath:_file toPath:newFile handler:nil]; - - [self replaceTagsInFileAtPath:newFile withProject:aProject type:CHeaderFile]; - [files setObject:CHeaderFile forKey:newFile]; - } - } - - /* - * - */ - - else if ([type isEqualToString:ObjCHeader]) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"]; - newFile = [path stringByAppendingPathExtension:@"h"]; - [fm copyPath:_file toPath:newFile handler:nil]; - [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; - [files setObject:ObjCHeader forKey:newFile]; - } - - /* - * - */ - - else if ([type isEqualToString:CHeaderFile]) { - _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"]; - newFile = [path stringByAppendingPathExtension:@"h"]; - [fm copyPath:_file toPath:newFile handler:nil]; - [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; - [files setObject:ObjCHeader forKey:newFile]; - } - - /* - * Notify the browser! - */ - - [[NSNotificationCenter defaultCenter] postNotificationName:@"ProjectDictDidChangeNotification" object:self]; - - return files; + /* + * + */ + + else if ([type isEqualToString:ProtocolFile]) { + _file = [[NSBundle bundleForClass:[self class]] pathForResource:@"protocol" ofType:@"template"]; + newFile = [path stringByAppendingPathExtension:@"h"]; + [fm copyPath:_file toPath:newFile handler:nil]; + [self replaceTagsInFileAtPath:newFile withProject:aProject type:type]; + [files setObject:ProtocolFile forKey:newFile]; + } + + /* + * Notify the browser! + */ + + [[NSNotificationCenter defaultCenter] postNotificationName:@"ProjectDictDidChangeNotification" object:self]; + + return files; } - (void)replaceTagsInFileAtPath:(NSString *)newFile withProject:(PCProject *)aProject type:(NSString *)aType @@ -166,7 +181,7 @@ static NSDictionary *dict = nil; NSString *pname = [aProject projectName]; NSString *date = [[NSCalendarDate calendarDate] description]; NSString *aFile = [newFile lastPathComponent]; - + file = [[NSMutableString stringWithContentsOfFile:newFile] retain]; [file replaceCharactersInRange: @@ -183,6 +198,7 @@ static NSDictionary *dict = nil; if ([aType isEqualToString:ObjCClass] || [aType isEqualToString:CFile] || + [aType isEqualToString:ProtocolFile] || [aType isEqualToString:ObjCHeader]) { NSString *name = [aFile stringByDeletingPathExtension]; diff --git a/PCBaseFileTypes/protocol.template b/PCBaseFileTypes/protocol.template new file mode 100644 index 0000000..db356f9 --- /dev/null +++ b/PCBaseFileTypes/protocol.template @@ -0,0 +1,13 @@ +/* + * $FILENAME$ created by $USERNAME$ on $DATE$ + * + * Project $PROJECTNAME$ + * + * Created with ProjectCenter - http://www.projectcenter.ch + * + * $Id$ + */ + +@protocol $FILENAMESANSEXTENSION$ + +@end diff --git a/PCLib/PCEditorView.m b/PCLib/PCEditorView.m index bfd78cd..316c25b 100644 --- a/PCLib/PCEditorView.m +++ b/PCLib/PCEditorView.m @@ -56,7 +56,7 @@ static BOOL isInitialised = NO; isInitialised = YES; } - _keywords = [[NSArray alloc] initWithObjects:@"@class",@"@selector",@"#import",@"#include",@"#define",@"#pragma",@"#warning",@"@interface",@"@implementation",@"@end",nil]; + _keywords = [[NSArray alloc] initWithObjects:@"@class",@"@selector",@"#import",@"#include",@"#define",@"#pragma",@"#warning",@"@interface",@"@implementation",@"@end",@"@protocol",nil]; } return self; } diff --git a/PCLib/PCProject.m b/PCLib/PCProject.m index 5681e94..2c6fdfe 100644 --- a/PCLib/PCProject.m +++ b/PCLib/PCProject.m @@ -331,7 +331,7 @@ [textField setEditable: NO]; [textField setBezeled: NO]; [textField setDrawsBackground: NO]; - [textField setStringValue:@"Project Type:"]; + [textField setStringValue:@"Type:"]; [projectProjectInspectorView addSubview:[textField autorelease]]; projectTypeField =[[NSTextField alloc] initWithFrame:NSMakeRect(84,280,176,21)]; diff --git a/ProjectCenter/PCAppController.m b/ProjectCenter/PCAppController.m index b419979..9c0002c 100644 --- a/ProjectCenter/PCAppController.m +++ b/ProjectCenter/PCAppController.m @@ -172,7 +172,7 @@ - (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName { - if ([[fileName lastPAthComponent] isEqualToString:@"PC.project"] == NO) { + if ([[fileName lastPathComponent] isEqualToString:@"PC.project"] == NO) { return NO; } @@ -189,6 +189,8 @@ NSString *h = [[NSProcessInfo processInfo] hostName]; NSString *connectionName = [NSString stringWithFormat:@"ProjectCenter:%@",h]; [logger logMessage:@"Loading additional subsystems..." tag:INFORMATION]; + + //[bundleLoader loadBundles]; // The DO server doServer = [[PCServer alloc] init];