DepotViewSelection.m #2

  • //
  • guest/
  • jeff_argast/
  • P4Cocoa/
  • source/
  • Selection/
  • DepotViewSelection.m
  • View
  • Commits
  • Open Download .zip Download (5 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 "DepotViewSelection.h"
#import "PerforceActionRevert.h"
#import "PerforceActionEdit.h"
#import "PerforceActionSync.h"
#import "PerforceActionDelete.h"

@implementation DepotViewSelection

- (id) initWithItems: (NSArray*) selectedItems
{
	self = [super init];
	
	fSelectedItems = [selectedItems retain];
	
#if 0
	int numItems = [fSelectedItems count];
	int n;
	
	// if no items then we can't do anything
	if ( numItems == 0 )
	{
		fCanSyncToHead		= NO;
		fCanSyncToNone		= NO;
		fCanEdit			= NO;
		fCanDelete			= NO;
		fCanRevert			= NO;
		fCanDiff			= NO;
		fCanGetRevisions	= NO;
		fCanViewInEditor	= NO;
	}
	else
	{
		fCanSyncToHead		= YES;
		fCanSyncToNone		= YES;
		fCanEdit			= YES;
		fCanDelete			= YES;
		fCanRevert			= YES;
		fCanDiff			= YES;
		fCanGetRevisions	= YES;
		fCanViewInEditor	= YES;
		
		for ( n = 0; n < numItems; n++ )
		{
			id<DepotViewProtocol> item = [fSelectedItems objectAtIndex:n];
			
			if ( ![item canSyncToHead] )
			{
				fCanSyncToHead = NO;
			}
			
			if ( ![item canSyncToNone] )
			{
				fCanSyncToNone = NO;
			}
			
			if ( ![item canEdit] )
			{
				fCanEdit = NO;
			}
			
			if ( ![item canDelete] )
			{
				fCanDelete = NO;
			}
			
			if ( ![item canRevert] )
			{
				fCanRevert = NO;
			}
			
			if ( ![item canDiff] )
			{
				fCanDiff = NO;
			}
			
			if ( ![item canGetRevisions] )
			{
				fCanGetRevisions = NO;
			}
			
			if ( ![item canViewInEditor] )
			{
				fCanViewInEditor = NO;
			}			
		}	
	}
#endif
			
	return self;
}

- (void) dealloc
{
	[fSelectedItems release];
}

- (BOOL) canDoSelector: (SEL) selector
{
	int numItems = [fSelectedItems count];
	int n;
	
	BOOL canDo = YES;
	
	for ( n = 0; (n < numItems) && canDo; n++ )
	{
		id<NSObject> item = [fSelectedItems objectAtIndex:n];
			 
		if ( ![item performSelector:selector] )
		{
			canDo = NO;
		}
	}
	
	return canDo;
}

- (BOOL) canSyncToHead
{
	return [self canDoSelector:@selector(canSyncToHead)];
}

- (BOOL) canSyncToNone
{
	return [self canDoSelector:@selector(canSyncToNone)];
}

- (BOOL) canEdit
{
	return [self canDoSelector:@selector(canEdit)];
}

- (BOOL) canDelete
{
	return [self canDoSelector:@selector(canDelete)];
}

- (BOOL) canRevert
{
	return [self canDoSelector:@selector(canRevert)];
}

- (BOOL) canDiff
{
	return [self canDoSelector:@selector(canDiff)];
}

- (BOOL) canGetRevisions
{
	return [self canDoSelector:@selector(canGetRevisions)];
}

- (BOOL) canViewInEditor
{
	return [self canDoSelector:@selector(canViewInEditor)];
}

//
// Actions
//
- (NSArray*) selectedDepotPaths
{
	NSMutableArray* depotArray = [NSMutableArray array];
	
	int numItems = [fSelectedItems count];
	int n;

	for ( n = 0; n < numItems; n++ )
	{
		id<DepotViewProtocol> item = [fSelectedItems objectAtIndex:n];
			
		[depotArray addObject:[item getPerforceActionPath]];
	}
	
	return depotArray;
}

- (void) doSelector: (SEL) selector
{
	int numItems = [fSelectedItems count];
	int n;

	for ( n = 0; n < numItems; n++ )
	{
		id<NSObject> item = [fSelectedItems objectAtIndex:n];
			
		[item performSelector:selector];
	}
}

- (void) syncToHead
{
	[PerforceActionSync defaultRun:[self selectedDepotPaths] revision:nil];
}

- (void) syncToNone
{
	[PerforceActionSync defaultRun:[self selectedDepotPaths] revision:@"#none"];
}

- (void) syncTo: (NSString*) target
{
	[PerforceActionSync defaultRun:[self selectedDepotPaths] revision:target];
}

- (void) showRevisionHistory
{
	[self doSelector:@selector(showRevisionHistory)];
}

- (void) edit
{
	[PerforceActionEdit defaultRun:[self selectedDepotPaths]];
}

- (void) delete
{
	[PerforceActionDelete defaultRun:[self selectedDepotPaths]];
}

- (void) revert
{
	[PerforceActionRevert defaultRun:[self selectedDepotPaths]];
}

- (void) diff
{
	[self doSelector:@selector(diff)];
}

- (void) viewInEditor
{
	[self doSelector:@selector(viewInEditor)];
}

- (NSString*) getPasteboardData
{
	return nil;
}


- (void) fileChanged:(NSString*)depotPath
{
	// do nothing
}

- (void) pathChanged:(NSString*)depotPath theFile:(PerforceFile**)theFile
{
	// do nothing
}

- (NSString*) getDepotPath
{
	return nil; // ACK, another reason to break the selection and depot view protocol into separate pieces
}

- (NSString*) getPerforceActionPath
{
	return nil; // ACK, another reason to break the selection and depot view protocol into separate pieces
}


@end
# Change User Description Committed
#6 4225 Jeff Argast Added resolve support, reveal in finder, drag and drop edit,
show local files, and showing added files.
#5 3147 Jeff Argast Testing std in blockage
#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 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).
#1 2737 Jeff Argast Added several 0.15 revision functionality