/* 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 "PerforceChangeFile.h" #import "IconDefs.h" #import "IconController.h" #import "PerforceAction.h" #import "PerforceActionRevert.h" #import "MessageDefs.h" #import "AppUtils.h" #import "PerforceActionDiff.h" #import "PerforceChangeList.h" #import "PerforceActionWhere.h" #import "AppUtils.h" static NSString* kDefaultChange = @"default"; @implementation PerforceChangeFile - (id) initWithName: (NSString*) fileName withRevision: (int) revision withFileType: (NSString*) fileType withChangeName: (NSString*) changeName withChangeType: (NSString*) changeType withUserInfo: (NSString*) userInfo isClient: (BOOL) isClient { NSMutableString* nsString = [NSMutableString stringWithString:changeName]; self = [super init]; fFileName = [fileName copy]; fRevision = revision; fFileType = [fileType copy]; fChangeName = [changeName copy]; fChangeType = [changeType copy]; fFileNameAndRevision = [[NSString stringWithFormat:@"%@#%d", fFileName, fRevision] retain]; fIsClientChange = isClient; if ( userInfo ) { fUserInfo = [userInfo copy]; [nsString appendString:@" - "]; [nsString appendString:userInfo]; } else { fUserInfo = [[NSString alloc] initWithString:@""]; } // force into an NSString fChangeAndUser = [[NSString alloc] initWithCString:[nsString cString]]; if ( isClient ) { if ( [fChangeType isEqualTo:@"edit"] ) { fIconID = kClientEditIcon; } else if ( [fChangeType isEqualTo:@"delete"] ) { fIconID = kClientDeleteIcon; } else { fIconID = kClientAddIcon; } } else { if ( [fChangeType isEqualTo:@"edit"] ) { fIconID = kOtherEditIcon; } else if ( [fChangeType isEqualTo:@"delete"] ) { fIconID = kOtherDeleteIcon; } else { fIconID = kOtherAddIcon; } } return self; } - (void) dealloc { [fFileName release]; [fFileType release]; [fChangeName release]; [fChangeType release]; [fUserInfo release]; [fFileNameAndRevision release]; [super dealloc]; } - (BOOL) isClientChange { return fIsClientChange; } - (int) getNumberOfChildren { return 0; } - (BOOL) hasChildren { return NO; } - (id) getChildAtIndex: (int) index { return nil; } - (id) getCellText { return fFileNameAndRevision; } - (id) getCellImage { return [[IconController defaultIconController] getIcon:fIconID]; } - (NSString*) getChangeAndUser { return fChangeAndUser; } - (NSString*) getChangeName { return fChangeName; } - (NSString*) getUserInfo { return fUserInfo; } - (NSComparisonResult) compare: (PerforceChangeFile*) rhs { if ( [fChangeName isEqualTo:rhs->fChangeName] && [fUserInfo isEqualTo:rhs->fUserInfo] ) { return [fFileName caseInsensitiveCompare:rhs->fFileName]; } if ( [fChangeName isEqualTo:kDefaultChange] ) { if ( [rhs->fChangeName isEqualTo:kDefaultChange] ) { return [fUserInfo caseInsensitiveCompare:rhs->fUserInfo]; } return NSOrderedAscending; } if ( [rhs->fChangeName isEqualTo:kDefaultChange] ) { return NSOrderedDescending; } if ( [fUserInfo isEqualTo:rhs->fUserInfo] ) { return [fChangeName caseInsensitiveCompare:rhs->fChangeName]; } return [fUserInfo caseInsensitiveCompare:rhs->fUserInfo]; } - (NSString*) depotFileName { return fFileName; } - (void) setParentChangelist: (PerforceChangeList*) parent { fParent = parent; // don't retain because the parent already owns us } - (PerforceChangeList*) parentChangelist { return fParent; } /* - (NSString*) clientFileName { return [[PerforceAction defaultAction] where:[self depotFileName]]; } */ // ///// // // The enablement - (BOOL) canEdit { return NO; } - (BOOL) canDescribe { return NO; } - (BOOL) canDelete { return NO; } - (BOOL) canSubmit { return NO; } - (BOOL) canRevert { return YES; } - (BOOL) canDiff { return YES; } - (BOOL) canViewInEditor { if ( fIconID == kClientDeleteIcon ) { return NO; } return [fParent isClientChangelist]; } // The actions - (void) doEdit { } - (void) doDescribe { } - (void) doDelete { } - (void) doSubmit { } - (void) doRevert { // Do nothing // TODO: This means the protocol is too braod and should be broken into more // granular protocols. } - (void) doRevertUnchanged { // Do nothing // TODO: This means the protocol is too braod and should be broken into more // granular protocols. } - (void) doDiff { [PerforceActionDiff depotPath:fFileName]; } - (void) resultFromPerforceWhere: (PerforceActionWhere*) action { if ( [action wasSuccess] ) { ViewFileInEditor ([action getFilePath]); } } - (void) doViewInEditor { // we don't have the client path stored locally // p4win does an fstat to get the location of the file // p4 where should work just as well [PerforceActionWhere defaultRunFor:self selector:@selector(resultFromPerforceWhere:) withPath:fFileName]; } - (void) appendRevertPath: (NSMutableArray*) revertPathList { [revertPathList addObject:fFileName]; } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 3210 | Paul Ferguson | Initial branch | ||
//guest/jeff_argast/P4Cocoa/source/Perforce/PerforceChangeFile.m | |||||
#6 | 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. |
||
#5 | 3126 | Jeff Argast |
Added drag and drop reordering/reopening of files in the pending change list view |
||
#4 | 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. |
||
#3 | 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). |
||
#2 | 2737 | Jeff Argast | Added several 0.15 revision functionality | ||
#1 | 2732 | Jeff Argast | Initial submission of P4Cocoa |