mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-15 16:11:25 +00:00
* Framework/PCBundleManager.m,
* Headers/ProjectCenter/PCBundleManager.h: Make massive cleaup. some methods changed, some deleted, some added. * Framework/PCProjectManager.m, * Framework/PCProjectEditor.m: Make use of changed PCBundleManager. * TextFinder.m: (-enterSelection:): Add sanity check for text variable. (-jumpToSelection:): Ditto. * Modules/Parsers/ProjectCenter/Resources/Info.table: Fix value of "Name" key. * Headers/Protocols/CodeEditor.h: Remove declaration of openExternalEditor:withPath:projectEditor: method. It will be provided by Custom.editor bundle (will be added soon). * Headers/ProjectCenter/PCProjectEditor.h: Cleanup. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@25504 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e8e18614e8
commit
26dc666444
9 changed files with 300 additions and 175 deletions
|
@ -1,5 +1,22 @@
|
||||||
2007-09-24 Sergii Stoian <stoyan255@gmail.com>
|
2007-09-24 Sergii Stoian <stoyan255@gmail.com>
|
||||||
|
|
||||||
|
* Framework/PCBundleManager.m,
|
||||||
|
* Headers/ProjectCenter/PCBundleManager.h: Make massive cleaup.
|
||||||
|
some methods changed, some deleted, some added.
|
||||||
|
* Framework/PCProjectManager.m,
|
||||||
|
* Framework/PCProjectEditor.m: Make use of changed PCBundleManager.
|
||||||
|
* TextFinder.m:
|
||||||
|
(-enterSelection:): Add sanity check for text variable.
|
||||||
|
(-jumpToSelection:): Ditto.
|
||||||
|
* Modules/Parsers/ProjectCenter/Resources/Info.table: Fix value of
|
||||||
|
"Name" key.
|
||||||
|
* Headers/Protocols/CodeEditor.h: Remove declaration of
|
||||||
|
openExternalEditor:withPath:projectEditor: method. It will be provided
|
||||||
|
by Custom.editor bundle (will be added soon).
|
||||||
|
* Headers/ProjectCenter/PCProjectEditor.h: Cleanup.
|
||||||
|
|
||||||
|
2007-09-24 Sergii Stoian <stoyan255@gmail.com>
|
||||||
|
|
||||||
* English.lproj/FindPanel.gorm: Added Find panel.
|
* English.lproj/FindPanel.gorm: Added Find panel.
|
||||||
* PCMenuController.m: Added Find panel support.
|
* PCMenuController.m: Added Find panel support.
|
||||||
* TextFinder.[hm]: Added implementation of Find panel.
|
* TextFinder.[hm]: Added implementation of Find panel.
|
||||||
|
|
|
@ -23,6 +23,14 @@
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Finish support for third party bundles.
|
||||||
|
// It involves support for user defined bundle directories
|
||||||
|
// through preferences. Now supported are:
|
||||||
|
// - PC application resource dir
|
||||||
|
// (GNUSTEP_SYSTEM_APPS/ProjectCenter.app/Resources)
|
||||||
|
// - GNUSTEP_SYSTEM_LIBRARY/Bundles/ProjectCenter
|
||||||
|
// (NSApplicationSupportDirectory)
|
||||||
|
|
||||||
#include <ProjectCenter/PCBundleManager.h>
|
#include <ProjectCenter/PCBundleManager.h>
|
||||||
#include <ProjectCenter/PCDefines.h>
|
#include <ProjectCenter/PCDefines.h>
|
||||||
|
|
||||||
|
@ -68,11 +76,13 @@
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// --- Handling of bundles' Info.table dictionaries without actual
|
||||||
|
// --- bundles loading
|
||||||
|
|
||||||
// bundlesInfo is a dictionary. key/value pair is the following:
|
// bundlesInfo is a dictionary. key/value pair is the following:
|
||||||
|
// (NSString *) (NSDictionary *)
|
||||||
// "full path of a bundle" = "Info.table contents"
|
// "full path of a bundle" = "Info.table contents"
|
||||||
// propertyValueOfClass:withKey:
|
- (NSDictionary *)infoForBundlesType:(NSString *)extension
|
||||||
- (NSDictionary *)infoForBundlesOfType:(NSString *)extension
|
|
||||||
{
|
{
|
||||||
NSArray *bundles;
|
NSArray *bundles;
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
|
@ -90,6 +100,8 @@
|
||||||
{
|
{
|
||||||
infoTablePath = [NSString
|
infoTablePath = [NSString
|
||||||
stringWithFormat:@"%@/Resources/Info.table", bundlePath];
|
stringWithFormat:@"%@/Resources/Info.table", bundlePath];
|
||||||
|
// TODO: fill 'reqBundlesInfo' with element from 'bundlesInfo' if
|
||||||
|
// exists
|
||||||
infoTable = [NSDictionary dictionaryWithContentsOfFile:infoTablePath];
|
infoTable = [NSDictionary dictionaryWithContentsOfFile:infoTablePath];
|
||||||
[reqBundlesInfo setObject:infoTable forKey:bundlePath];
|
[reqBundlesInfo setObject:infoTable forKey:bundlePath];
|
||||||
[bundlesInfo setObject:infoTable forKey:bundlePath];
|
[bundlesInfo setObject:infoTable forKey:bundlePath];
|
||||||
|
@ -98,6 +110,95 @@
|
||||||
return reqBundlesInfo;
|
return reqBundlesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Key value can be checked against NSString and NSArray values only.
|
||||||
|
- (NSDictionary *)infoForBundleType:(NSString *)extension
|
||||||
|
keyName:(NSString *)key
|
||||||
|
keyContains:(NSString *)value
|
||||||
|
{
|
||||||
|
NSDictionary *reqBundlesInfo;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *bundlePath;
|
||||||
|
id keyValue;
|
||||||
|
NSDictionary *infoTable;
|
||||||
|
|
||||||
|
if (extension == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
reqBundlesInfo = [self infoForBundlesType:extension];
|
||||||
|
enumerator = [[reqBundlesInfo allKeys] objectEnumerator];
|
||||||
|
|
||||||
|
while ((bundlePath = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
infoTable = [reqBundlesInfo objectForKey:bundlePath];
|
||||||
|
|
||||||
|
if (key == nil || value == nil)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
keyValue = [infoTable objectForKey:key];
|
||||||
|
|
||||||
|
if ([keyValue isKindOfClass:[NSString class]] &&
|
||||||
|
[keyValue isEqualToString:value])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if ([keyValue isKindOfClass:[NSArray class]] &&
|
||||||
|
[keyValue containsObject:value])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoTable = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return infoTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)infoForBundleName:(NSString *)name
|
||||||
|
type:(NSString *)type
|
||||||
|
{
|
||||||
|
NSDictionary *reqBundlesInfo = [self infoForBundlesType:type];
|
||||||
|
NSEnumerator *enumerator = [[reqBundlesInfo allKeys] objectEnumerator];
|
||||||
|
NSString *bundlePath;
|
||||||
|
NSDictionary *infoTable;
|
||||||
|
|
||||||
|
while ((bundlePath = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
infoTable = [reqBundlesInfo objectForKey:bundlePath];
|
||||||
|
if ([[infoTable objectForKey:@"Name"] isEqualToString:name])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoTable = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return infoTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)classNameForBundleType:(NSString*)type
|
||||||
|
fileName:(NSString *)fileName
|
||||||
|
{
|
||||||
|
NSString *fileExtension = [fileName pathExtension];
|
||||||
|
NSDictionary *infoTable = nil;
|
||||||
|
NSString *className = nil;
|
||||||
|
|
||||||
|
infoTable = [self infoForBundleType:type
|
||||||
|
keyName:@"FileTypes"
|
||||||
|
keyContains:fileExtension];
|
||||||
|
|
||||||
|
className = [infoTable objectForKey:@"PrincipalClassName"];
|
||||||
|
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *)bundlePathWithName:(NSString *)bundleName
|
- (NSString *)bundlePathWithName:(NSString *)bundleName
|
||||||
{
|
{
|
||||||
NSArray *bundlePaths = nil;
|
NSArray *bundlePaths = nil;
|
||||||
|
@ -108,6 +209,9 @@
|
||||||
bundlePaths = [bundlesInfo allKeys];
|
bundlePaths = [bundlesInfo allKeys];
|
||||||
enumerator = [bundlePaths objectEnumerator];
|
enumerator = [bundlePaths objectEnumerator];
|
||||||
|
|
||||||
|
NSLog(@"Bundle fullpath method #1: %@",
|
||||||
|
[[self resourcePath] stringByAppendingPathComponent:bundleName]);
|
||||||
|
|
||||||
while ((bundleFullPath = [enumerator nextObject]))
|
while ((bundleFullPath = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
if ([[bundleFullPath lastPathComponent] isEqualToString:bundleName])
|
if ([[bundleFullPath lastPathComponent] isEqualToString:bundleName])
|
||||||
|
@ -116,14 +220,73 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Bundle fullpath method #2: %@", bundleFullPath);
|
||||||
|
|
||||||
return bundleFullPath;
|
return bundleFullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSBundle *)bundleOfType:(NSString *)type forClassName:(NSString *)className
|
// --- Invokes loading of bundle
|
||||||
|
|
||||||
|
- (id)objectForClassName:(NSString *)className
|
||||||
|
bundleType:(NSString *)bundleExtension
|
||||||
|
protocol:(Protocol *)proto
|
||||||
|
{
|
||||||
|
Class objectClass;
|
||||||
|
|
||||||
|
if ([self bundleOfType:bundleExtension withClassName:className] == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"Bundle for class %@ NOT FOUND!", className);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
objectClass = NSClassFromString(className);
|
||||||
|
|
||||||
|
if (proto != nil && ![objectClass conformsToProtocol:proto])
|
||||||
|
{
|
||||||
|
[NSException raise:NOT_A_PROJECT_TYPE_EXCEPTION
|
||||||
|
format:@"%@ does not conform to protocol!", className];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[objectClass alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)objectForBundleWithName:(NSString *)name
|
||||||
|
type:(NSString *)extension
|
||||||
|
protocol:(Protocol *)proto
|
||||||
|
{
|
||||||
|
NSDictionary *infoTable;
|
||||||
|
NSString *className;
|
||||||
|
|
||||||
|
infoTable = [self infoForBundleName:name type:extension];
|
||||||
|
className = [infoTable objectForKey:@"PrincipalClassName"];
|
||||||
|
|
||||||
|
return [self objectForClassName:className
|
||||||
|
bundleType:extension
|
||||||
|
protocol:proto];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)objectForBundleType:(NSString *)extension
|
||||||
|
protocol:(Protocol *)proto
|
||||||
|
fileName:(NSString *)fileName
|
||||||
|
{
|
||||||
|
NSString *className;
|
||||||
|
|
||||||
|
className = [self classNameForBundleType:extension fileName:fileName];
|
||||||
|
|
||||||
|
return [self objectForClassName:className
|
||||||
|
bundleType:extension
|
||||||
|
protocol:proto];
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Bundle loading
|
||||||
|
|
||||||
|
- (NSBundle *)bundleOfType:(NSString *)type
|
||||||
|
withClassName:(NSString *)className
|
||||||
{
|
{
|
||||||
NSArray *bundlePaths = nil;
|
NSArray *bundlePaths = nil;
|
||||||
NSDictionary *infoTable = nil;
|
|
||||||
NSString *bundleFullPath = nil;
|
NSString *bundleFullPath = nil;
|
||||||
|
NSDictionary *infoTable = nil;
|
||||||
NSEnumerator *enumerator = nil;
|
NSEnumerator *enumerator = nil;
|
||||||
NSString *bundleName = nil;
|
NSString *bundleName = nil;
|
||||||
NSString *principalClass;
|
NSString *principalClass;
|
||||||
|
@ -158,35 +321,9 @@
|
||||||
return [loadedBundles objectForKey:bundleFullPath];
|
return [loadedBundles objectForKey:bundleFullPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)objectForClassName:(NSString *)className
|
|
||||||
withProtocol:(Protocol *)proto
|
|
||||||
inBundleType:(NSString *)type
|
|
||||||
{
|
|
||||||
Class objectClass;
|
|
||||||
|
|
||||||
if ([self bundleOfType:type forClassName:className] == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"Bundle for class %@ NOT FOUND!", className);
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
objectClass = NSClassFromString(className);
|
|
||||||
|
|
||||||
if (proto != nil && ![objectClass conformsToProtocol:proto])
|
|
||||||
{
|
|
||||||
[NSException raise:NOT_A_PROJECT_TYPE_EXCEPTION
|
|
||||||
format:@"%@ does not conform to protocol!", className];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [[objectClass alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)loadBundleIfNeededWithName:(NSString *)bundleName
|
- (BOOL)loadBundleIfNeededWithName:(NSString *)bundleName
|
||||||
{
|
{
|
||||||
NSString *bundleFullPath;
|
NSString *bundleFullPath = [self bundlePathWithName:bundleName];
|
||||||
|
|
||||||
bundleFullPath = [self bundlePathWithName:bundleName];
|
|
||||||
|
|
||||||
// Check if bundle allready loaded
|
// Check if bundle allready loaded
|
||||||
if ([[loadedBundles allKeys] containsObject:bundleFullPath] == NO)
|
if ([[loadedBundles allKeys] containsObject:bundleFullPath] == NO)
|
||||||
|
@ -197,7 +334,6 @@
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---
|
|
||||||
- (void)loadBundlesWithExtension:(NSString *)extension
|
- (void)loadBundlesWithExtension:(NSString *)extension
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
|
@ -216,10 +352,9 @@
|
||||||
objectEnumerator];
|
objectEnumerator];
|
||||||
while ((path = [enumerator nextObject]) != nil)
|
while ((path = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
path = [path stringByAppendingPathComponent: @"ProjectCenter"];
|
path = [path stringByAppendingPathComponent:@"ProjectCenter"];
|
||||||
|
|
||||||
if ([fileManager fileExistsAtPath: path isDirectory: &isDir]
|
if ([fileManager fileExistsAtPath:path isDirectory:&isDir] && isDir)
|
||||||
&& isDir)
|
|
||||||
{
|
{
|
||||||
PCLogInfo(self, @"Loading bundles at %@", path);
|
PCLogInfo(self, @"Loading bundles at %@", path);
|
||||||
[self loadBundlesAtPath:path withExtension:extension];
|
[self loadBundlesAtPath:path withExtension:extension];
|
||||||
|
|
|
@ -115,7 +115,6 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
|
|
||||||
- (id)initWithProject:(PCProject *)aProject
|
- (id)initWithProject:(PCProject *)aProject
|
||||||
{
|
{
|
||||||
PCBundleManager *bundleManager;
|
|
||||||
NSAssert(aProject, @"No project specified!");
|
NSAssert(aProject, @"No project specified!");
|
||||||
|
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
|
@ -125,15 +124,6 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
componentView = nil;
|
componentView = nil;
|
||||||
editorsDict = [[NSMutableDictionary alloc] init];
|
editorsDict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
// Bundles
|
|
||||||
bundleManager = [[project projectManager] bundleManager];
|
|
||||||
|
|
||||||
// Editor bundles
|
|
||||||
editorBundlesInfo = [[bundleManager infoForBundlesOfType:@"editor"] copy];
|
|
||||||
|
|
||||||
// Parser bundles
|
|
||||||
parserBundlesInfo = [[bundleManager infoForBundlesOfType:@"parser"] copy];
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver:self
|
addObserver:self
|
||||||
selector:@selector(editorDidOpen:)
|
selector:@selector(editorDidOpen:)
|
||||||
|
@ -182,8 +172,6 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
RELEASE(componentView);
|
RELEASE(componentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
RELEASE(editorBundlesInfo);
|
|
||||||
RELEASE(parserBundlesInfo);
|
|
||||||
RELEASE(editorsDict);
|
RELEASE(editorsDict);
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -208,63 +196,12 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
// ==== Project and Editor handling
|
// ==== Project and Editor handling
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
- (NSDictionary *)infoTableForBundleType:(NSString *)type
|
|
||||||
andFileType:(NSString *)extension
|
|
||||||
{
|
|
||||||
NSDictionary *bundlesInfo = nil;
|
|
||||||
NSEnumerator *enumerator = nil;
|
|
||||||
NSString *bundlePathKey = nil;
|
|
||||||
NSDictionary *infoTable = nil;
|
|
||||||
|
|
||||||
if ([type isEqualToString:@"editor"])
|
|
||||||
{
|
|
||||||
bundlesInfo = editorBundlesInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bundlesInfo = parserBundlesInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
enumerator = [[bundlesInfo allKeys] objectEnumerator];
|
|
||||||
while ((bundlePathKey = [enumerator nextObject]))
|
|
||||||
{
|
|
||||||
infoTable = [bundlesInfo objectForKey:bundlePathKey];
|
|
||||||
if ([[infoTable objectForKey:@"FileTypes"] containsObject:extension])
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
infoTable = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return infoTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)classNameForBundleType:(NSString*)type
|
|
||||||
andFile:(NSString *)file
|
|
||||||
{
|
|
||||||
NSString *fileExtension = [file pathExtension];
|
|
||||||
NSDictionary *infoTable = nil;
|
|
||||||
NSString *className = nil;
|
|
||||||
|
|
||||||
infoTable = [self infoTableForBundleType:type andFileType:fileExtension];
|
|
||||||
className = [infoTable objectForKey:@"PrincipalClassName"];
|
|
||||||
|
|
||||||
if (className == nil && [type isEqualToString:@"editor"])
|
|
||||||
{
|
|
||||||
className = [NSString stringWithString:@"PCEditor"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Should it be editor or parser?
|
// TODO: Should it be editor or parser?
|
||||||
- (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item
|
- (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item
|
||||||
{
|
{
|
||||||
NSString *file = [[project projectBrowser] nameOfSelectedFile];
|
NSString *file = [[project projectBrowser] nameOfSelectedFile];
|
||||||
NSDictionary *infoTable = nil;
|
PCBundleManager *bundleManager = [[project projectManager] bundleManager];
|
||||||
|
NSDictionary *infoTable = nil;
|
||||||
|
|
||||||
// File selected and editor should already be loaded
|
// File selected and editor should already be loaded
|
||||||
if (file != nil)
|
if (file != nil)
|
||||||
|
@ -276,8 +213,9 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category selected
|
// Category selected
|
||||||
infoTable = [self infoTableForBundleType:@"editor"
|
infoTable = [bundleManager infoForBundleType:@"editor"
|
||||||
andFileType:[item pathExtension]];
|
keyName:@"FileTypes"
|
||||||
|
keyContains:[item pathExtension]];
|
||||||
|
|
||||||
if ([[infoTable objectForKey:@"ProvidesBrowserItems"] isEqualToString:@"YES"])
|
if ([[infoTable objectForKey:@"ProvidesBrowserItems"] isEqualToString:@"YES"])
|
||||||
{
|
{
|
||||||
|
@ -381,48 +319,35 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
editable:(BOOL)editable
|
editable:(BOOL)editable
|
||||||
windowed:(BOOL)windowed
|
windowed:(BOOL)windowed
|
||||||
{
|
{
|
||||||
// NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
||||||
// NSString *ed = [ud objectForKey:Editor];
|
|
||||||
PCBundleManager *bundleManager = [[project projectManager] bundleManager];
|
PCBundleManager *bundleManager = [[project projectManager] bundleManager];
|
||||||
NSString *editorClassName = nil;
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
NSString *parserClassName = nil;
|
NSString *ed = [ud objectForKey:Editor];
|
||||||
|
NSString *fileName = [path lastPathComponent];
|
||||||
id<CodeEditor> editor;
|
id<CodeEditor> editor;
|
||||||
id<CodeParser> parser;
|
id<CodeParser> parser;
|
||||||
|
|
||||||
NSLog(@"PCPE: categoryPath: \"%@\"", categoryPath);
|
NSLog(@"PCPE: categoryPath: \"%@\"", categoryPath);
|
||||||
|
|
||||||
// TODO: Include external editor code into editor bundle?
|
|
||||||
/* if (![ed isEqualToString:@"ProjectCenter"])
|
|
||||||
{
|
|
||||||
[editor initExternalEditor:ed withPath:path projectEditor:self];
|
|
||||||
return editor;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (!(editor = [editorsDict objectForKey:path]))
|
if (!(editor = [editorsDict objectForKey:path]))
|
||||||
{
|
{
|
||||||
// Editor
|
// Editor
|
||||||
editorClassName = [self classNameForBundleType:@"editor"
|
editor = [bundleManager objectForBundleWithName:ed
|
||||||
andFile:[path lastPathComponent]];
|
type:@"editor"
|
||||||
editor = [bundleManager objectForClassName:editorClassName
|
protocol:@protocol(CodeEditor)];
|
||||||
withProtocol:@protocol(CodeEditor)
|
if (editor == nil)
|
||||||
inBundleType:@"editor"];
|
|
||||||
if (!editor)
|
|
||||||
{
|
{
|
||||||
|
editor = [bundleManager
|
||||||
|
objectForBundleWithName:@"ProjectCenter"
|
||||||
|
type:@"editor"
|
||||||
|
protocol:@protocol(CodeEditor)];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parser
|
// Parser
|
||||||
parserClassName = [self classNameForBundleType:@"parser"
|
parser = [bundleManager objectForBundleType:@"parser"
|
||||||
andFile:[path lastPathComponent]];
|
protocol:@protocol(CodeParser)
|
||||||
if (parserClassName != nil)
|
fileName:fileName];
|
||||||
{
|
[editor setParser:parser];
|
||||||
NSLog(@"PCPE: parser: %@", parserClassName);
|
|
||||||
parser = [bundleManager objectForClassName:parserClassName
|
|
||||||
withProtocol:@protocol(CodeParser)
|
|
||||||
inBundleType:@"parser"];
|
|
||||||
[editor setParser:parser];
|
|
||||||
RELEASE(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
[editor openFileAtPath:path
|
[editor openFileAtPath:path
|
||||||
categoryPath:categoryPath
|
categoryPath:categoryPath
|
||||||
|
|
|
@ -178,7 +178,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
if (projectTypes == nil)
|
if (projectTypes == nil)
|
||||||
{
|
{
|
||||||
projectTypes = [[NSMutableDictionary alloc] init];
|
projectTypes = [[NSMutableDictionary alloc] init];
|
||||||
bundlesInfo = [bundleManager infoForBundlesOfType:@"project"];
|
bundlesInfo = [bundleManager infoForBundlesType:@"project"];
|
||||||
|
|
||||||
bundlePaths = [bundlesInfo allKeys];
|
bundlePaths = [bundlesInfo allKeys];
|
||||||
enumerator = [bundlePaths objectEnumerator];
|
enumerator = [bundlePaths objectEnumerator];
|
||||||
|
@ -521,8 +521,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
stringByAppendingPathComponent:@"PC.project"];
|
stringByAppendingPathComponent:@"PC.project"];
|
||||||
|
|
||||||
project = [bundleManager objectForClassName:projectClassName
|
project = [bundleManager objectForClassName:projectClassName
|
||||||
withProtocol:@protocol(ProjectType)
|
bundleType:@"project"
|
||||||
inBundleType:@"project"];
|
protocol:@protocol(ProjectType)];
|
||||||
|
|
||||||
projectTypeName = [project projectTypeName];
|
projectTypeName = [project projectTypeName];
|
||||||
[pDict setObject:projectTypeName forKey:PCProjectType];
|
[pDict setObject:projectTypeName forKey:PCProjectType];
|
||||||
|
@ -565,8 +565,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
project = [bundleManager objectForClassName:projectClassName
|
project = [bundleManager objectForClassName:projectClassName
|
||||||
withProtocol:@protocol(ProjectType)
|
bundleType:@"project"
|
||||||
inBundleType:@"project"];
|
protocol:@protocol(ProjectType)];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![project openWithDictionaryAt:aPath])
|
if (![project openWithDictionaryAt:aPath])
|
||||||
|
@ -652,8 +652,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}
|
}
|
||||||
|
|
||||||
projectCreator = [bundleManager objectForClassName:className
|
projectCreator = [bundleManager objectForClassName:className
|
||||||
withProtocol:@protocol(ProjectType)
|
bundleType:@"project"
|
||||||
inBundleType:@"project"];
|
protocol:@protocol(ProjectType)];
|
||||||
// NSLog(@"%@ CLASS: %@", className, projectCreator);
|
// NSLog(@"%@ CLASS: %@", className, projectCreator);
|
||||||
if (!projectCreator)
|
if (!projectCreator)
|
||||||
{
|
{
|
||||||
|
@ -1076,21 +1076,19 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (void)openFileWithEditor:(NSString *)path
|
- (void)openFileWithEditor:(NSString *)path
|
||||||
{
|
{
|
||||||
/* id<CodeEditor> editor;
|
// id<CodeEditor> editor;
|
||||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
/* NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
NSString *editor = [ud objectForKey:Editor];
|
NSString *editor = [ud objectForKey:Editor];
|
||||||
|
|
||||||
editor = [PCProjectEditor openFileInEditor:path];
|
|
||||||
|
|
||||||
if (![editor isEqualToString:@"ProjectCenter"])
|
if (![editor isEqualToString:@"ProjectCenter"])
|
||||||
{
|
{
|
||||||
NSArray *ea = [editor componentsSeparatedByString:@" "];
|
NSArray *ea = [editor componentsSeparatedByString:@" "];
|
||||||
NSString *app = [ea objectAtIndex: 0];
|
NSString *app = [ea objectAtIndex:0];
|
||||||
|
|
||||||
if ([[app pathExtension] isEqualToString:@"app"])
|
if ([[app pathExtension] isEqualToString:@"app"])
|
||||||
{
|
{
|
||||||
BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path
|
BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path
|
||||||
withApplication:app];
|
withApplication:app];
|
||||||
|
|
||||||
if (ret == NO)
|
if (ret == NO)
|
||||||
{
|
{
|
||||||
|
@ -1101,24 +1099,22 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}
|
}
|
||||||
|
|
||||||
editor = [[editorClass alloc] initExternalEditor:editor
|
editor = [[editorClass alloc] initExternalEditor:editor
|
||||||
withPath:path
|
withPath:path
|
||||||
projectEditor:self];
|
projectEditor:self];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
id<CodeEditor> editor;
|
id<CodeEditor> editor;
|
||||||
|
|
||||||
editor = [[editorClass alloc] initWithPath:path
|
editor = [[editorClass alloc] initWithPath:path
|
||||||
categoryPath:nil
|
categoryPath:nil
|
||||||
projectEditor:self];
|
projectEditor:self];
|
||||||
[editor setWindowed:YES];
|
[editor setWindowed:YES];
|
||||||
[editor show];
|
[editor show];
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
|
||||||
|
|
||||||
[nonProjectEditors setObject:editor forKey:path];
|
[nonProjectEditors setObject:editor forKey:path];
|
||||||
|
|
||||||
[editor release];*/
|
[editor release];*/
|
||||||
|
@ -1251,8 +1247,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
projectCreator = [bundleManager objectForClassName:className
|
projectCreator = [bundleManager objectForClassName:className
|
||||||
withProtocol:@protocol(ProjectType)
|
bundleType:@"project"
|
||||||
inBundleType:@"project"];
|
protocol:@protocol(ProjectType)];
|
||||||
if (!(subproject = [projectCreator createProjectAt:aPath]))
|
if (!(subproject = [projectCreator createProjectAt:aPath]))
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -43,14 +43,44 @@
|
||||||
|
|
||||||
- (NSString *)resourcePath;
|
- (NSString *)resourcePath;
|
||||||
|
|
||||||
- (NSDictionary *)infoForBundlesOfType:(NSString *)extension;
|
// --- Handling of bundles' Info.table dictionaries without actual
|
||||||
- (NSString *)bundlePathWithName:(NSString *)bundleName;
|
// --- bundles loading
|
||||||
- (NSBundle *)bundleOfType:(NSString *)type forClassName:(NSString *)className;
|
|
||||||
- (id)objectForClassName:(NSString *)className
|
|
||||||
withProtocol:(Protocol *)proto
|
|
||||||
inBundleType:(NSString *)type;
|
|
||||||
- (BOOL)loadBundleIfNeededWithName:(NSString *)bundleName;
|
|
||||||
|
|
||||||
|
- (NSDictionary *)infoForBundlesType:(NSString *)extension;
|
||||||
|
|
||||||
|
// Key value can be checked against NSString and NSArray values only.
|
||||||
|
- (NSDictionary *)infoForBundleType:(NSString *)extension
|
||||||
|
keyName:(NSString *)key
|
||||||
|
keyContains:(NSString *)value;
|
||||||
|
|
||||||
|
- (NSDictionary *)infoForBundleName:(NSString *)name
|
||||||
|
type:(NSString *)type;
|
||||||
|
|
||||||
|
- (NSString *)classNameForBundleType:(NSString*)type
|
||||||
|
fileName:(NSString *)fileName;
|
||||||
|
|
||||||
|
- (NSString *)bundlePathWithName:(NSString *)bundleName;
|
||||||
|
|
||||||
|
// --- Invokes loading of bundle
|
||||||
|
|
||||||
|
- (id)objectForClassName:(NSString *)className
|
||||||
|
bundleType:(NSString *)bundleExtension
|
||||||
|
protocol:(Protocol *)proto;
|
||||||
|
|
||||||
|
- (id)objectForBundleWithName:(NSString *)name
|
||||||
|
type:(NSString *)extension
|
||||||
|
protocol:(Protocol *)proto;
|
||||||
|
|
||||||
|
- (id)objectForBundleType:(NSString *)extension
|
||||||
|
protocol:(Protocol *)proto
|
||||||
|
fileName:(NSString *)fileName;
|
||||||
|
|
||||||
|
- (NSBundle *)bundleOfType:(NSString *)type
|
||||||
|
withClassName:(NSString *)className;
|
||||||
|
|
||||||
|
// --- Bundle loading
|
||||||
|
|
||||||
|
- (BOOL)loadBundleIfNeededWithName:(NSString *)bundleName;
|
||||||
// Load all bundles found in the BundlePaths
|
// Load all bundles found in the BundlePaths
|
||||||
- (void)loadBundlesWithExtension:(NSString *)extension;
|
- (void)loadBundlesWithExtension:(NSString *)extension;
|
||||||
- (void)loadBundlesAtPath:(NSString *)path withExtension:(NSString *)extension;
|
- (void)loadBundlesAtPath:(NSString *)path withExtension:(NSString *)extension;
|
||||||
|
|
|
@ -67,12 +67,6 @@
|
||||||
// ==== Project and Editor handling
|
// ==== Project and Editor handling
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
- (NSDictionary *)infoTableForBundleType:(NSString *)type
|
|
||||||
andFileType:(NSString *)extension;
|
|
||||||
|
|
||||||
- (NSString *)classNameForBundleType:(NSString*)type
|
|
||||||
andFile:(NSString *)file;
|
|
||||||
|
|
||||||
- (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item;
|
- (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item;
|
||||||
|
|
||||||
// Returns nil if editor is not opened
|
// Returns nil if editor is not opened
|
||||||
|
|
|
@ -40,10 +40,6 @@
|
||||||
projectEditor:(id)aProjectEditor
|
projectEditor:(id)aProjectEditor
|
||||||
editable:(BOOL)editable;
|
editable:(BOOL)editable;
|
||||||
|
|
||||||
- (id)openExternalEditor:(NSString *)editor
|
|
||||||
withPath:(NSString *)file
|
|
||||||
projectEditor:(id)aProjectEditor;
|
|
||||||
|
|
||||||
- (void)show;
|
- (void)show;
|
||||||
- (void)setWindowed:(BOOL)yn;
|
- (void)setWindowed:(BOOL)yn;
|
||||||
- (BOOL)isWindowed;
|
- (BOOL)isWindowed;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
Type = "Parser";
|
Type = "Parser";
|
||||||
Name = "CodeEditor ObjectiveC parser";
|
Name = "ProjectCenter";
|
||||||
Description = "Parser for C and ObjectiveC language";
|
Description = "Parser for C and ObjectiveC language";
|
||||||
PrincipalClassName = "PCParser";
|
PrincipalClassName = "PCParser";
|
||||||
FileTypes = (C,c,m,M,h,H,cc,CC);
|
FileTypes = (C,c,m,M,h,H,cc,CC);
|
||||||
|
|
40
TextFinder.m
40
TextFinder.m
|
@ -280,18 +280,22 @@ static id sharedFindObject = nil;
|
||||||
- (void)enterSelection:(id)sender
|
- (void)enterSelection:(id)sender
|
||||||
{
|
{
|
||||||
NSTextView *text = [self textObjectToSearchIn];
|
NSTextView *text = [self textObjectToSearchIn];
|
||||||
NSRange range = [text selectedRange];
|
|
||||||
NSString *string = [text string];
|
NSString *string = [text string];
|
||||||
|
|
||||||
[self setFindString:[string substringWithRange:range]];
|
if (text && string)
|
||||||
|
{
|
||||||
|
[self setFindString:[string substringWithRange:[text selectedRange]]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)jumpToSelection:(id)sender
|
- (void)jumpToSelection:(id)sender
|
||||||
{
|
{
|
||||||
NSTextView *text = [self textObjectToSearchIn];
|
NSTextView *text = [self textObjectToSearchIn];
|
||||||
NSRange range = [text selectedRange];
|
|
||||||
|
|
||||||
[text scrollRangeToVisible:range];
|
if (text)
|
||||||
|
{
|
||||||
|
[text scrollRangeToVisible:[text selectedRange]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)replace:(id)sender
|
- (void)replace:(id)sender
|
||||||
|
@ -386,6 +390,34 @@ static id sharedFindObject = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateMenuItem:(NSMenuItem *)anItem
|
||||||
|
{
|
||||||
|
|
||||||
|
if ([anItem action] == @selector(orderFrontFindPanel:))
|
||||||
|
{
|
||||||
|
return ([self textObjectToSearchIn] != NULL);
|
||||||
|
}
|
||||||
|
if ([anItem action] == @selector(findNext:))
|
||||||
|
{
|
||||||
|
return ([self textObjectToSearchIn] != NULL);
|
||||||
|
}
|
||||||
|
if ([anItem action] == @selector(findPrevious:))
|
||||||
|
{
|
||||||
|
return ([self textObjectToSearchIn] != NULL);
|
||||||
|
}
|
||||||
|
if ([anItem action] == @selector(enterSelection:))
|
||||||
|
{
|
||||||
|
return ([self textObjectToSearchIn] != NULL);
|
||||||
|
}
|
||||||
|
if ([anItem action] == @selector(jumpToSelection:))
|
||||||
|
{
|
||||||
|
return ([self textObjectToSearchIn] != NULL);
|
||||||
|
}
|
||||||
|
// if it isn't one of our menu items, we'll let the
|
||||||
|
// superclass take care of it
|
||||||
|
return [super validateMenuItem:anItem];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue