/*
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 "LabelsController.h"
#import "IconDefs.h"
#import "PerforceActionLabels.h"
#import "MessageDefs.h"
static NSString* kBrowserCellColumnName = @"getLabelName";
static NSString* kDefaultSortColumnKey = @"LabelsSortColumn";
static NSString* kDefaultSortDirectionKey = @"LabelsSortDirection";
@implementation LabelsController
+ (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 = fLabelsView;
fIconID = kLabelsIcon;
fIconColumnName = kBrowserCellColumnName;
//fPerforceActionMethod = @selector(labels);
fDefaultSortColumnKey = kDefaultSortColumnKey;
fDefaultSortDirectionKey = kDefaultSortDirectionKey;
NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter];
[nCenter addObserver:self selector:@selector(labelChanged:) name:kLabelChanged object:nil];
[super setUpCell];
[fLabelsView setAutosaveName:@"LabelsTableInfo"];
[fLabelsView setAutosaveTableColumns:YES];
}
- (void) labelChanged:(NSNotification*) notification
{
[self refreshData];
}
- (void) resultFromPerforce: (PerforceActionLabels*) action
{
if ( [action wasSuccess] )
{
[fChildren setArray:[action getLabels]];
[self sortChildren];
}
}
- (void) buildChildren
{
fChildren = [[NSMutableArray alloc] init];
[PerforceActionLabels defaultRunFor:self selector:@selector(resultFromPerforce:)];
}
- (void) doubleClick: (id) sender
{
[self doDescribe];
}
// The enablement
- (BOOL) canEdit
{
id <LabelProtocol> selection = [self getSelection];
return [selection canEdit];
}
- (BOOL) canDescribe
{
id <LabelProtocol> selection = [self getSelection];
return [selection canDescribe];
}
- (BOOL) canDelete
{
id <LabelProtocol> selection = [self getSelection];
return [selection canDelete];
}
- (BOOL) canSyncTo
{
id <LabelProtocol> selection = [self getSelection];
return [selection canSyncTo];
}
// The actions
- (void) doEdit
{
id <LabelProtocol> selection = [self getSelection];
[selection doEdit];
}
- (void) doDescribe
{
id <LabelProtocol> selection = [self getSelection];
[selection doDescribe];
}
- (void) doDelete
{
id <LabelProtocol> selection = [self getSelection];
[selection doDelete];
}
- (void) doSyncTo
{
id <LabelProtocol> selection = [self getSelection];
[selection doSyncTo];
}
@end
# |
Change |
User |
Description |
Committed |
|
#1
|
3210 |
Paul Ferguson |
Initial branch |
|
|
//guest/jeff_argast/P4Cocoa/source/Controllers/LabelsController.m |
#1
|
2732 |
Jeff Argast |
Initial submission of P4Cocoa |
|
|