-
Notifications
You must be signed in to change notification settings - Fork 5
/
ISRepositoriesController.j
71 lines (58 loc) · 1.59 KB
/
ISRepositoriesController.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* ISRepositoriesController.j
* GithubIssues
*
* Created by Randy Luecke on April 14, 2011.
* Copyright 2011, RCLConcepts, LLC All rights reserved.
*/
/*!
This class serves to manage all the repositories.
The Repo list is bound to this controller for the
data.
*/
@implementation ISRepositoriesController : CPArrayController
{
@outlet ISIssuesController issuesController;
@outlet ISModel model @accessors;
CPTableView sourceList @accessors;
CPTableView filterlist @accessors;
}
+ (CPSet)keyPathsForValuesAffectingSelectedObject
{
return [CPSet setWithObjects:"selectedObjects"];
}
- (void)awakeFromCib
{
// TODO This could just as well be done in the CIB.
[self bind:@"contentArray" toObject:model withKeyPath:@"repositories" options:nil];
[issuesController bind:@"activeRepository" toObject:self withKeyPath:@"selectedObject" options:nil];
}
/*!
Exactly like 'selectedObjects' but always gets the first selected object or nothing.
Observable.
*/
- (id)selectedObject
{
var selectedObjects = [self selectedObjects];
if (![selectedObjects count])
return nil;
return [selectedObjects firstObject];
}
- (void)addRepository:(ISRepository)aRepo select:(BOOL)shouldSelect
{
if (![self canAdd])
return;
var repositories = [model repositories];
if (![repositories containsObject:aRepo])
[self addObject:aRepo];
[aRepo load];
// TODO Do this automatically somehow.
[model save];
}
- (void)remove:(id)sender
{
[super remove:sender];
// TODO Do this automatically somehow.
[model save];
}
@end