diff --git a/ChangeLog b/ChangeLog index c6771f3..96ff22b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,48 @@ +2003-05-29 Serg Stoyan + + * PCMenuController.m: + (projectRemoveFiles:): Call removeFilesPermanently. + (fileSaveAs:): Implemented. + + * PCAppProj/PCAppProject.m: + (init): Initialize rootObjects and rootKeys arrays. Initialize + rootCategories dictionary with these arrays to preserve order of + categories in browser. "Non Project Files" category added. + (dealloc): Release rootObjects and rootKeys arrays. + (otherKeys): Added PCNonProject. + * PCBundleProj/PCBundleProject.m: Ditto. + * PCGormProj/PCGormProject.m: Ditto. + * PCLibProj/PCLibProject.m: Ditto. + * PCRenaissanceProj/PCRenaissanceProject.m: Ditto. + * PCToolProj/PCToolProject.m: Ditto. + + * PCLib/PCBrowserController.[hm]: Rename method setPathForFile: to + setPathForFile:category:. + * PCLib/PCBrowserController.m: + (isEditableCategory:file:): PCOtherSources, PCOtherResources and + PCNonProject to editable categories. + (projectDictDidChange:): Set path to category if there is no file + editing. + * PCLib/PCEditor.[hm]: Added _category ivar. Every editor now holds + category of the file being edited. Added methods category and + setCategory:. Removed saveFileAs: method. + * PCLib/PCEditorController.[hm]: Added and implemented method + closeEditorForFile:. + * PCLib/PCEditorController.m: + (editorDidClose:): Call [PCBrowserController projectDictDidChange:] + instead of [self setBrowserPath:]. + * PCLib/PCProject.h: Added PCNonProject contant. Added rootObjects, + rootKeys ivars. Removed categoryForFile: method. Renamed + removeSelectedFilePermanently: to removeSelectedFilesPermanently:. + * PCLib/PCProject.m: + (fileExtensionsForCategory:): Removed .m and .M extenstions from + PCOtherSources category. + (browserDidClickFile:category:): Setting category to editor added. + (removeFile:forKey:): Close editor when file removed. + (contentAtKeyPath:): Return rootKeys instead of all keys of rootCategories dictionary. + (removeFilesPermanently:): Call removeSelectedFilesPermanently: + (after renaming). + 2003-05-23 Serg Stoyan * PCMenuController.h: Added fileOpenQuickly:, fileNewUntitled: diff --git a/PCAppProj/PCAppProject.m b/PCAppProj/PCAppProject.m index fb99ca8..65e6333 100644 --- a/PCAppProj/PCAppProject.m +++ b/PCAppProj/PCAppProject.m @@ -123,27 +123,48 @@ - (id)init { - if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCGModels,@"Interfaces", - PCSupportingFiles,@"Supporting Files", - PCImages,@"Images", - PCOtherResources,@"Other Resources", - PCSubprojects,@"Subprojects", - PCLibraries,@"Libraries", - PCDocuFiles,@"Documentation", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; + if ((self = [super init])) + { + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCGModels, + PCImages, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; - } + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Interfaces", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", +// @"Context Help", + @"Supporting Files", +// @"Frameworks", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + + } return self; } - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [appClassField release]; [appImageField release]; @@ -218,7 +239,8 @@ - (NSArray *)otherKeys { - return [NSArray arrayWithObjects:PCDocuFiles,PCSupportingFiles,nil]; + return [NSArray arrayWithObjects:PCDocuFiles,PCSupportingFiles, + PCNonProject,nil]; } - (NSArray *)buildTargets diff --git a/PCBundleProj/PCBundleProject.m b/PCBundleProj/PCBundleProject.m index b88c530..7ebe508 100644 --- a/PCBundleProj/PCBundleProject.m +++ b/PCBundleProj/PCBundleProject.m @@ -83,27 +83,47 @@ - (id)init { - if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCGModels,@"Interfaces", - PCSupportingFiles,@"Supporting Files", - PCImages,@"Images", - PCOtherResources,@"Other Resources", - PCSubprojects,@"Subprojects", - PCLibraries,@"Libraries", - PCDocuFiles,@"Documentation", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; - - } + if ((self = [super init])) + { + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCGModels, + PCImages, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; + + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Interfaces", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", + @"Supporting Files", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + + } + return self; } - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [principalClassField release]; [super dealloc]; diff --git a/PCGormProj/PCGormProject.m b/PCGormProj/PCGormProject.m index 7cbabef..972c641 100644 --- a/PCGormProj/PCGormProject.m +++ b/PCGormProj/PCGormProject.m @@ -121,27 +121,46 @@ - (id)init { - if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCGModels,@"Interfaces", - PCSupportingFiles,@"Supporting Files", - PCImages,@"Images", - PCOtherResources,@"Other Resources", - PCSubprojects,@"Subprojects", - PCLibraries,@"Libraries", - PCDocuFiles,@"Documentation", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; + if ((self = [super init])) + { + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCGModels, + PCImages, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; + + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Interfaces", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", + @"Supporting Files", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + } - } return self; } - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [appClassField release]; [appImageField release]; diff --git a/PCLib/PCBrowserController.h b/PCLib/PCBrowserController.h index c7c04ff..890e53e 100644 --- a/PCLib/PCBrowserController.h +++ b/PCLib/PCBrowserController.h @@ -52,7 +52,7 @@ - (void)setBrowser:(NSBrowser *)aBrowser; - (void)setProject:(PCProject *)aProj; -- (BOOL)setPathForFile:(NSString *)file; +- (BOOL)setPathForFile:(NSString *)file category:(NSString *)category; @end diff --git a/PCLib/PCBrowserController.m b/PCLib/PCBrowserController.m index 80d4cc7..ca7dff8 100644 --- a/PCLib/PCBrowserController.m +++ b/PCLib/PCBrowserController.m @@ -25,6 +25,7 @@ */ #include "PCBrowserController.h" +#include "PCEditorController.h" #include "PCProject.h" #include "PCFileManager.h" @@ -84,7 +85,9 @@ [k isEqualToString:PCHeaders] || [k isEqualToString:PCSupportingFiles] || [k isEqualToString:PCDocuFiles] || - [k isEqualToString:PCOtherSources]) + [k isEqualToString:PCOtherSources] || + [k isEqualToString:PCOtherResources] || + [k isEqualToString:PCNonProject]) { return YES; } @@ -100,9 +103,18 @@ - (void)projectDictDidChange:(NSNotification *)aNotif { - if (browser) + if (browser) { - [browser reloadColumn:[browser lastColumn]]; + NSString *browserPath = [browser path]; + NSString *path = [[browserPath componentsSeparatedByString:@"/"] objectAtIndex:1]; + + if (![browserPath isEqualToString:path] + && [[[project editorController] allEditors] count] == 0) + { + [self setPathForFile:nil category:path]; + } + + [browser reloadColumn:[browser lastColumn]]; } } @@ -163,13 +175,9 @@ project = aProj; } -- (BOOL)setPathForFile:(NSString *)file +- (BOOL)setPathForFile:(NSString *)file category:(NSString *)category { - NSString *category = [project categoryForFile:file]; - NSString *browserCategory = [[[project rootCategories] - allKeysForObject: category] - lastObject]; - NSArray *comp = [NSArray arrayWithObjects: @"/",browserCategory,file,nil]; + NSArray *comp = [NSArray arrayWithObjects: @"/",category,@"/",file,nil]; NSString *path = [NSString pathWithComponents:comp]; int selectedColumn; diff --git a/PCLib/PCEditor.h b/PCLib/PCEditor.h index bd9a388..17f7be4 100644 --- a/PCLib/PCEditor.h +++ b/PCLib/PCEditor.h @@ -23,6 +23,7 @@ NSTextStorage *_storage; NSWindow *_window; NSMutableString *_path; + NSString *_category; id _delegate; @@ -40,6 +41,8 @@ - (NSWindow *)editorWindow; - (NSString *)path; - (void)setPath:(NSString *)path; +- (NSString *)category; +- (void)setCategory:(NSString *)category; - (BOOL)isEdited; - (void)setIsEdited:(BOOL)yn; @@ -47,7 +50,6 @@ - (void)show; - (BOOL)saveFileIfNeeded; - (BOOL)saveFile; -- (BOOL)saveFileAs:(NSString *)path; - (BOOL)saveFileTo:(NSString *)path; - (BOOL)revertFileToSaved; - (BOOL)closeFile:(id)sender; diff --git a/PCLib/PCEditor.m b/PCLib/PCEditor.m index 6af03fa..4477e77 100644 --- a/PCLib/PCEditor.m +++ b/PCLib/PCEditor.m @@ -119,6 +119,16 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification"; _path = [path copy]; } +- (NSString *)category +{ + return _category; +} + +- (void)setCategory:(NSString *)category +{ + _category = [category copy]; +} + - (BOOL)isEdited { return _isEdited; @@ -162,15 +172,6 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification"; return [[_storage string] writeToFile:_path atomically:YES]; } -- (BOOL)saveFileAs:(NSString *)path -{ - // Unfinished -/* [self setPath:file]; - - // Operate on the text storage!*/ - return [self saveFile]; -} - - (BOOL)saveFileTo:(NSString *)path { // Operate on the text storage! @@ -323,3 +324,4 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification"; } @end + diff --git a/PCLib/PCEditorController.h b/PCLib/PCEditorController.h index 45d5641..317e9b5 100644 --- a/PCLib/PCEditorController.h +++ b/PCLib/PCEditorController.h @@ -45,6 +45,7 @@ - (PCEditor *)editorForFile:(NSString *)path; - (PCEditor *)activeEditor; - (NSArray *)allEditors; +- (void)closeEditorForFile:(NSString *)file; - (void)closeAllEditors; diff --git a/PCLib/PCEditorController.m b/PCLib/PCEditorController.m index 0817035..83252f3 100644 --- a/PCLib/PCEditorController.m +++ b/PCLib/PCEditorController.m @@ -168,6 +168,15 @@ return [editorDict allValues]; } +- (void)closeEditorForFile:(NSString *)file +{ + PCEditor *editor; + + editor = [editorDict objectForKey:file]; + [editor closeFile:self]; + [editorDict removeObjectForKey:file]; +} + - (void)closeAllEditors { NSEnumerator *enumerator = [editorDict keyEnumerator]; @@ -224,7 +233,13 @@ if (editor != nil) { - return [editor saveFileAs:file]; + BOOL res; + res = [editor saveFileTo:file]; + [editor closeFile:self]; + + [[self internalEditorForFile:file] + showInProjectEditor:[project projectEditor]]; + return res; } return NO; @@ -259,7 +274,6 @@ [[self activeEditor] closeFile:self]; } - // =========================================================================== // ==== Delegate // =========================================================================== @@ -279,13 +293,14 @@ else { [[project projectEditor] setEditorView:nil]; - [self setBrowserPath:nil]; + [[project browserController] projectDictDidChange:nil]; } } - (void)setBrowserPath:(NSString *)file { - [(PCBrowserController *)[project browserController] setPathForFile:file]; + [[project browserController] setPathForFile:file + category:[[self activeEditor] category]]; } @end diff --git a/PCLib/PCEditorView.m b/PCLib/PCEditorView.m index eaf0a58..be77be9 100644 --- a/PCLib/PCEditorView.m +++ b/PCLib/PCEditorView.m @@ -226,16 +226,3 @@ static int _tabFlags = PCTab4Sp; @end - - - - - - - - - - - - - diff --git a/PCLib/PCProject.h b/PCLib/PCProject.h index 17814c1..4a5845d 100644 --- a/PCLib/PCProject.h +++ b/PCLib/PCProject.h @@ -81,15 +81,17 @@ typedef int PCProjInfoBits; static NSString * const PCClasses = @"CLASS_FILES"; static NSString * const PCHeaders = @"HEADER_FILES"; -static NSString * const PCGSMarkupFiles = @"INTERFACES"; static NSString * const PCOtherSources = @"OTHER_SOURCES"; -static NSString * const PCOtherResources = @"OTHER_RESOURCES"; -static NSString * const PCSupportingFiles = @"SUPPORTING_FILES"; -static NSString * const PCDocuFiles = @"DOCU_FILES"; -static NSString * const PCSubprojects = @"SUBPROJECTS"; static NSString * const PCGModels = @"INTERFACES"; static NSString * const PCImages = @"IMAGES"; +static NSString * const PCOtherResources = @"OTHER_RESOURCES"; +static NSString * const PCSubprojects = @"SUBPROJECTS"; +static NSString * const PCDocuFiles = @"DOCU_FILES"; +static NSString * const PCSupportingFiles = @"SUPPORTING_FILES"; static NSString * const PCLibraries = @"LIBRARIES"; +static NSString * const PCNonProject = @"NON_PROJECT_FILES"; +static NSString * const PCGSMarkupFiles = @"INTERFACES"; + static NSString * const PCCompilerOptions = @"COMPILEROPTIONS"; static NSString * const PCLinkerOptions = @"LINKEROPTIONS"; static NSString * const PCProjectName = @"PROJECT_NAME"; @@ -158,6 +160,8 @@ static NSString * const PCBuildTool = @"BUILDTOOL"; NSString *projectPath; NSMutableDictionary *projectDict; + NSArray *rootObjects; + NSArray *rootKeys; NSDictionary *rootCategories; // Needs to be initialised by subclasses! NSMutableDictionary *buildOptions; @@ -181,7 +185,6 @@ static NSString * const PCBuildTool = @"BUILDTOOL"; - (NSString *)selectedRootCategory; - (NSArray *)fileExtensionsForCategory:(NSString *)key; -- (NSString *)categoryForFile:(NSString *)file; - (void)setProjectName:(NSString *)aName; - (NSString *)projectName; @@ -236,7 +239,7 @@ static NSString * const PCBuildTool = @"BUILDTOOL"; - (void)addFile:(NSString *)file forKey:(NSString *)key copy:(BOOL)yn; - (void)removeFile:(NSString *)file forKey:(NSString *)key; -- (BOOL)removeSelectedFilePermanently:(BOOL)yn; +- (BOOL)removeSelectedFilesPermanently:(BOOL)yn; - (void)renameFile:(NSString *)aFile; - (BOOL)assignProjectDict:(NSDictionary *)aDict; diff --git a/PCLib/PCProject.m b/PCLib/PCProject.m index e9ebdb5..e7cb253 100644 --- a/PCLib/PCProject.m +++ b/PCLib/PCProject.m @@ -148,7 +148,7 @@ return [NSArray arrayWithObjects:@"h",nil]; } else if ([key isEqualToString:PCOtherSources]) { - return [NSArray arrayWithObjects:@"c",@"C",@"m",@"M",nil]; + return [NSArray arrayWithObjects:@"c",@"C",nil]; } else if ([key isEqualToString:PCLibraries]) { return [NSArray arrayWithObjects:@"so",@"a",@"lib",nil]; @@ -163,55 +163,6 @@ return nil; } -- (NSString *)categoryForFile:(NSString *)file -{ - NSString *fileExt = [[file componentsSeparatedByString: @"."] lastObject]; - - if ([fileExt isEqualToString:@"gmodel"] || [fileExt isEqualToString:@"gorm"]) - { - return PCGModels; - } - else if ([fileExt isEqualToString:@"gsmarkup"]) - { - return PCGSMarkupFiles; - } - else if ([fileExt isEqualToString:@"h"] || [fileExt isEqualToString:@"H"]) - { - return PCHeaders; - } - else if ([fileExt isEqualToString:@"m"] || [fileExt isEqualToString:@"M"]) - { - return PCClasses; - } - else if ([fileExt isEqualToString:@"c"] || [fileExt isEqualToString:@"C"]) - { - return PCOtherSources; - } - else if ([fileExt isEqualToString:@"so"] || [fileExt isEqualToString:@"lib"] - || [fileExt isEqualToString:@"a"]) - { - return PCLibraries; - } - else if ([fileExt isEqualToString:@"subproj"]) - { - return PCSubprojects; - } - else if ([[NSImage imageFileTypes] containsObject: fileExt]) - { - return PCImages; - } - else if ([file hasPrefix: @"GNUmakefile"]) - { - return PCSupportingFiles; - } - else if (file != nil) - { - return PCOtherResources; - } - - return nil; -} - - (void)setProjectName:(NSString *)aName { AUTORELEASE(projectName); @@ -351,6 +302,7 @@ } [self showEditorView:self]; + [e setCategory:c]; [e showInProjectEditor:projectEditor]; [projectWindow makeFirstResponder:(NSResponder*)[projectEditor editorView]]; @@ -358,13 +310,14 @@ - (void)browserDidDblClickFile:(NSString *)fileName category:(NSString*)c { - PCEditor *e; + PCEditor *e; - e = [editorController editorForFile:fileName]; + e = [editorController editorForFile:fileName]; - if( e ) + if (e) { - [e show]; + [e setCategory:c]; + [e show]; } } @@ -431,12 +384,20 @@ - (void)removeFile:(NSString *)file forKey:(NSString *)key { - NSMutableArray *array; + NSMutableArray *array; + NSMutableString *filePath; if (!file || !key) { return; } + // Close editor + filePath = [[NSMutableString alloc] initWithString:projectPath]; + [filePath appendString:@"/"]; + [filePath appendString:file]; + [editorController closeEditorForFile:filePath]; + [filePath release]; + array = [NSMutableArray arrayWithArray:[projectDict objectForKey:key]]; [array removeObject:file]; [projectDict setObject:array forKey:key]; @@ -444,7 +405,7 @@ [projectWindow setDocumentEdited:YES]; } -- (BOOL)removeSelectedFilePermanently:(BOOL)yn +- (BOOL)removeSelectedFilesPermanently:(BOOL)yn { NSEnumerator *files = [[browserController selectedFiles] objectEnumerator]; NSString *file = nil; @@ -824,8 +785,9 @@ NSLog(@"<%@ %x>: content at path %@",[self class],self,keyPath); #endif - if ([keyPath isEqualToString:@""] || [keyPath isEqualToString:@"/"]) { - return [rootCategories allKeys]; + if ([keyPath isEqualToString:@""] || [keyPath isEqualToString:@"/"]) + { + return rootKeys; } key = [[keyPath componentsSeparatedByString:@"/"] lastObject]; diff --git a/PCLib/PCProjectManager.h b/PCLib/PCProjectManager.h index ca22772..c0da17c 100644 --- a/PCLib/PCProjectManager.h +++ b/PCLib/PCProjectManager.h @@ -156,7 +156,7 @@ - (void)closeFile; - (BOOL)renameFileTo:(NSString *)path; -- (BOOL)removeFilePermanently:(BOOL)yn; +- (BOOL)removeFilesPermanently:(BOOL)yn; @end diff --git a/PCLib/PCProjectManager.m b/PCLib/PCProjectManager.m index 5723c9e..353a4d2 100644 --- a/PCLib/PCProjectManager.m +++ b/PCLib/PCProjectManager.m @@ -491,14 +491,14 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; return YES; } -- (BOOL)removeFilePermanently:(BOOL)yn +- (BOOL)removeFilesPermanently:(BOOL)yn { if (!activeProject) { return NO; } - return [activeProject removeSelectedFilePermanently:yn]; + return [activeProject removeSelectedFilesPermanently:yn]; } @end diff --git a/PCLibProj/PCLibProject.m b/PCLibProj/PCLibProject.m index 8af12f0..9558469 100644 --- a/PCLibProj/PCLibProject.m +++ b/PCLibProj/PCLibProject.m @@ -54,16 +54,30 @@ - (id)init { if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCSupportingFiles,@"Supporting Files", - PCSubprojects, @"Subprojects", - PCLibraries, @"Libraries", - PCDocuFiles,@"Documentation", - PCOtherResources,@"Other Resources", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; + + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Other Resources", + @"Subprojects", + @"Documentation", + @"Supporting Files", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; } return self; @@ -72,6 +86,8 @@ - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [super dealloc]; } diff --git a/PCMenuController.m b/PCMenuController.m index e69ed8b..5aa03f6 100644 --- a/PCMenuController.m +++ b/PCMenuController.m @@ -255,7 +255,7 @@ { BOOL flag = (ret == NSAlertOtherReturn) ? YES : NO; - [projectManager removeFilePermanently:flag]; + [projectManager removeFilesPermanently:flag]; } } } @@ -343,22 +343,29 @@ // Not finished - (void)fileSaveAs:(id)sender { -/* NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; NSSavePanel *savePanel = [NSSavePanel savePanel];; - NSString *oldFilePath; - NSString *newFilePath; - int retval; + NSString *oldFilePath = nil; + NSString *newFilePath = nil; + NSString *directory = nil; + int retval = NSOKButton; oldFilePath = [[[[projectManager activeProject] editorController] activeEditor] path]; [savePanel setTitle: @"Save As..."]; - retval = [savePanel runModalForDirectory:[projectManager projectPath] - file:[projectManager selectedFileName]]; + while (![directory isEqualToString: [projectManager projectPath]] + && retval != NSCancelButton) + { + retval = [savePanel + runModalForDirectory:[projectManager projectPath] + file:[projectManager selectedFileName]]; + directory = [savePanel directory]; + } if (retval == NSOKButton) { - [ud setObject:[savePanel directory] forKey:@"LastOpenDirectory"]; + [ud setObject:directory forKey:@"LastOpenDirectory"]; newFilePath = [savePanel filename]; @@ -368,10 +375,17 @@ @"Couldn't save file as\n%@!", @"OK",nil,nil,newFilePath); } - }*/ - NSRunAlertPanel(@"PCMenuController: Sorry!", - @"This feature not finished yet", - @"OK",nil,nil); + else + { + PCProject *project = [projectManager activeProject]; + NSString *category = [[[project rootCategories] allKeysForObject:PCNonProject] objectAtIndex:0]; + + [projectManager closeFile]; + [project addFile:newFilePath forKey:PCNonProject]; + [project browserDidClickFile:[newFilePath lastPathComponent] + category:category]; + } + } } - (void)fileSaveTo:(id)sender diff --git a/PCRenaissanceProj/PCRenaissanceProject.m b/PCRenaissanceProj/PCRenaissanceProject.m index baee102..b78d79a 100644 --- a/PCRenaissanceProj/PCRenaissanceProject.m +++ b/PCRenaissanceProj/PCRenaissanceProject.m @@ -122,27 +122,46 @@ - (id)init { - if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCGModels,@"Interfaces", - PCSupportingFiles,@"Supporting Files", - PCImages,@"Images", - PCOtherResources,@"Other Resources", - PCSubprojects,@"Subprojects", - PCLibraries,@"Libraries", - PCDocuFiles,@"Documentation", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; + if ((self = [super init])) + { + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCGModels, + PCImages, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; + + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Interfaces", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", + @"Supporting Files", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + } - } return self; } - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [appClassField release]; [appImageField release]; diff --git a/PCToolProj/PCToolProject.m b/PCToolProj/PCToolProject.m index 3846680..6dd62ac 100644 --- a/PCToolProj/PCToolProject.m +++ b/PCToolProj/PCToolProject.m @@ -53,26 +53,45 @@ - (id)init { - if ((self = [super init])) { - rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys: - PCSupportingFiles,@"Supporting Files", - PCImages,@"Images", - PCOtherResources,@"Other Resources", - PCSubprojects,@"Subprojects", - PCLibraries,@"Libraries", - PCDocuFiles,@"Documentation", - PCOtherSources,@"Other Sources", - PCHeaders,@"Headers", - PCClasses,@"Classes", - nil] retain]; + if ((self = [super init])) + { + rootObjects = [[NSArray arrayWithObjects: PCClasses, + PCHeaders, + PCOtherSources, + PCImages, + PCOtherResources, + PCSubprojects, + PCDocuFiles, + PCSupportingFiles, + PCLibraries, + PCNonProject, + nil] retain]; + + rootKeys = [[NSArray arrayWithObjects: @"Classes", + @"Headers", + @"Other Sources", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", + @"Supporting Files", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootCategories = [[NSDictionary + dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; - } + } + return self; } - (void)dealloc { [rootCategories release]; + [rootObjects release]; + [rootKeys release]; [super dealloc]; }