mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-19 10:00:48 +00:00
* Framework/PCProjectManager.[mh]: Cleaning up code that manages
non-project editors. Use PCEditorManager instead. Remove PCFileManager's dalegate code(FileManagerDelegates category). (-newFile): Call PCFileCreator's method newFileInProject:. * Framework/PCFileManager.[mh]: Move code related to creation of new file in project from here * Framework/PCFileCreator.[mh]: to here. (-createFile): Add additional check before adding file to project (fixes bug #17493). * Framework/English.lproj/NewFile.gorm: Set owner to PCFileCreator. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@26024 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4e24cf3451
commit
87bc0ef57b
11 changed files with 220 additions and 276 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2008-02-05 Sergii Stoian <stoyan255@gmail.com>
|
||||||
|
|
||||||
|
* Framework/PCProjectManager.[mh]: Cleaning up code that manages
|
||||||
|
non-project editors. Use PCEditorManager instead. Remove
|
||||||
|
PCFileManager's dalegate code(FileManagerDelegates category).
|
||||||
|
(-newFile): Call PCFileCreator's method newFileInProject:.
|
||||||
|
* Framework/PCFileManager.[mh]: Move code related to creation of
|
||||||
|
new file in project from here
|
||||||
|
* Framework/PCFileCreator.[mh]: to here.
|
||||||
|
(-createFile): Add additional check before adding file to
|
||||||
|
project (fixes bug #17493).
|
||||||
|
* Framework/English.lproj/NewFile.gorm: Set owner to PCFileCreator.
|
||||||
|
|
||||||
2008-01-22 Sergii Stoian <stoyan255@gmail.com>
|
2008-01-22 Sergii Stoian <stoyan255@gmail.com>
|
||||||
|
|
||||||
* Framework/PCEditorManager.m: Added.
|
* Framework/PCEditorManager.m: Added.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
);
|
);
|
||||||
Super = NSObject;
|
Super = NSObject;
|
||||||
};
|
};
|
||||||
PCFileManager = {
|
PCFileCreator = {
|
||||||
Actions = (
|
Actions = (
|
||||||
"closeNewFilePanel:",
|
"closeNewFilePanel:",
|
||||||
"createFile:",
|
"createFile:",
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -30,12 +30,11 @@
|
||||||
|
|
||||||
#include <ProjectCenter/PCLogController.h>
|
#include <ProjectCenter/PCLogController.h>
|
||||||
|
|
||||||
@implementation PCFileCreator
|
|
||||||
|
|
||||||
static PCFileCreator *_creator = nil;
|
static PCFileCreator *_creator = nil;
|
||||||
static NSString *_name = @"FileCreator";
|
|
||||||
static NSDictionary *dict = nil;
|
static NSDictionary *dict = nil;
|
||||||
|
|
||||||
|
@implementation PCFileCreator
|
||||||
|
|
||||||
+ (id)sharedCreator
|
+ (id)sharedCreator
|
||||||
{
|
{
|
||||||
if (_creator == nil)
|
if (_creator == nil)
|
||||||
|
@ -107,9 +106,20 @@ static NSDictionary *dict = nil;
|
||||||
return _creator;
|
return _creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)name
|
- (id)init
|
||||||
{
|
{
|
||||||
return _name;
|
self = [super init];
|
||||||
|
activeProject = nil;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
RELEASE(newFilePanel);
|
||||||
|
RELEASE(dict);
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)creatorDictionary
|
- (NSDictionary *)creatorDictionary
|
||||||
|
@ -117,6 +127,13 @@ static NSDictionary *dict = nil;
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)newFileInProject:(PCProject *)aProject
|
||||||
|
{
|
||||||
|
// Set to nil after panel closing
|
||||||
|
activeProject = aProject;
|
||||||
|
[self showNewFilePanel];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *)createFileOfType:(NSString *)type
|
- (NSDictionary *)createFileOfType:(NSString *)type
|
||||||
path:(NSString *)path
|
path:(NSString *)path
|
||||||
project:(PCProject *)aProject
|
project:(PCProject *)aProject
|
||||||
|
@ -285,3 +302,134 @@ static NSDictionary *dict = nil;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation PCFileCreator (UInterface)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// ==== "New File in Project" Panel
|
||||||
|
// ============================================================================
|
||||||
|
- (void)showNewFilePanel
|
||||||
|
{
|
||||||
|
if (!newFilePanel)
|
||||||
|
{
|
||||||
|
if ([NSBundle loadNibNamed:@"NewFile" owner:self] == NO)
|
||||||
|
{
|
||||||
|
PCLogError(self, @"error loading NewFile NIB!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[newFilePanel setFrameAutosaveName:@"NewFile"];
|
||||||
|
if (![newFilePanel setFrameUsingName: @"NewFile"])
|
||||||
|
{
|
||||||
|
[newFilePanel center];
|
||||||
|
}
|
||||||
|
[newFilePanel center];
|
||||||
|
[nfImage setImage:[NSApp applicationIconImage]];
|
||||||
|
[nfTypePB setRefusesFirstResponder:YES];
|
||||||
|
[nfTypePB removeAllItems];
|
||||||
|
[nfTypePB addItemsWithTitles:
|
||||||
|
[[dict allKeys]
|
||||||
|
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
|
||||||
|
[nfTypePB selectItemAtIndex:0];
|
||||||
|
[nfCancleButton setRefusesFirstResponder:YES];
|
||||||
|
[nfCreateButton setRefusesFirstResponder:YES];
|
||||||
|
[newFilePanel setDefaultButtonCell:[nfCreateButton cell]];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self newFilePopupChanged:nfTypePB];
|
||||||
|
|
||||||
|
[newFilePanel makeKeyAndOrderFront:self];
|
||||||
|
[nfNameField setStringValue:@""];
|
||||||
|
[newFilePanel makeFirstResponder:nfNameField];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)closeNewFilePanel:(id)sender
|
||||||
|
{
|
||||||
|
[newFilePanel orderOut:self];
|
||||||
|
activeProject = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)createFile:(id)sender
|
||||||
|
{
|
||||||
|
[self createFile];
|
||||||
|
[self closeNewFilePanel:self];
|
||||||
|
activeProject = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)newFilePopupChanged:(id)sender
|
||||||
|
{
|
||||||
|
NSString *type = [sender titleOfSelectedItem];
|
||||||
|
NSDictionary *creator = [dict objectForKey:type];
|
||||||
|
|
||||||
|
if (type)
|
||||||
|
{
|
||||||
|
[nfDescriptionTV setString:[creator objectForKey:@"TypeDescription"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)controlTextDidChange:(NSNotification *)aNotif
|
||||||
|
{
|
||||||
|
if ([aNotif object] != nfNameField)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add check for valid file names
|
||||||
|
if ([[nfNameField stringValue] length] > 0)
|
||||||
|
{
|
||||||
|
[nfCreateButton setEnabled:YES];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[nfCreateButton setEnabled:NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)createFile
|
||||||
|
{
|
||||||
|
NSString *path = nil;
|
||||||
|
NSString *fileName = [nfNameField stringValue];
|
||||||
|
NSString *fileType = [nfTypePB titleOfSelectedItem];
|
||||||
|
NSDictionary *fileDict = [dict objectForKey:fileType];
|
||||||
|
NSString *projectKey = [fileDict objectForKey:@"ProjectKey"];
|
||||||
|
|
||||||
|
// PCLogInfo(self, @"[createFile] %@", fileName);
|
||||||
|
|
||||||
|
if ([activeProject doesAcceptFile:fileName forKey:projectKey])
|
||||||
|
{
|
||||||
|
path = [[activeProject projectPath]
|
||||||
|
stringByAppendingPathComponent:fileName];
|
||||||
|
}
|
||||||
|
|
||||||
|
// PCLogInfo(self, @"creating file at %@", path);
|
||||||
|
|
||||||
|
// Create file
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
NSDictionary *newFiles = nil;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *aFile;
|
||||||
|
|
||||||
|
// Do it finally...
|
||||||
|
newFiles = [self createFileOfType:fileType
|
||||||
|
path:path
|
||||||
|
project:activeProject];
|
||||||
|
|
||||||
|
// Add files to a project
|
||||||
|
enumerator = [[newFiles allKeys] objectEnumerator];
|
||||||
|
while ((aFile = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
fileType = [newFiles objectForKey:aFile];
|
||||||
|
fileDict = [dict objectForKey:fileType];
|
||||||
|
projectKey = [fileDict objectForKey:@"ProjectKey"];
|
||||||
|
|
||||||
|
if ([activeProject doesAcceptFile:aFile forKey:projectKey])
|
||||||
|
{
|
||||||
|
[activeProject addFiles:[NSArray arrayWithObject:aFile]
|
||||||
|
forKey:projectKey
|
||||||
|
notify:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,6 @@ static PCFileManager *_mgr = nil;
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
projectManager = aProjectManager;
|
projectManager = aProjectManager;
|
||||||
creators = [[PCFileCreator sharedCreator] creatorDictionary];
|
|
||||||
RETAIN(creators);
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -72,9 +70,6 @@ static PCFileManager *_mgr = nil;
|
||||||
NSLog (@"PCFileManager: dealloc");
|
NSLog (@"PCFileManager: dealloc");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RELEASE(creators);
|
|
||||||
RELEASE(newFilePanel);
|
|
||||||
|
|
||||||
if (addFilesPanel)
|
if (addFilesPanel)
|
||||||
{
|
{
|
||||||
RELEASE(addFilesPanel);
|
RELEASE(addFilesPanel);
|
||||||
|
@ -321,56 +316,6 @@ static PCFileManager *_mgr = nil;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)createFile
|
|
||||||
{
|
|
||||||
NSString *path = nil;
|
|
||||||
NSString *fileName = [nfNameField stringValue];
|
|
||||||
NSString *fileType = [nfTypePB titleOfSelectedItem];
|
|
||||||
NSDictionary *theCreator = [creators objectForKey:fileType];
|
|
||||||
NSString *key = [theCreator objectForKey:@"ProjectKey"];
|
|
||||||
|
|
||||||
// PCLogInfo(self, @"[createFile] %@", fileName);
|
|
||||||
|
|
||||||
path = [projectManager fileManager:self
|
|
||||||
willCreateFile:fileName
|
|
||||||
withKey:key];
|
|
||||||
|
|
||||||
// PCLogInfo(self, @"creating file at %@", path);
|
|
||||||
|
|
||||||
// Create file
|
|
||||||
if (path)
|
|
||||||
{
|
|
||||||
NSDictionary *newFiles = nil;
|
|
||||||
PCFileCreator *creator = nil;
|
|
||||||
PCProject *project = [projectManager activeProject];
|
|
||||||
NSEnumerator *enumerator;
|
|
||||||
NSString *aFile;
|
|
||||||
|
|
||||||
creator = [theCreator objectForKey:@"Creator"];
|
|
||||||
if (!creator)
|
|
||||||
{
|
|
||||||
NSRunAlertPanel(@"Attention!",
|
|
||||||
@"Could not create %@. The creator is missing!",
|
|
||||||
@"OK",nil,nil,fileName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do it finally...
|
|
||||||
newFiles = [creator createFileOfType:fileType path:path project:project];
|
|
||||||
|
|
||||||
// Key: name of file
|
|
||||||
enumerator = [[newFiles allKeys] objectEnumerator];
|
|
||||||
while ((aFile = [enumerator nextObject]))
|
|
||||||
{
|
|
||||||
fileType = [newFiles objectForKey:aFile];
|
|
||||||
theCreator = [creators objectForKey:fileType];
|
|
||||||
key = [theCreator objectForKey:@"ProjectKey"];
|
|
||||||
|
|
||||||
[projectManager fileManager:self didCreateFile:aFile withKey:key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation PCFileManager (UInterface)
|
@implementation PCFileManager (UInterface)
|
||||||
|
@ -533,82 +478,6 @@ static PCFileManager *_mgr = nil;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// ==== "New File in Project" Panel
|
|
||||||
// ============================================================================
|
|
||||||
- (void)showNewFilePanel
|
|
||||||
{
|
|
||||||
if (!newFilePanel)
|
|
||||||
{
|
|
||||||
if ([NSBundle loadNibNamed:@"NewFile" owner:self] == NO)
|
|
||||||
{
|
|
||||||
PCLogError(self, @"error loading NewFile NIB!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[newFilePanel setFrameAutosaveName:@"NewFile"];
|
|
||||||
if (![newFilePanel setFrameUsingName: @"NewFile"])
|
|
||||||
{
|
|
||||||
[newFilePanel center];
|
|
||||||
}
|
|
||||||
[newFilePanel center];
|
|
||||||
[nfImage setImage:[NSApp applicationIconImage]];
|
|
||||||
[nfTypePB setRefusesFirstResponder:YES];
|
|
||||||
[nfTypePB removeAllItems];
|
|
||||||
[nfTypePB addItemsWithTitles:
|
|
||||||
[[creators allKeys]
|
|
||||||
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
|
|
||||||
[nfTypePB selectItemAtIndex:0];
|
|
||||||
[nfCancleButton setRefusesFirstResponder:YES];
|
|
||||||
[nfCreateButton setRefusesFirstResponder:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self newFilePopupChanged:nfTypePB];
|
|
||||||
|
|
||||||
[newFilePanel makeKeyAndOrderFront:self];
|
|
||||||
[nfNameField setStringValue:@""];
|
|
||||||
[newFilePanel makeFirstResponder:nfNameField];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)closeNewFilePanel:(id)sender
|
|
||||||
{
|
|
||||||
[newFilePanel orderOut:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)createFile:(id)sender
|
|
||||||
{
|
|
||||||
[self createFile];
|
|
||||||
[self closeNewFilePanel:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)newFilePopupChanged:(id)sender
|
|
||||||
{
|
|
||||||
NSString *type = [sender titleOfSelectedItem];
|
|
||||||
NSDictionary *creator = [creators objectForKey:type];
|
|
||||||
|
|
||||||
if (type)
|
|
||||||
{
|
|
||||||
[nfDescriptionTV setString:[creator objectForKey:@"TypeDescription"]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)controlTextDidChange:(NSNotification *)aNotif
|
|
||||||
{
|
|
||||||
if ([aNotif object] != nfNameField)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Add check for valid file names
|
|
||||||
if ([[nfNameField stringValue] length] > 0)
|
|
||||||
{
|
|
||||||
[nfCreateButton setEnabled:YES];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[nfCreateButton setEnabled:NO];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// ==== PCAddFilesPanel delegate
|
// ==== PCAddFilesPanel delegate
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <ProjectCenter/PCBundleManager.h>
|
#include <ProjectCenter/PCBundleManager.h>
|
||||||
#include <ProjectCenter/PCFileManager.h>
|
#include <ProjectCenter/PCFileManager.h>
|
||||||
|
#include <ProjectCenter/PCFileCreator.h>
|
||||||
#include <ProjectCenter/PCEditorManager.h>
|
#include <ProjectCenter/PCEditorManager.h>
|
||||||
#include <ProjectCenter/PCProjectManager.h>
|
#include <ProjectCenter/PCProjectManager.h>
|
||||||
|
|
||||||
|
@ -67,23 +68,14 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
loadedProjects = [[NSMutableDictionary alloc] init];
|
loadedProjects = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
nonProjectEditors = [[NSMutableDictionary alloc] init];
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver:self
|
addObserver:self
|
||||||
selector:@selector(resetSaveTimer:)
|
selector:@selector(resetSaveTimer:)
|
||||||
name:PCSavePeriodDidChangeNotification
|
name:PCSavePeriodDidChangeNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
addObserver:self
|
|
||||||
selector:@selector(editorDidClose:)
|
|
||||||
name:PCEditorDidCloseNotification
|
|
||||||
object:nil];
|
|
||||||
|
|
||||||
fileManager = [[PCFileManager alloc] initWithProjectManager:self];
|
fileManager = [[PCFileManager alloc] initWithProjectManager:self];
|
||||||
editorManager = [[PCEditorManager alloc] init];
|
|
||||||
[editorManager setProjectManager:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -103,7 +95,6 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}
|
}
|
||||||
|
|
||||||
RELEASE(loadedProjects);
|
RELEASE(loadedProjects);
|
||||||
RELEASE(nonProjectEditors);
|
|
||||||
RELEASE(fileManager);
|
RELEASE(fileManager);
|
||||||
|
|
||||||
RELEASE(bundleManager);
|
RELEASE(bundleManager);
|
||||||
|
@ -256,6 +247,18 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
return fileManager;
|
return fileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (PCEditorManager *)editorManager
|
||||||
|
{
|
||||||
|
if (!editorManager)
|
||||||
|
{
|
||||||
|
// For non project editors
|
||||||
|
editorManager = [[PCEditorManager alloc] init];
|
||||||
|
[editorManager setProjectManager:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
return editorManager;
|
||||||
|
}
|
||||||
|
|
||||||
- (PCProjectInspector *)projectInspector
|
- (PCProjectInspector *)projectInspector
|
||||||
{
|
{
|
||||||
if (!projectInspector)
|
if (!projectInspector)
|
||||||
|
@ -1000,6 +1003,16 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
// ==== File actions
|
// ==== File actions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
- (void)openFileAtPath:(NSString *)filePath
|
||||||
|
{
|
||||||
|
if (filePath != nil)
|
||||||
|
{
|
||||||
|
[[self editorManager] openEditorForFile:filePath
|
||||||
|
editable:YES
|
||||||
|
windowed:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)openFile
|
- (void)openFile
|
||||||
{
|
{
|
||||||
NSArray *files = nil;
|
NSArray *files = nil;
|
||||||
|
@ -1011,16 +1024,12 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
title:@"Open File"
|
title:@"Open File"
|
||||||
accView:nil];
|
accView:nil];
|
||||||
filePath = [files objectAtIndex:0];
|
filePath = [files objectAtIndex:0];
|
||||||
|
[self openFileAtPath:filePath];
|
||||||
if (filePath != nil)
|
|
||||||
{
|
|
||||||
[editorManager openEditorForFile:filePath editable:YES windowed:YES];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)newFile
|
- (void)newFile
|
||||||
{
|
{
|
||||||
[fileManager showNewFilePanel];
|
[[PCFileCreator sharedCreator] newFileInProject:activeProject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)saveFile
|
- (BOOL)saveFile
|
||||||
|
@ -1111,93 +1120,6 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
return [[activeProject projectEditor] closeActiveEditor:self];
|
return [[activeProject projectEditor] closeActiveEditor:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project menu
|
|
||||||
// ============================================================================
|
|
||||||
// ==== Non project editors
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
- (void)openFileWithEditor:(NSString *)path
|
|
||||||
{
|
|
||||||
// id<CodeEditor> editor;
|
|
||||||
/* NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
||||||
NSString *editor = [ud objectForKey:Editor];
|
|
||||||
|
|
||||||
if (![editor isEqualToString:@"ProjectCenter"])
|
|
||||||
{
|
|
||||||
NSArray *ea = [editor componentsSeparatedByString:@" "];
|
|
||||||
NSString *app = [ea objectAtIndex:0];
|
|
||||||
|
|
||||||
if ([[app pathExtension] isEqualToString:@"app"])
|
|
||||||
{
|
|
||||||
BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path
|
|
||||||
withApplication:app];
|
|
||||||
|
|
||||||
if (ret == NO)
|
|
||||||
{
|
|
||||||
PCLogError(self, @"Could not open %@ using %@", path, app);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
editor = [[editorClass alloc] initExternalEditor:editor
|
|
||||||
withPath:path
|
|
||||||
projectEditor:self];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id<CodeEditor> editor;
|
|
||||||
|
|
||||||
editor = [[editorClass alloc] initWithPath:path
|
|
||||||
categoryPath:nil
|
|
||||||
projectEditor:self];
|
|
||||||
[editor setWindowed:YES];
|
|
||||||
[editor show];
|
|
||||||
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
[nonProjectEditors setObject:editor forKey:path];
|
|
||||||
|
|
||||||
[editor release];*/
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)editorDidClose:(NSNotification *)aNotif
|
|
||||||
{
|
|
||||||
id<CodeEditor> editor = [aNotif object];
|
|
||||||
|
|
||||||
[nonProjectEditors removeObjectForKey:[editor path]];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation PCProjectManager (FileManagerDelegates)
|
|
||||||
|
|
||||||
// willCreateFile
|
|
||||||
- (NSString *)fileManager:(id)sender
|
|
||||||
willCreateFile:(NSString *)aFile
|
|
||||||
withKey:(NSString *)key
|
|
||||||
{
|
|
||||||
NSString *path = nil;
|
|
||||||
|
|
||||||
if ([activeProject doesAcceptFile:aFile forKey:key])
|
|
||||||
{
|
|
||||||
path = [[activeProject projectPath] stringByAppendingPathComponent:aFile];
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// didCreateFiles
|
|
||||||
- (void)fileManager:(id)sender
|
|
||||||
didCreateFile:(NSString *)aFile
|
|
||||||
withKey:(NSString *)key
|
|
||||||
{
|
|
||||||
[activeProject addFiles:[NSArray arrayWithObject:aFile]
|
|
||||||
forKey:key
|
|
||||||
notify:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation PCProjectManager (Subprojects)
|
@implementation PCProjectManager (Subprojects)
|
||||||
|
|
|
@ -39,14 +39,24 @@
|
||||||
|
|
||||||
@interface PCFileCreator : NSObject
|
@interface PCFileCreator : NSObject
|
||||||
{
|
{
|
||||||
|
PCProject *activeProject;
|
||||||
NSMutableString *file;
|
NSMutableString *file;
|
||||||
|
|
||||||
|
// New File in Project panel
|
||||||
|
IBOutlet NSPanel *newFilePanel;
|
||||||
|
IBOutlet NSImageView *nfImage;
|
||||||
|
IBOutlet NSPopUpButton *nfTypePB;
|
||||||
|
IBOutlet NSTextView *nfDescriptionTV;
|
||||||
|
IBOutlet NSTextField *nfNameField;
|
||||||
|
IBOutlet NSButton *nfCancleButton;
|
||||||
|
IBOutlet NSButton *nfCreateButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)sharedCreator;
|
+ (id)sharedCreator;
|
||||||
|
|
||||||
- (NSString *)name;
|
|
||||||
- (NSDictionary *)creatorDictionary;
|
- (NSDictionary *)creatorDictionary;
|
||||||
|
|
||||||
|
- (void)newFileInProject:(PCProject *)aProject;
|
||||||
// The implementation needs some heavy cleanup!
|
// The implementation needs some heavy cleanup!
|
||||||
- (NSDictionary *)createFileOfType:(NSString *)type
|
- (NSDictionary *)createFileOfType:(NSString *)type
|
||||||
path:(NSString *)path
|
path:(NSString *)path
|
||||||
|
@ -57,4 +67,15 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface PCFileCreator (UInterface)
|
||||||
|
|
||||||
|
- (void)showNewFilePanel;
|
||||||
|
- (void)closeNewFilePanel:(id)sender;
|
||||||
|
- (void)createFile:(id)sender;
|
||||||
|
- (void)newFilePopupChanged:(id)sender;
|
||||||
|
- (void)controlTextDidChange:(NSNotification *)aNotif;
|
||||||
|
- (void)createFile;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,8 +45,6 @@ enum {
|
||||||
PCProjectManager *projectManager;
|
PCProjectManager *projectManager;
|
||||||
id delegate; // PCProjectManager
|
id delegate; // PCProjectManager
|
||||||
|
|
||||||
NSDictionary *creators;
|
|
||||||
|
|
||||||
// New File in Project panel
|
// New File in Project panel
|
||||||
IBOutlet NSPanel *newFilePanel;
|
IBOutlet NSPanel *newFilePanel;
|
||||||
IBOutlet NSImageView *nfImage;
|
IBOutlet NSImageView *nfImage;
|
||||||
|
@ -113,8 +111,6 @@ enum {
|
||||||
|
|
||||||
- (BOOL)moveFile:(NSString *)file intoDirectory:(NSString *)directory;
|
- (BOOL)moveFile:(NSString *)file intoDirectory:(NSString *)directory;
|
||||||
|
|
||||||
- (void)createFile;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface PCFileManager (UInterface)
|
@interface PCFileManager (UInterface)
|
||||||
|
@ -125,10 +121,6 @@ enum {
|
||||||
multiple:(BOOL)yn
|
multiple:(BOOL)yn
|
||||||
title:(NSString *)title
|
title:(NSString *)title
|
||||||
accView:(NSView *)accessoryView;
|
accView:(NSView *)accessoryView;
|
||||||
- (void)showNewFilePanel;
|
|
||||||
- (void)closeNewFilePanel:(id)sender;
|
|
||||||
- (void)createFile:(id)sender;
|
|
||||||
- (void)newFilePopupChanged:(id)sender;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,6 @@ extern NSString *PCActiveProjectDidChangeNotification;
|
||||||
|
|
||||||
NSTimer *saveTimer;
|
NSTimer *saveTimer;
|
||||||
|
|
||||||
NSMutableDictionary *nonProjectEditors;
|
|
||||||
|
|
||||||
NSBox *projectTypeAccessaryView;
|
NSBox *projectTypeAccessaryView;
|
||||||
id projectTypePopup;
|
id projectTypePopup;
|
||||||
|
|
||||||
|
@ -110,6 +108,7 @@ extern NSString *PCActiveProjectDidChangeNotification;
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
- (PCBundleManager *)bundleManager;
|
- (PCBundleManager *)bundleManager;
|
||||||
- (PCFileManager *)fileManager;
|
- (PCFileManager *)fileManager;
|
||||||
|
- (PCEditorManager *)editorManager;
|
||||||
- (PCProjectInspector *)projectInspector;
|
- (PCProjectInspector *)projectInspector;
|
||||||
- (NSPanel *)inspectorPanel;
|
- (NSPanel *)inspectorPanel;
|
||||||
- (void)showProjectInspector:(id)sender;
|
- (void)showProjectInspector:(id)sender;
|
||||||
|
@ -169,6 +168,8 @@ extern NSString *PCActiveProjectDidChangeNotification;
|
||||||
// ==== File actions
|
// ==== File actions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
// Also called by PCAppController
|
||||||
|
- (void)openFileAtPath:(NSString *)filePath;
|
||||||
- (void)openFile;
|
- (void)openFile;
|
||||||
- (void)newFile;
|
- (void)newFile;
|
||||||
- (BOOL)saveFile;
|
- (BOOL)saveFile;
|
||||||
|
@ -178,27 +179,6 @@ extern NSString *PCActiveProjectDidChangeNotification;
|
||||||
- (BOOL)renameFile;
|
- (BOOL)renameFile;
|
||||||
- (void)closeFile;
|
- (void)closeFile;
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// ==== Non project editors
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
- (void)openFileWithEditor:(NSString *)path;
|
|
||||||
- (void)editorDidClose:(NSNotification *)aNotif;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface PCProjectManager (FileManagerDelegates)
|
|
||||||
|
|
||||||
// Returns the full path if the type is valid, nil else.
|
|
||||||
- (NSString *)fileManager:(id)sender
|
|
||||||
willCreateFile:(NSString *)aFile
|
|
||||||
withKey:(NSString *)key;
|
|
||||||
|
|
||||||
// Adds the file to the project and updates the makefile!
|
|
||||||
- (void)fileManager:(id)sender
|
|
||||||
didCreateFile:(NSString *)aFile
|
|
||||||
withKey:(NSString *)key;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSObject (PCProjectManagerDelegates)
|
@interface NSObject (PCProjectManagerDelegates)
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[projectManager openFileWithEditor:fileName];
|
[projectManager openFileAtPath:fileName];
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -121,7 +121,6 @@
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
// [bundleLoader loadBundles];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||||
|
|
Loading…
Reference in a new issue