/* 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 "PerforceJob.h" #import "AppController.h" #import "ReadOnlyEditorController.h" #import "PerforceActionJob.h" @implementation PerforceJob - (id) initWithName: (NSString*) jobName withStatus: (NSString*) jobStatus withUser: (NSString*) jobUser withDate: (NSString*) jobDate withDesc: (NSString*) jobDesc; { self = [super init]; fName = [jobName copy]; fStatus = [jobStatus copy]; fUser = [jobUser copy]; fDate = [jobDate copy]; fDescription = [jobDesc copy]; return self; } - (void) dealloc { [fName release]; [fStatus release]; [fUser release]; [fDate release]; [fDescription release]; [super dealloc]; } - (NSString*) getJobName; { return fName; } - (NSString*) getJobStatus; { return fStatus; } - (NSString*) getJobUser; { return fUser; } - (NSString*) getJobDate; { return fDate; } - (NSString*) getJobDescription; { return fDescription; } - (NSComparisonResult) comparegetJobNameAscending: (PerforceJob*) rhs { return [fName compare:rhs->fName]; } - (NSComparisonResult) comparegetJobNameDescending: (PerforceJob*) rhs { return [rhs->fName compare:fName]; } - (NSComparisonResult) comparegetJobStatusAscending: (PerforceJob*) rhs { return [fStatus compare:rhs->fStatus]; } - (NSComparisonResult) comparegetJobStatusDescending: (PerforceJob*) rhs { return [rhs->fStatus compare:fStatus]; } - (NSComparisonResult) comparegetJobUserAscending: (PerforceJob*) rhs { return [fUser compare:rhs->fUser]; } - (NSComparisonResult) comparegetJobUserDescending: (PerforceJob*) rhs { return [rhs->fUser compare:fUser]; } - (NSComparisonResult) comparegetJobDateAscending: (PerforceJob*) rhs { return [fDate compare:rhs->fDate]; } - (NSComparisonResult) comparegetJobDateDescending: (PerforceJob*) rhs { return [rhs->fDate compare:fDate]; } - (NSComparisonResult) comparegetJobDescriptionAscending: (PerforceJob*) rhs { return [fDescription compare:rhs->fDescription]; } - (NSComparisonResult) comparegetJobDescriptionDescending: (PerforceJob*) rhs { return [rhs->fDescription compare:fDescription]; } // The enablement - (BOOL) canEdit { return YES; } - (BOOL) canDescribe { return YES; } - (BOOL) canDelete { return YES; } // The actions - (void) doEdit { [PerforceActionJobGet defaultRunFor:[NSApp delegate] selector:@selector(resultFromPerforceJobOut:) identifier:fName]; } - (void) doDescribe { [PerforceActionJobGet defaultRunFor:self selector:@selector(resultFromDescribe:) identifier:fName]; } - (void) doDelete { int isOK = NSRunAlertPanel (@"Delete", @"Are you sure you want to delete job %s?", @"OK", @"Cancel", nil, [fName cString]); if ( isOK ) { [PerforceActionJobDelete defaultRunFor:nil selector:nil identifier:fName]; } } - (void) resultFromDescribe:(PerforceActionJobGet*)action { if ( [action wasSuccess] ) { NSMutableString* titleString = [NSMutableString stringWithString:@"Description of Job "]; [titleString appendString:[action getIdentifier]]; [ReadOnlyEditorController showWindowWith:[action getOutput] title:titleString]; } } @end