/* 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 "JobsController.h" #import "IconDefs.h" #import "PerforceActionJobs.h" #import "MessageDefs.h" static NSString* kBrowserCellColumnName = @"getJobName"; static NSString* kDefaultSortColumnKey = @"JobsSortColumn"; static NSString* kDefaultSortDirectionKey = @"JobsSortDirection"; @implementation JobsController + (void) initialize { NSMutableDictionary* defaultValues = [NSMutableDictionary dictionary]; [defaultValues setObject:kBrowserCellColumnName forKey:kDefaultSortColumnKey]; [defaultValues setObject:[NSNumber numberWithBool:NO] forKey:kDefaultSortDirectionKey]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; } - (void) awakeFromNib { fTableView = fJobsView; fIconID = kJobsIcon; fIconColumnName = kBrowserCellColumnName; //fPerforceActionMethod = @selector(jobs); fDefaultSortColumnKey = kDefaultSortColumnKey; fDefaultSortDirectionKey = kDefaultSortDirectionKey; NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter]; [nCenter addObserver:self selector:@selector(jobChanged:) name:kJobChanged object:nil]; [super setUpCell]; [fJobsView setAutosaveName:@"JobsTableInfo"]; [fJobsView setAutosaveTableColumns:YES]; } - (void) jobChanged:(NSNotification*) notification { [self refreshData]; } - (void) resultFromPerforce: (PerforceActionJobs*) action { if ( [action wasSuccess] ) { [fChildren setArray:[action getJobs]]; [self sortChildren]; } } - (void) buildChildren { fChildren = [[NSMutableArray alloc] init]; [PerforceActionJobs defaultRunFor:self selector:@selector(resultFromPerforce:)]; } - (void) doubleClick: (id) sender { [self doDescribe]; } // The enablement - (BOOL) canEdit { id selection = [self getSelection]; return [selection canEdit]; } - (BOOL) canDescribe { id selection = [self getSelection]; return [selection canDescribe]; } - (BOOL) canDelete { id selection = [self getSelection]; return [selection canDelete]; } // The actions - (void) doEdit { id selection = [self getSelection]; [selection doEdit]; } - (void) doDescribe { id selection = [self getSelection]; [selection doDescribe]; } - (void) doDelete { id selection = [self getSelection]; [selection doDelete]; } @end