diff --git a/PCLib/GNUmakefile b/PCLib/GNUmakefile index 57ca5eb..cb6c11a 100644 --- a/PCLib/GNUmakefile +++ b/PCLib/GNUmakefile @@ -68,7 +68,8 @@ PCTextFinder.h \ PCProjectEditor.h \ ProjectComponent.h \ PCProject+ComponentHandling.h \ -PCEditorView+Highlighting.h +PCEditorView+Highlighting.h \ +PCHistoryController.h # @@ -92,7 +93,8 @@ PCEditorController.m \ PCTextFinder.m \ PCProjectEditor.m \ PCProject+ComponentHandling.m \ -PCEditorView+Highlighting.m +PCEditorView+Highlighting.m \ +PCHistoryController.m # diff --git a/PCLib/PCBrowserController.m b/PCLib/PCBrowserController.m index 9529770..de11da0 100644 --- a/PCLib/PCBrowserController.m +++ b/PCLib/PCBrowserController.m @@ -46,6 +46,8 @@ if ([self isEditableCategory:category]) { + [[NSNotificationCenter defaultCenter] postNotificationName:@"FileBecomesEditedNotification" object:ltitle]; + [project browserDidClickFile:ltitle category:category]; } } @@ -118,8 +120,7 @@ - (void)setBrowser:(NSBrowser *)aBrowser { - [browser autorelease]; - browser = [aBrowser retain]; + browser = aBrowser; [browser setTitled:NO]; @@ -138,8 +139,7 @@ - (void)setProject:(PCProject *)aProj { - AUTORELEASE(project); - project = RETAIN(aProj); + project = aProj; } @end @@ -153,18 +153,10 @@ int i; int count = [files count]; - if (count == 0) { -#ifdef DEBUG - NSLog(@"<%@ %x>: create rows for column in %@ (%x) aborted - 0 files!",[self class],self,[project class],project); -#endif - return; - } + if( sender != browser ) return; -#ifdef DEBUG - NSLog(@"<%@ %x>: create rows for column %d in %x",[self class],self,column,sender); -#endif //DEBUG - - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) + { NSMutableString *keyPath = [NSMutableString stringWithString:pathToCol]; id cell; @@ -182,9 +174,6 @@ - (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(int)row column:(int)column { -#ifdef DEBUG - NSLog(@"<%@ %x>: browser %x will display %@ %x at %d,%d",[self class],self,sender,[cell class],cell,row,column); -#endif //DEBUG } - (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column diff --git a/PCLib/PCHistoryController.h b/PCLib/PCHistoryController.h new file mode 100644 index 0000000..3dc774a --- /dev/null +++ b/PCLib/PCHistoryController.h @@ -0,0 +1,45 @@ +/* + * PCHistoryController.h created by probert on 2002-02-21 14:28:09 +0000 + * + * Project ProjectCenter + * + * Created with ProjectCenter - http://www.gnustep.org + * + * $Id$ + */ + +#ifndef _PCHISTORYCONTROLLER_H_ +#define _PCHISTORYCONTROLLER_H_ + +#import + +@class PCProject; + +@interface PCHistoryController : NSObject +{ + id browser; + PCProject *project; + NSMutableArray *editedFiles; +} + +- (id)initWithProject:(PCProject *)aProj; +- (void)dealloc; + +- (void)click:(id)sender; + +- (void)setBrowser:(NSBrowser *)aBrowser; + +- (void)historyDidChange:(NSNotification *)notif; + +@end + +@interface PCHistoryController (HistoryBrowserDelegate) + +- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix; +- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(int)row column:(int)column; +- (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column; + +@end + +#endif // _PCHISTORYCONTROLLER_H_ + diff --git a/PCLib/PCHistoryController.m b/PCLib/PCHistoryController.m new file mode 100644 index 0000000..bcf768e --- /dev/null +++ b/PCLib/PCHistoryController.m @@ -0,0 +1,113 @@ +/* + * PCHistoryController.m created by probert on 2002-02-21 14:28:08 +0000 + * + * Project ProjectCenter + * + * Created with ProjectCenter - http://www.gnustep.org + * + * $Id$ + */ + +#import "PCHistoryController.h" +#import "PCProject.h" + +@implementation PCHistoryController + +- (id)initWithProject:(PCProject *)aProj +{ + NSAssert(aProj, @"Project is mandatory!"); + + if((self = [super init])) + { + project = aProj; + + editedFiles = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + RELEASE(editedFiles); + + [super dealloc]; +} + +- (void)click:(id)sender +{ + NSString *file = [[[sender selectedCell] stringValue] copy]; + + [project browserDidClickFile:file category:nil]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"FileBecomesEditedNotification" object:file]; + //[browser selectRow:0 inColumn:0]; + + RELEASE(file); +} + +- (void)setBrowser:(NSBrowser *)aBrowser +{ + NSAssert(browser==nil,@"The browser is already set!"); + + browser = aBrowser; + + [browser setTitled:NO]; + + [browser setTarget:self]; + [browser setAction:@selector(click:)]; + + [browser setMaxVisibleColumns:1]; + [browser setAllowsMultipleSelection:NO]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(historyDidChange:) name:@"FileBecomesEditedNotification" object:nil]; +} + +- (void)historyDidChange:(NSNotification *)notif +{ + NSString *file = [notif object]; + + if( [editedFiles containsObject:file] == YES ) + { + [editedFiles removeObject:file]; + } + + [editedFiles insertObject:file atIndex:0]; + [browser reloadColumn:0]; +} + +@end + +@implementation PCHistoryController (HistoryBrowserDelegate) + +- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix +{ + int i; + int count = [editedFiles count]; + + if( sender != browser ) return; + + for( i=0; i #import #import +#import #import #import #import diff --git a/PCLib/ProjectCenter.pcproj b/PCLib/ProjectCenter.pcproj index c45c061..fb18e8d 100644 --- a/PCLib/ProjectCenter.pcproj +++ b/PCLib/ProjectCenter.pcproj @@ -18,7 +18,8 @@ PCTextFinder.m, PCProjectEditor.m, PCProject+ComponentHandling.m, - PCEditorView+Highlighting.m + PCEditorView+Highlighting.m, + PCHistoryController.m ); COMPILEROPTIONS = ""; CREATION_DATE = ""; @@ -54,7 +55,8 @@ PCProjectEditor.h, ProjectComponent.h, PCProject+ComponentHandling.h, - PCEditorView+Highlighting.h + PCEditorView+Highlighting.h, + PCHistoryController.h ); INSTALLDIR = "$(GNUSTEP_SYSTEM_ROOT)"; LANGUAGE = English;