Implemented a first 'editor', UI enhancements and other nice things

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@7530 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Robert Slover 2000-09-17 12:13:10 +00:00
parent 8f5233a551
commit a1cfff2685
14 changed files with 592 additions and 303 deletions

View file

@ -56,3 +56,6 @@
- (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column; - (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column;
@end @end
extern NSString *FileShouldOpenNotification;

View file

@ -26,14 +26,17 @@
#import "PCBrowserController.h" #import "PCBrowserController.h"
#import "PCProject.h" #import "PCProject.h"
#import "PCFileManager.h"
NSString *FileShouldOpenNotification = @"FileShouldOpenNotification";
@implementation PCBrowserController @implementation PCBrowserController
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc]; [super dealloc];
} }
- (void)click:(id)sender - (void)click:(id)sender
@ -72,31 +75,23 @@
- (void)doubleClick:(id)sender - (void)doubleClick:(id)sender
{ {
#warning No subproject support here yet! if ([sender selectedColumn] != 0) {
/* NSString *category = [[[browser path] componentsSeparatedByString:@"/"] objectAtIndex:1];
if ([sender selectedColumn] == 0) { NSString *k = [[project rootCategories] objectForKey:category];
// Ask the project about the valid file types
//NSArray *types = [project typesForKeyPath:[sender pathToColumn:0]];
NSOpenPanel *openPanel;
int retval;
NSArray *types;
openPanel = [NSOpenPanel openPanel]; if ([k isEqualToString:PCClasses] || [k isEqualToString:PCHeaders] || [k isEqualToString:PCOtherSources]) {
[openPanel setAllowsMultipleSelection:NO]; NSString *projectPath = [project projectPath];
[openPanel setCanChooseDirectories:NO]; NSString *fn = [self nameOfSelectedFile];
[openPanel setCanChooseFiles:YES]; NSString *file = [projectPath stringByAppendingPathComponent:fn];
NSDictionary *ui =[NSDictionary dictionaryWithObjectsAndKeys:
if ((retval = [openPanel runModalForDirectory:[[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenDirectory"] file:nil types:types])) { file,@"FilePathKey",nil];
NSString *key = [project projectKeyForKeyPath:[sender path]];
[[NSNotificationCenter defaultCenter] postNotificationName:FileShouldOpenNotification object:self userInfo:ui];
[project addFile:[[openPanel filenames] objectAtIndex:0] forKey:key];
[[NSUserDefaults standardUserDefaults] setObject:[openPanel directory] forKey:@"LastOpenDirectory"];
}
} }
else { }
} else {
*/ [[PCFileManager fileManager] showAddFileWindow];
}
} }
- (void)projectDictDidChange:(NSNotification *)aNotif - (void)projectDictDidChange:(NSNotification *)aNotif
@ -118,14 +113,7 @@
- (NSString *)pathOfSelectedFile - (NSString *)pathOfSelectedFile
{ {
NSString *path = nil; return [browser path];
// Doesn't work with subprojects!
if ([browser selectedColumn] != 0) {
path = [browser path];
}
return path;
} }
- (void)setBrowser:(NSBrowser *)aBrowser - (void)setBrowser:(NSBrowser *)aBrowser

View file

@ -32,16 +32,17 @@
id fileTypePopup; id fileTypePopup;
id newFileName; id newFileName;
id delegate; id delegate; // PCProjectManager
id fileTypeAccessaryView;
id addFileTypePopup;
NSMutableDictionary *creators; NSMutableDictionary *creators;
BOOL _needsAdditionalReleasing;
} }
//===========================================================================================
// ==== Class methods
//===========================================================================================
+ (PCFileManager *)fileManager;
//=========================================================================================== //===========================================================================================
// ==== Init and free // ==== Init and free
//=========================================================================================== //===========================================================================================
@ -62,7 +63,6 @@
// ==== File stuff // ==== File stuff
// =========================================================================== // ===========================================================================
- (void)fileTypePopupChanged:(id)sender;
- (void)showAddFileWindow; - (void)showAddFileWindow;
- (void)showNewFileWindow; - (void)showNewFileWindow;

View file

@ -135,33 +135,26 @@
[newFileName setStringValue:@""]; [newFileName setStringValue:@""];
[newFileName setAutoresizingMask: (NSViewWidthSizable | NSViewMinYMargin)]; [newFileName setAutoresizingMask: (NSViewWidthSizable | NSViewMinYMargin)];
[_c_view addSubview:[newFileName autorelease]]; [_c_view addSubview:[newFileName autorelease]];
/*
* the accessory view needed for adding files
*
*/
fileTypeAccessaryView = [[NSBox alloc] init];
addFileTypePopup = [[[NSPopUpButton alloc] initWithFrame:NSMakeRect(20,30,160,20) pullsDown:NO] autorelease];
[addFileTypePopup addItemWithTitle:@"No type available!"];
[fileTypeAccessaryView setTitle:@"Add to category"];
[fileTypeAccessaryView setTitlePosition:NSAtTop];
[fileTypeAccessaryView setBorderType:NSGrooveBorder];
[fileTypeAccessaryView addSubview:addFileTypePopup];
[fileTypeAccessaryView sizeToFit];
[fileTypeAccessaryView setAutoresizingMask: NSViewWidthSizable];
[fileTypePopup setTarget:self];
[fileTypePopup setAction:@selector(fileTypePopupChanged:)];
_needsAdditionalReleasing = YES;
} }
@end @end
@implementation PCFileManager @implementation PCFileManager
//===========================================================================================
// ==== Class methods
//===========================================================================================
static PCFileManager *_mgr = nil;
+ (PCFileManager *)fileManager
{
if (!_mgr) {
_mgr = [[PCFileManager alloc] init];
}
return _mgr;
}
//=========================================================================================== //===========================================================================================
// ==== Init and free // ==== Init and free
//=========================================================================================== //===========================================================================================
@ -170,15 +163,7 @@
{ {
if ((self = [super init])) { if ((self = [super init])) {
creators = [[NSMutableDictionary alloc] init]; creators = [[NSMutableDictionary alloc] init];
#if defined(GNUSTEP)
[self _initUI]; [self _initUI];
#else
if(![NSBundle loadNibNamed:@"FileCreation.nib" owner:self]) {
[[NSException exceptionWithName:NIB_NOT_FOUND_EXCEPTION reason:@"Could not load FileCreation.gmodel" userInfo:nil] raise];
return nil;
}
#endif
} }
return self; return self;
} }
@ -186,18 +171,14 @@
- (void)dealloc - (void)dealloc
{ {
[creators release]; [creators release];
[newFileWindow release];
if (_needsAdditionalReleasing) {
[fileTypeAccessaryView release];
[newFileWindow release];
}
[super dealloc]; [super dealloc];
} }
- (void)awakeFromNib - (void)awakeFromNib
{ {
[fileTypePopup removeAllItems]; [fileTypePopup removeAllItems];
} }
// =========================================================================== // ===========================================================================
@ -206,56 +187,53 @@
- (id)delegate - (id)delegate
{ {
return delegate; return delegate;
} }
- (void)setDelegate:(id)aDelegate - (void)setDelegate:(id)aDelegate
{ {
delegate = aDelegate; delegate = aDelegate;
} }
// =========================================================================== // ===========================================================================
// ==== File stuff // ==== File stuff
// =========================================================================== // ===========================================================================
- (void)fileTypePopupChanged:(id)sender
{
}
- (void)showAddFileWindow - (void)showAddFileWindow
{ {
NSOpenPanel *openPanel; NSOpenPanel *openPanel;
int retval; int retval;
NSMutableArray *validTypes = nil; NSMutableArray *validTypes = nil;
NSDictionary *categories = nil; NSDictionary *categories = nil;
PCProject *project = nil; PCProject *project = nil;
NSString *key = nil;
NSString *title = nil;
NSArray *types = nil;
if (delegate && [delegate respondsToSelector:@selector(fileManagerWillAddFiles:)]) { if (delegate && [delegate respondsToSelector:@selector(fileManagerWillAddFiles:)]) {
if (!(project = [delegate fileManagerWillAddFiles:self])) { if (!(project = [delegate fileManagerWillAddFiles:self])) {
NSLog(@"No project to add files available..."); NSLog(@"No project to add files available...");
return;
} }
} }
// Ask the active project for the valid file types first! key = [project selectedRootCategory];
categories = [project rootCategories]; title = [[[project rootCategories] allKeysForObject:key] objectAtIndex:0];
validTypes = [NSMutableArray arrayWithArray:[categories allKeys]]; title = [NSString stringWithFormat:@"Add to %@...",title];
[validTypes removeObject:@"Subprojects"];
types = [project fileExtensionsForCategory:key];
[addFileTypePopup removeAllItems];
[addFileTypePopup addItemsWithTitles:validTypes];
openPanel = [NSOpenPanel openPanel]; openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:YES]; [openPanel setAllowsMultipleSelection:YES];
[openPanel setCanChooseDirectories:NO]; [openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES]; [openPanel setCanChooseFiles:YES];
[openPanel setTitle:title];
[openPanel setTitle:@"Add File(s)..."];
[openPanel setAccessoryView:fileTypeAccessaryView]; retval = [openPanel runModalForDirectory:[[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenDirectory"] file:nil types:types];
retval = [openPanel runModalForDirectory:[[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenDirectory"] file:nil types:nil];
if (retval == NSOKButton) { if (retval == NSOKButton) {
NSString *key = [categories objectForKey:[addFileTypePopup titleOfSelectedItem]];
NSEnumerator *enumerator; NSEnumerator *enumerator;
NSString *file; NSString *file;
@ -263,17 +241,57 @@
enumerator = [[openPanel filenames] objectEnumerator]; enumerator = [[openPanel filenames] objectEnumerator];
while (file = [enumerator nextObject]) { while (file = [enumerator nextObject]) {
NSString *otherKey;
NSString *ext;
BOOL ret = NO;
NSString *fn;
NSString *fileName;
NSString *pth;
if ([delegate fileManager:self shouldAddFile:file forKey:key]) { if ([delegate fileManager:self shouldAddFile:file forKey:key]) {
NSString *fileName = [file lastPathComponent]; fileName = [file lastPathComponent];
NSString *pth = [[project projectPath] stringByAppendingPathComponent:fileName]; pth = [[project projectPath] stringByAppendingPathComponent:fileName];
if (![key isEqualToString:PCLibraries]) { if (![key isEqualToString:PCLibraries]) {
if ([[NSFileManager defaultManager] copyPath:file toPath:pth handler:nil]) { if (![[NSFileManager defaultManager] fileExistsAtPath:pth]) {
[delegate fileManager:self didAddFile:pth forKey:key]; [[NSFileManager defaultManager] copyPath:file toPath:pth handler:nil];
} }
} }
else { [project addFile:pth forKey:key];
[delegate fileManager:self didAddFile:pth forKey:key]; }
if ([key isEqualToString:PCClasses]) {
otherKey = PCHeaders;
ext = [NSString stringWithString:@"h"];
fn = [file stringByDeletingPathExtension];
fn = [fn stringByAppendingPathExtension:ext];
if ([[NSFileManager defaultManager] fileExistsAtPath:fn]) {
ret = NSRunAlertPanel(@"Adding Header?",@"Should %@ be added to project %@ as well?",@"Yes",@"No",nil,fn,[project projectName]);
}
}
else if ([key isEqualToString:PCHeaders]) {
otherKey = PCClasses;
ext = [NSString stringWithString:@"m"];
fn = [file stringByDeletingPathExtension];
fn = [fn stringByAppendingPathExtension:ext];
if ([[NSFileManager defaultManager] fileExistsAtPath:fn]) {
ret = NSRunAlertPanel(@"Adding Class?",@"Should %@ be added to project %@ as well?",@"Yes",@"No",nil,fn,[project projectName]);
}
}
if (ret) {
if ([delegate fileManager:self shouldAddFile:fn forKey:otherKey]) {
NSString *pp = [project projectPath];
fileName = [fn lastPathComponent];
pth = [pp stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] copyPath:fn toPath:pth handler:nil];
[project addFile:pth forKey:otherKey];
} }
} }
} }
@ -367,3 +385,6 @@
} }
@end @end

View file

@ -28,6 +28,20 @@
#import "ProjectBuilder.h" #import "ProjectBuilder.h"
#ifndef IMAGE
#define IMAGE(X) [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:(X)]] autorelease]
#endif
#define BUILD_KEY @"BuildKey"
#define BUILD_ARGS_KEY @"BuildArgsKey"
#define BUILD_HOST_KEY @"BuildHostKey"
#define TARGET_MAKE @"Make"
#define TARGET_MAKE_DEBUG @"MakeDebug"
#define TARGET_MAKE_PROFILE @"MakeProfile"
#define TARGET_MAKE_INSTALL @"MakeInstall"
#define TARGET_MAKE_CLEAN @"MakeClean"
#define TOUCHED_NOTHING (0) #define TOUCHED_NOTHING (0)
#define TOUCHED_EVERYTHING (1 << 0) #define TOUCHED_EVERYTHING (1 << 0)
#define TOUCHED_PROJECT_NAME (1 << 1) #define TOUCHED_PROJECT_NAME (1 << 1)
@ -82,7 +96,7 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
{ {
id projectWindow; id projectWindow;
id delegate; id delegate;
id projectBuilder; id projectManager;
id browserController; id browserController;
id textView; id textView;
@ -92,6 +106,8 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
id projectFileInspectorView; id projectFileInspectorView;
id buildTargetPanel; id buildTargetPanel;
id buildTargetHostField;
id buildTargetArgsField;
id buildTargetPopup; id buildTargetPopup;
id buildStatusField; id buildStatusField;
@ -102,10 +118,11 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
NSMutableDictionary *projectDict; NSMutableDictionary *projectDict;
NSDictionary *rootCategories; // Needs to be initialised by subclasses! NSDictionary *rootCategories; // Needs to be initialised by subclasses!
NSMutableDictionary *buildOptions;
@private @private
BOOL _needsReleasing; BOOL _needsReleasing;
btarget _buildTarget; btarget _target;
} }
//=========================================================================================== //===========================================================================================
@ -122,6 +139,9 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
//=========================================================================================== //===========================================================================================
- (id)browserController; - (id)browserController;
- (NSString *)selectedRootCategory;
- (NSArray *)fileExtensionsForCategory:(NSString *)key;
- (void)setProjectName:(NSString *)aName; - (void)setProjectName:(NSString *)aName;
- (NSString *)projectName; - (NSString *)projectName;
@ -209,7 +229,8 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
- (void)setArguments:(id)sender; - (void)setArguments:(id)sender;
- (void)build:(id)sender; - (void)build:(id)sender;
- (void)clean:(id)sender;
- (NSDictionary *)buildOptions;
@end @end
@ -228,3 +249,9 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR";
- (void)windowWillClose:(NSNotification *)aNotification; - (void)windowWillClose:(NSNotification *)aNotification;
@end @end
@interface PCProject (TextDelegate)
- (void)textDidEndEditing:(NSNotification *)aNotification;
@end

View file

@ -79,6 +79,7 @@
textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,472,88)]; textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,472,88)];
[textView setMaxSize:NSMakeSize(1e7, 1e7)]; [textView setMaxSize:NSMakeSize(1e7, 1e7)];
[textView setRichText:NO];
[textView setVerticallyResizable:YES]; [textView setVerticallyResizable:YES];
[textView setHorizontallyResizable:YES]; [textView setHorizontallyResizable:YES];
[textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
@ -110,27 +111,28 @@
prototype: buttonCell prototype: buttonCell
numberOfRows: 1 numberOfRows: 1
numberOfColumns: 3] autorelease]; numberOfColumns: 3] autorelease];
[matrix setIntercellSpacing:NSMakeSize(1,1)];
[matrix setSelectionByRect:YES]; [matrix setSelectionByRect:YES];
[matrix setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)]; [matrix setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[_c_view addSubview:matrix]; [_c_view addSubview:matrix];
button = [matrix cellAtRow:0 column:0]; button = [matrix cellAtRow:0 column:0];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_build.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_build")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
[button setTarget:self]; [button setTarget:self];
[button setAction:@selector(build:)]; [button setAction:@selector(build:)];
button = [matrix cellAtRow:0 column:1]; button = [matrix cellAtRow:0 column:1];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_clean.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_settings.tiff")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
[button setTarget:self]; [button setTarget:self];
[button setAction:@selector(clean:)]; [button setAction:@selector(showInspector:)];
button = [matrix cellAtRow:0 column:2]; button = [matrix cellAtRow:0 column:2];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_prefs.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_prefs.tiff")];
[button setTarget:self]; [button setTarget:self];
[button setAction:@selector(showBuildTarget:)]; [button setAction:@selector(showBuildTarget:)];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
@ -144,28 +146,29 @@
prototype: buttonCell prototype: buttonCell
numberOfRows: 1 numberOfRows: 1
numberOfColumns: 4] autorelease]; numberOfColumns: 4] autorelease];
[matrix setIntercellSpacing:NSMakeSize(1,1)];
[matrix setSelectionByRect:YES]; [matrix setSelectionByRect:YES];
[matrix setAutoresizingMask: (NSViewMinXMargin | NSViewMinYMargin)]; [matrix setAutoresizingMask: (NSViewMinXMargin | NSViewMinYMargin)];
[_c_view addSubview:matrix]; [_c_view addSubview:matrix];
button = [matrix cellAtRow:0 column:0]; button = [matrix cellAtRow:0 column:0];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_run.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_run.tiff")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
button = [matrix cellAtRow:0 column:1]; button = [matrix cellAtRow:0 column:1];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_uml.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_uml.tiff")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
button = [matrix cellAtRow:0 column:2]; button = [matrix cellAtRow:0 column:2];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_documentation.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_documentation.tiff")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
button = [matrix cellAtRow:0 column:3]; button = [matrix cellAtRow:0 column:3];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
[button setImage:[[[NSImage alloc] initWithContentsOfFile:@"ProjectCentre_find.tiff"] autorelease]]; [button setImage:IMAGE(@"ProjectCentre_find.tiff")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
// Status // Status
@ -225,7 +228,7 @@
_w_frame = NSMakeRect(100,100,272,104); _w_frame = NSMakeRect(100,100,272,104);
buildTargetPanel = [[NSWindow alloc] initWithContentRect:_w_frame styleMask:style backing:NSBackingStoreBuffered defer:NO]; buildTargetPanel = [[NSWindow alloc] initWithContentRect:_w_frame styleMask:style backing:NSBackingStoreBuffered defer:NO];
[buildTargetPanel setDelegate:self];
[buildTargetPanel setReleasedWhenClosed:NO]; [buildTargetPanel setReleasedWhenClosed:NO];
[buildTargetPanel setTitle:@"Build Options"]; [buildTargetPanel setTitle:@"Build Options"];
_c_view = [buildTargetPanel contentView]; _c_view = [buildTargetPanel contentView];
@ -236,7 +239,6 @@
[buildTargetPopup addItemWithTitle:@"Profile"]; [buildTargetPopup addItemWithTitle:@"Profile"];
[buildTargetPopup addItemWithTitle:@"Install"]; [buildTargetPopup addItemWithTitle:@"Install"];
[buildTargetPopup autorelease]; [buildTargetPopup autorelease];
[buildTargetPopup setTarget:self]; [buildTargetPopup setTarget:self];
[buildTargetPopup setAction:@selector(setTarget:)]; [buildTargetPopup setAction:@selector(setTarget:)];
[_c_view addSubview:buildTargetPopup]; [_c_view addSubview:buildTargetPopup];
@ -262,14 +264,17 @@
[_c_view addSubview:[textField autorelease]]; [_c_view addSubview:[textField autorelease]];
// Host message // Host message
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(72,48,184,21)]; buildTargetHostField = [[NSTextField alloc] initWithFrame:NSMakeRect(72,48,184,21)];
[textField setAlignment: NSLeftTextAlignment]; [buildTargetHostField setAlignment: NSLeftTextAlignment];
[textField setBordered: NO]; [buildTargetHostField setBordered: NO];
[textField setEditable: YES]; [buildTargetHostField setEditable: YES];
[textField setBezeled: YES]; [buildTargetHostField setBezeled: YES];
[textField setDrawsBackground: YES]; [buildTargetHostField setDrawsBackground: YES];
[textField setStringValue:@"localhost"]; [buildTargetHostField setStringValue:@"localhost"];
[_c_view addSubview:[textField autorelease]]; [buildTargetHostField setDelegate:self];
[buildTargetHostField setTarget:self];
[buildTargetHostField setAction:@selector(setHost:)];
[_c_view addSubview:[buildTargetHostField autorelease]];
// Args // Args
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(12,68,60,21)]; textField = [[NSTextField alloc] initWithFrame:NSMakeRect(12,68,60,21)];
@ -282,19 +287,20 @@
[_c_view addSubview:[textField autorelease]]; [_c_view addSubview:[textField autorelease]];
// Args message // Args message
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(72,68,184,21)]; buildTargetArgsField = [[NSTextField alloc] initWithFrame:NSMakeRect(72,68,184,21)];
[textField setAlignment: NSLeftTextAlignment]; [buildTargetArgsField setAlignment: NSLeftTextAlignment];
[textField setBordered: NO]; [buildTargetArgsField setBordered: NO];
[textField setEditable: YES]; [buildTargetArgsField setEditable: YES];
[textField setBezeled: YES]; [buildTargetArgsField setBezeled: YES];
[textField setDrawsBackground: YES]; [buildTargetArgsField setDrawsBackground: YES];
[textField setStringValue:@""]; [buildTargetArgsField setStringValue:@""];
[_c_view addSubview:[textField autorelease]]; [buildTargetArgsField setDelegate:self];
[buildTargetArgsField setTarget:self];
[buildTargetArgsField setAction:@selector(setArguments:)];
[_c_view addSubview:[buildTargetArgsField autorelease]];
// Redisplay! // Redisplay!
[browser loadColumnZero]; [browser loadColumnZero];
_needsReleasing = YES;
} }
@end @end
@ -308,18 +314,12 @@
- (id)init - (id)init
{ {
if ((self = [super init])) { if ((self = [super init])) {
_buildTarget = defaultTarget; _target = defaultTarget;
_needsReleasing = NO; buildOptions = [[NSMutableDictionary alloc] init];
[buildOptions setObject:TARGET_MAKE forKey:BUILD_KEY];
#if defined(GNUSTEP)
[self _initUI]; [self _initUI];
#else
if(![NSBundle loadNibNamed:@"Project.nib" owner:self]) {
[[NSException exceptionWithName:NIB_NOT_FOUND_EXCEPTION reason:@"Could not load Project.gmodel" userInfo:nil] raise];
return nil;
}
#endif
} }
return self; return self;
} }
@ -351,11 +351,11 @@
[projectPath release]; [projectPath release];
[projectDict release]; [projectDict release];
if (_needsReleasing) { [browserController release];
[browserController release]; [projectWindow release];
[projectWindow release]; [buildTargetPanel release];
[buildTargetPanel release];
} [buildOptions release];
[super dealloc]; [super dealloc];
} }
@ -369,6 +369,38 @@
return browserController; return browserController;
} }
- (NSString *)selectedRootCategory
{
return [self projectKeyForKeyPath:[browserController pathOfSelectedFile]];
}
- (NSArray *)fileExtensionsForCategory:(NSString *)key
{
if ([key isEqualToString:PCGModels]) {
return [NSArray arrayWithObjects:@"gmodel",@"gorm",nil];
}
else if ([key isEqualToString:PCClasses]) {
return [NSArray arrayWithObjects:@"m",nil];
}
else if ([key isEqualToString:PCHeaders]) {
return [NSArray arrayWithObjects:@"h",nil];
}
else if ([key isEqualToString:PCOtherSources]) {
return [NSArray arrayWithObjects:@"c",@"C",nil];
}
else if ([key isEqualToString:PCLibraries]) {
return [NSArray arrayWithObjects:@"so",@"a",@"lib",nil];
}
else if ([key isEqualToString:PCSubprojects]) {
return [NSArray arrayWithObjects:@"subproj",nil];
}
else if ([key isEqualToString:PCImages]) {
return [NSArray arrayWithObjects:@"tiff",@"TIFF",@"jpg",@"JPG",@"jpeg",@"JPEG",@"bmp",@"BMP",nil];
}
return nil;
}
- (void)setProjectName:(NSString *)aName - (void)setProjectName:(NSString *)aName
{ {
[projectName autorelease]; [projectName autorelease];
@ -408,13 +440,13 @@
- (void)setProjectBuilder:(id<ProjectBuilder>)aBuilder - (void)setProjectBuilder:(id<ProjectBuilder>)aBuilder
{ {
[projectBuilder autorelease]; [projectManager autorelease];
projectBuilder = [aBuilder retain]; projectManager = [aBuilder retain];
} }
- (id<ProjectBuilder>)projectBuilder - (id<ProjectBuilder>)projectBuilder
{ {
return projectBuilder; return projectManager;
} }
//=========================================================================================== //===========================================================================================
@ -489,7 +521,7 @@
} }
if ([files containsObject:newFile]) { if ([files containsObject:newFile]) {
NSRunAlertPanel(@"Attention!",@"The file %@ is already contained in this project!",@"OK",nil,nil,newFile); NSRunAlertPanel(@"Attention!",@"The file %@ is already part of this project!",@"OK",nil,nil,newFile);
return; return;
} }
@ -522,6 +554,10 @@
NSString *file = [browserController nameOfSelectedFile]; NSString *file = [browserController nameOfSelectedFile];
NSMutableArray *array; NSMutableArray *array;
NSString *key; NSString *key;
NSString *otherKey;
NSString *ext;
NSString *fn;
BOOL ret = NO;
if (!file) { if (!file) {
return NO; return NO;
@ -530,11 +566,43 @@
key = [self projectKeyForKeyPath:[browserController pathOfSelectedFile]]; key = [self projectKeyForKeyPath:[browserController pathOfSelectedFile]];
[self removeFile:file forKey:key]; [self removeFile:file forKey:key];
if ([key isEqualToString:PCClasses]) {
otherKey = PCHeaders;
ext = [NSString stringWithString:@"h"];
fn = [file stringByDeletingPathExtension];
fn = [fn stringByAppendingPathExtension:ext];
if ([self doesAcceptFile:fn forKey:otherKey] == NO) {
ret = NSRunAlertPanel(@"Removing Header?",@"Should %@ be removed from the project %@ as well?",@"Yes",@"No",nil,fn,[self projectName]);
}
}
else if ([key isEqualToString:PCHeaders]) {
otherKey = PCClasses;
ext = [NSString stringWithString:@"m"];
fn = [file stringByDeletingPathExtension];
fn = [fn stringByAppendingPathExtension:ext];
if ([self doesAcceptFile:fn forKey:otherKey] == NO) {
ret = NSRunAlertPanel(@"Removing Class?",@"Should %@ be removed from the project %@ as well?",@"Yes",@"No",nil,fn,[self projectName]);
}
}
if (ret) {
[self removeFile:fn forKey:otherKey];
}
// Remove the file permanently?! // Remove the file permanently?!
if (yn) { if (yn) {
NSString *pth = [projectPath stringByAppendingPathComponent:file]; NSString *pth = [projectPath stringByAppendingPathComponent:file];
[[NSFileManager defaultManager] removeFileAtPath:pth handler:nil]; [[NSFileManager defaultManager] removeFileAtPath:pth handler:nil];
if (ret) {
pth = [projectPath stringByAppendingPathComponent:fn];
[[NSFileManager defaultManager] removeFileAtPath:pth handler:nil];
}
} }
return YES; return YES;
@ -641,7 +709,7 @@
- (void)showInspector:(id)sender - (void)showInspector:(id)sender
{ {
[projectBuilder showInspectorForProject:self]; [projectManager showInspectorForProject:self];
} }
- (id)updatedAttributeView - (id)updatedAttributeView
@ -661,74 +729,41 @@
- (void)showBuildTargetPanel:(id)sender - (void)showBuildTargetPanel:(id)sender
{ {
[buildTargetPanel center]; if (![buildTargetPanel isVisible]) {
[buildTargetPanel center];
}
[buildTargetPanel makeKeyAndOrderFront:self]; [buildTargetPanel makeKeyAndOrderFront:self];
} }
- (void)setTarget:(id)sender - (void)setTarget:(id)sender
{ {
_buildTarget = [buildTargetPopup indexOfSelectedItem]; _target = [buildTargetPopup indexOfSelectedItem];
[buildOptions setObject:[NSNumber numberWithInt:_target] forKey:BUILD_KEY];
} }
- (void)setHost:(id)sender - (void)setHost:(id)sender
{ {
NSLog(@"Setting host..."); NSString *host = [buildTargetHostField stringValue];
[buildOptions setObject:host forKey:BUILD_HOST_KEY];
NSLog(@"New host %@",host);
} }
- (void)setArguments:(id)sender - (void)setArguments:(id)sender
{ {
NSLog(@"Setting args..."); NSString *args = [buildTargetArgsField stringValue];
[buildOptions setObject:args forKey:BUILD_ARGS_KEY];
} }
- (void)build:(id)sender - (void)build:(id)sender
{ {
BOOL ret = YES; [[PCProjectBuilder sharedBuilder] showPanelWithProject:self options:buildOptions];
NSString *target = [buildTargetPopup titleOfSelectedItem];
NSMutableDictionary *optionDict = [NSMutableDictionary dictionary];
[buildStatusField setStringValue:@"Building..."];
// Check the panel for this option!
if ([target isEqualToString:@"Debug"]) {
[optionDict setObject:TARGET_MAKE_DEBUG forKey:BUILD_KEY];
}
if ([target isEqualToString:@"Profile"]) {
[optionDict setObject:TARGET_MAKE_PROFILE forKey:BUILD_KEY];
}
if ([target isEqualToString:@"Install"]) {
[optionDict setObject:TARGET_MAKE_INSTALL forKey:BUILD_KEY];
}
else {
[optionDict setObject:TARGET_MAKE forKey:BUILD_KEY];
}
[[PCProjectBuilder sharedBuilder] buildProject:self options:optionDict];
if (ret) {
[buildStatusField setStringValue:@"Build completed!"];
}
else {
[buildStatusField setStringValue:@"Build failed!"];
}
} }
- (void)clean:(id)sender - (NSDictionary *)buildOptions
{ {
BOOL ret = YES; return (NSDictionary *)buildOptions;
NSMutableDictionary *optionDict = [NSMutableDictionary dictionary];
[buildStatusField setStringValue:@"Cleaning..."];
// Check the panel for this option!
[optionDict setObject:TARGET_MAKE_CLEAN forKey:BUILD_KEY];
[[PCProjectBuilder sharedBuilder] buildProject:self options:optionDict];
if (ret) {
[buildStatusField setStringValue:@"Cleaning completed!"];
}
else {
[buildStatusField setStringValue:@"Cleaning failed!"];
}
} }
@end @end
@ -758,7 +793,8 @@
} }
key = [[keyPath componentsSeparatedByString:@"/"] lastObject]; key = [[keyPath componentsSeparatedByString:@"/"] lastObject];
if ([[rootCategories allKeys] containsObject:key] || [[projectDict objectForKey:PCSubprojects] containsObject:key]) { if ([[rootCategories allKeys] containsObject:key] ||
[[projectDict objectForKey:PCSubprojects] containsObject:key]) {
return YES; return YES;
} }
@ -767,9 +803,9 @@
- (NSString *)projectKeyForKeyPath:(NSString *)kp - (NSString *)projectKeyForKeyPath:(NSString *)kp
{ {
NSString *type = [[kp componentsSeparatedByString:@"/"] objectAtIndex:1]; NSString *type = [[kp componentsSeparatedByString:@"/"] objectAtIndex:1];
return [rootCategories objectForKey:type]; return [rootCategories objectForKey:type];
} }
@end @end
@ -778,23 +814,39 @@
- (void)windowDidBecomeKey:(NSNotification *)aNotification - (void)windowDidBecomeKey:(NSNotification *)aNotification
{ {
[projectBuilder setActiveProject:self]; [projectManager setActiveProject:self];
} }
- (void)windowDidBecomeMain:(NSNotification *)aNotification - (void)windowDidBecomeMain:(NSNotification *)aNotification
{ {
[projectBuilder setActiveProject:self]; [projectManager setActiveProject:self];
} }
- (void)windowWillClose:(NSNotification *)aNotification - (void)windowWillClose:(NSNotification *)aNotification
{ {
id object = [aNotification object];
if (object == buildTargetPanel) {
}
else if (object == [self projectWindow]) {
if ([[self projectWindow] isDocumentEdited]) { if ([[self projectWindow] isDocumentEdited]) {
if (NSRunAlertPanel(@"Project changed!",@"The project %@ has unsaved files! Should they be saved before closing it?",@"Yes",@"No",nil,[self projectName])) { if (NSRunAlertPanel(@"Project changed!",@"The project %@ has unsaved files! Should they be saved before closing it?",@"Yes",@"No",nil,[self projectName])) {
[self save]; [self save];
} }
} }
// The PCProjectController is our delegate! // The PCProjectController is our delegate!
[projectBuilder closeProject:self]; [projectManager closeProject:self];
}
} }
@end @end
@implementation PCProject (TextDelegate)
- (void)textDidEndEditing:(NSNotification *)aNotification
{
}
@end

View file

@ -28,15 +28,6 @@
@class PCProject; @class PCProject;
#define BUILD_KEY @"BuildKey"
#define BUILD_OPTIONS_KEY @"BuildOptionsKey"
#define TARGET_MAKE @"Make"
#define TARGET_MAKE_DEBUG @"MakeDebug"
#define TARGET_MAKE_PROFILE @"MakeProfile"
#define TARGET_MAKE_INSTALL @"MakeInstall"
#define TARGET_MAKE_CLEAN @"MakeClean"
@class NSWindow; @class NSWindow;
@class NSTextView; @class NSTextView;
@ -48,6 +39,9 @@
NSMutableDictionary *buildTasks; NSMutableDictionary *buildTasks;
NSString *makePath; NSString *makePath;
PCProject *currentProject;
NSDictionary *currentOptions;
} }
+ (id)sharedBuilder; + (id)sharedBuilder;
@ -55,6 +49,16 @@
- (id)init; - (id)init;
- (void)dealloc; - (void)dealloc;
- (BOOL)buildProject:(PCProject *)aProject options:(NSDictionary *)optionDict; - (void)showPanelWithProject:(PCProject *)proj options:(NSDictionary *)options;
- (void)build:(id)sender;
- (void)clean:(id)sender;
- (void)install:(id)sender;
- (void)projectDidChange:(NSNotification *)aNotif;
@end @end

View file

@ -26,6 +26,7 @@
#import "PCProjectBuilder.h" #import "PCProjectBuilder.h"
#import "PCProject.h" #import "PCProject.h"
#import "PCProjectManager.h"
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
@ -44,11 +45,12 @@
NSMiniaturizableWindowMask | NSResizableWindowMask; NSMiniaturizableWindowMask | NSResizableWindowMask;
NSSplitView *split; NSSplitView *split;
NSScrollView *scrollView1; NSScrollView *scrollView1;
NSScrollView *scrollView2; NSScrollView *scrollView2;
NSTextView *textView2; NSTextView *textView2;
NSMatrix* matrix;
NSRect _w_frame; NSRect _w_frame;
NSButtonCell* buttonCell = [[[NSButtonCell alloc] init] autorelease];
id button;
/* /*
* Build Window * Build Window
@ -69,7 +71,7 @@
[logOutput setVerticallyResizable:YES]; [logOutput setVerticallyResizable:YES];
[logOutput setHorizontallyResizable:YES]; [logOutput setHorizontallyResizable:YES];
[logOutput setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [logOutput setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[logOutput setBackgroundColor:[NSColor whiteColor]]; //[logOutput setBackgroundColor:[NSColor whiteColor]];
[[logOutput textContainer] setWidthTracksTextView:YES]; [[logOutput textContainer] setWidthTracksTextView:YES];
scrollView1 = [[NSScrollView alloc] initWithFrame:NSMakeRect (0,0,496,92)]; scrollView1 = [[NSScrollView alloc] initWithFrame:NSMakeRect (0,0,496,92)];
@ -111,6 +113,43 @@
_c_view = [buildWindow contentView]; _c_view = [buildWindow contentView];
[_c_view addSubview:split]; [_c_view addSubview:split];
/*
* Buttons
*/
_w_frame = NSMakeRect(8,268,144,48);
matrix = [[[NSMatrix alloc] initWithFrame: _w_frame
mode: NSHighlightModeMatrix
prototype: buttonCell
numberOfRows: 1
numberOfColumns: 3] autorelease];
[matrix setSelectionByRect:YES];
[matrix setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[_c_view addSubview:matrix];
button = [matrix cellAtRow:0 column:0];
[button setImagePosition:NSImageOnly];
[button setImage:IMAGE(@"ProjectCentre_build.tiff")];
[button setButtonType:NSMomentaryPushButton];
[button setTarget:self];
[button setAction:@selector(build:)];
button = [matrix cellAtRow:0 column:1];
[button setImagePosition:NSImageOnly];
[button setImage:IMAGE(@"ProjectCentre_clean.tiff")];
[button setButtonType:NSMomentaryPushButton];
[button setTarget:self];
[button setAction:@selector(clean:)];
button = [matrix cellAtRow:0 column:2];
[button setImagePosition:NSImageOnly];
[button setImage:IMAGE(@"ProjectCentre_prefs.tiff")];
[button setTarget:self];
[button setAction:@selector(showBuildTarget:)];
[button setButtonType:NSMomentaryPushButton];
[button setTarget:self];
[button setAction:@selector(install:)];
} }
@end @end
@ -133,12 +172,16 @@ static PCProjectBuilder *_builder;
[self _initUI]; [self _initUI];
makePath = [[NSString stringWithString:@"/usr/bin/make"] retain]; makePath = [[NSString stringWithString:@"/usr/bin/make"] retain];
buildTasks = [[NSMutableDictionary dictionary] retain]; buildTasks = [[NSMutableDictionary dictionary] retain];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(projectDidChange:) name:ActiveProjectDidChangeNotification object:nil];
} }
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[buildWindow release]; [buildWindow release];
[makePath release]; [makePath release];
[buildTasks release]; [buildTasks release];
@ -146,9 +189,21 @@ static PCProjectBuilder *_builder;
[super dealloc]; [super dealloc];
} }
- (BOOL)buildProject:(PCProject *)aProject options:(NSDictionary *)optionDict - (void)showPanelWithProject:(PCProject *)proj options:(NSDictionary *)options;
{
if (![buildWindow isVisible]) {
[buildWindow center];
}
[buildWindow makeKeyAndOrderFront:self];
currentProject = proj;
currentOptions = options;
[buildWindow setTitle:[proj projectName]];
}
- (void)build:(id)sender
{ {
BOOL ret = NO;
NSString *tg = nil; NSString *tg = nil;
NSTask *makeTask; NSTask *makeTask;
NSMutableArray *args; NSMutableArray *args;
@ -156,14 +211,18 @@ static PCProjectBuilder *_builder;
NSPipe *logPipe; NSPipe *logPipe;
NSFileHandle *readHandle; NSFileHandle *readHandle;
NSData *inData = nil; NSData *inData = nil;
NSDictionary *optionDict;
if (!currentProject) {
return;
}
logPipe = [NSPipe pipe]; logPipe = [NSPipe pipe];
readHandle = [logPipe fileHandleForReading]; readHandle = [logPipe fileHandleForReading];
NSAssert(aProject,@"No project provided!");
makeTask = [[NSTask alloc] init]; makeTask = [[NSTask alloc] init];
optionDict = [currentProject buildOptions];
if ((tg = [optionDict objectForKey:BUILD_KEY])) { if ((tg = [optionDict objectForKey:BUILD_KEY])) {
if ([tg isEqualToString:TARGET_MAKE_DEBUG]) { if ([tg isEqualToString:TARGET_MAKE_DEBUG]) {
args = [NSMutableArray array]; args = [NSMutableArray array];
@ -176,28 +235,13 @@ static PCProjectBuilder *_builder;
[args addObject:@"static=YES"]; [args addObject:@"static=YES"];
[makeTask setArguments:args]; [makeTask setArguments:args];
} }
else if ([tg isEqualToString:TARGET_MAKE_INSTALL]) {
args = [NSMutableArray array];
[args addObject:@"install"];
[makeTask setArguments:args];
}
else if ([tg isEqualToString:TARGET_MAKE_CLEAN]) {
args = [NSMutableArray array];
[args addObject:@"clean"];
[makeTask setArguments:args];
}
[makeTask setCurrentDirectoryPath:[aProject projectPath]]; [makeTask setCurrentDirectoryPath:[currentProject projectPath]];
[makeTask setLaunchPath:makePath]; [makeTask setLaunchPath:makePath];
[makeTask setStandardOutput:logPipe]; [makeTask setStandardOutput:logPipe];
[makeTask setStandardError:logPipe]; [makeTask setStandardError:logPipe];
if (![buildWindow isVisible]) {
[buildWindow center];
[buildWindow makeKeyAndOrderFront:self];
}
[makeTask launch]; [makeTask launch];
/* /*
@ -212,17 +256,30 @@ static PCProjectBuilder *_builder;
} }
[makeTask waitUntilExit]; [makeTask waitUntilExit];
ret = [makeTask terminationStatus];
#ifdef DEBUG
NSLog(@"Task terminated %@...",(ret)?@"successfully":@"not successfully");
#endif DEBUG
[makeTask autorelease]; [makeTask autorelease];
} }
}
return ret;
- (void)clean:(id)sender
{
}
- (void)install:(id)sender
{
}
- (void)projectDidChange:(NSNotification *)aNotif
{
PCProject *project = [aNotif object];
if (project) {
currentProject = project;
[buildWindow setTitle:[project projectName]];
}
else {
currentProject = nil;
[buildWindow orderOut:self];
}
} }
@end @end

View file

@ -167,3 +167,7 @@
- (BOOL)projectManager:(id)sender shouldOpenProject:(PCProject *)aProject; - (BOOL)projectManager:(id)sender shouldOpenProject:(PCProject *)aProject;
@end @end
extern NSString *ActiveProjectDidChangeNotification;

View file

@ -31,6 +31,8 @@
#import <AppKit/IMLoading.h> #import <AppKit/IMLoading.h>
#endif #endif
NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
@interface PCProjectManager (CreateUI) @interface PCProjectManager (CreateUI)
- (void)_initUI; - (void)_initUI;
@ -155,18 +157,20 @@
- (void)setActiveProject:(PCProject *)aProject - (void)setActiveProject:(PCProject *)aProject
{ {
if (aProject != activeProject) { if (aProject != activeProject) {
activeProject = aProject; activeProject = aProject;
//~ Is this needed? [[NSNotificationCenter defaultCenter] postNotificationName:ActiveProjectDidChangeNotification object:activeProject];
if (activeProject) {
[[activeProject projectWindow] makeKeyAndOrderFront:self]; //~ Is this needed?
} if (activeProject) {
[[activeProject projectWindow] makeKeyAndOrderFront:self];
if ([inspector isVisible]) {
[self inspectorPopupDidChange:inspectorPopup];
}
} }
if ([inspector isVisible]) {
[self inspectorPopupDidChange:inspectorPopup];
}
}
} }
- (void)saveAllProjects - (void)saveAllProjects
@ -198,6 +202,8 @@
concretBuilder = [NSClassFromString([builders objectForKey:builderKey]) sharedCreator]; concretBuilder = [NSClassFromString([builders objectForKey:builderKey]) sharedCreator];
if ((project = [concretBuilder openProjectAt:aPath])) { if ((project = [concretBuilder openProjectAt:aPath])) {
[[project projectWindow] center];
return project; return project;
} }
} }
@ -250,6 +256,8 @@
return NO; return NO;
} }
[[project projectWindow] center];
[project setProjectBuilder:self]; [project setProjectBuilder:self];
[loadedProjects setObject:project forKey:aPath]; [loadedProjects setObject:project forKey:aPath];
[self setActiveProject:project]; [self setActiveProject:project];
@ -271,38 +279,31 @@
- (void)inspectorPopupDidChange:(id)sender - (void)inspectorPopupDidChange:(id)sender
{ {
NSView *view = nil; NSView *view = nil;
if (![self activeProject]) { if (![self activeProject]) {
return; return;
} }
switch([sender indexOfSelectedItem]) { switch([sender indexOfSelectedItem]) {
case 0: case 0:
view = [[[self activeProject] updatedAttributeView] retain]; view = [[[self activeProject] updatedAttributeView] retain];
break; break;
case 1: case 1:
view = [[[self activeProject] updatedProjectView] retain]; view = [[[self activeProject] updatedProjectView] retain];
break; break;
case 2: case 2:
view = [[[self activeProject] updatedFilesView] retain]; view = [[[self activeProject] updatedFilesView] retain];
break; break;
} }
[(NSBox *)inspectorView setContentView:view]; [(NSBox *)inspectorView setContentView:view];
[inspectorView display]; [inspectorView display];
} }
- (void)showInspectorForProject:(PCProject *)aProject - (void)showInspectorForProject:(PCProject *)aProject
{ {
if (!inspectorPopup) { if (!inspectorPopup) {
#if defined(GNUSTEP)
[self _initUI]; [self _initUI];
#else
if(![NSBundle loadNibNamed:@"Inspector.nib" owner:self]) {
[[NSException exceptionWithName:NIB_NOT_FOUND_EXCEPTION reason:@"Could not load Inspector.gmodel" userInfo:nil] raise];
return nil;
}
#endif
[inspectorPopup removeAllItems]; [inspectorPopup removeAllItems];
[inspectorPopup addItemWithTitle:@"Build Attributes"]; [inspectorPopup addItemWithTitle:@"Build Attributes"];
@ -460,3 +461,5 @@
@end @end

View file

@ -42,7 +42,7 @@ extern NSString *PCProjectDidUpdateNotification;
extern NSString *PCFileAddedToProjectNotification; extern NSString *PCFileAddedToProjectNotification;
extern NSString *PCFileRemovedFromProjectNotification; extern NSString *PCFileRemovedFromProjectNotification;
extern NSString *PCFileWillOpenNotification; extern NSString *PCFileWillOpenNotification;
extern NSString *PCFileDidOpenNotification; extern NSString *PCFileDidOpenNotification;
extern NSString *PCFileWillCloseNotification; extern NSString *PCFileWillCloseNotification;
extern NSString *PCFileDidCloseNotification; extern NSString *PCFileDidCloseNotification;
@ -64,11 +64,28 @@ extern NSString *PCProjectBuildDidStopNotification;
@interface PCServer : NSObject <Server> @interface PCServer : NSObject <Server>
{ {
NSMutableArray *clients; NSMutableArray *clients;
NSMutableArray *openDocuments;
} }
//----------------------------------------------------------------------------
// Init and free
//----------------------------------------------------------------------------
- (id)init; - (id)init;
- (void)dealloc; - (void)dealloc;
//----------------------------------------------------------------------------
// Miscellaneous
//----------------------------------------------------------------------------
- (void)fileShouldBeOpened:(NSNotification *)aNotif;
- (void)openFileInExternalEditor:(NSString *)file;
- (void)openFileInInternalEditor:(NSString *)file;
- (NSWindow *)editorForFile:(NSString *)aFile;
- (void)windowDidClose:(NSNotification *)aNotif;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Server // Server
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -90,7 +107,7 @@ extern NSString *PCProjectBuildDidStopNotification;
- (NSArray*)touchedFiles; - (NSArray*)touchedFiles;
// Both methods return full paths! // Both methods return full paths!
- (BOOL)querTouchedFiles; - (BOOL)queryTouchedFiles;
// Prompts user to save all files and projects with dirtied buffers. // Prompts user to save all files and projects with dirtied buffers.
- (BOOL)addFileAt:(NSString*)filePath toProject:(PCProject *)projectPath; - (BOOL)addFileAt:(NSString*)filePath toProject:(PCProject *)projectPath;

View file

@ -26,23 +26,135 @@
#import "PCServer.h" #import "PCServer.h"
#import "ProjectCenter.h" #import "ProjectCenter.h"
#import "PCBrowserController.h"
@implementation PCServer @implementation PCServer
//----------------------------------------------------------------------------
// Init and free
//----------------------------------------------------------------------------
- (id)init - (id)init
{ {
if ((self = [super init])) { if ((self = [super init])) {
clients = [[NSMutableArray alloc] init]; clients = [[NSMutableArray alloc] init];
} openDocuments = [[NSMutableArray alloc] init];
return self;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileShouldBeOpened:) name:FileShouldOpenNotification object:nil];
}
return self;
} }
- (void)dealloc - (void)dealloc
{ {
[clients release]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
[openDocuments release];
[clients release];
[super dealloc];
} }
//----------------------------------------------------------------------------
// Miscellaneous
//----------------------------------------------------------------------------
- (void)fileShouldBeOpened:(NSNotification *)aNotif
{
NSString *file = [[aNotif userInfo] objectForKey:@"FilePathKey"];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:ExternalEditor] isEqualToString:@"YES"]) {
[self openFileInExternalEditor:file];
}
else {
[self openFileInInternalEditor:file];
}
}
- (void)openFileInExternalEditor:(NSString *)file
{
NSTask *editorTask;
NSMutableArray *args = [NSMutableArray array];
NSUserDefaults *udef = [NSUserDefaults standardUserDefaults];
NSString *editor = [udef objectForKey:Editor];
editorTask = [[[NSTask alloc] init] autorelease];
[editorTask setLaunchPath:editor];
[args addObject:file];
[editorTask setArguments:args];
[editorTask launch];
}
- (void)openFileInInternalEditor:(NSString *)file
{
NSWindow *editorWindow = [self editorForFile:file];
[editorWindow setDelegate:self];
[editorWindow center];
[editorWindow makeKeyAndOrderFront:self];
[openDocuments addObject:editorWindow];
}
- (NSWindow *)editorForFile:(NSString *)aFile
{
unsigned int style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
NSRect rect = NSMakeRect(100,100,512,320);
NSWindow *window = [[NSWindow alloc] initWithContentRect:rect
styleMask:style
backing:NSBackingStoreBuffered
defer:NO];
NSTextView *textView;
NSScrollView *scrollView;
NSString *text = [NSString stringWithContentsOfFile:aFile];
[window setMinSize:NSMakeSize(512,320)];
[window setTitle:[aFile lastPathComponent]];
textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,498,306)];
[textView setMaxSize:NSMakeSize(1e7, 1e7)];
[textView setVerticallyResizable:YES];
[textView setHorizontallyResizable:YES];
[textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[textView setBackgroundColor:[NSColor whiteColor]];
[[textView textContainer] setWidthTracksTextView:YES];
[textView autorelease];
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect (-1,-1,514,322)];
[scrollView setDocumentView:textView];
[textView setMinSize:NSMakeSize(0.0,[scrollView contentSize].height)];
[[textView textContainer] setContainerSize:NSMakeSize([scrollView contentSize].width,1e7)];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
[scrollView autorelease];
[[window contentView] addSubview:scrollView];
/*
* Will be replaced when a real editor is available...
*/
[textView setText:text];
return [window autorelease];
}
- (void)windowDidClose:(NSNotification *)aNotif
{
NSWindow *window = [aNotif object];
[openDocuments removeObject:window];
}
//----------------------------------------------------------------------------
// Server
//----------------------------------------------------------------------------
- (BOOL)registerProjectSubmenu:(NSMenu *)menu - (BOOL)registerProjectSubmenu:(NSMenu *)menu
{ {
} }
@ -91,7 +203,7 @@
{ {
} }
- (BOOL)querTouchedFiles - (BOOL)queryTouchedFiles
{ {
} }

View file

@ -42,6 +42,7 @@
#define BundlePaths @"BundlePaths" #define BundlePaths @"BundlePaths"
#define SuccessSound @"SuccessSound" #define SuccessSound @"SuccessSound"
#define FailureSound @"FailureSound" #define FailureSound @"FailureSound"
#define ExternalEditor @"ExternalEditor"
#define PCAppDidInitNotification @"PCAppDidInit" #define PCAppDidInitNotification @"PCAppDidInit"
#define PCAppWillTerminateNotification @"PCAppWillTerminate" #define PCAppWillTerminateNotification @"PCAppWillTerminate"

View file

@ -50,7 +50,7 @@
- (NSArray*)touchedFiles; - (NSArray*)touchedFiles;
// Returns array of paths of files that are "unsaved" or nil if none. // Returns array of paths of files that are "unsaved" or nil if none.
- (BOOL)querTouchedFiles; - (BOOL)queryTouchedFiles;
// Prompts user to save all files and projects with dirtied buffers. // Prompts user to save all files and projects with dirtied buffers.
- (BOOL)addFileAt:(NSString*)filePath toProject:(PCProject *)projectPath; - (BOOL)addFileAt:(NSString*)filePath toProject:(PCProject *)projectPath;