mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-21 19:01:18 +00:00
Added support for a NSView subclass template. Also added a description to
every file template. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12547 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a51615f9d
commit
f5b3597a80
5 changed files with 138 additions and 14 deletions
|
@ -40,7 +40,9 @@ cfile.template \
|
||||||
cheader.template \
|
cheader.template \
|
||||||
class.template \
|
class.template \
|
||||||
header.template \
|
header.template \
|
||||||
protocol.template
|
protocol.template \
|
||||||
|
nsviewclass.template \
|
||||||
|
nsviewheader.template
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,12 @@
|
||||||
#import "PCBaseFileType.h"
|
#import "PCBaseFileType.h"
|
||||||
#import <ProjectCenter/PCProject.h>
|
#import <ProjectCenter/PCProject.h>
|
||||||
|
|
||||||
#define ObjCClass @"ObjC Class"
|
#define ObjCNSViewClass @"Objective-C NSView Subclass"
|
||||||
#define ObjCHeader @"ObjC Header"
|
#define ObjCClass @"Objective-C Class"
|
||||||
|
#define ObjCHeader @"Objective-C Header"
|
||||||
#define CFile @"C File"
|
#define CFile @"C File"
|
||||||
#define CHeader @"C Header"
|
#define CHeader @"C Header"
|
||||||
#define ProtocolFile @"ObjC Protocol"
|
#define ProtocolFile @"Objective-C Protocol"
|
||||||
|
|
||||||
@implementation PCBaseFileType
|
@implementation PCBaseFileType
|
||||||
|
|
||||||
|
@ -42,34 +43,57 @@ static NSDictionary *dict = nil;
|
||||||
+ (id)sharedCreator
|
+ (id)sharedCreator
|
||||||
{
|
{
|
||||||
if (!_creator) {
|
if (!_creator) {
|
||||||
|
NSDictionary *nsviewClassDict;
|
||||||
NSDictionary *classDict;
|
NSDictionary *classDict;
|
||||||
NSDictionary *headerDict;
|
NSDictionary *headerDict;
|
||||||
NSDictionary *ccDict;
|
NSDictionary *ccDict;
|
||||||
NSDictionary *chDict;
|
NSDictionary *chDict;
|
||||||
NSDictionary *protocolDict;
|
NSDictionary *protocolDict;
|
||||||
|
NSString *descr;
|
||||||
|
|
||||||
_creator = [[[self class] alloc] init];
|
_creator = [[[self class] alloc] init];
|
||||||
|
|
||||||
// Setting up the dictionary needed for registration!
|
// Setting up the dictionary needed for registration!
|
||||||
|
descr = [NSString stringWithString:@"Special Objective-C class.\n\nThis is a subclass of NSView which includes AppKit.h."];
|
||||||
|
nsviewClassDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
_creator,@"Creator",
|
||||||
|
PCClasses,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
|
nil];
|
||||||
|
// Setting up the dictionary needed for registration!
|
||||||
|
descr = [NSString stringWithString:@"Generic Objective-C class.\n\nThis is a plain subclass of NSObject which includes only Foundation.h."];
|
||||||
classDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
classDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
_creator,@"Creator",
|
_creator,@"Creator",
|
||||||
PCClasses,@"ProjectKey",
|
PCClasses,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
|
descr = [NSString stringWithString:@"Generic Objective-C header.\n\nThis is a plain interface subclassing NSObject. The file includes Foundation.h"];
|
||||||
headerDict =[NSDictionary dictionaryWithObjectsAndKeys:
|
headerDict =[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
_creator,@"Creator",
|
_creator,@"Creator",
|
||||||
PCHeaders,@"ProjectKey",
|
PCHeaders,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
|
descr = [NSString stringWithString:@"Generic ANSI-C implementation file.\n\nThis file contains no Objective-C dependency in any form."];
|
||||||
ccDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
ccDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
_creator,@"Creator",
|
_creator,@"Creator",
|
||||||
PCOtherSources,@"ProjectKey",
|
PCOtherSources,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
|
descr = [NSString stringWithString:@"Generic ANSI-C header.\n\nThis file contains no Objective-C dependency in any form."];
|
||||||
chDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
chDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
_creator,@"Creator",
|
_creator,@"Creator",
|
||||||
PCHeaders,@"ProjectKey",
|
PCHeaders,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
|
descr = [NSString stringWithString:@"Generic Objective-C protocol.\n\nThis is common Objective-C protocol, comparable i.e. to a Java interface."];
|
||||||
protocolDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
protocolDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
_creator,@"Creator",
|
_creator,@"Creator",
|
||||||
PCHeaders,@"ProjectKey",
|
PCHeaders,@"ProjectKey",
|
||||||
|
descr,@"TypeDescription",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
@ -78,6 +102,7 @@ static NSDictionary *dict = nil;
|
||||||
protocolDict,ProtocolFile,
|
protocolDict,ProtocolFile,
|
||||||
headerDict,ObjCHeader,
|
headerDict,ObjCHeader,
|
||||||
classDict,ObjCClass,
|
classDict,ObjCClass,
|
||||||
|
nsviewClassDict,ObjCNSViewClass,
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
return _creator;
|
return _creator;
|
||||||
|
@ -109,7 +134,8 @@ static NSDictionary *dict = nil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ([type isEqualToString:ObjCClass]) {
|
if ([type isEqualToString:ObjCClass])
|
||||||
|
{
|
||||||
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"template"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"template"];
|
||||||
newFile = [path stringByAppendingPathExtension:@"m"];
|
newFile = [path stringByAppendingPathExtension:@"m"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
@ -119,7 +145,10 @@ static NSDictionary *dict = nil;
|
||||||
|
|
||||||
// Should a header be created as well?
|
// Should a header be created as well?
|
||||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||||
if (NSRunAlertPanel(@"Attention!",@"Should %@ be created and inserted in the project as well?",@"Yes",@"No",nil,[newFile lastPathComponent])) {
|
if (NSRunAlertPanel(@"Attention!",
|
||||||
|
@"Should %@ be created and inserted into the project?",
|
||||||
|
@"Yes",@"No",nil,[newFile lastPathComponent]))
|
||||||
|
{
|
||||||
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
|
||||||
|
@ -132,7 +161,35 @@ static NSDictionary *dict = nil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ([type isEqualToString:CFile]) {
|
else if ([type isEqualToString:ObjCNSViewClass])
|
||||||
|
{
|
||||||
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"nsviewclass" ofType:@"template"];
|
||||||
|
newFile = [path stringByAppendingPathExtension:@"m"];
|
||||||
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
[files setObject:ObjCNSViewClass 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 into the project?",
|
||||||
|
@"Yes",@"No",nil,[newFile lastPathComponent]))
|
||||||
|
{
|
||||||
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"nsviewheader" 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"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cfile" ofType:@"template"];
|
||||||
newFile = [path stringByAppendingPathExtension:@"c"];
|
newFile = [path stringByAppendingPathExtension:@"c"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
@ -155,7 +212,8 @@ static NSDictionary *dict = nil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ([type isEqualToString:ObjCHeader]) {
|
else if ([type isEqualToString:ObjCHeader])
|
||||||
|
{
|
||||||
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"];
|
||||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
@ -167,7 +225,8 @@ static NSDictionary *dict = nil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ([type isEqualToString:CHeader]) {
|
else if ([type isEqualToString:CHeader])
|
||||||
|
{
|
||||||
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"];
|
||||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
@ -179,7 +238,8 @@ static NSDictionary *dict = nil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ([type isEqualToString:ProtocolFile]) {
|
else if ([type isEqualToString:ProtocolFile])
|
||||||
|
{
|
||||||
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"protocol" ofType:@"template"];
|
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"protocol" ofType:@"template"];
|
||||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||||
[fm copyPath:_file toPath:newFile handler:nil];
|
[fm copyPath:_file toPath:newFile handler:nil];
|
||||||
|
@ -217,7 +277,8 @@ static NSDictionary *dict = nil;
|
||||||
[file replaceCharactersInRange:
|
[file replaceCharactersInRange:
|
||||||
[file rangeOfString:@"$DATE$"] withString:date];
|
[file rangeOfString:@"$DATE$"] withString:date];
|
||||||
|
|
||||||
if ([aType isEqualToString:ObjCHeader] || [aType isEqualToString:CHeader]) {
|
if ([aType isEqualToString:ObjCHeader] || [aType isEqualToString:CHeader])
|
||||||
|
{
|
||||||
NSString *nm = [[aFile stringByDeletingPathExtension] uppercaseString];
|
NSString *nm = [[aFile stringByDeletingPathExtension] uppercaseString];
|
||||||
|
|
||||||
[file replaceCharactersInRange:
|
[file replaceCharactersInRange:
|
||||||
|
@ -230,6 +291,7 @@ static NSDictionary *dict = nil;
|
||||||
|
|
||||||
if ([aType isEqualToString:ObjCClass] ||
|
if ([aType isEqualToString:ObjCClass] ||
|
||||||
[aType isEqualToString:CFile] ||
|
[aType isEqualToString:CFile] ||
|
||||||
|
[aType isEqualToString:ObjCNSViewClass] ||
|
||||||
[aType isEqualToString:ProtocolFile] ||
|
[aType isEqualToString:ProtocolFile] ||
|
||||||
[aType isEqualToString:ObjCHeader]) {
|
[aType isEqualToString:ObjCHeader]) {
|
||||||
NSString *name = [aFile stringByDeletingPathExtension];
|
NSString *name = [aFile stringByDeletingPathExtension];
|
||||||
|
@ -237,7 +299,9 @@ static NSDictionary *dict = nil;
|
||||||
[file replaceCharactersInRange:
|
[file replaceCharactersInRange:
|
||||||
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
||||||
|
|
||||||
if ([aType isEqualToString:ObjCClass]) {
|
if ([aType isEqualToString:ObjCClass] ||
|
||||||
|
[aType isEqualToString:ObjCNSViewClass])
|
||||||
|
{
|
||||||
[file replaceCharactersInRange:
|
[file replaceCharactersInRange:
|
||||||
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
cheader.template,
|
cheader.template,
|
||||||
class.template,
|
class.template,
|
||||||
header.template,
|
header.template,
|
||||||
protocol.template
|
protocol.template,
|
||||||
|
nsviewclass.template,
|
||||||
|
nsviewheader.template
|
||||||
);
|
);
|
||||||
OTHER_SOURCES = (
|
OTHER_SOURCES = (
|
||||||
);
|
);
|
||||||
|
|
28
PCBaseFileTypes/nsviewclass.template
Normal file
28
PCBaseFileTypes/nsviewclass.template
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||||
|
*
|
||||||
|
* Project $PROJECTNAME$
|
||||||
|
*
|
||||||
|
* Created with ProjectCenter - http://www.gnustep.org
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "$FILENAMESANSEXTENSION$.h"
|
||||||
|
|
||||||
|
@implementation $FILENAMESANSEXTENSION$
|
||||||
|
|
||||||
|
- (id)initWithFrame:(NSRect)aFrame
|
||||||
|
{
|
||||||
|
if((self = [super initWithFrame:aFrame]))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(NSRect)rect
|
||||||
|
{
|
||||||
|
// Drawing...
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
28
PCBaseFileTypes/nsviewheader.template
Normal file
28
PCBaseFileTypes/nsviewheader.template
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||||
|
*
|
||||||
|
* Project $PROJECTNAME$
|
||||||
|
*
|
||||||
|
* Created with ProjectCenter - http://www.gnustep.org
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _$UCFILENAMESANSEXTENSION$_H_
|
||||||
|
#define _$UCFILENAMESANSEXTENSION$_H_
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
@interface $FILENAMESANSEXTENSION$ : NSView
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithFrame:(NSRect)aFrame;
|
||||||
|
|
||||||
|
- (void)drawRect:(NSRect)rect;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // _$UCFILENAMESANSEXTENSION$_H_
|
||||||
|
|
Loading…
Reference in a new issue