-
Notifications
You must be signed in to change notification settings - Fork 205
/
Copy pathCPCodePilotWindowDelegate.m
101 lines (84 loc) · 2.76 KB
/
CPCodePilotWindowDelegate.m
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// CPCodePilotWindowDelegate.m
// CodePilot
//
// Created by Zbigniew Sobiecki on 2/9/10.
// Copyright 2010 Macoscope. All rights reserved.
//
#import "CPCodePilotWindowDelegate.h"
#import "CPXcodeWrapper.h"
#import "CPSearchController.h"
#import "CPResultTableView.h"
#import "CPWindow.h"
#import "CPSearchWindowView.h"
#import "CPCodePilotConfig.h"
#import "CPStatusLabel.h"
#import "CPSearchField.h"
#import "CPSearchFieldTextView.h"
@implementation CPCodePilotWindowDelegate
- (id)initWithXcodeWrapper:(CPXcodeWrapper *)xcodeWrapper
{
self = [super init];
if (self) {
self.ourWindowIsOpen = NO;
self.searchController = [CPSearchController new];
[self.searchController setXcodeWrapper:xcodeWrapper];
self.window = [[CPWindow alloc] initWithDefaultSettings];
[self.window setDelegate:self];
[self.searchController setSearchField:[self.window.searchWindowView searchField]];
[[self.window.searchWindowView searchField] setDelegate:self.searchController];
[self.searchController setIndexingProgressIndicator:[self.window.searchWindowView indexingProgressIndicator]];
[self.searchController setUpperStatusLabel:[self.window.searchWindowView upperStatusLabel]];
[self.searchController setLowerStatusLabel:[self.window.searchWindowView lowerStatusLabel]];
[self.searchController setInfoStatusLabel:[self.window.searchWindowView infoStatusLabel]];
[self.searchController setTableView:[self.window.searchWindowView resultTableView]];
[[self.window.searchWindowView resultTableView] setDataSource:self.searchController];
[[self.window.searchWindowView resultTableView] setDelegate:self.searchController];
}
return self;
}
- (void)openFirstRunWindow
{
[self.window firstRunOrderFront];
[self.window makeKeyWindow];
self.ourWindowIsOpen = YES;
}
- (void)openWindow
{
if (self.ourWindowIsOpen) {
return;
}
[self.searchController windowWillBecomeActive];
[self.window orderFront:self];
[self.window makeKeyWindow];
[self.searchController windowDidBecomeActive];
self.ourWindowIsOpen = YES;
}
- (void)hideWindow
{
[self.window orderOut:self];
self.ourWindowIsOpen = NO;
}
// we need custom field editor in order to work with search field the way we want
- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject
{
if ([anObject isKindOfClass:[CPSearchField class]]) {
if (!self.searchFieldTextEditor) {
self.searchFieldTextEditor = [[CPSearchFieldTextView alloc] init];
[self.searchFieldTextEditor setFieldEditor:YES];
}
return self.searchFieldTextEditor;
}
return nil;
}
- (void)windowDidResignKey:(NSNotification *)notification
{
[self hideWindow];
}
- (void)windowDidResignMain:(NSNotification *)notification
{
}
- (void)windowWillClose:(NSNotification *)notification
{
}
@end