Support for protocols in file creation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@7865 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Robert Slover 2000-10-20 15:18:43 +00:00
parent fd8c5a701a
commit f359db21e8
6 changed files with 141 additions and 108 deletions

View file

@ -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

View file

@ -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];

View file

@ -0,0 +1,13 @@
/*
* $FILENAME$ created by $USERNAME$ on $DATE$
*
* Project $PROJECTNAME$
*
* Created with ProjectCenter - http://www.projectcenter.ch
*
* $Id$
*/
@protocol $FILENAMESANSEXTENSION$ <NSObject>
@end

View file

@ -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;
}

View file

@ -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)];

View file

@ -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];