/* 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 "PerforceChangeList.h" #import "PerforceAction.h" #import "IconController.h" #import "IconDefs.h" #import "AppUtils.h" #import "PerforceActionChange.h" #import "PerforceActionDescribe.h" #import "ReadOnlyEditorController.h" #import "PerforceActionSubmit.h" #import "AppController.h" #import "PerforceChangeFile.h" #import "PerforceActionReopen.h" static NSString* kDefaultChange = @"default"; @implementation PerforceChangeList - (void) dealloc { [fChildren release]; [fChangeNumber release]; [fUserInfo release]; [fChangeDesc release]; [fDisplayString release]; [super dealloc]; } - (void) makeDisplayString: (BOOL) includeUserInfo { NSMutableString* nsString = [[[NSMutableString alloc] init] autorelease]; if ( !fIsDefaultChange ) { [nsString appendString:@"Change "]; } [nsString appendString:fChangeNumber]; if ( includeUserInfo ) { if ( [fUserInfo length] > 0 ) { [nsString appendString:@" - "]; [nsString appendString:fUserInfo]; } if ( [fChangeDesc length] > 0 ) { [nsString appendString:@" {"]; [nsString appendString:fChangeDesc]; [nsString appendString:@"}"]; } } // force into an NSString fDisplayString = [[NSString alloc] initWithCString:[nsString cString]]; } - (id) initWithNumber: (NSString*) changeNumber withUserInfo: (NSString*) userInfo withChangeDesc: (NSString*) changeDesc isClient: (BOOL) isClient { self = [super init]; fChangeNumber = [changeNumber copy]; if ( [fChangeNumber isEqualToString:kDefaultChange] ) { fIsDefaultChange = YES; } else { fIsDefaultChange = NO; } if ( userInfo && ([userInfo length] > 0) ) { fUserInfo = [userInfo copy]; } else { fUserInfo = [[NSString alloc] initWithString:@""]; } if ( changeDesc ) { fChangeDesc = [changeDesc copy]; } else { fChangeDesc = [[NSString alloc] initWithString:@""]; } fIsClientChangelist = isClient; [self makeDisplayString:!fIsClientChangelist]; if ( fIsClientChangelist ) { fIconID = kClientChangeIcon; } else { fIconID = kOtherChangeIcon; } return self; } - (void) setChildren: (NSArray*) children { [fChildren release]; fChildren = [[NSMutableArray alloc] initWithArray:children]; int numChildren = [fChildren count]; int n; for ( n = 0; n < numChildren; n++ ) { PerforceChangeFile* changeFile = [fChildren objectAtIndex:n]; [changeFile setParentChangelist:self]; } } - (int) getNumberOfChildren { if ( fChildren ) { return [fChildren count]; } return 0; } - (BOOL) hasChildren { if ( fChildren ) { return ([fChildren count] > 0); } return NO; } - (id) getChildAtIndex: (int) index { if ( fChildren ) { return [fChildren objectAtIndex:index]; } return nil; } - (id) getCellText { return fDisplayString; } - (id) getCellImage { return [[IconController defaultIconController] getIcon:fIconID]; } - (NSComparisonResult) compare: (PerforceChangeList*) rhs { if ( fIsDefaultChange ) { if ( rhs->fIsDefaultChange ) { return [fUserInfo caseInsensitiveCompare:rhs->fUserInfo]; } return NSOrderedAscending; } if ( rhs->fIsDefaultChange ) { return NSOrderedDescending; } if ( [fUserInfo isEqualTo:rhs->fUserInfo] ) { return [fChangeNumber caseInsensitiveCompare:rhs->fChangeNumber]; } return [fUserInfo caseInsensitiveCompare:rhs->fUserInfo]; } - (BOOL) isClientChangelist { return fIsClientChangelist; } - (BOOL) isDefaultChangelist { return fIsDefaultChange; } - (void) copyFrom:(PerforceChangeList*) rhs { [fChangeNumber release]; [fUserInfo release]; [fChangeDesc release]; [fDisplayString release]; // [fChildren release]; now occurs in setChildren fChangeNumber = [rhs->fChangeNumber retain]; fUserInfo = [rhs->fUserInfo retain]; fChangeDesc = [rhs->fChangeDesc retain]; fDisplayString = [rhs->fDisplayString retain]; // fChildren = [rhs->fChildren copy]; fIsClientChangelist = rhs->fIsClientChangelist; fIsDefaultChange = rhs->fIsDefaultChange; fIconID = rhs->fIconID; // Wow, talk about design flaw. CopyFrom forces the children to // point to a new parent rather than copying the children. The // current implementation is faster but is seriously prone to // error. It assumes the rhs change list is going away after // the call to copyFrom. [self setChildren:rhs->fChildren]; } - (void) addChild: (PerforceChangeFile*) child { if ( !fChildren ) { fChildren = [[NSMutableArray alloc] init]; } [fChildren addObject:child]; [child setParentChangelist:self]; } - (void) removeChild: (PerforceChangeFile*) child { int childIndex = [fChildren indexOfObjectIdenticalTo:child]; if ( childIndex >= 0 ) { [fChildren removeObjectAtIndex:childIndex]; } } - (void) reopen: (NSArray*) fileArray { NSMutableArray* pathArray = [NSMutableArray array]; int numFiles = [fileArray count]; int n; for ( n = 0; n < numFiles; n++ ) { PerforceChangeFile* aFile = (PerforceChangeFile*) [fileArray objectAtIndex:n]; PerforceChangeList* fileParent = [aFile parentChangelist]; if ( fileParent != self ) { [pathArray addObject:[aFile depotFileName]]; [fileParent removeChild:aFile]; [self addChild:aFile]; } } if ( [pathArray count] > 0 ) { [fChildren sortUsingSelector:@selector(compare:)]; [PerforceActionReopen defaultRun:pathArray changeNumber:fChangeNumber]; } } // ///// // // The enablement - (BOOL) canEdit { return (fIsClientChangelist && !fIsDefaultChange); } - (BOOL) canDescribe { return !fIsDefaultChange; } - (BOOL) canDelete { return ![self hasChildren]; } - (BOOL) canSubmit { return [self hasChildren]; } - (BOOL) canRevert { return fIsClientChangelist; } - (BOOL) canDiff { return NO; } - (BOOL) canViewInEditor { return NO; } - (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 { [PerforceActionChangeGet defaultRunFor:[NSApp delegate] selector:@selector(resultFromPerforceChangeOut:) identifier:fChangeNumber]; } - (void) doDescribe { [PerforceActionDescribe defaultRunFor:self selector:@selector(resultFromDescribe:) changeNum:fChangeNumber]; } - (void) doDelete { int isOK = NSRunAlertPanel (@"Delete", @"Are you sure you want to delete changelist %s?", @"OK", @"Cancel", nil, [fChangeNumber cString]); if ( isOK ) { [PerforceActionChangeDelete defaultRunFor:nil selector:nil identifier:fChangeNumber]; } } - (void) doSubmit { if ( fIsDefaultChange ) { [PerforceActionChangeNew defaultRunFor:self selector:@selector(resultFromPerforceChangeNew:)]; } else { [PerforceActionSubmitChangelist defaultRunFor:nil selector:nil changeNum:fChangeNumber]; } } - (void) doRevert { } - (void) doRevertUnchanged { } - (void) doDiff { } - (void) doViewInEditor { } - (void) appendRevertPath: (NSMutableArray*) revertPathList { int numItems = [fChildren count]; int n; for ( n = 0; n < numItems; n++ ) { id<PendingChangelistProtocol> item = [fChildren objectAtIndex:n]; [item appendRevertPath:revertPathList]; } } // // // - (void) submitChangeOK: (NSString*) contentString { [PerforceActionSubmit defaultRunFor:self selector:@selector(resultFromPerforceSubmit:) form:contentString]; } - (void) resultFromPerforceSubmit: (PerforceActionSubmit*) action { if ( [action wasError] ) { [[NSApp delegate] showEditSheet:self contentData:[action getForm] endSelector:@selector(submitChangeOK:) title:@"Edit Changelist"]; } } - (void) resultFromPerforceChangeNew: (PerforceActionChangeNew*) action { if ( [action wasSuccess] ) { [[NSApp delegate] showEditSheet:self contentData:[action getOutput] endSelector:@selector(submitChangeOK:) title:@"Edit Changelist"]; } } /* - (void) resultFromPerforceChangeOut: (PerforceActionChangeGet*) action { if ( [action wasSuccess] ) { [[NSApp delegate] showEditSheet:self contentData:[action getOutput] endSelector:@selector(submitChangeOK:)]; } } */ @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 3210 | Paul Ferguson | Initial branch | ||
//guest/jeff_argast/P4Cocoa/source/Perforce/PerforceChangeList.m | |||||
#9 | 3149 | Jeff Argast | Add default changelist to pending list always even if default is empty | ||
#8 | 3132 | Jeff Argast |
Finally fixed the stupid wrapping problem. Turns out there are tabs in the text returned from Perforce. No problem. But in NSTextView if a tab occurs beyond the last tab stop then NSTextView breaks the line. So no what I want. The fix is to create a bunch of tab stops out to the etherlands. |
||
#7 | 3130 | Jeff Argast |
Added double click support to the depot view and pending changelist view. Added View File In Editor item on the pending changeist context menu. |
||
#6 | 3126 | Jeff Argast |
Added drag and drop reordering/reopening of files in the pending change list view |
||
#5 | 3113 | Jeff Argast |
Reduced the times the depot view completely collapses. Now it won't collapse on refresh views or submit, but still collapses when the defaults change. |
||
#4 | 3111 | Jeff Argast |
Made multiple selection smarter by operating on the entire selection as an atomic operation with the server. Also partially fixed the read only window to not wrap at the window boundary. I did the same for the editable window, but now the problem appears to be that p4 change -o is breaking its output at some character location before the string gets into the editor (at least I think that is the problem). |
||
#3 | 2803 | Jeff Argast |
Added submit default changelist to the changelist menu Made the out window selectable Changed the tabs in a few places |
||
#2 | 2737 | Jeff Argast | Added several 0.15 revision functionality | ||
#1 | 2732 | Jeff Argast | Initial submission of P4Cocoa |