diff --git a/GNUmakefile b/GNUmakefile index ccdaa9a..04aa43a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,7 +12,7 @@ PACKAGE_NAME = ProjectCenter APP_NAME = ProjectCenter ProjectCenter_APPLICATION_ICON = Images/ProjectCenter.tiff VERSION = 0.4 -COMPRESSION = bzip2 +COMPRESSION = gzip # # Subprojects diff --git a/Library/PCEditor.m b/Library/PCEditor.m index 6a2c940..a1bf297 100644 --- a/Library/PCEditor.m +++ b/Library/PCEditor.m @@ -451,7 +451,14 @@ - (void)textDidChange:(NSNotification *)aNotification { - [self setIsEdited:YES]; + id object = [aNotification object]; + + + if ([object isKindOfClass:[PCEditorView class]] + && (object == _intEditorView || object == _extEditorView)) + { + [self setIsEdited:YES]; + } } - (BOOL)becomeFirstResponder diff --git a/Library/PCFileManager+UInterface.m b/Library/PCFileManager+UInterface.m index 0c5d02d..968b598 100644 --- a/Library/PCFileManager+UInterface.m +++ b/Library/PCFileManager+UInterface.m @@ -217,8 +217,7 @@ [self _createAddFilesPanel]; - [fileTypePopup selectItemWithTitle: - [project keyForCategory:[project selectedRootCategory]]]; + [fileTypePopup selectItemWithTitle:[project selectedRootCategory]]; [self filesForAddPopupClicked:self]; @@ -259,7 +258,7 @@ NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL isDir; NSString *fileType = nil; - NSString *category = nil; + NSString *categoryKey = nil; // NSLog(@"Panel should show %@", filename); if ([fileManager fileExistsAtPath:filename isDirectory:&isDir] && isDir) @@ -279,13 +278,13 @@ return YES; } - category = [project projectKeyForKeyPath: + categoryKey = [project keyForCategoryPath: [NSString stringWithFormat:@"/%@",fileType]]; - fileTypes = [project fileTypesForCategory:category]; + fileTypes = [project fileTypesForCategoryKey:categoryKey]; if (fileTypes == nil); { - NSLog(@"Project file types is nil! Category: %@", category); + NSLog(@"Project file types is nil! Category: %@", categoryKey); return YES; } diff --git a/Library/PCProject.h b/Library/PCProject.h index e0371c2..2374e33 100644 --- a/Library/PCProject.h +++ b/Library/PCProject.h @@ -69,9 +69,9 @@ extern NSString *PCProjectDictDidSaveNotification; NSString *projectName; NSString *projectPath; - NSArray *rootObjects; - NSArray *rootKeys; - NSDictionary *rootCategories; // Needs to be initialised by subclasses! + NSArray *rootKeys; // CLASS_FILES + NSArray *rootCategories; // Classes + NSDictionary *rootEntries; // Initialised by subclasses NSMutableDictionary *buildOptions; BOOL editorIsActive; @@ -105,7 +105,9 @@ extern NSString *PCProjectDictDidSaveNotification; - (NSString *)projectName; - (void)setProjectName:(NSString *)aName; - (BOOL)isProjectChanged; + - (NSString *)selectedRootCategory; +- (NSString *)selectedRootCategoryKey; - (Class)principalClass; @@ -123,8 +125,8 @@ extern NSString *PCProjectDictDidSaveNotification; // Subclasses need to call this before their customised implementation! - (BOOL)writeMakefile; -- (NSArray *)fileTypesForCategory:(NSString *)category; -- (NSString *)dirForCategory:(NSString *)category; +- (NSArray *)fileTypesForCategoryKey:(NSString *)key; +- (NSString *)dirForCategoryKey:(NSString *)key; - (NSArray *)sourceFileKeys; - (NSArray *)resourceFileKeys; @@ -165,8 +167,10 @@ extern NSString *PCProjectDictDidSaveNotification; - (NSString *)projectPath; - (NSArray *)rootKeys; -- (NSDictionary *)rootCategories; +- (NSArray *)rootCategories; +- (NSDictionary *)rootEntries; - (NSString *)keyForCategory:(NSString *)category; +- (NSString *)categoryForKey:(NSString *)key; - (BOOL)save; - (BOOL)saveAt:(NSString *)projPath; @@ -195,11 +199,13 @@ extern NSString *PCProjectDictDidSaveNotification; @end -@interface PCProject (ProjectKeyPaths) +@interface PCProject (CategoryPaths) -- (NSArray *)contentAtKeyPath:(NSString *)keyPath; -- (BOOL)hasChildrenAtKeyPath:(NSString *)keyPath; -- (NSString *)projectKeyForKeyPath:(NSString *)kp; +- (NSArray *)contentAtCategoryPath:(NSString *)categoryPath; +- (BOOL)hasChildrenAtCategoryPath:(NSString *)keyPath; + +- (NSString *)categoryForCategoryPath:(NSString *)categoryPath; +- (NSString *)keyForCategoryPath:(NSString *)kp; @end diff --git a/Library/PCProject.m b/Library/PCProject.m index 894f38f..97a5f36 100644 --- a/Library/PCProject.m +++ b/Library/PCProject.m @@ -296,7 +296,14 @@ NSString { NSString *_path = [[self projectBrowser] pathOfSelectedFile]; - return [self projectKeyForKeyPath:_path]; + return [self categoryForCategoryPath:_path]; +} + +- (NSString *)selectedRootCategoryKey +{ + NSString *_path = [[self projectBrowser] pathOfSelectedFile]; + + return [self keyForCategoryPath:_path]; } - (void)setProjectDictObject:(id)object forKey:(NSString *)key @@ -369,12 +376,12 @@ NSString return nil; } -- (NSArray *)fileTypesForCategory:(NSString *)category +- (NSArray *)fileTypesForCategoryKey:(NSString *)key { return nil; } -- (NSString *)dirForCategory:(NSString *)category +- (NSString *)dirForCategoryKey:(NSString *)key { return projectPath; } @@ -481,7 +488,7 @@ NSString NSString *file = nil; NSMutableArray *fileList = [[files mutableCopy] autorelease]; PCFileManager *fileManager = [projectManager fileManager]; - NSString *directory = [self dirForCategory:key]; + NSString *directory = [self dirForCategoryKey:key]; // Validate files while ((file = [fileEnum nextObject])) @@ -561,23 +568,23 @@ NSString { NSFileManager *fm = [NSFileManager defaultManager]; NSString *selectedCategory = [self selectedRootCategory]; + NSString *selectedCategoryKey = [self selectedRootCategoryKey]; NSString *fromPath = nil; NSString *toPath = nil; - fromPath = [[self dirForCategory:selectedCategory] + fromPath = [[self dirForCategoryKey:selectedCategoryKey] stringByAppendingPathComponent:fromFile]; - toPath = [[self dirForCategory:selectedCategory] + toPath = [[self dirForCategoryKey:selectedCategoryKey] stringByAppendingPathComponent:toFile]; + [self removeFiles:[NSArray arrayWithObjects:fromFile,nil] + forKey:selectedCategoryKey]; + [self addFiles:[NSArray arrayWithObjects:toFile,nil] + forKey:selectedCategoryKey]; + [fm movePath:fromPath toPath:toPath handler:nil]; - [self removeFiles:[NSArray arrayWithObjects:fromFile,nil] - forKey:selectedCategory]; - [self addFiles:[NSArray arrayWithObjects:toFile,nil] - forKey:selectedCategory]; - - [projectBrowser setPathForFile:toFile - category:[self keyForCategory:selectedCategory]]; + [projectBrowser setPathForFile:toFile category:selectedCategory]; return YES; } @@ -624,21 +631,37 @@ NSString - (NSArray *)rootKeys { + // e.g. CLASS_FILES return rootKeys; } -- (NSDictionary *)rootCategories +- (NSArray *)rootCategories { + // e.g. Classes return rootCategories; } -- (NSString *)keyForCategory:(NSString *)category +- (NSDictionary *)rootEntries { - int index = [rootObjects indexOfObject:category]; + return rootEntries; +} + +// Category is the name we see in project browser, e.g. +// Classes. +// Key is the uppercase names which are located in PC.roject, e.g. +// CLASS_FILES +- (NSString *)keyForCategory:(NSString *)category +{ + int index = [rootCategories indexOfObject:category]; return [rootKeys objectAtIndex:index]; } +- (NSString *)categoryForKey:(NSString *)key +{ + return [rootEntries objectForKey:key]; +} + - (BOOL)save { NSString *file = [projectPath stringByAppendingPathComponent:@"PC.project"]; @@ -855,47 +878,55 @@ NSString @end -@implementation PCProject (ProjectKeyPaths) +@implementation PCProject (CategoryPaths) -- (NSArray *)contentAtKeyPath:(NSString *)keyPath +- (NSArray *)contentAtCategoryPath:(NSString *)categoryPath { - NSString *key; + NSString *key = nil; -#ifdef DEBUG - NSLog(@"<%@ %x>: content at path %@",[self class],self,keyPath); -#endif - - if ([keyPath isEqualToString:@""] || [keyPath isEqualToString:@"/"]) + if ([categoryPath isEqualToString:@""] || [categoryPath isEqualToString:@"/"]) { - return rootKeys; + return rootCategories; } - key = [[keyPath componentsSeparatedByString:@"/"] lastObject]; - return [projectDict objectForKey:[rootCategories objectForKey:key]]; + key = [self keyForCategoryPath:categoryPath]; + + return [projectDict objectForKey:key];; } -- (BOOL)hasChildrenAtKeyPath:(NSString *)keyPath +- (BOOL)hasChildrenAtCategoryPath:(NSString *)categoryPath { - NSString *key; + NSString *listEntry = nil; - if (!keyPath || [keyPath isEqualToString:@""]) { - return NO; + if (!categoryPath || [categoryPath isEqualToString:@""] + ||[categoryPath isEqualToString:@"/"]) + { + return NO; } - key = [[keyPath componentsSeparatedByString:@"/"] lastObject]; - if ([[rootCategories allKeys] containsObject:key] || - [[projectDict objectForKey:PCSubprojects] containsObject:key]) { - return YES; + listEntry = [[categoryPath componentsSeparatedByString:@"/"] lastObject]; + + if ([rootCategories containsObject:listEntry] + || [[projectDict objectForKey:PCSubprojects] containsObject:listEntry]) + { + return YES; } - - return NO; + + return NO; } -- (NSString *)projectKeyForKeyPath:(NSString *)kp +- (NSString *)categoryForCategoryPath:(NSString *)categoryPath { - NSString *type = [[kp componentsSeparatedByString:@"/"] objectAtIndex:1]; + return [[categoryPath componentsSeparatedByString:@"/"] objectAtIndex:1]; +} + +- (NSString *)keyForCategoryPath:(NSString *)categoryPath +{ + NSString *category = nil; - return [rootCategories objectForKey:type]; + category = [[categoryPath componentsSeparatedByString:@"/"] objectAtIndex:1]; + + return [self keyForCategory:category]; } @end diff --git a/Library/PCProjectBrowser.m b/Library/PCProjectBrowser.m index 3a5f87b..19f5896 100644 --- a/Library/PCProjectBrowser.m +++ b/Library/PCProjectBrowser.m @@ -89,20 +89,20 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; // This is responsibility of PC*Project classes - (BOOL)isEditableCategory:(NSString *)category file:(NSString *)title { - NSString *k = [[project rootCategories] objectForKey:category]; + NSString *key = [project keyForCategory:category]; - if ([k isEqualToString:PCClasses] || - [k isEqualToString:PCHeaders] || - [k isEqualToString:PCSupportingFiles] || - [k isEqualToString:PCDocuFiles] || - [k isEqualToString:PCOtherSources] || - [k isEqualToString:PCOtherResources] || - [k isEqualToString:PCNonProject]) + if ([key isEqualToString:PCClasses] + || [key isEqualToString:PCHeaders] + || [key isEqualToString:PCSupportingFiles] + || [key isEqualToString:PCDocuFiles] + || [key isEqualToString:PCOtherSources] + || [key isEqualToString:PCOtherResources] + || [key isEqualToString:PCNonProject]) { return YES; } - if ([k isEqualToString:PCGSMarkupFiles] + if ([key isEqualToString:PCGSMarkupFiles] && [[title pathExtension] isEqual: @"gorm"] == NO) { return YES; @@ -165,12 +165,14 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; [columnMatrix deselectAllCells]; } // End of HACK - + result = [browser setPath:path]; + + [self click:browser]; - [[NSNotificationCenter defaultCenter] +/* [[NSNotificationCenter defaultCenter] postNotificationName:PCBrowserDidSetPathNotification - object:self]; + object:self];*/ return result; } @@ -236,12 +238,19 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; if (browser) { NSString *browserPath = [browser path]; - NSString *path = [[browserPath componentsSeparatedByString:@"/"] objectAtIndex:1]; - - if (![browserPath isEqualToString:path] - && [[[project projectEditor] allEditors] count] == 0) + NSString *path = nil; + NSString *slctdCategory = [project selectedRootCategory]; + + if (slctdCategory && browserPath && ![browserPath isEqualToString:@"/"]) { - [self setPathForFile:nil category:path]; + path = [[browserPath componentsSeparatedByString:@"/"] + objectAtIndex:1]; + + if ([[[project projectEditor] allEditors] count] == 0 + && [self isEditableCategory:slctdCategory file:nil]) + { + [self setPathForFile:nil category:path]; + } } [browser reloadColumn:[browser lastColumn]]; @@ -255,26 +264,31 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; - (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix { NSString *pathToCol = [sender pathToColumn:column]; - NSArray *files = [project contentAtKeyPath:pathToCol]; + NSArray *files = [project contentAtCategoryPath:pathToCol]; int i; int count = [files count]; - if( sender != browser ) return; + if (sender != browser) + { + return; + } for (i = 0; i < count; ++i) { - NSMutableString *keyPath = [NSMutableString stringWithString:pathToCol]; - id cell; - + NSMutableString *categoryPath = nil; + id cell; + + categoryPath = [NSMutableString stringWithString:pathToCol]; + [matrix insertRow:i]; cell = [matrix cellAtRow:i column:0]; [cell setStringValue:[files objectAtIndex:i]]; - [keyPath appendString:@"/"]; - [keyPath appendString:[files objectAtIndex:i]]; + [categoryPath appendString:@"/"]; + [categoryPath appendString:[files objectAtIndex:i]]; - [cell setLeaf:![project hasChildrenAtKeyPath:keyPath]]; + [cell setLeaf:![project hasChildrenAtCategoryPath:categoryPath]]; } } diff --git a/Library/PCProjectInspector.m b/Library/PCProjectInspector.m index f71525a..7799e0a 100644 --- a/Library/PCProjectInspector.m +++ b/Library/PCProjectInspector.m @@ -50,6 +50,8 @@ [self setBackgroundColor:[NSColor whiteColor]]; [self setEditable:YES]; [self selectText:nil]; + [self setNeedsDisplay:YES]; + [[self superview] setNeedsDisplay:YES]; } else { @@ -57,9 +59,10 @@ frame.origin.x += 4; [self setFrame:frame]; - [self setBordered:NO]; [self setBackgroundColor:[NSColor lightGrayColor]]; + [self setBordered:NO]; [self setEditable:NO]; + [self setNeedsDisplay:YES]; [[self superview] setNeedsDisplay:YES]; } } @@ -67,7 +70,7 @@ - (void)mouseDown:(NSEvent *)theEvent { [self setEditableField:YES]; - [super mouseDown:theEvent]; +// [super mouseDown:theEvent]; } - (BOOL)textShouldSetEditable @@ -670,6 +673,11 @@ selector:@selector(browserDidSetPath:) name:PCBrowserDidSetPathNotification object:[project projectBrowser]];*/ + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(panelDidResignKey:) + name: NSWindowDidResignKeyNotification + object:inspectorPanel]; } - (void)browserDidSetPath:(NSNotification *)aNotif @@ -704,20 +712,29 @@ - (void)fileNameDidChange:(id)sender { - NSLog(@"PCProjectInspector: file name changed from: %@ to: %@", - fileName, [fileNameField stringValue]); - if ([fileName isEqualToString:[fileNameField stringValue]]) { return; } + NSLog(@"PCProjectInspector: file name changed from: %@ to: %@", + fileName, [fileNameField stringValue]); + if ([project renameFile:fileName toFile:[fileNameField stringValue]] == NO) { [fileNameField setStringValue:fileName]; } } +- (void)panelDidResignKey:(NSNotification *)aNotif +{ + if ([fileNameField isEditable] == YES) + { + [inspectorPanel makeFirstResponder:fileIconView]; + [fileNameField setStringValue:fileName]; + } +} + // ============================================================================ // ==== NSTableViews // ============================================================================ diff --git a/Library/PCProjectManager.m b/Library/PCProjectManager.m index 9f6f779..9e0ee5c 100644 --- a/Library/PCProjectManager.m +++ b/Library/PCProjectManager.m @@ -521,12 +521,12 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; - (BOOL)addProjectFiles { - NSString *category = nil; + NSString *categoryKey = nil; NSArray *fileTypes = nil; NSMutableArray *files = nil; - category = [activeProject selectedRootCategory]; - fileTypes = [activeProject fileTypesForCategory:category]; + categoryKey = [activeProject selectedRootCategoryKey]; + fileTypes = [activeProject fileTypesForCategoryKey:categoryKey]; /* [fileTypePopup removeAllItems]; [fileTypePopup addItemsWithTitles:[activeProject rootKeys]]; @@ -544,7 +544,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; } // Copy and add files - [activeProject addAndCopyFiles:files forKey:category]; + [activeProject addAndCopyFiles:files forKey:categoryKey]; return YES; } @@ -557,7 +557,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; - (BOOL)removeProjectFiles { NSArray *files = nil; - NSString *category = nil; + NSString *categoryKey = nil; NSString *directory = nil; if (!activeProject) @@ -566,8 +566,8 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; } files = [[activeProject projectBrowser] selectedFiles]; - category = [activeProject selectedRootCategory]; - directory = [activeProject dirForCategory:category]; + categoryKey = [activeProject selectedRootCategoryKey]; + directory = [activeProject dirForCategoryKey:categoryKey]; if (files) { @@ -583,7 +583,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; { BOOL flag = (ret == NSAlertDefaultReturn) ? YES : NO; - ret = [activeProject removeFiles:files forKey:category]; + ret = [activeProject removeFiles:files forKey:categoryKey]; if (flag && ret) { ret = [fileManager removeFiles:files fromDirectory:directory]; diff --git a/Modules/ApplicationProject/GNUmakefile b/Modules/ApplicationProject/GNUmakefile index 90c2989..0f51442 100644 --- a/Modules/ApplicationProject/GNUmakefile +++ b/Modules/ApplicationProject/GNUmakefile @@ -29,7 +29,8 @@ Resources/main.m \ Resources/PC.project \ Resources/GNUmakefile.preamble \ Resources/GNUmakefile.postamble \ -Resources/Main.gorm +Resources/Main.gorm \ +Resources/Inspector.gorm # # Header files diff --git a/Modules/ApplicationProject/PCAppProject+Inspector.m b/Modules/ApplicationProject/PCAppProject+Inspector.m index ce9003c..5a900da 100644 --- a/Modules/ApplicationProject/PCAppProject+Inspector.m +++ b/Modules/ApplicationProject/PCAppProject+Inspector.m @@ -30,13 +30,7 @@ // ---------------------------------------------------------------------------- NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; -@interface PCITextField : NSTextField -{ -} - -@end - -@implementation PCITextField +@implementation PCAppTextField - (BOOL)becomeFirstResponder { @@ -57,127 +51,20 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; - (void)createProjectAttributes { - NSTextField *textField = nil; - NSBox *_iconViewBox = nil; - NSBox *_iconsBox = nil; - - if (projectAttributesView) +/* if (projectAttributesView) { return; - } - - projectAttributesView = [[NSBox alloc] init]; - [projectAttributesView setFrame:NSMakeRect(0,0,295,384)]; - [projectAttributesView setTitlePosition:NSNoTitle]; - [projectAttributesView - setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [projectAttributesView setContentViewMargins:NSMakeSize(0.0, 0.0)]; - - // Project Type - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,343,104,21)]; - [textField setAlignment: NSRightTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Project Type:"]; - [projectAttributesView addSubview:textField]; - RELEASE(textField); - - projectTypeField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,343,185,21)]; - [projectTypeField setAlignment: NSLeftTextAlignment]; - [projectTypeField setBordered: NO]; - [projectTypeField setEditable: NO]; - [projectTypeField setSelectable: NO]; - [projectTypeField setBezeled: NO]; - [projectTypeField setDrawsBackground: NO]; - [projectTypeField setFont:[NSFont boldSystemFontOfSize: 12.0]]; - [projectTypeField setStringValue:@""]; - [projectAttributesView addSubview:projectTypeField]; - RELEASE(projectTypeField); - - // Project Name - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,318,104,21)]; - [textField setAlignment: NSRightTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Project Name:"]; - [projectAttributesView addSubview:textField]; - RELEASE(textField); - - projectNameField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,318,185,21)]; - [projectNameField setAlignment: NSLeftTextAlignment]; - [projectNameField setBordered: NO]; - [projectNameField setEditable: NO]; - [projectNameField setBezeled: YES]; - [projectNameField setDrawsBackground: YES]; - [projectNameField setStringValue:@""]; - [projectAttributesView addSubview:projectNameField]; - RELEASE(projectNameField); - - // Project Language - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,293,104,21)]; - [textField setAlignment: NSRightTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Language:"]; - [projectAttributesView addSubview:textField]; - RELEASE(textField); - - projectLanguageField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,293,185,21)]; - [projectLanguageField setAlignment: NSLeftTextAlignment]; - [projectLanguageField setBordered: NO]; - [projectLanguageField setEditable: NO]; - [projectLanguageField setBezeled: YES]; - [projectLanguageField setDrawsBackground: YES]; - [projectLanguageField setStringValue:@""]; - [projectAttributesView addSubview:projectLanguageField]; - RELEASE(projectLanguageField); - - // Application Class - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,268,104,21)]; - [textField setAlignment: NSRightTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Application Class:"]; - [projectAttributesView addSubview:textField]; - RELEASE(textField); - - appClassField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,268,185,21)]; - [appClassField setAlignment: NSLeftTextAlignment]; - [appClassField setBordered: YES]; - [appClassField setEditable: YES]; - [appClassField setBezeled: YES]; - [appClassField setDrawsBackground: YES]; - [appClassField setStringValue:@""]; - [appClassField setTarget:self]; - [appClassField setAction:@selector(setAppClass:)]; - [projectAttributesView addSubview:appClassField]; - RELEASE(appClassField); + }*/ // Icons, Main NIB file, Help file - _iconsBox = [[NSBox alloc] init]; +/* _iconsBox = [[NSBox alloc] init]; [_iconsBox setFrame:NSMakeRect(6,6,290,259)]; [_iconsBox setContentViewMargins:NSMakeSize(4.0, 4.0)]; [_iconsBox setTitlePosition:NSNoTitle]; - [projectAttributesView addSubview:_iconsBox]; + [projectAttributesView addSubview:_iconsBox];*/ // Icon view - _iconViewBox = [[NSBox alloc] initWithFrame:NSMakeRect(220,189,56,56)]; +/* _iconViewBox = [[NSBox alloc] initWithFrame:NSMakeRect(220,189,56,56)]; [_iconViewBox setTitlePosition:NSNoTitle]; [_iconViewBox setBorderType:NSBezelBorder]; [_iconViewBox setContentViewMargins:NSMakeSize(2.0, 2.0)]; @@ -186,110 +73,13 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; iconView = [[NSImageView alloc] initWithFrame:NSMakeRect(220,0,56,56)]; [_iconViewBox addSubview:iconView]; - RELEASE(iconView); + RELEASE(iconView);*/ // TFs Buttons - setAppIconButton = [[NSButton alloc] - initWithFrame:NSMakeRect(220,156,56,24)]; - [setAppIconButton setTitle:@"Set..."]; - [setAppIconButton setRefusesFirstResponder:YES]; - [setAppIconButton setTarget:self]; - [setAppIconButton setAction:@selector(setFile:)]; - [setAppIconButton setEnabled:NO]; - [_iconsBox addSubview:setAppIconButton]; - RELEASE(setAppIconButton); - - clearAppIconButton = [[NSButton alloc] - initWithFrame:NSMakeRect(220,128,56,24)]; - [clearAppIconButton setTitle:@"Clear"]; - [clearAppIconButton setRefusesFirstResponder:YES]; - [clearAppIconButton setTarget:self]; - [clearAppIconButton setAction:@selector(clearFile:)]; - [clearAppIconButton setEnabled:NO]; - [_iconsBox addSubview:clearAppIconButton]; - RELEASE(clearAppIconButton); - - // Application Icon - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(2,227,108,18)]; - [textField setAlignment: NSLeftTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Application Icon:"]; - [_iconsBox addSubview:textField]; - RELEASE(textField); - - appImageField = [[PCITextField alloc] initWithFrame:NSMakeRect(2,206,211,21)]; - [appImageField setAlignment: NSLeftTextAlignment]; - [appImageField setBordered: YES]; - [appImageField setEditable: YES]; - [appImageField setBezeled: YES]; - [appImageField setDrawsBackground: YES]; - [appImageField setStringValue:@""]; - [appImageField setDelegate:self]; - [_iconsBox addSubview:appImageField]; - RELEASE(appImageField); - - // Help File - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(2,188,108,18)]; - [textField setAlignment: NSLeftTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Help File:"]; - [_iconsBox addSubview:textField]; - RELEASE(textField); - - helpFileField = [[PCITextField alloc] initWithFrame:NSMakeRect(2,167,211,21)]; - [helpFileField setAlignment: NSLeftTextAlignment]; - [helpFileField setBordered: YES]; - [helpFileField setEditable: YES]; - [helpFileField setBezeled: YES]; - [helpFileField setDrawsBackground: YES]; - [helpFileField setStringValue:@""]; - [helpFileField setDelegate:self]; - [_iconsBox addSubview:helpFileField]; - RELEASE(helpFileField); - - // Main NIB File - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(2,149,108,18)]; - [textField setAlignment: NSLeftTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Main Interface File:"]; - [_iconsBox addSubview:textField]; - RELEASE(textField); - - mainNIBField = [[PCITextField alloc] initWithFrame:NSMakeRect(2,128,211,21)]; - [mainNIBField setAlignment: NSLeftTextAlignment]; - [mainNIBField setBordered: YES]; - [mainNIBField setEditable: YES]; - [mainNIBField setBezeled: YES]; - [mainNIBField setDrawsBackground: YES]; - [mainNIBField setStringValue:@""]; - [mainNIBField setDelegate:self]; - [_iconsBox addSubview:mainNIBField]; - RELEASE(mainNIBField); + [setFieldButton setRefusesFirstResponder:YES]; + [clearFieldButton setRefusesFirstResponder:YES]; // Document Icons - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(2,107,108,21)]; - [textField setAlignment: NSLeftTextAlignment]; - [textField setBordered: NO]; - [textField setEditable: NO]; - [textField setSelectable: NO]; - [textField setBezeled: NO]; - [textField setDrawsBackground: NO]; - [textField setStringValue:@"Document Icons:"]; - [_iconsBox addSubview:textField]; - RELEASE(textField); - // docExtColumn = [[NSTableColumn alloc] initWithIdentifier: @"extension"]; [[docExtColumn headerCell] setStringValue:@"Extenstion"]; @@ -297,8 +87,7 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; docIconColumn = [[NSTableColumn alloc] initWithIdentifier: @"icon"]; [[docIconColumn headerCell] setStringValue:@"Icon name"]; - docIconsList = [[NSTableView alloc] - initWithFrame:NSMakeRect(2,0,211,108)]; + docIconsList = [[NSTableView alloc] initWithFrame:NSMakeRect(2,0,211,108)]; [docIconsList setAllowsMultipleSelection:NO]; [docIconsList setAllowsColumnReordering:NO]; [docIconsList setAllowsColumnResizing:NO]; @@ -310,40 +99,21 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; [docIconsList setTarget:self]; // - docIconsScroll = [[NSScrollView alloc] initWithFrame: - NSMakeRect (2,0,211,106)]; [docIconsScroll setDocumentView:docIconsList]; [docIconsScroll setHasHorizontalScroller:NO]; [docIconsScroll setHasVerticalScroller:YES]; [docIconsScroll setBorderType:NSBezelBorder]; RELEASE(docIconsList); - [_iconsBox addSubview:docIconsScroll]; - RELEASE(docIconsScroll); - [docIconsList reloadData]; // Document icons buttons - addDocIcon = [[NSButton alloc] initWithFrame:NSMakeRect(220,28,56,24)]; - [addDocIcon setTitle:@"Add"]; [addDocIcon setRefusesFirstResponder:YES]; - [addDocIcon setTarget:self]; - [addDocIcon setAction:@selector(addDocIcon:)]; - [_iconsBox addSubview:addDocIcon]; - RELEASE(addDocIcon); - - removeDocIcon = [[NSButton alloc] initWithFrame:NSMakeRect(220,0,56,24)]; - [removeDocIcon setTitle:@"Remove"]; [removeDocIcon setRefusesFirstResponder:YES]; - [removeDocIcon setTarget:self]; - [removeDocIcon setAction:@selector(removeDocIcon:)]; - [_iconsBox addSubview:removeDocIcon]; - RELEASE(removeDocIcon); - - RELEASE(_iconsBox); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tfGetFocus:) name:PCITextFieldGetFocus object:nil]; + [projectAttributesView retain]; [self updateInspectorValues:nil]; } @@ -352,8 +122,14 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; { if (!projectAttributesView) { + if ([NSBundle loadNibNamed:@"Inspector" owner:self] == NO) + { + NSLog(@"PCAppProject: error loading Inspector NIB!"); + return nil; + } [self createProjectAttributes]; } + return projectAttributesView; } @@ -369,8 +145,6 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; - (void)setIconViewImage:(NSImage *)image { - NSRect frame = {{0,0}, {64, 64}}; - [iconView setImage:nil]; [iconView display]; @@ -379,8 +153,6 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; return; } - frame.size = [image size]; - [iconView setFrame:frame]; [iconView setImage:image]; [iconView display]; } @@ -466,7 +238,6 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; - (BOOL)setAppIconWithImageAtPath:(NSString *)path { -// NSRect frame = {{0,0}, {64, 64}}; NSImage *image = nil; NSString *imageName = nil; @@ -481,15 +252,6 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; [self setIconViewImage:image]; -/* [iconView setImage:nil]; - [iconView display]; - - frame.size = [image size]; - [iconView setFrame:frame]; - [iconView setImage:image]; - [iconView display]; - RELEASE(image);*/ - [self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCImages]; [infoDict setObject:imageName forKey:@"NSIcon"]; @@ -699,7 +461,7 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; if (![file isEqualToString:@""]) { - path = [self dirForCategory:PCImages]; + path = [self dirForCategoryKey:PCImages]; path = [path stringByAppendingPathComponent:file]; [self setIconViewImage:[[NSImage alloc] initWithContentsOfFile:path]]; @@ -723,8 +485,8 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; activeTextField = mainNIBField; } - [setAppIconButton setEnabled:YES]; - [clearAppIconButton setEnabled:YES]; + [setFieldButton setEnabled:YES]; + [clearFieldButton setEnabled:YES]; } - (void)controlTextDidEndEditing:(NSNotification *)aNotification @@ -742,8 +504,8 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; activeTextField = nil; [self setIconViewImage:nil]; - [setAppIconButton setEnabled:NO]; - [clearAppIconButton setEnabled:NO]; + [setFieldButton setEnabled:NO]; + [clearFieldButton setEnabled:NO]; } @end diff --git a/Modules/ApplicationProject/PCAppProject.h b/Modules/ApplicationProject/PCAppProject.h index d7c692d..7e16652 100644 --- a/Modules/ApplicationProject/PCAppProject.h +++ b/Modules/ApplicationProject/PCAppProject.h @@ -37,37 +37,38 @@ #include #include -@class PCITextField; +@interface PCAppTextField : NSTextField +{ +} + +@end @interface PCAppProject : PCProject { - NSBox *projectAttributesView; - NSTextField *projectTypeField; - NSTextField *projectNameField; - NSTextField *projectLanguageField; - NSTextField *appClassField; + IBOutlet NSBox *projectAttributesView; + IBOutlet NSTextField *projectTypeField; + IBOutlet NSTextField *projectNameField; + IBOutlet NSTextField *projectLanguageField; + IBOutlet NSTextField *appClassField; - PCITextField *activeTextField; - PCITextField *appImageField; - PCITextField *helpFileField; - PCITextField *mainNIBField; + PCAppTextField *activeTextField; + IBOutlet PCAppTextField *appImageField; + IBOutlet PCAppTextField *helpFileField; + IBOutlet PCAppTextField *mainNIBField; - NSImageView *iconView; - NSImage *icon; - NSButton *setAppIconButton; - NSButton *clearAppIconButton; + IBOutlet NSImageView *iconView; + NSImage *icon; + IBOutlet NSButton *setFieldButton; + IBOutlet NSButton *clearFieldButton; - NSTableView *docIconsList; - NSTableColumn *docExtColumn; - NSTableColumn *docIconColumn; - NSMutableArray *docIconsItems; - NSScrollView *docIconsScroll; + NSTableView *docIconsList; + NSTableColumn *docExtColumn; + NSTableColumn *docIconColumn; + NSMutableArray *docIconsItems; + IBOutlet NSScrollView *docIconsScroll; - NSBrowser *docIconsBrowser; - NSPopUpButton *iconNamePopup; - NSPopUpButton *extensionPopup; - NSButton *addDocIcon; - NSButton *removeDocIcon; + IBOutlet NSButton *addDocIcon; + IBOutlet NSButton *removeDocIcon; NSMutableDictionary *infoDict; } diff --git a/Modules/ApplicationProject/PCAppProject.m b/Modules/ApplicationProject/PCAppProject.m index 95f1c84..c6aa156 100644 --- a/Modules/ApplicationProject/PCAppProject.m +++ b/Modules/ApplicationProject/PCAppProject.m @@ -42,36 +42,38 @@ if ((self = [super init])) { - rootObjects = [[NSArray arrayWithObjects: PCClasses, - PCHeaders, - PCOtherSources, - PCInterfaces, - PCImages, - PCOtherResources, - PCSubprojects, - PCDocuFiles, - PCSupportingFiles, - PCLibraries, - PCNonProject, - nil] retain]; + rootKeys = [[NSArray arrayWithObjects: + PCClasses, + PCHeaders, + PCOtherSources, + PCInterfaces, + 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]; + rootCategories = [[NSArray arrayWithObjects: + @"Classes", + @"Headers", + @"Other Sources", + @"Interfaces", + @"Images", + @"Other Resources", + @"Subprojects", + @"Documentation", +// @"Context Help", + @"Supporting Files", +// @"Frameworks", + @"Libraries", + @"Non Project Files", + nil] retain]; + + rootEntries = [[NSDictionary + dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; } return self; @@ -107,8 +109,8 @@ RELEASE(projectAttributesView); RELEASE(rootCategories); - RELEASE(rootObjects); RELEASE(rootKeys); + RELEASE(rootEntries); [super dealloc]; } @@ -137,35 +139,35 @@ return [NSString stringWithString:@"openapp"]; } -- (NSArray *)fileTypesForCategory:(NSString *)category +- (NSArray *)fileTypesForCategoryKeyy:(NSString *)key { // NSLog(@"Category: %@", category); - if ([category isEqualToString:PCClasses]) + if ([key isEqualToString:PCClasses]) { return [NSArray arrayWithObjects:@"m",nil]; } - else if ([category isEqualToString:PCHeaders]) + else if ([key isEqualToString:PCHeaders]) { return [NSArray arrayWithObjects:@"h",nil]; } - else if ([category isEqualToString:PCOtherSources]) + else if ([key isEqualToString:PCOtherSources]) { return [NSArray arrayWithObjects:@"c",@"C",nil]; } - else if ([category isEqualToString:PCInterfaces]) + else if ([key isEqualToString:PCInterfaces]) { return [NSArray arrayWithObjects:@"gmodel",@"gorm",nil]; } - else if ([category isEqualToString:PCImages]) + else if ([key isEqualToString:PCImages]) { return [NSImage imageFileTypes]; } - else if ([category isEqualToString:PCSubprojects]) + else if ([key isEqualToString:PCSubprojects]) { return [NSArray arrayWithObjects:@"subproj",nil]; } - else if ([category isEqualToString:PCLibraries]) + else if ([key isEqualToString:PCLibraries]) { return [NSArray arrayWithObjects:@"so",@"a",@"lib",nil]; } @@ -173,13 +175,13 @@ return nil; } -- (NSString *)dirForCategory:(NSString *)category +- (NSString *)dirForCategoryKey:(NSString *)key { - if ([category isEqualToString:PCImages]) + if ([key isEqualToString:PCImages]) { return [projectPath stringByAppendingPathComponent:@"Images"]; } - else if ([category isEqualToString:PCDocuFiles]) + else if ([key isEqualToString:PCDocuFiles]) { return [projectPath stringByAppendingPathComponent:@"Documentation"]; } @@ -285,7 +287,7 @@ { NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; NSString *appIcon = [projectDict objectForKey:PCAppIcon]; - NSString *key = [self selectedRootCategory]; + NSString *key = [self selectedRootCategoryKey]; NSString *ff = [fromFile copy]; NSString *tf = [toFile copy]; BOOL success = NO; @@ -298,7 +300,7 @@ if ([super renameFile:ff toFile:tf] == YES) { [self setMainNibWithFileAtPath: - [[self dirForCategory:key] stringByAppendingPathComponent:tf]]; + [[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]]; success = YES; } } @@ -310,10 +312,14 @@ if ([super renameFile:ff toFile:tf] == YES) { [self setAppIconWithImageAtPath: - [[self dirForCategory:key] stringByAppendingPathComponent:tf]]; + [[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]]; success = YES; } } + + [projectBrowser setPathForFile:toFile + category:[self categoryForKey:key]]; + [ff release]; [tf release]; diff --git a/Modules/BundleProject/PCBundleProject.m b/Modules/BundleProject/PCBundleProject.m index 7e0a164..aa8e70f 100644 --- a/Modules/BundleProject/PCBundleProject.m +++ b/Modules/BundleProject/PCBundleProject.m @@ -40,7 +40,7 @@ { if ((self = [super init])) { - rootObjects = [[NSArray arrayWithObjects: PCClasses, + rootKeys = [[NSArray arrayWithObjects: PCClasses, PCHeaders, PCOtherSources, PCInterfaces, @@ -53,7 +53,7 @@ PCNonProject, nil] retain]; - rootKeys = [[NSArray arrayWithObjects: @"Classes", + rootCategories = [[NSArray arrayWithObjects: @"Classes", @"Headers", @"Other Sources", @"Interfaces", @@ -66,8 +66,8 @@ @"Non Project Files", nil] retain]; - rootCategories = [[NSDictionary - dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + rootEntries = [[NSDictionary + dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; } @@ -77,8 +77,9 @@ - (void)dealloc { [rootCategories release]; - [rootObjects release]; [rootKeys release]; + [rootEntries release]; + [projectAttributesView release]; [super dealloc]; diff --git a/Modules/LibraryProject/PCLibProject.m b/Modules/LibraryProject/PCLibProject.m index b6c7bd5..9efcb2d 100644 --- a/Modules/LibraryProject/PCLibProject.m +++ b/Modules/LibraryProject/PCLibProject.m @@ -52,7 +52,7 @@ - (id)init { if ((self = [super init])) { - rootObjects = [[NSArray arrayWithObjects: PCClasses, + rootKeys = [[NSArray arrayWithObjects: PCClasses, PCHeaders, PCOtherSources, PCOtherResources, @@ -63,7 +63,7 @@ PCNonProject, nil] retain]; - rootKeys = [[NSArray arrayWithObjects: @"Classes", + rootCategories = [[NSArray arrayWithObjects: @"Classes", @"Headers", @"Other Sources", @"Other Resources", @@ -74,8 +74,8 @@ @"Non Project Files", nil] retain]; - rootCategories = [[NSDictionary - dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + rootEntries = [[NSDictionary + dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; } return self; @@ -84,8 +84,8 @@ - (void)dealloc { [rootCategories release]; - [rootObjects release]; [rootKeys release]; + [rootEntries release]; [super dealloc]; } diff --git a/Modules/RenaissanceProject/PCRenaissanceProject.m b/Modules/RenaissanceProject/PCRenaissanceProject.m index ae11594..44cefe7 100644 --- a/Modules/RenaissanceProject/PCRenaissanceProject.m +++ b/Modules/RenaissanceProject/PCRenaissanceProject.m @@ -121,7 +121,7 @@ { if ((self = [super init])) { - rootObjects = [[NSArray arrayWithObjects: PCClasses, + rootKeys = [[NSArray arrayWithObjects: PCClasses, PCHeaders, PCOtherSources, PCInterfaces, @@ -134,7 +134,7 @@ PCNonProject, nil] retain]; - rootKeys = [[NSArray arrayWithObjects: @"Classes", + rootCategories = [[NSArray arrayWithObjects: @"Classes", @"Headers", @"Other Sources", @"Interfaces", @@ -147,8 +147,8 @@ @"Non Project Files", nil] retain]; - rootCategories = [[NSDictionary - dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + rootEntries = [[NSDictionary + dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; } return self; @@ -157,8 +157,9 @@ - (void)dealloc { RELEASE(rootCategories); - RELEASE(rootObjects); RELEASE(rootKeys); + RELEASE(rootEntries); + RELEASE(appClassField); RELEASE(appImageField); diff --git a/Modules/ToolProject/PCToolProject.m b/Modules/ToolProject/PCToolProject.m index 7b1e8be..a49565a 100644 --- a/Modules/ToolProject/PCToolProject.m +++ b/Modules/ToolProject/PCToolProject.m @@ -53,7 +53,7 @@ { if ((self = [super init])) { - rootObjects = [[NSArray arrayWithObjects: PCClasses, + rootKeys = [[NSArray arrayWithObjects: PCClasses, PCHeaders, PCOtherSources, PCImages, @@ -65,7 +65,7 @@ PCNonProject, nil] retain]; - rootKeys = [[NSArray arrayWithObjects: @"Classes", + rootCategories = [[NSArray arrayWithObjects: @"Classes", @"Headers", @"Other Sources", @"Images", @@ -77,8 +77,8 @@ @"Non Project Files", nil] retain]; - rootCategories = [[NSDictionary - dictionaryWithObjects:rootObjects forKeys:rootKeys] retain]; + rootEntries = [[NSDictionary + dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; } @@ -88,8 +88,8 @@ - (void)dealloc { [rootCategories release]; - [rootObjects release]; [rootKeys release]; + [rootEntries release]; [super dealloc]; } diff --git a/PCMenuController.m b/PCMenuController.m index 91aed40..9e79046 100644 --- a/PCMenuController.m +++ b/PCMenuController.m @@ -198,7 +198,9 @@ else { PCProject *project = [projectManager activeProject]; - NSString *category = [[[project rootCategories] allKeysForObject:PCNonProject] objectAtIndex:0]; + NSString *category = nil; + + category = [[project rootEntries] objectForKey:PCNonProject]; [projectManager closeFile]; [project addFiles:[NSArray arrayWithObject:newFilePath] @@ -210,6 +212,7 @@ } } + - (void)fileSaveTo:(id)sender { [projectManager saveFileTo];