/* 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 "DepotOutlineView.h" #import "DepotViewProtocol.h" #import "AppDefaults.h" #import "MessageDefs.h" #import "PerforceAction.h" #import "DepotViewSelection.h" #import "DepotController.h" #import "AppUtils.h" @implementation DepotOutlineView - (void)expandItem:(id)item expandChildren:(BOOL)expandChildren { // never expand children as it can cause undo server load. [super expandItem:item expandChildren:NO]; } - (IBAction) copy:(id)sender { DepotViewSelection* selectedItems = [fDepotController getSelection]; NSPasteboard* pb = [NSPasteboard generalPasteboard]; WriteStringToPasteboard ([selectedItems getCopyToPboardString], pb); } - (NSMenu *)menuForEvent:(NSEvent *)theEvent { [[self window] makeFirstResponder:self]; // Figure out what we hit. If a valid row then make it the selection // unless the item is already in the selection NSPoint clickPoint = [theEvent locationInWindow]; clickPoint = [self convertPoint:clickPoint fromView:nil]; int rowIdx = [self rowAtPoint:clickPoint]; if ( rowIdx >= 0 ) { BOOL inSelection = NO; // Is the hit row in the selection? NSEnumerator* items = [self selectedRowEnumerator]; NSNumber* rowNum; while ( rowNum = [items nextObject] ) { if ( rowIdx == [rowNum intValue] ) { inSelection = YES; } } if ( !inSelection ) { [self selectRow:rowIdx byExtendingSelection:NO]; } } NSMenuItem* mItem = nil; NSMenu* contextMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; BOOL deletedFilesShown = [[AppDefaults defaultAppDefaults] getShowDeletedFiles]; BOOL entireDepotShown = [[AppDefaults defaultAppDefaults] getShowEntireDepot]; // We control the menu items here so no need to ask the target for enablement [contextMenu setAutoenablesItems:NO]; if ( rowIdx >= 0 ) { DepotViewSelection* selectedItems = [fDepotController getSelection]; BOOL isNoCriticalActionRunning = ![PerforceAction isCriticalActionRunning]; if ( [selectedItems canSyncToHead] ) { mItem = [contextMenu addItemWithTitle:@"Sync to Head Revision" action:@selector(syncToHead:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; } mItem = [contextMenu addItemWithTitle:@"Sync to Revision..." action:@selector(syncToRevision:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; mItem = [contextMenu addItemWithTitle:@"Sync to Changelist..." action:@selector(syncToChangelist:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; mItem = [contextMenu addItemWithTitle:@"Sync to Label..." action:@selector(syncToLabel:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; if ( [selectedItems canEdit] ) { mItem = [contextMenu addItemWithTitle:@"Open for Edit" action:@selector(edit:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; } if ( mItem ) { // separator mItem = [NSMenuItem separatorItem]; [contextMenu addItem:mItem]; mItem = nil; } if ( [selectedItems canDelete] ) { mItem = [contextMenu addItemWithTitle:@"Open for Delete" action:@selector(delete:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; } if ( [selectedItems canSyncToNone] ) { mItem = [contextMenu addItemWithTitle:@"Sync to None" action:@selector(syncToNone:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; } if ( [selectedItems canRevert] ) { mItem = [contextMenu addItemWithTitle:@"Revert" action:@selector(revert:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; mItem = [contextMenu addItemWithTitle:@"Revert Unchanged" action:@selector(revertUnchanged:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; [mItem setEnabled:isNoCriticalActionRunning]; } // separator if ( mItem ) { // separator mItem = [NSMenuItem separatorItem]; [contextMenu addItem:mItem]; mItem = nil; } if ( [selectedItems canDiff] ) { mItem = [contextMenu addItemWithTitle:@"Diff vs Depot File" action:@selector(diff:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } if ( [selectedItems canViewInEditor] ) { mItem = [contextMenu addItemWithTitle:@"View File in Editor" action:@selector(viewInEditor:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } if ( [selectedItems canGetRevisions] ) { mItem = [contextMenu addItemWithTitle:@"Revision History..." action:@selector(showRevisionHistory:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } // separator if ( mItem ) { // separator mItem = [NSMenuItem separatorItem]; [contextMenu addItem:mItem]; mItem = nil; } if ( [self numberOfSelectedRows] == 1 ) { mItem = [contextMenu addItemWithTitle:@"Add Bookmark" action:@selector(addBookmark:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } // separator if ( mItem ) { // separator mItem = [NSMenuItem separatorItem]; [contextMenu addItem:mItem]; mItem = nil; } /* lastItemIdx = [contextMenu numberOfItems] - 1; if ( [[contextMenu itemAtIndex:lastItemIdx] isSeparatorItem] ) { [contextMenu removeItemAtIndex:lastItemIdx]; } */ } mItem = [contextMenu addItemWithTitle:@"Client View of Depot" action:@selector(clientViewOfDepot:) keyEquivalent:@""]; if ( !entireDepotShown ) { [mItem setState:NSOnState]; } [mItem setTarget:fDepotController]; mItem = [contextMenu addItemWithTitle:@"Entire View of Depot" action:@selector(entireViewOfDepot:) keyEquivalent:@""]; if ( entireDepotShown ) { [mItem setState:NSOnState]; } [mItem setTarget:fDepotController]; mItem = [NSMenuItem separatorItem]; [contextMenu addItem:mItem]; if ( !deletedFilesShown ) { mItem = [contextMenu addItemWithTitle:@"Show Deleted Files" action:@selector(showDeletedFiles:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } else { mItem = [contextMenu addItemWithTitle:@"Hide Deleted Files" action:@selector(hideDeletedFiles:) keyEquivalent:@""]; [mItem setTarget:fDepotController]; } return contextMenu; } - (BOOL) validateMenuItem:(NSMenuItem*)menuItem { if ( [self numberOfSelectedRows] == 0 ) return NO; DepotViewSelection* selectedItems = [fDepotController getSelection]; BOOL isNoCriticalActionRunning = ![PerforceAction isCriticalActionRunning]; SEL selector = [menuItem action]; if ( selector == @selector(showRevisionHistory:) ) { return [selectedItems canGetRevisions]; } if ( selector == @selector(syncToHead:) ) { return (isNoCriticalActionRunning && [selectedItems canSyncToHead]); } if ( selector == @selector(syncToNone:) ) { return (isNoCriticalActionRunning && [selectedItems canSyncToNone]); } if ( selector == @selector(edit:) ) { return (isNoCriticalActionRunning && [selectedItems canEdit]); } if ( selector == @selector(deleteDepotPath:) ) { return (isNoCriticalActionRunning && [selectedItems canDelete]); } if ( selector == @selector(revert:) ) { return (isNoCriticalActionRunning && [selectedItems canRevert]); } if ( selector == @selector(revertUnchanged:) ) { return (isNoCriticalActionRunning && [selectedItems canRevert]); } if ( selector == @selector(diff:) ) { return [selectedItems canDiff]; } if ( selector == @selector(viewInEditor:) ) { return [selectedItems canViewInEditor]; } if ( selector == @selector(addBookmark:) ) { return ([self numberOfSelectedRows] == 1); } if ( selector == @selector(syncToHead:) ) { return (isNoCriticalActionRunning && [selectedItems canSyncToHead]); } if ( selector == @selector(syncToRevision:) ) { return isNoCriticalActionRunning; } if ( selector == @selector(syncToChangelist:) ) { return isNoCriticalActionRunning; } if ( selector == @selector(syncToLabel:) ) { return isNoCriticalActionRunning; } return YES; } // show the revision history of the selected file - (IBAction) showRevisionHistory: (id) sender { [fDepotController showRevisionHistory:sender]; } // sync - (IBAction) syncToHead: (id) sender { [fDepotController syncToHead:sender]; } // sync - (IBAction) syncToNone: (id) sender { [fDepotController syncToNone:sender]; } // sync - (IBAction) syncToRevision: (id) sender { [fDepotController syncToRevision:sender]; } // sync - (IBAction) syncToChangelist: (id) sender { [fDepotController syncToChangelist:sender]; } // sync - (IBAction) syncToLabel: (id) sender { [fDepotController syncToLabel:sender]; } // edit - (IBAction) edit: (id) sender { [fDepotController edit:sender]; } // delete - (IBAction) deleteDepotPath: (id) sender { [fDepotController delete:sender]; } // revert - (IBAction) revert: (id) sender { [fDepotController revert:sender]; } // revert -a - (IBAction) revertUnchanged: (id) sender { [fDepotController revertUnchanged:sender]; } // diff - (IBAction) diff: (id) sender { [fDepotController diff:sender]; } // view in editor - (IBAction) viewInEditor: (id) sender { [fDepotController viewInEditor:sender]; } // add bookmark - (IBAction) addBookmark: (id) sender { [fDepotController addBookmark:sender]; } - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { return NSDragOperationCopy; } /* - (void) mouseDown: (NSEvent*) theEvent { [super mouseDown:theEvent]; NSLog (@"mouse down"); } - (void) mouseDragged: (NSEvent*) theEvent { [super mouseDragged:theEvent]; NSLog (@"mouse dragged"); } - (void) mouseUp: (NSEvent*) theEvent { [super mouseUp:theEvent]; NSLog (@"mouse up"); } */ @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 3210 | Paul Ferguson | Initial branch | ||
//guest/jeff_argast/P4Cocoa/source/Views/DepotOutlineView.m | |||||
#4 | 3134 | Jeff Argast |
Added copy/paste support in the depot view Added expand path to depot view Added bookmarks |
||
#3 | 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. |
||
#2 | 2737 | Jeff Argast | Added several 0.15 revision functionality | ||
#1 | 2732 | Jeff Argast | Initial submission of P4Cocoa |