/*
Copyright (C) 2002-2003, Jeffrey D. Argast.
The authors make NO WARRANTY or representation, either express or implied,
with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.
Permission is hereby granted to use, copy, modify, and distribute this
software or portions thereof for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code is distributed, then this
statement must be included, with this copyright and no-warranty notice
unaltered.
(2) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.
*/
#import "UsersController.h"
#import "IconDefs.h"
#import "PerforceActionUsers.h"
#import "MessageDefs.h"
static NSString* kBrowserCellColumnName = @"getUserName";
static NSString* kDefaultSortColumnKey = @"UsersSortColumn";
static NSString* kDefaultSortDirectionKey = @"UsersSortDirection";
@implementation UsersController
+ (void) initialize
{
NSMutableDictionary* defaultValues = [NSMutableDictionary dictionary];
[defaultValues setObject:kBrowserCellColumnName forKey:kDefaultSortColumnKey];
[defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kDefaultSortDirectionKey];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
- (void) awakeFromNib
{
fTableView = fUsersView;
fIconID = kUsersIcon;
fIconColumnName = kBrowserCellColumnName;
//fPerforceActionMethod = @selector(users);
fDefaultSortColumnKey = kDefaultSortColumnKey;
fDefaultSortDirectionKey = kDefaultSortDirectionKey;
NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter];
[nCenter addObserver:self selector:@selector(userChanged:) name:kUserChanged object:nil];
[super setUpCell];
[fUsersView setAutosaveName:@"UsersTableInfo"];
[fUsersView setAutosaveTableColumns:YES];
}
- (void) userChanged:(NSNotification*) notification
{
[self refreshData];
}
- (void) resultFromPerforce: (PerforceActionUsers*) action
{
if ( [action wasSuccess] )
{
[fChildren setArray:[action getUsers]];
[self sortChildren];
}
}
- (void) buildChildren
{
fChildren = [[NSMutableArray alloc] init];
[PerforceActionUsers defaultRunFor:self selector:@selector(resultFromPerforce:)];
}
- (void) doubleClick: (id) sender
{
[self doDescribe];
}
// The enablement
- (BOOL) canEdit
{
id <UserProtocol> selection = [self getSelection];
return [selection canEdit];
}
- (BOOL) canDescribe
{
id <UserProtocol> selection = [self getSelection];
return [selection canDescribe];
}
- (BOOL) canDelete
{
id <UserProtocol> selection = [self getSelection];
return [selection canDelete];
}
- (BOOL) canSwitchTo
{
id <UserProtocol> selection = [self getSelection];
return [selection canSwitchTo];
}
// The actions
- (void) doEdit
{
id <UserProtocol> selection = [self getSelection];
[selection doEdit];
}
- (void) doDescribe
{
id <UserProtocol> selection = [self getSelection];
[selection doDescribe];
}
- (void) doDelete
{
id <UserProtocol> selection = [self getSelection];
[selection doDelete];
}
- (void) doSwitchTo
{
id <UserProtocol> selection = [self getSelection];
[selection doSwitchTo];
}
@end
# |
Change |
User |
Description |
Committed |
|
#1
|
3176 |
paolo_resmini |
initial branch for Paolo Resmini |
|
|
//guest/jeff_argast/P4Cocoa/source/Controllers/UsersController.m |
#1
|
2732 |
Jeff Argast |
Initial submission of P4Cocoa |
|
|