EditBookmarksController.m #2

  • //
  • guest/
  • jeff_argast/
  • P4Cocoa/
  • source/
  • Controllers/
  • EditBookmarksController.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 "EditBookmarksController.h"
#import "AppDefaults.h"
#import "AppUtils.h"
#import "PerforceConfigurationsList.h"
#import "PerforceConfiguration.h"

@implementation EditBookmarksController

- (void) dealloc
{
	[fBookmarks release];

	[super dealloc];
}

- (void) setBookmarks:(NSArray*)bookmarks
{
	if ( !fBookmarks )
	{
		fBookmarks = [[NSMutableArray alloc] init];
	}
	
	[fBookmarks removeAllObjects];
	
	[fBookmarks addObjectsFromArray:bookmarks];

	[fBookmarksView reloadData];
}

- (NSArray*) bookmarks
{
	return fBookmarks;
}

- (IBAction) chooseNew:(id)sender
{
	int selectedRow = [fBookmarksView selectedRow];
	int insertRow = selectedRow > 0 ? (selectedRow + 1) : 0;
	
	[fBookmarks insertObject:@"" atIndex:insertRow];
	[fBookmarksView reloadData];
	
	[fBookmarksView selectRow:insertRow byExtendingSelection:NO];
		
	[fBookmarksView editColumn:0 row:insertRow withEvent:nil select:NO];
}

- (IBAction) chooseDelete:(id)sender
{
	int selectedRow = [fBookmarksView selectedRow];

	if ( selectedRow >= 0 )
	{
		[fBookmarks removeObjectAtIndex:selectedRow];
		
		[fBookmarksView reloadData];
	}
}

- (IBAction) chooseCancel:(id)sender
{
	[NSApp endSheet:fBookmarkPanel returnCode:0];
}

- (IBAction) chooseDone:(id)sender
{
	[NSApp endSheet:fBookmarkPanel returnCode:1];
}

// 
// datasource
//

- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
	return [fBookmarks count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
	return [fBookmarks objectAtIndex:row];
}

//
// delegates
//

- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
	id anObject = [aNotification object];
	
	if ( anObject == fBookmarksView )
	{
		NSDictionary* dict = [aNotification userInfo];
		NSText* fieldEditor = [dict objectForKey:@"NSFieldEditor"];
		
		NSString* newName = [[[fieldEditor string] copy] autorelease];
		
		int selectedRow = [fBookmarksView selectedRow];
		
		[fBookmarks replaceObjectAtIndex:selectedRow withObject:newName];
		
		[fBookmarksView reloadData];
	}
}


@end
# Change User Description Committed
#2 3147 Jeff Argast Testing std in blockage
#1 3134 Jeff Argast Added copy/paste support in the depot view
Added expand path to depot view
Added bookmarks