PendingChangesView.m #1

  • //
  • guest/
  • jeff_argast/
  • P4Cocoa/
  • source/
  • Views/
  • PendingChangesView.m
  • View
  • Commits
  • Open Download .zip Download (3 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 "ChangelistProtocol.h"

@implementation PendingChangesView

- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
	[[self window] makeFirstResponder:self];

    NSPoint clickPoint = [theEvent locationInWindow];
    
    clickPoint = [self convertPoint:clickPoint fromView:nil];
    
    int rowIdx = [self rowAtPoint:clickPoint];

	if ( rowIdx >= 0 )
	{
		id item = [self itemAtRow:rowIdx];
		
		if ( item )
		{
			[self selectRow:rowIdx byExtendingSelection:NO];
			
			return [super menuForEvent:theEvent];
		}
	}
	
	return nil;
}

- (id) getSelection;
{
	int rowIdx = [self selectedRow];
	
	if ( rowIdx < 0 )
		return NO;
		
	return [self itemAtRow:rowIdx];
}

- (BOOL) validateMenuItem:(NSMenuItem*)menuItem
{
	id <ChangelistProtocol> item = [self getSelection];
	
	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];
	}
	
	return YES;
}

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

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

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

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

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

@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