/*
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 "PerforceClient.h"
#import "PerforceActionClient.h"
#import "AppController.h"
#import "ReadOnlyEditorController.h"
#import "AppDefaults.h"
@implementation PerforceClient
- (id) initWithName: (NSString*) clientName
withDate: (NSString*) clientDate
withRoot: (NSString*) clientRoot
withDesc: (NSString*) clientDesc;
{
self = [super init];
fName = [clientName copy];
fDate = [clientDate copy];
fRoot = [clientRoot copy];
fDescription = [clientDesc copy];
return self;
}
- (void) dealloc
{
[fName release];
[fDate release];
[fRoot release];
[fDescription release];
[super dealloc];
}
- (NSString*) getClientName
{
return fName;
}
- (NSString*) getClientDate
{
return fDate;
}
- (NSString*) getClientRoot
{
return fRoot;
}
- (NSString*) getClientDescription
{
return fDescription;
}
- (NSComparisonResult) comparegetClientNameAscending: (PerforceClient*) rhs
{
return [fName compare:rhs->fName];
}
- (NSComparisonResult) comparegetClientNameDescending: (PerforceClient*) rhs
{
return [rhs->fName compare:fName];
}
- (NSComparisonResult) comparegetClientDateAscending: (PerforceClient*) rhs
{
return [fDate compare:rhs->fDate];
}
- (NSComparisonResult) comparegetClientDateDescending: (PerforceClient*) rhs
{
return [rhs->fDate compare:fDate];
}
- (NSComparisonResult) comparegetClientRootAscending: (PerforceClient*) rhs
{
return [fRoot compare:rhs->fRoot];
}
- (NSComparisonResult) comparegetClientRootDescending: (PerforceClient*) rhs
{
return [rhs->fRoot compare:fRoot];
}
- (NSComparisonResult) comparegetClientDescriptionAscending: (PerforceClient*) rhs
{
return [fDescription compare:rhs->fDescription];
}
- (NSComparisonResult) comparegetClientDescriptionDescending: (PerforceClient*) rhs
{
return [rhs->fDescription compare:fDescription];
}
// The enablement
- (BOOL) canEdit:(NSString**)clientName
{
*clientName = fName;
return YES;
}
- (BOOL) canDescribe
{
return YES;
}
- (BOOL) canDelete
{
AppDefaults* appDef = [AppDefaults defaultAppDefaults];
return [fName isEqualToString:[appDef getPerforceClient]];
}
- (BOOL) canSwitchTo
{
AppDefaults* appDef = [AppDefaults defaultAppDefaults];
return ![fName isEqualToString:[appDef getPerforceClient]];
}
// The actions
- (void) doEdit
{
[PerforceActionClientGet defaultRunFor:[NSApp delegate] selector:@selector(resultFromPerforceClientOut:) identifier:fName];
}
- (void) doDescribe
{
[PerforceActionClientGet defaultRunFor:self selector:@selector(resultFromDescribe:) identifier:fName];
}
- (void) doDelete
{
int isOK = NSRunAlertPanel (@"Delete",
@"Are you sure you want to delete client %s?",
@"OK",
@"Cancel",
nil,
[fName cString]);
if ( isOK )
{
[PerforceActionClientDelete defaultRunFor:nil selector:nil identifier:fName];
}
}
- (void) doSwitchTo
{
AppDefaults* appDef = [AppDefaults defaultAppDefaults];
[appDef setPerforceClient:fName];
}
- (void) resultFromDescribe:(PerforceActionClientGet*)action
{
if ( [action wasSuccess] )
{
NSMutableString* titleString = [NSMutableString stringWithString:@"Description of Client "];
[titleString appendString:[action getIdentifier]];
[ReadOnlyEditorController showWindowWith:[action getOutput] title:titleString];
}
}
@end
# |
Change |
User |
Description |
Committed |
|
#1
|
3176 |
paolo_resmini |
initial branch for Paolo Resmini |
|
|
//guest/jeff_argast/P4Cocoa/source/Perforce/PerforceClient.m |
#1
|
2732 |
Jeff Argast |
Initial submission of P4Cocoa |
|
|