PendingChangesView.m #4

  • //
  • guest/
  • jeff_argast/
  • P4Cocoa/
  • source/
  • Views/
  • PendingChangesView.m
  • View
  • Commits
  • Open Download .zip Download (4 KB)
/*

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 "PendingChangesView.h"
#import "PerforceAction.h"
#import "PendingChangelistProtocol.h"
#import "PendingChangesController.h"

@implementation PendingChangesView

- (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];		
		}
	}

	if ( rowIdx >= 0 )
	{
		return [super menuForEvent:theEvent];
	}
	
	return nil;
}


- (BOOL) validateMenuItem:(NSMenuItem*)menuItem
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	if ( !item )
		return NO;
		
	BOOL isNoCriticalActionRunning = ![PerforceAction isCriticalActionRunning];
	
	SEL selector = [menuItem action];
   
	if ( selector == @selector(editChangelist:) )
	{
		return [item canEdit];
	}
	
	if ( selector == @selector(describeChangelist:) )
	{
		return [item canDescribe];
	}
	
	if ( selector == @selector(deleteChangelist:) )
	{
		return [item canDelete];
	}
	
	if ( selector == @selector(submitChangelist:) )
	{
		return isNoCriticalActionRunning && [item canSubmit];
	}
	
	if ( selector == @selector(revert:) )
	{
		return isNoCriticalActionRunning && [item canRevert];
	}
	
	if ( selector == @selector(revertUnchanged:) )
	{
		return isNoCriticalActionRunning && [item canRevert];
	}
	
	if ( selector == @selector(diff:) )
	{
		return isNoCriticalActionRunning && [item canDiff];
	}
	
	if ( selector == @selector(viewInEditor:) )
	{
		return [item canViewInEditor];
	}
	
	return YES;
}

- (IBAction) editChangelist:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doEdit];
}

- (IBAction) describeChangelist:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doDescribe];
}

- (IBAction) deleteChangelist:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doDelete];
}

- (IBAction) submitChangelist:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doSubmit];
}

- (IBAction) revert:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doRevert];
}

- (IBAction) revertUnchanged:(id)sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doRevertUnchanged];
}

- (IBAction) diff: (id) sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doDiff];
}

- (IBAction) viewInEditor: (id) sender
{
	id <PendingChangelistProtocol> item = [self delegate];
	
	[item doViewInEditor];
}

@end
# Change User Description Committed
#5 4225 Jeff Argast Added resolve support, reveal in finder, drag and drop edit,
show local files, and showing added files.
#4 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.
#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