/* 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 "PerforceSubmittedChange.h" #import "ReadOnlyEditorController.h" #import "PerforceActionDescribe.h" #import "PerforceActionSync.h" #import "MessageDefs.h" #import "AppUtils.h" const static int kNumDigits = 6; static NSString* kFiveZeros = @"00000"; static NSString* kFourZeros = @"0000"; static NSString* kThreeZeros = @"000"; static NSString* kTwoZeros = @"00"; static NSString* kOneZero = @"0"; @implementation PerforceSubmittedChange - (id) initWithNumber: (NSString*) changeNumber withDate: (NSString*) changeDate withUser: (NSString*) changeUser withDesc: (NSString*) changeDesc { int numLen = [changeNumber length]; self = [super init]; // display at least kNumDigits digits if ( numLen < kNumDigits ) { int numToPrepend = kNumDigits - numLen; NSMutableString* numString = [NSMutableString stringWithCapacity:kNumDigits]; switch ( numToPrepend ) { case 5: [numString appendString:kFiveZeros]; break; case 4: [numString appendString:kFourZeros]; break; case 3: [numString appendString:kThreeZeros]; break; case 2: [numString appendString:kTwoZeros]; break; case 1: [numString appendString:kOneZero]; break; } [numString appendString:changeNumber]; fNumber = [[NSString stringWithCString:[numString cString]] retain]; } else { fNumber = [changeNumber copy]; } fDate = [changeDate copy]; fUser = [changeUser copy]; fDescription = [changeDesc copy]; return self; } - (void) dealloc { [fNumber release]; [fDate release]; [fUser release]; [fDescription release]; [super dealloc]; } - (NSString*) getChangeNumber { return fNumber; } - (NSString*) getChangeDate { return fDate; } - (NSString*) getChangeUser { return fUser; } - (NSString*) getChangeDescription { return fDescription; } - (NSComparisonResult) comparegetChangeNumberAscending: (PerforceSubmittedChange*) rhs { return [fNumber caseInsensitiveCompare:rhs->fNumber]; } - (NSComparisonResult) comparegetChangeNumberDescending: (PerforceSubmittedChange*) rhs { return [rhs->fNumber caseInsensitiveCompare:fNumber]; } - (NSComparisonResult) comparegetChangeDateAscending: (PerforceSubmittedChange*) rhs { return [fDate caseInsensitiveCompare:rhs->fDate]; } - (NSComparisonResult) comparegetChangeDateDescending: (PerforceSubmittedChange*) rhs { return [rhs->fDate caseInsensitiveCompare:fDate]; } - (NSComparisonResult) comparegetChangeUserAscending: (PerforceSubmittedChange*) rhs { return [fUser caseInsensitiveCompare:rhs->fUser]; } - (NSComparisonResult) comparegetChangeUserDescending: (PerforceSubmittedChange*) rhs { return [rhs->fUser caseInsensitiveCompare:fUser]; } - (NSComparisonResult) comparegetChangeDescriptionAscending: (PerforceSubmittedChange*) rhs { return [fDescription caseInsensitiveCompare:rhs->fDescription]; } - (NSComparisonResult) comparegetChangeDescriptionDescending: (PerforceSubmittedChange*) rhs { return [rhs->fDescription caseInsensitiveCompare:fDescription]; } // ///// // // The enablement - (BOOL) canDescribe { return YES; } - (BOOL) canSyncTo { return YES; } - (BOOL) canSyncOnly { return YES; } - (void) resultFromDescribe:(PerforceActionDescribe*)action { if ( [action wasSuccess] ) { NSMutableString* titleString = [NSMutableString stringWithString:@"Description of Changelist "]; [titleString appendString:[action getChangeNum]]; [ReadOnlyEditorController showWindowWith:[action getOutput] title:titleString]; } } // // The actions - (void) doEdit { } - (void) doDescribe { [PerforceActionDescribe defaultRunFor:self selector:@selector(resultFromDescribe:) changeNum:fNumber]; } - (void) doDelete { } - (void) doSubmit { } - (void) doRevert { } - (void) doSyncTo { NSMutableString* syncPath = [NSMutableString stringWithString:@"@"]; [syncPath appendString:fNumber]; [PerforceActionSync defaultRun:nil revision:syncPath]; } - (void) doSyncOnly { NSMutableString* syncPath = [NSMutableString stringWithString:@"@"]; [syncPath appendString:fNumber]; [syncPath appendString:@","]; [syncPath appendString:fNumber]; [PerforceActionSync defaultRun:nil revision:syncPath]; } // // // @end