/* 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 "SubmittedChangesController.h" #import "IconDefs.h" #import "PerforceActionChangesSubmitted.h" #import "MessageDefs.h" #import "PerforceFileRevision.h" #import "PerforceActionDescribe.h" #import "ReadOnlyEditorController.h" #import "PerforceSubmittedChange.h" #import "AppUtils.h" #import "SubmittedChangeView.h" static NSString* kBrowserCellColumnName = @"getChangeNumber"; static NSString* kDefaultSortColumnKey = @"SubmittedChangesSortColumn"; static NSString* kDefaultSortDirectionKey = @"SubmittedChangesSortDirection"; @implementation SubmittedChangesController + (void) initialize { NSMutableDictionary* defaultValues = [NSMutableDictionary dictionary]; [defaultValues setObject:kBrowserCellColumnName forKey:kDefaultSortColumnKey]; [defaultValues setObject:[NSNumber numberWithBool:NO] forKey:kDefaultSortDirectionKey]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; } - (void) dealloc { [fFilterPath release]; [super dealloc]; } - (void) doubleClick: (id) sender { [self doDescribe]; } - (void) handleContentChanged: (NSNotification*) aNotification { [self refreshData]; } - (void) awakeFromNib { fTableView = fSubmittedView; fIconID = kSubmittedChangeIcon; fIconColumnName = kBrowserCellColumnName; fFilterPath = [[NSString alloc] initWithString:@""]; //fPerforceActionMethod = @selector(allsubmittedchanges); fDefaultSortColumnKey = kDefaultSortColumnKey; fDefaultSortDirectionKey = kDefaultSortDirectionKey; [fSubmittedView registerForDraggedTypes:[NSArray arrayWithObject:NSStringPboardType]]; [fFilterPathEditBox registerForDraggedTypes:[NSArray arrayWithObject:NSStringPboardType]]; [super setUpCell]; NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter]; [nCenter addObserver:self selector:@selector(handleContentChanged:) name:kDefaultsNumChangesToFetchChanged object:nil]; [nCenter addObserver:self selector:@selector(handleContentChanged:) name:kActionSubmitCommandComplete object:nil]; [fSubmittedView setAutosaveName:@"SubmittedChangesTableInfo"]; [fSubmittedView setAutosaveTableColumns:YES]; } - (void) resultFromPerforce: (PerforceActionChangesSubmitted*) action { if ( [action wasSuccess] ) { [fChildren setArray:[action getChangesSubmitted]]; [self sortChildren]; } } - (void) buildChildren { fChildren = [[NSMutableArray alloc] init]; [PerforceActionChangesSubmitted defaultRunFor:self selector:@selector(resultFromPerforce:) withPath:fFilterPath]; } - (void) setFilterPath: (NSString*) newPath { if ( ![newPath isEqualToString:fFilterPath] ) { [fFilterPath release]; fFilterPath = [newPath retain]; [self refreshData]; } } - (void)controlTextDidEndEditing:(NSNotification *)aNotification { NSString* newPath = [fFilterPathEditBox stringValue]; [self setFilterPath:newPath]; } - (void) textDidClear:(id)sender { NSString* newPath = [fFilterPathEditBox stringValue]; [self setFilterPath:newPath]; } // This method is used by NSTableView to determine a valid drop target. // Based on the mouse position, the table view will suggest a proposed drop // location. This method must return a value that indicates which dragging // operation the data source will perform. The data source may "re-target" a // drop if desired by calling setDropRow:dropOperation: and returning something // other than NSDragOperationNone. One may choose to re-target for various // reasons (eg. for better visual feedback when inserting into a sorted position). - (NSDragOperation) tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op { [tv setDropRow:-1 dropOperation:NSTableViewDropOn]; //NSLog (@"drop row = %d, op = %d", row, op); return NSDragOperationCopy; } // This method is called when the mouse is released over an outline view that // previously decided to allow a drop via the validateDrop method. The data // source should incorporate the data from the dragging pasteboard at this time. - (BOOL) tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { NSPasteboard* pb = [info draggingPasteboard]; NSString* value = ReadStringFromPasteboard (pb); if ( value ) { // read up to the first break NSScanner* scanner = [NSScanner scannerWithString:value]; NSString* resultString = nil; if ( [scanner scanUpToString:@"\n" intoString:&resultString] == YES ) { [fFilterPathEditBox setStringValue:resultString]; [self setFilterPath:resultString]; } return YES; } return NO; } // The enablement - (BOOL) canDescribe { id <ChangelistProtocol> selection = [self getSelection]; return [selection canDescribe]; } - (BOOL) canSyncTo { id <ChangelistProtocol> selection = [self getSelection]; return [selection canSyncTo]; } - (BOOL) canSyncOnly { id <ChangelistProtocol> selection = [self getSelection]; return [selection canSyncOnly]; } // The actions - (void) doDescribe { id <ChangelistProtocol> selection = [self getSelection]; [selection doDescribe]; } - (void) doSyncTo { id <ChangelistProtocol> selection = [self getSelection]; [selection doSyncTo]; } - (void) doSyncOnly { id <ChangelistProtocol> selection = [self getSelection]; [selection doSyncOnly]; } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 3176 | paolo_resmini | initial branch for Paolo Resmini | ||
//guest/jeff_argast/P4Cocoa/source/Controllers/SubmittedChangesController.m | |||||
#4 | 3134 | Jeff Argast |
Added copy/paste support in the depot view Added expand path to depot view Added bookmarks |
||
#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 |