diff --git a/Documentation/SCHEME b/Documentation/SCHEME index 6430299..7c48da8 100644 --- a/Documentation/SCHEME +++ b/Documentation/SCHEME @@ -25,25 +25,24 @@ PCMenuController/ | || | +- [SI]PCProjectFinder | | | +- PCProjectEditor - | - PCEditorController - | || - | PCEditor - | | - | +- PCEditorView + | || + | PCEditor + | | + | +- PCEditorView | PCTextFinder | PCFileManager + | + +- PCFileCreator ------------------------------ Other (controls, tools, etc.): ------------------------------ PCButton PCSplitView -PCOutputView +PCOutputView (Should be implemented. Used by e.g. Project Builder) PCBundleLoader (Used in ProjectCenter application) -PCFileManager (Used in PCLib) PCMakefileFactory (Used in PC*Project bundles) PCServer (don't used) @@ -55,10 +54,10 @@ Part I: descendants; + implement PCLaunchPanel; + implement PCHistoryPanel (also make PCProjectHistory be a separate); -- implement PCInspectorPanel and move common inspectors to its suitable ++ implement PCInspectorPanel and move common inspectors to its suitable position; -- implement PCProjectFinder and PCFindPanel GUI; - refactor PC*Editor* family; +- implement PCProjectFinder and PCFindPanel GUI; - make PC prefernces changes applying immediately after changing; Part II: diff --git a/Library/GNUmakefile b/Library/GNUmakefile index 3f08cfc..ca4fe26 100644 --- a/Library/GNUmakefile +++ b/Library/GNUmakefile @@ -63,7 +63,6 @@ libProjectCenter_HEADER_FILES = \ PCEditor+UInterface.h \ PCEditorView.h \ PCEditorView+Highlighting.h \ - PCEditorController.h \ PCTextFinder.h \ PCTextFinder+UInterface.h \ \ @@ -109,7 +108,6 @@ libProjectCenter_OBJC_FILES = \ PCEditor+UInterface.m \ PCEditorView.m \ PCEditorView+Highlighting.m \ - PCEditorController.m \ PCTextFinder.m \ PCTextFinder+UInterface.m diff --git a/Library/GNUmakefile.postamble b/Library/GNUmakefile.postamble index f22ccb2..1dcf7bf 100644 --- a/Library/GNUmakefile.postamble +++ b/Library/GNUmakefile.postamble @@ -29,3 +29,7 @@ before-all:: after-clean:: rm -f ProjectCenter +after-uninstall:: + rm -rf $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/ProjectCenter + rm -rf $(GNUSTEP_SYSTEM_ROOT)/Library/Libraries/Resources/ProjectCenter + diff --git a/Library/PCDefines.h b/Library/PCDefines.h index 5889139..daf9355 100644 --- a/Library/PCDefines.h +++ b/Library/PCDefines.h @@ -33,7 +33,7 @@ #define TabBehaviour @"TabBehaviour" #define SeparateBuilder @"SeparateBuilder" #define SeparateLauncher @"SeparateLauncher" -#define SeparateHistory @"SeparateLauncher" +#define SeparateHistory @"SeparateHistory" #define SeparateEditor @"SeparateEditor" #define PCAppDidInitNotification @"PCAppDidInit" diff --git a/Library/PCEditorController.h b/Library/PCEditorController.h deleted file mode 100644 index be5f58a..0000000 --- a/Library/PCEditorController.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * PCEditorController.h created by probert on 2002-02-02 15:28:33 +0000 - * - * Project ProjectCenter - * - * Created with ProjectCenter - http://www.gnustep.org - * - * $Id$ - */ - -#ifndef _PCEDITORCONTROLLER_H_ -#define _PCEDITORCONTROLLER_H_ - -#include - -@class PCProject; -@class PCEditor; - -@interface PCEditorController : NSObject -{ - PCProject *project; - NSMutableDictionary *editorDict; -} - -// =========================================================================== -// ==== Class Methods -// =========================================================================== - -+ (void)openFileInEditor:(NSString *)path; - -// =========================================================================== -// ==== Initialisation -// =========================================================================== - -- (id)init; -- (void)dealloc; - -// =========================================================================== -// ==== Project and Editor handling -// =========================================================================== - -- (void)setProject:(PCProject *)aProject; - -- (PCEditor *)internalEditorForFile:(NSString *)path; -- (PCEditor *)editorForFile:(NSString *)path; -- (PCEditor *)activeEditor; -- (NSArray *)allEditors; -- (void)closeEditorForFile:(NSString *)file; -- (void)closeAllEditors; - - -// =========================================================================== -// ==== File handling -// =========================================================================== - -- (BOOL)saveAllFiles; -- (BOOL)saveFile; -- (BOOL)saveFileAs:(NSString *)file; -- (BOOL)saveFileTo:(NSString *)file; -- (void)closeFile:(id)sender; -- (BOOL)revertFileToSaved; - -// =========================================================================== -// ==== Delegate -// =========================================================================== - -- (void)editorDidClose:(id)sender; -- (void)setBrowserPath:(NSString *)file category:(NSString *)category; - -@end - -#endif // _PCEDITORCONTROLLER_H_ - diff --git a/Library/PCEditorController.m b/Library/PCEditorController.m deleted file mode 100644 index b849bf1..0000000 --- a/Library/PCEditorController.m +++ /dev/null @@ -1,305 +0,0 @@ -/* - * PCEditorController.m created by probert on 2002-02-02 15:28:31 +0000 - * - * Project ProjectCenter - * - * Created with ProjectCenter - http://www.gnustep.org - * - * $Id$ - */ - -#include "PCProjectEditor.h" -#include "PCEditorController.h" -#include "PCEditorView.h" -#include "PCDefines.h" -#include "PCProject.h" -#include "PCEditor.h" -#include "PCProject+ComponentHandling.h" -#include "PCProjectBrowser.h" -#include "PCProjectWindow.h" - -@implementation PCEditorController - -// =========================================================================== -// ==== Class Methods -// =========================================================================== - -+ (void)openFileInEditor:(NSString *)path -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - - if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"]) - { - NSTask *editorTask; - NSMutableArray *args; - NSString *editor = [ud objectForKey:Editor]; - NSString *app; - NSArray *ea = [editor componentsSeparatedByString: @" "]; - - args = [NSMutableArray arrayWithArray:ea]; - app = [args objectAtIndex: 0]; - - if( [[app pathExtension] isEqualToString:@"app"] ) - { - BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path - withApplication:app]; - - if( ret == NO ) - { - NSLog(@"Could not open %@ using %@",path,app); - } - - return; - } - - editorTask = [[NSTask alloc] init]; - - [editorTask setLaunchPath:app]; - [args removeObjectAtIndex: 0]; - [args addObject:path]; - - [editorTask setArguments:args]; - - AUTORELEASE( editorTask ); - [editorTask launch]; - } - else - { - PCEditor *editor; - - editor = [[PCEditor alloc] initWithPath:path]; - [editor setDelegate:self]; - [editor show]; - } -} - -// =========================================================================== -// ==== Initialisation -// =========================================================================== - -- (id)init -{ - if((self = [super init])) - { - editorDict = [[NSMutableDictionary alloc] init]; - } - return self; -} - -- (void)dealloc -{ - [editorDict removeAllObjects]; - RELEASE( editorDict ); - - [super dealloc]; -} - -// =========================================================================== -// ==== Project and Editor handling -// =========================================================================== - -- (void)setProject:(PCProject *)aProject -{ - project = aProject; -} - -- (PCEditor *)internalEditorForFile:(NSString *)path -{ - PCEditor *editor; - - if((editor = [editorDict objectForKey:path])) - { - return editor; - } - else - { - editor = [[PCEditor alloc] initWithPath:path]; - - [editor setDelegate:self]; - - [editorDict setObject:editor forKey:path]; - //RELEASE(editor); - - return editor; - } -} - -- (PCEditor *)editorForFile:(NSString *)path -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - - if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"]) - { - [PCEditorController openFileInEditor:path]; - - return nil; - } - else - { - return [self internalEditorForFile:path]; - } -} - -- (PCEditor *)activeEditor -{ - NSEnumerator *enumerator = [editorDict keyEnumerator]; - PCEditor *editor; - NSString *key; - NSWindow *window; - - while(( key = [enumerator nextObject] )) - { - editor = [editorDict objectForKey:key]; - window = [editor editorWindow]; - - if (([window isVisible] && [window isKeyWindow]) - || ([[editor internalView] superview] - && [[project projectWindow] isKeyWindow])) - { - return editor; - } - } - - return nil; -} - -- (NSArray *)allEditors -{ - 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]; - PCEditor *editor; - NSString *key; - - while ((key = [enumerator nextObject])) - { - editor = [editorDict objectForKey:key]; - [editor closeFile:self]; - } - [editorDict removeAllObjects]; -} - -// =========================================================================== -// ==== File handling -// =========================================================================== - -- (BOOL)saveAllFiles -{ - NSEnumerator *enumerator = [editorDict keyEnumerator]; - PCEditor *editor; - NSString *key; - BOOL ret = YES; - - while(( key = [enumerator nextObject] )) - { - editor = [editorDict objectForKey:key]; - - if( [editor saveFileIfNeeded] == NO ) - { - ret = NO; - } - } - - return ret; -} - -- (BOOL)saveFile -{ - PCEditor *editor = [self activeEditor]; - - if (editor != nil) - { - return [editor saveFileIfNeeded]; - } - - return NO; -} - -- (BOOL)saveFileAs:(NSString *)file -{ - PCEditor *editor = [self activeEditor]; - - if (editor != nil) - { - BOOL res; - res = [editor saveFileTo:file]; - [editor closeFile:self]; - - [[self internalEditorForFile:file] - showInProjectEditor:[project projectEditor]]; - return res; - } - - return NO; -} - -- (BOOL)saveFileTo:(NSString *)file -{ - PCEditor *editor = [self activeEditor]; - - if (editor != nil) - { - return [editor saveFileTo:file]; - } - - return NO; -} - -- (BOOL)revertFileToSaved -{ - PCEditor *editor = [self activeEditor]; - - if (editor != nil) - { - return [editor revertFileToSaved]; - } - - return NO; -} - -- (void)closeFile:(id)sender -{ - [[self activeEditor] closeFile:self]; -} - -// =========================================================================== -// ==== Delegate -// =========================================================================== - -- (void)editorDidClose:(id)sender -{ - PCEditor *editor = (PCEditor*)sender; - - [editorDict removeObjectForKey:[editor path]]; - - if ([editorDict count]) - { - editor = [editorDict objectForKey: [[editorDict allKeys] lastObject]]; - [editor showInProjectEditor: [project projectEditor]]; - [[project projectWindow] makeFirstResponder:[editor internalView]]; - } - else - { - [[project projectEditor] setEditorView:nil]; -// [[project browserController] projectDictDidChange:nil]; - } -} - -- (void)setBrowserPath:(NSString *)file category:(NSString *)category -{ - [[project projectBrowser] setPathForFile:file category:category]; -} - -@end diff --git a/Library/PCProject+ComponentHandling.h b/Library/PCProject+ComponentHandling.h index 780a7e8..bf65e1f 100644 --- a/Library/PCProject+ComponentHandling.h +++ b/Library/PCProject+ComponentHandling.h @@ -12,10 +12,7 @@ @interface PCProject (ComponentHandling) -//- (void)showBuildView:(id)sender; -//- (void)showRunView:(id)sender; - (void)showEditorView:(id)sender; -- (void)showInspector:(id)sender; - (void)runSelectedTarget:(id)sender; diff --git a/Library/PCProject+ComponentHandling.m b/Library/PCProject+ComponentHandling.m index 99211f1..3a2915b 100644 --- a/Library/PCProject+ComponentHandling.m +++ b/Library/PCProject+ComponentHandling.m @@ -22,104 +22,6 @@ @implementation PCProject (ComponentHandling) -/*- (void)showBuildView:(id)sender -{ - BOOL separate = NO; - NSView *view = nil; - NSPanel *buildPanel = nil; - - if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - objectForKey: SeparateBuilder] isEqualToString: @"YES"]) - { - separate = YES; - } - - view = [[self projectBuilder] componentView]; - buildPanel = [projectManager buildPanel]; - - if (separate) - { - if ([projectWindow customContentView] == view) - { - [self showEditorView:self]; - } - [buildPanel orderFront: nil]; - } - else - { - if (buildPanel) - { - [buildPanel close]; - } - [projectWindow setCustomContentView:view]; - } - [projectBuilder setTooltips]; -}*/ - -/*- (void)showRunView:(id)sender -{ - NSView *view = nil; - BOOL separate = NO; - - if ([self isExecutable] == NO) - { - NSRunAlertPanel(@"Attention!", - @"This project is not executable!", - @"OK",nil,nil); - return; - } - - if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - objectForKey: SeparateLauncher] isEqualToString: @"YES"]) - { - separate = YES; - } - - [[NSNotificationCenter defaultCenter] - postNotificationName: PCEditorDidResignKeyNotification - object: self]; - - editorIsActive = NO; - - if (!projectDebugger) - { - projectDebugger = [[PCProjectLauncher alloc] initWithProject:self]; - } - - view = [[projectDebugger componentView] retain]; - - if (separate) - { - NSPanel *panel = [projectDebugger createLaunchPanel]; - NSRect frame = [NSPanel contentRectForFrameRect: [panel frame] - styleMask: [panel styleMask]]; - - frame.origin.x = 8; - frame.origin.y = -2; - frame.size.height += 2; - frame.size.width -= 16; - [view setFrame: frame]; - - if ([projectWindow customContentView] == view) - { - [self showEditorView: self]; - } - [[panel contentView] addSubview: view]; - [panel orderFront: nil]; - } - else - { - NSPanel *panel = [projectDebugger launchPanel]; - - if (panel) - { - [panel close]; - } - [projectWindow setCustomContentView: view]; - } - [projectDebugger setTooltips]; -}*/ - - (void)showEditorView:(id)sender { NSView *view = nil; @@ -140,12 +42,6 @@ [projectWindow setCustomContentView:view]; } -- (void)showInspector:(id)sender -{ - [self createInspectors]; - [[[projectManager projectInspector] panel] makeKeyAndOrderFront:self]; -} - // - (void)runSelectedTarget:(id)sender { diff --git a/Library/PCProject.h b/Library/PCProject.h index ea84539..86e7799 100644 --- a/Library/PCProject.h +++ b/Library/PCProject.h @@ -124,7 +124,6 @@ static NSString * const PCBuildTool = @"BUILDTOOL"; @class PCProjectBuilder; @class PCProjectLauncher; @class PCProjectEditor; -@class PCEditorController; #ifndef GNUSTEP_BASE_VERSION @protocol ProjectBuilder; @@ -142,6 +141,7 @@ extern NSString *ProjectDictDidSaveNotification; PCProjectWindow *projectWindow; PCProjectBrowser *projectBrowser; PCProjectHistory *projectHistory; + PCProjectEditor *projectEditor; PCProjectBuilder *projectBuilder; PCProjectLauncher *projectLauncher; @@ -150,8 +150,6 @@ extern NSString *ProjectDictDidSaveNotification; // For compatibility. Should be changed later NSView *projectProjectInspectorView; - PCProjectEditor *projectEditor; - PCEditorController *editorController; // NSMutableDictionary *projectDict; @@ -187,9 +185,7 @@ extern NSString *ProjectDictDidSaveNotification; - (PCProjectHistory *)projectHistory; - (PCProjectBuilder *)projectBuilder; - (PCProjectLauncher *)projectLauncher; - - (PCProjectEditor *)projectEditor; -- (PCEditorController *)editorController; - (NSString *)projectName; - (void)setProjectName:(NSString *)aName; @@ -245,7 +241,6 @@ extern NSString *ProjectDictDidSaveNotification; - (BOOL)addAndCopyFiles:(NSArray *)files forKey:(NSString *)key; - (void)addFiles:(NSArray *)files forKey:(NSString *)key; - - (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key; - (void)renameFile:(NSString *)aFile; diff --git a/Library/PCProject.m b/Library/PCProject.m index 703e1da..c475b03 100644 --- a/Library/PCProject.m +++ b/Library/PCProject.m @@ -40,7 +40,6 @@ #include "PCProjectEditor.h" #include "PCProjectLauncher.h" #include "PCEditor.h" -#include "PCEditorController.h" NSString *ProjectDictDidSetNotification = @"ProjectDictDidSetNotification"; NSString *ProjectDictDidChangeNotification = @"ProjectDictDidChangeNotification"; @@ -59,13 +58,10 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; buildOptions = [[NSMutableDictionary alloc] init]; projectBrowser = [[PCProjectBrowser alloc] initWithProject:self]; projectHistory = [[PCProjectHistory alloc] initWithProject:self]; + projectEditor = [[PCProjectEditor alloc] initWithProject:self]; projectWindow = [[PCProjectWindow alloc] initWithProject:self]; - projectBuilder = nil; projectLauncher = nil; - - editorController = [[PCEditorController alloc] init]; - [editorController setProject:self]; } return self; @@ -111,7 +107,7 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; - (void)close { - [editorController closeAllEditors]; + [projectEditor closeAllEditors]; [projectManager closeProject:self]; } @@ -133,7 +129,7 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; if (projectLauncher) RELEASE(projectLauncher); if (projectEditor) RELEASE(projectEditor); - RELEASE(editorController); + RELEASE(projectEditor); RELEASE(buildOptions); @@ -184,11 +180,6 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; return projectEditor; } -- (PCEditorController*)editorController -{ - return editorController; -} - - (NSString *)selectedRootCategory { NSString *_path = [[self projectBrowser] pathOfSelectedFile]; @@ -333,7 +324,7 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; // [fileNameField setStringValue:fileName]; // Show the file in the internal editor! - e = [editorController internalEditorForFile:p]; + e = [projectEditor internalEditorForFile:p]; if( e == nil ) { @@ -352,7 +343,7 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; { PCEditor *e; - e = [editorController editorForFile:fileName]; + e = [projectEditor editorForFile:fileName]; if (e) { @@ -453,38 +444,17 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification"; NSString *filePath = nil; NSString *file = nil; NSMutableArray *projectFiles = nil; - NSMutableArray *filesToRemove = [[files mutableCopy] autorelease]; - NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; - - if (!files || !key) - { - return NO; - } - - // Check for main NIB files - if ([key isEqualToString:PCInterfaces] && [files containsObject:mainNibFile]) - { - int ret; - ret = NSRunAlertPanel(@"Remove", - @"You've selected to remove main interface file.\nDo you still want to remove it?", - @"Remove", @"Leave", nil); - - if (ret == NSAlertAlternateReturn) // Leave - { - [filesToRemove removeObject:mainNibFile]; - } - } // Remove files from project projectFiles = [NSMutableArray arrayWithArray:[projectDict objectForKey:key]]; - enumerator = [filesToRemove objectEnumerator]; + enumerator = [files objectEnumerator]; while ((file = [enumerator nextObject])) { [projectFiles removeObject:file]; // Close editor filePath = [projectPath stringByAppendingPathComponent:file]; - [editorController closeEditorForFile:filePath]; + [projectEditor closeEditorForFile:filePath]; } [projectDict setObject:projectFiles forKey:key]; diff --git a/Library/PCProjectBrowser.m b/Library/PCProjectBrowser.m index fbfd543..64a3f1a 100644 --- a/Library/PCProjectBrowser.m +++ b/Library/PCProjectBrowser.m @@ -25,7 +25,7 @@ #include "PCFileManager.h" #include "PCProjectManager.h" #include "PCProject.h" -#include "PCEditorController.h" +#include "PCProjectEditor.h" #include "PCProjectBrowser.h" NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; @@ -230,7 +230,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; NSString *path = [[browserPath componentsSeparatedByString:@"/"] objectAtIndex:1]; if (![browserPath isEqualToString:path] - && [[[project editorController] allEditors] count] == 0) + && [[[project projectEditor] allEditors] count] == 0) { [self setPathForFile:nil category:path]; } diff --git a/Library/PCProjectEditor.h b/Library/PCProjectEditor.h index 32f325f..f4fd4c3 100644 --- a/Library/PCProjectEditor.h +++ b/Library/PCProjectEditor.h @@ -8,16 +8,18 @@ * $Id$ */ -#ifndef _PCPROJECTEDITOR_H_ -#define _PCPROJECTEDITOR_H_ +#ifndef _PCProjectEditor_h_ +#define _PCProjectEditor_h_ #include +@class PCProject; +@class PCEditor; +@class PCEditorView; + @class NSBox; @class NSView; @class NSScrollView; -@class PCEditorView; -@class PCProject; #ifndef GNUSTEP_BASE_VERSION @protocol ProjectComponent; @@ -27,21 +29,62 @@ @interface PCProjectEditor : NSObject { - NSBox *_componentView; - PCProject *_currentProject; - PCEditorView *_editorView; - NSScrollView *_scrollView; + PCProject *project; + NSMutableDictionary *editorsDict; + NSBox *componentView; + PCEditorView *editorView; + NSScrollView *scrollView; } -- (id)initWithProject:(PCProject *)aProject; -- (void)dealloc; - -- (NSView *)componentView; - - (void)setEditorView:(PCEditorView *)ev; - (PCEditorView *)editorView; +// =========================================================================== +// ==== Class Methods +// =========================================================================== + ++ (void)openFileInEditor:(NSString *)path; + +// =========================================================================== +// ==== Initialisation +// =========================================================================== + +- (id)initWithProject:(PCProject *)aProject; +- (void)dealloc; +- (NSView *)emptyEditorView; +- (NSView *)componentView; + +// =========================================================================== +// ==== Project and Editor handling +// =========================================================================== + +- (PCEditor *)internalEditorForFile:(NSString *)path; +- (PCEditor *)editorForFile:(NSString *)path; +- (PCEditor *)activeEditor; +- (NSArray *)allEditors; +- (void)closeEditorForFile:(NSString *)file; +- (void)closeAllEditors; + + +// =========================================================================== +// ==== File handling +// =========================================================================== + +- (BOOL)saveAllFiles; +- (BOOL)saveFile; +- (BOOL)saveFileAs:(NSString *)file; +- (BOOL)saveFileTo:(NSString *)file; +- (void)closeFile:(id)sender; +- (BOOL)revertFileToSaved; + +// =========================================================================== +// ==== Delegate +// =========================================================================== + +- (void)editorDidClose:(id)sender; +- (void)setBrowserPath:(NSString *)file category:(NSString *)category; + @end -#endif // _PCPROJECTEDITOR_H_ +#endif diff --git a/Library/PCProjectEditor.m b/Library/PCProjectEditor.m index a633f6b..f1bfdd3 100644 --- a/Library/PCProjectEditor.m +++ b/Library/PCProjectEditor.m @@ -8,8 +8,12 @@ * $Id$ */ -#include "PCProjectEditor.h" #include "PCDefines.h" +#include "PCProject.h" +#include "PCProjectWindow.h" +#include "PCProjectBrowser.h" +#include "PCProjectEditor.h" +#include "PCEditor.h" #include "PCEditorView.h" #include "ProjectComponent.h" @@ -27,21 +31,21 @@ NSTextView *textView; frame = NSMakeRect(0,0,562,248); - _componentView = [[NSBox alloc] initWithFrame:frame]; - [_componentView setTitlePosition: NSNoTitle]; - [_componentView setBorderType: NSNoBorder]; - [_componentView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; - [_componentView setContentViewMargins: NSMakeSize(0.0,0.0)]; + componentView = [[NSBox alloc] initWithFrame:frame]; + [componentView setTitlePosition: NSNoTitle]; + [componentView setBorderType: NSNoBorder]; + [componentView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; + [componentView setContentViewMargins: NSMakeSize(0.0,0.0)]; frame = NSMakeRect (0, 0, 562, 40); - _scrollView = [[NSScrollView alloc] initWithFrame:frame]; - [_scrollView setHasHorizontalScroller: NO]; - [_scrollView setHasVerticalScroller: YES]; - [_scrollView setBorderType: NSBezelBorder]; - [_scrollView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)]; + scrollView = [[NSScrollView alloc] initWithFrame:frame]; + [scrollView setHasHorizontalScroller: NO]; + [scrollView setHasVerticalScroller: YES]; + [scrollView setBorderType: NSBezelBorder]; + [scrollView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)]; // This is a placeholder! - frame = [[_scrollView contentView] frame]; + frame = [[scrollView contentView] frame]; textView = [[NSTextView alloc] initWithFrame:frame]; [textView setMinSize: NSMakeSize (0, 0)]; [textView setMaxSize: NSMakeSize(1e7, 1e7)]; @@ -52,21 +56,77 @@ [textView setHorizontallyResizable: NO]; [textView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)]; [[textView textContainer] setWidthTracksTextView: YES]; - [_scrollView setDocumentView: textView]; + [scrollView setDocumentView: textView]; RELEASE(textView); - frame.size = NSMakeSize([_scrollView contentSize].width,1e7); + frame.size = NSMakeSize([scrollView contentSize].width,1e7); [[textView textContainer] setContainerSize:frame.size]; - [_componentView addSubview:_scrollView]; - RELEASE(_scrollView); + [componentView addSubview:scrollView]; + RELEASE(scrollView); - [_componentView sizeToFit]; + [componentView sizeToFit]; } @end @implementation PCProjectEditor +// =========================================================================== +// ==== Class Methods +// =========================================================================== + ++ (void)openFileInEditor:(NSString *)path +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"]) + { + NSTask *editorTask; + NSMutableArray *args; + NSString *editor = [ud objectForKey:Editor]; + NSString *app; + NSArray *ea = [editor componentsSeparatedByString: @" "]; + + args = [NSMutableArray arrayWithArray:ea]; + app = [args objectAtIndex: 0]; + + if( [[app pathExtension] isEqualToString:@"app"] ) + { + BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path + withApplication:app]; + + if( ret == NO ) + { + NSLog(@"Could not open %@ using %@",path,app); + } + + return; + } + + editorTask = [[NSTask alloc] init]; + + [editorTask setLaunchPath:app]; + [args removeObjectAtIndex: 0]; + [args addObject:path]; + + [editorTask setArguments:args]; + + AUTORELEASE( editorTask ); + [editorTask launch]; + } + else + { + PCEditor *editor; + + editor = [[PCEditor alloc] initWithPath:path]; + [editor setDelegate:self]; + [editor show]; + } +} + +// =========================================================================== +// ==== Initialisation +// =========================================================================== - (id)initWithProject: (PCProject *)aProject { @@ -74,50 +134,267 @@ if((self = [super init])) { - _currentProject = aProject; - _componentView = nil; + project = aProject; + componentView = nil; + editorsDict = [[NSMutableDictionary alloc] init]; } return self; } - (void) dealloc { - if( _componentView ) + if (componentView) { - RELEASE(_componentView); + RELEASE(componentView); } + [editorsDict removeAllObjects]; + RELEASE( editorsDict ); + [super dealloc]; } -- (NSView *) componentView +- (NSView *)emptyEditorView { - if (_componentView == nil) + if (componentView == nil) { [self _createComponentView]; } - return _componentView; + return componentView; } -- (void)setEditorView: (PCEditorView *)ev +- (NSView *)componentView +{ + if (componentView == nil) + { + [self _createComponentView]; + } + + return componentView; +} + +- (void)setEditorView:(PCEditorView *)ev { NSRect frame; - _editorView = ev; + editorView = ev; - [_scrollView setDocumentView:_editorView]; + [scrollView setDocumentView:editorView]; - frame = [[_scrollView contentView] frame]; - frame.size = NSMakeSize([_scrollView contentSize].width,1e7); - [_editorView setFrame:frame]; - [_editorView sizeToFit]; + frame = [[scrollView contentView] frame]; + frame.size = NSMakeSize([scrollView contentSize].width,1e7); + [editorView setFrame:frame]; + [editorView sizeToFit]; } - (PCEditorView *) editorView { - return _editorView; + return editorView; } +// =========================================================================== +// ==== Project and Editor handling +// =========================================================================== + +- (PCEditor *)internalEditorForFile:(NSString *)path +{ + PCEditor *editor; + + if ((editor = [editorsDict objectForKey:path])) + { + return editor; + } + else + { + editor = [[PCEditor alloc] initWithPath:path]; + + [editor setDelegate:self]; + + [editorsDict setObject:editor forKey:path]; + //RELEASE(editor); + + return editor; + } +} + +- (PCEditor *)editorForFile:(NSString *)path +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"]) + { +/* [self openFileInEditor:path];*/ + return nil; + } + else + { + return [self internalEditorForFile:path]; + } +} + +- (PCEditor *)activeEditor +{ + NSEnumerator *enumerator = [editorsDict keyEnumerator]; + PCEditor *editor; + NSString *key; + NSWindow *window; + + while (( key = [enumerator nextObject] )) + { + editor = [editorsDict objectForKey:key]; + window = [editor editorWindow]; + + if (([window isVisible] && [window isKeyWindow]) + || ([[editor internalView] superview] + && [[project projectWindow] isKeyWindow])) + { + return editor; + } + } + + return nil; +} + +- (NSArray *)allEditors +{ + return [editorsDict allValues]; +} + +- (void)closeEditorForFile:(NSString *)file +{ + PCEditor *editor; + + editor = [editorsDict objectForKey:file]; + [editor closeFile:self]; + [editorsDict removeObjectForKey:file]; +} + +- (void)closeAllEditors +{ + NSEnumerator *enumerator = [editorsDict keyEnumerator]; + PCEditor *editor; + NSString *key; + + while ((key = [enumerator nextObject])) + { + editor = [editorsDict objectForKey:key]; + [editor closeFile:self]; + } + [editorsDict removeAllObjects]; +} + +// =========================================================================== +// ==== File handling +// =========================================================================== + +- (BOOL)saveAllFiles +{ + NSEnumerator *enumerator = [editorsDict keyEnumerator]; + PCEditor *editor; + NSString *key; + BOOL ret = YES; + + while(( key = [enumerator nextObject] )) + { + editor = [editorsDict objectForKey:key]; + + if( [editor saveFileIfNeeded] == NO ) + { + ret = NO; + } + } + + return ret; +} + +- (BOOL)saveFile +{ + PCEditor *editor = [self activeEditor]; + + if (editor != nil) + { + return [editor saveFileIfNeeded]; + } + + return NO; +} + +- (BOOL)saveFileAs:(NSString *)file +{ + PCEditor *editor = [self activeEditor]; + + if (editor != nil) + { + BOOL res; + res = [editor saveFileTo:file]; + [editor closeFile:self]; + + [[self internalEditorForFile:file] + showInProjectEditor:[project projectEditor]]; + return res; + } + + return NO; +} + +- (BOOL)saveFileTo:(NSString *)file +{ + PCEditor *editor = [self activeEditor]; + + if (editor != nil) + { + return [editor saveFileTo:file]; + } + + return NO; +} + +- (BOOL)revertFileToSaved +{ + PCEditor *editor = [self activeEditor]; + + if (editor != nil) + { + return [editor revertFileToSaved]; + } + + return NO; +} + +- (void)closeFile:(id)sender +{ + [[self activeEditor] closeFile:self]; +} + +// =========================================================================== +// ==== Delegate +// =========================================================================== + +- (void)editorDidClose:(id)sender +{ + PCEditor *editor = (PCEditor*)sender; + + [editorsDict removeObjectForKey:[editor path]]; + + if ([editorsDict count]) + { + editor = [editorsDict objectForKey: [[editorsDict allKeys] lastObject]]; + [editor showInProjectEditor: [project projectEditor]]; + [[project projectWindow] makeFirstResponder:[editor internalView]]; + } + else + { + [[project projectEditor] setEditorView:nil]; +// [[project browserController] projectDictDidChange:nil]; + } +} + +- (void)setBrowserPath:(NSString *)file category:(NSString *)category +{ + [[project projectBrowser] setPathForFile:file category:category]; +} + + @end diff --git a/Library/PCProjectInspector.m b/Library/PCProjectInspector.m index 05300e2..8c38ec5 100644 --- a/Library/PCProjectInspector.m +++ b/Library/PCProjectInspector.m @@ -80,11 +80,11 @@ { // Panel inspectorPanel = [[NSWindow alloc] - initWithContentRect:NSMakeRect(200,300,280,384) + initWithContentRect:NSMakeRect(200,300,280,404) styleMask:NSTitledWindowMask | NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES]; - [inspectorPanel setMinSize:NSMakeSize(280,384)]; + [inspectorPanel setMinSize:NSMakeSize(280,404)]; [inspectorPanel setTitle:@"Project Inspector"]; [inspectorPanel setTitle: [NSString stringWithFormat: @"%@ - Project Inspector", [[projectManager activeProject] projectName]]]; @@ -97,13 +97,13 @@ // Content contentView = [[NSBox alloc] init]; [contentView setTitlePosition:NSNoTitle]; - [contentView setFrame:NSMakeRect(0,0,280,364)]; + [contentView setFrame:NSMakeRect(0,0,280,384)]; [contentView setBorderType:NSNoBorder]; [contentView setContentViewMargins:NSMakeSize(0.0, 0.0)]; [inspectorPanel setContentView:contentView]; inspectorPopup = [[NSPopUpButton alloc] - initWithFrame:NSMakeRect(80,358,128,20)]; + initWithFrame:NSMakeRect(80,378,128,20)]; [inspectorPopup setTarget:self]; [inspectorPopup setAction:@selector(inspectorPopupDidChange:)]; [contentView addSubview:inspectorPopup]; @@ -115,13 +115,13 @@ hLine = [[[NSBox alloc] init] autorelease]; [hLine setTitlePosition:NSNoTitle]; - [hLine setFrame:NSMakeRect(0,336,280,2)]; + [hLine setFrame:NSMakeRect(0,356,280,2)]; [contentView addSubview:hLine]; // Holder of PC*Proj inspectors inspectorView = [[NSBox alloc] init]; [inspectorView setTitlePosition:NSNoTitle]; - [inspectorView setFrame:NSMakeRect(-8,-8,295,364)]; + [inspectorView setFrame:NSMakeRect(-8,-8,295,384)]; [inspectorView setBorderType:NSNoBorder]; [contentView addSubview:inspectorView]; diff --git a/Library/PCProjectManager.m b/Library/PCProjectManager.m index 017bfe2..9035f49 100644 --- a/Library/PCProjectManager.m +++ b/Library/PCProjectManager.m @@ -36,7 +36,7 @@ #include "PCProjectWindow.h" #include "PCProjectBrowser.h" #include "PCProjectInspector.h" -#include "PCEditorController.h" +#include "PCProjectEditor.h" #include "ProjectComponent.h" #include "PCProject+ComponentHandling.h" #include "PCServer.h" @@ -171,10 +171,10 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; - (void)showProjectHistory:(id)sender { - if (![[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - objectForKey: SeparateBuilder] isEqualToString: @"YES"]) + if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] + objectForKey: SeparateHistory] isEqualToString: @"YES"]) { - [[activeProject projectWindow] showProjectHistory:self]; + [[self historyPanel] orderFront: nil]; } } @@ -470,27 +470,27 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; - (BOOL)saveFile { - return [[activeProject editorController] saveFile]; + return [[activeProject projectEditor] saveFile]; } - (BOOL)saveFileAs:(NSString *)path { - return [[activeProject editorController] saveFileAs:path]; + return [[activeProject projectEditor] saveFileAs:path]; } - (BOOL)saveFileTo:(NSString *)path { - return [[activeProject editorController] saveFileTo:path]; + return [[activeProject projectEditor] saveFileTo:path]; } - (BOOL)revertFileToSaved { - return [[activeProject editorController] revertFileToSaved]; + return [[activeProject projectEditor] revertFileToSaved]; } - (void)closeFile { - return [[activeProject editorController] closeFile:self]; + return [[activeProject projectEditor] closeFile:self]; } - (BOOL)renameFileTo:(NSString *)path @@ -527,7 +527,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange"; - (BOOL)saveProjectFiles { - return [[activeProject editorController] saveAllFiles]; + return [[activeProject projectEditor] saveAllFiles]; } - (BOOL)removeProjectFiles diff --git a/Library/PCProjectWindow.m b/Library/PCProjectWindow.m index ead4360..91106f2 100644 --- a/Library/PCProjectWindow.m +++ b/Library/PCProjectWindow.m @@ -173,7 +173,7 @@ if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey: SeparateHistory] isEqualToString: @"NO"]) { - [v_split addSubview: [[project projectHistory] componentView]]; + [self showProjectHistory:self]; } [v_split adjustSubviews]; @@ -395,19 +395,7 @@ - (void)showProjectHistory:(id)sender { - NSView *view = nil; - NSPanel *historyPanel = nil; - - if (![[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - objectForKey: SeparateBuilder] isEqualToString: @"YES"]) - { - return; - } - - view = [[project projectHistory] componentView]; - historyPanel = [[project projectManager] historyPanel]; - - [historyPanel orderFront: nil]; + [v_split addSubview: [[project projectHistory] componentView]]; } - (void)showProjectBuild:(id)sender diff --git a/Library/ProjectCenter.h b/Library/ProjectCenter.h index 330f1a2..cdf8a95 100644 --- a/Library/ProjectCenter.h +++ b/Library/ProjectCenter.h @@ -32,21 +32,22 @@ #include #include #include +#include #include #include #include -#include -#include #include #include +#include +#include +#include #include -#include #include -#include #include #include #include #include + #include #include #include diff --git a/Modules/ApplicationProject/PCAppProject.h b/Modules/ApplicationProject/PCAppProject.h index 67a5176..15cdd24 100644 --- a/Modules/ApplicationProject/PCAppProject.h +++ b/Modules/ApplicationProject/PCAppProject.h @@ -59,6 +59,10 @@ NSButton *clearAppIconButton; NSImageView *appIconView; NSImage *icon; + NSBox *mainNibBox; + NSTextField *mainNibFileField; + NSButton *setMainNibButton; + NSButton *clearMainNibButton; NSBox *fileAttributesView; NSImageView *fileIconView; @@ -84,11 +88,15 @@ - (NSView *)buildAttributesView; - (NSView *)projectAttributesView; - (NSView *)fileAttributesView; -- (void)updateInspectorValues:(NSNotification *)aNotif; -- (void)clearAppIcon:(id)sender; +- (void)setAppClass:(id)sender; - (void)setAppIcon:(id)sender; - (BOOL)setAppIconWithImageAtPath:(NSString *)path; -- (void)setAppClass:(id)sender; +- (void)clearAppIcon:(id)sender; +- (void)setMainNib:(id)sender; +- (BOOL)setMainNibWithFileAtPath:(NSString *)path; +- (void)clearMainNib:(id)sender; + +- (void)updateInspectorValues:(NSNotification *)aNotif; // ---------------------------------------------------------------------------- // --- Project @@ -106,6 +114,8 @@ - (BOOL)isExecutable; +- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key; + @end #endif diff --git a/Modules/ApplicationProject/PCAppProject.m b/Modules/ApplicationProject/PCAppProject.m index 6ace2d1..e9ff94c 100644 --- a/Modules/ApplicationProject/PCAppProject.m +++ b/Modules/ApplicationProject/PCAppProject.m @@ -125,14 +125,14 @@ * "Build Attributes" View */ buildAttributesView = [[NSBox alloc] init]; - [buildAttributesView setFrame:NSMakeRect(0,0,295,364)]; + [buildAttributesView setFrame:NSMakeRect(0,0,295,384)]; [buildAttributesView setTitlePosition:NSNoTitle]; [buildAttributesView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; [buildAttributesView setContentViewMargins:NSMakeSize(0.0, 0.0)]; // Compiler Flags -- ADDITIONAL_OBJCFLAGS(?), ADDITIONAL_CFLAGS - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,323,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,343,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -142,7 +142,7 @@ [buildAttributesView addSubview:textField]; RELEASE(textField); - ccOptField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,323,165,21)]; + ccOptField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,343,165,21)]; [ccOptField setAlignment: NSLeftTextAlignment]; [ccOptField setBordered: YES]; [ccOptField setEditable: YES]; @@ -155,7 +155,7 @@ RELEASE(ccOptField); // Linker Flags -- ADDITIONAL_LDFLAGS - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,298,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,318,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -165,7 +165,7 @@ [buildAttributesView addSubview:textField]; RELEASE(textField); - ldOptField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,298,165,21)]; + ldOptField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,318,165,21)]; [ldOptField setAlignment: NSLeftTextAlignment]; [ldOptField setBordered: YES]; [ldOptField setEditable: YES]; @@ -178,7 +178,7 @@ RELEASE(ldOptField); // Install In - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,273,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,293,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -189,7 +189,7 @@ RELEASE(textField); installPathField =[[NSTextField alloc] - initWithFrame:NSMakeRect(111,273,165,21)]; + initWithFrame:NSMakeRect(111,293,165,21)]; [installPathField setAlignment: NSLeftTextAlignment]; [installPathField setBordered: YES]; [installPathField setEditable: YES]; @@ -202,7 +202,7 @@ RELEASE(installPathField); // Build Tool - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,248,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,268,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -212,7 +212,7 @@ [buildAttributesView addSubview:textField]; RELEASE(textField); - toolField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,248,165,21)]; + toolField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,268,165,21)]; [toolField setAlignment: NSLeftTextAlignment]; [toolField setBordered: YES]; [toolField setEditable: YES]; @@ -225,7 +225,7 @@ RELEASE(toolField); // Public Headers In -- ADDITIONAL_INCLUDE_DIRS - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,223,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,243,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -235,7 +235,7 @@ [buildAttributesView addSubview:textField]; RELEASE(textField); - headersField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,223,165,21)]; + headersField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,243,165,21)]; [headersField setAlignment: NSLeftTextAlignment]; [headersField setBordered: YES]; [headersField setEditable: YES]; @@ -248,7 +248,7 @@ RELEASE(headersField); // Public Libraries In -- ADDITIONAL_TOOL_LIBS - textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,198,104,21)]; + textField =[[NSTextField alloc] initWithFrame:NSMakeRect(4,218,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -258,7 +258,7 @@ [buildAttributesView addSubview:textField]; RELEASE(textField); - libsField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,198,165,21)]; + libsField =[[NSTextField alloc] initWithFrame:NSMakeRect(111,218,165,21)]; [libsField setAlignment: NSLeftTextAlignment]; [libsField setBordered: YES]; [libsField setEditable: YES]; @@ -275,14 +275,14 @@ * "Project Attributes" View */ projectAttributesView = [[NSBox alloc] init]; - [projectAttributesView setFrame:NSMakeRect(0,0,295,364)]; + [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,323,104,21)]; + textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,343,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -293,7 +293,7 @@ RELEASE(textField); projectTypeField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,323,165,21)]; + NSMakeRect(111,343,165,21)]; [projectTypeField setAlignment: NSLeftTextAlignment]; [projectTypeField setBordered: NO]; [projectTypeField setEditable: NO]; @@ -306,7 +306,7 @@ RELEASE(projectTypeField); // Project Name - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,298,104,21)]; + textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,318,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -317,7 +317,7 @@ RELEASE(textField); projectNameField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,298,165,21)]; + NSMakeRect(111,318,165,21)]; [projectNameField setAlignment: NSLeftTextAlignment]; [projectNameField setBordered: NO]; [projectNameField setEditable: NO]; @@ -328,7 +328,7 @@ RELEASE(projectNameField); // Project Language - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,273,104,21)]; + textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,293,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -339,7 +339,7 @@ RELEASE(textField); projectLanguageField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,273,165,21)]; + NSMakeRect(111,293,165,21)]; [projectLanguageField setAlignment: NSLeftTextAlignment]; [projectLanguageField setBordered: NO]; [projectLanguageField setEditable: NO]; @@ -350,7 +350,7 @@ RELEASE(projectLanguageField); // Application Class - textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,248,104,21)]; + textField = [[NSTextField alloc] initWithFrame:NSMakeRect(4,268,104,21)]; [textField setAlignment: NSRightTextAlignment]; [textField setBordered: NO]; [textField setEditable: NO]; @@ -361,7 +361,7 @@ RELEASE(textField); appClassField = [[NSTextField alloc] initWithFrame: - NSMakeRect(111,248,165,21)]; + NSMakeRect(111,268,165,21)]; [appClassField setAlignment: NSLeftTextAlignment]; [appClassField setBordered: YES]; [appClassField setEditable: YES]; @@ -375,7 +375,7 @@ // Application Icon _appIconBox = [[NSBox alloc] init]; - [_appIconBox setFrame:NSMakeRect(6,154,270,84)]; + [_appIconBox setFrame:NSMakeRect(6,174,270,84)]; [_appIconBox setContentViewMargins:NSMakeSize(4.0, 6.0)]; [_appIconBox setTitle:@"Application Icon"]; [projectAttributesView addSubview:_appIconBox]; @@ -421,18 +421,18 @@ * "File Attributes" View */ fileAttributesView = [[NSBox alloc] init]; - [fileAttributesView setFrame:NSMakeRect(0,0,295,364)]; + [fileAttributesView setFrame:NSMakeRect(0,0,295,384)]; [fileAttributesView setTitlePosition:NSNoTitle]; [fileAttributesView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; [fileAttributesView setContentViewMargins:NSMakeSize(0.0, 0.0)]; - fileIconView = [[NSImageView alloc] initWithFrame:NSMakeRect(8,290,48,48)]; + fileIconView = [[NSImageView alloc] initWithFrame:NSMakeRect(8,310,48,48)]; [fileIconView setImage:nil]; [fileAttributesView addSubview:fileIconView]; RELEASE(fileIconView); - fileNameField =[[NSTextField alloc] initWithFrame:NSMakeRect(60,290,216,48)]; + fileNameField =[[NSTextField alloc] initWithFrame:NSMakeRect(60,310,216,48)]; [fileNameField setAlignment: NSLeftTextAlignment]; [fileNameField setBordered: NO]; [fileNameField setEditable: NO]; @@ -444,7 +444,7 @@ [fileAttributesView addSubview:fileNameField]; RELEASE(fileNameField); - line = [[NSBox alloc] initWithFrame:NSMakeRect(0,278,295,2)]; + line = [[NSBox alloc] initWithFrame:NSMakeRect(0,298,295,2)]; [line setTitlePosition:NSNoTitle]; [fileAttributesView addSubview:line]; RELEASE(line); @@ -611,6 +611,60 @@ object:self]; } +- (void)setMainNib:(id)sender +{ + int result; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + NSString *dir = nil; + + [openPanel setAllowsMultipleSelection:NO]; + + dir = [[NSUserDefaults standardUserDefaults] + objectForKey:@"LastOpenDirectory"]; + result = [openPanel runModalForDirectory:dir + file:nil + types:[NSArray arrayWithObject:@"gorm"]]; + + if (result == NSOKButton) + { + NSString *file = [[openPanel filenames] objectAtIndex:0]; + + if (![self setMainNibWithFileAtPath:file]) + { + NSRunAlertPanel(@"Error while opening file!", + @"Couldn't open %@", @"OK", nil, nil,file); + } + } +} + +- (BOOL)setMainNibWithFileAtPath:(NSString *)path +{ + NSString *nibName = [path lastPathComponent]; + + [self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCInterfaces]; + [projectDict setObject:nibName forKey:PCMainInterfaceFile]; + [infoDict setObject:nibName forKey:@"NSMainNibFile"]; + +// [mainNibField setStringValue:nibName]; + + [[NSNotificationCenter defaultCenter] + postNotificationName:ProjectDictDidChangeNotification + object:self]; + + return YES; +} + +- (void)clearMainNib:(id)sender +{ + [projectDict setObject:@"" forKey:PCMainInterfaceFile]; + [infoDict setObject:@"" forKey:@"NSMainNibFile"]; +// [mainNibField setStringValue:@""]; + + [[NSNotificationCenter defaultCenter] + postNotificationName:ProjectDictDidChangeNotification + object:self]; +} + // ---------------------------------------------------------------------------- // --- Notifications // ---------------------------------------------------------------------------- @@ -827,4 +881,54 @@ return YES; } + +- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key +{ + NSMutableArray *filesToRemove = [[files mutableCopy] autorelease]; + NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; + NSString *appIcon = [projectDict objectForKey:PCAppIcon]; + + if (!files || !key) + { + return NO; + } + + // Check for main NIB file + if ([key isEqualToString:PCInterfaces] && [files containsObject:mainNibFile]) + { + int ret; + ret = NSRunAlertPanel(@"Remove", + @"You've selected to remove main interface file.\nDo you still want to remove it?", + @"Remove", @"Leave", nil); + + if (ret == NSAlertAlternateReturn) // Leave + { + [filesToRemove removeObject:mainNibFile]; + } + else + { + [self clearMainNib:self]; + } + } + // Check for application icon files + else if ([key isEqualToString:PCImages] && [files containsObject:appIcon]) + { + int ret; + ret = NSRunAlertPanel(@"Remove", + @"You've selected to remove application icon file.\nDo you still want to remove it?", + @"Remove", @"Leave", nil); + + if (ret == NSAlertAlternateReturn) // Leave + { + [filesToRemove removeObject:appIcon]; + } + else + { + [self clearAppIcon:self]; + } + } + + return [super removeFiles:filesToRemove forKey:key]; +} + @end diff --git a/PCMenuController.m b/PCMenuController.m index ed49218..7bf8a68 100644 --- a/PCMenuController.m +++ b/PCMenuController.m @@ -305,7 +305,7 @@ } else { - [PCEditorController openFileInEditor:filePath]; + [PCProjectEditor openFileInEditor:filePath]; } } } @@ -331,7 +331,7 @@ int retval = NSOKButton; oldFilePath = - [[[[projectManager activeProject] editorController] activeEditor] path]; + [[[[projectManager activeProject] projectEditor] activeEditor] path]; [savePanel setTitle: @"Save As..."]; while (![directory isEqualToString: [projectManager projectPath]] @@ -432,7 +432,7 @@ @"OK",nil,nil); } -// Edit. PCEditorController have to provide this menu and functionality +// Edit. PCProjectEditor have to provide this menu and functionality - (void)findShowPanel:(id)sender { [[PCTextFinder sharedFinder] showFindPanel:self]; @@ -456,7 +456,6 @@ - (void)showHistoryPanel:(id)sender { -// [[[projectManager activeProject] projectWindow] showProjectHistory:self]; [projectManager showProjectHistory:self]; }