2002-02-21 21:17:22 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2002-11-24 11:08:02 +00:00
|
|
|
#import "PCDefines.h"
|
2002-02-21 21:17:22 +00:00
|
|
|
#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];
|
|
|
|
|
2002-04-26 03:12:50 +00:00
|
|
|
/* This causes a problem because we try to reloadColumn on the browser
|
|
|
|
in the middle of someone clicking in it (-click: sends notification
|
|
|
|
which is received by histortDidChange:, etc. Is there a better
|
|
|
|
way around this? */
|
|
|
|
//[[NSNotificationCenter defaultCenter] postNotificationName:@"FileBecomesEditedNotification" object:file];
|
2002-02-21 21:17:22 +00:00
|
|
|
|
2002-03-03 13:47:38 +00:00
|
|
|
AUTORELEASE(file);
|
2002-02-21 21:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBrowser:(NSBrowser *)aBrowser
|
|
|
|
{
|
|
|
|
NSAssert(browser==nil,@"The browser is already set!");
|
|
|
|
|
2002-04-26 03:12:50 +00:00
|
|
|
browser = aBrowser;
|
2002-02-21 21:17:22 +00:00
|
|
|
|
|
|
|
[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<count;++i )
|
|
|
|
{
|
|
|
|
id cell;
|
|
|
|
|
|
|
|
[matrix insertRow:i];
|
|
|
|
|
|
|
|
cell = [matrix cellAtRow:i column:0];
|
|
|
|
[cell setStringValue:[editedFiles objectAtIndex:i]];
|
|
|
|
[cell setLeaf:YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(int)row column:(int)column
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|