Skip to content
Newer
Older
100644 136 lines (120 sloc) 3.97 KB
b49c291 Change IPC to using entirely distributed objects instead of distributed
mgorbach authored Mar 28, 2008
1 //
2 // MFLogViewerTableView.m
3 // MacFusion2
4 //
5 // Created by Michael Gorbach on 3/24/08.
6 // Copyright 2008 Michael Gorbach. All rights reserved.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19
20 #import "MFLogViewerTableView.h"
21 #import "MFLogViewerTableCell.h"
22 #import "MFLogReader.h"
23 #import "MFLogging.h"
24
25 @implementation MFLogViewerTableView
26
27 + (void)initialize
28 {
29 return [self exposeBinding:@"logMessages"];
30 }
31
32 - (id) initWithCoder: (NSCoder *) decoder
33 {
34 if (self = [super initWithCoder:decoder])
35 {
36 [self setDelegate: self];
37 [self setDataSource: self];
38 [[[self tableColumns] objectAtIndex: 0] setDataCell:
39 [MFLogViewerTableCell new]];
40 [self addObserver:self
41 forKeyPath:@"logMessages"
061e7c2 Fix bugs. Polish UI. Remove sparkle framework temporarily
mgorbach authored Jun 19, 2008
42 options:(NSKeyValueObservingOptions)0
43 context:self];
b49c291 Change IPC to using entirely distributed objects instead of distributed
mgorbach authored Mar 28, 2008
44 }
45
46 return self;
47 }
48
49 - (int) numberOfRowsInTableView: (NSTableView *) tableView
50 {
51 return [logMessages count];
52 }
53
54 - (id) tableView: (NSTableView *) tableView
55 objectValueForTableColumn: (NSTableColumn *) tableColumn
56 row: (int) row
57 {
58 return [(NSDictionary*)[logMessages objectAtIndex: row]
59 objectForKey: [NSString stringWithUTF8String: ASL_KEY_MSG]];
60 }
61
62 - (void) tableView: (NSTableView *) tableView
63 willDisplayCell: (NSCell*) cell
64 forTableColumn: (NSTableColumn *) tableColumn
65 row: (int) row
66 {
67 [cell setRepresentedObject:
68 [logMessages objectAtIndex: row]];
69 }
70
71 - (void)viewDidEndLiveResize
72 {
73 [self noteHeightOfRowsWithIndexesChanged:
74 [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [self.logMessages count])]];
75 [self setNeedsDisplay];
76 }
77
78 - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
79 {
80 CGFloat cellHeight = [(MFLogViewerTableCell*)[self preparedCellAtColumn:0 row:row]
81 heightForCellInWidth: [self visibleRect].size.width];
82 return cellHeight != 0 ? cellHeight : [self rowHeight];
83 }
84
85 - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
86 {
87 if (context == self) {
88 [self reloadData];
89 [self noteHeightOfRowsWithIndexesChanged:
90 [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [self.logMessages count])]];
91 }
92 else {
93 [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
94 }
95 }
96
97 # pragma markr C&P
98 - (void)copy:(id)sender
99 {
100 NSPasteboard* pb = [NSPasteboard generalPasteboard];
101 [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner:self];
102 NSMutableString* stringData = [NSMutableString new];
103 NSIndexSet* indexes = [self selectedRowIndexes];
104 NSInteger index = [indexes firstIndex];
105 NSInteger i;
106 for(i=0; i < [indexes count]; i++)
fd31161 Polish polish polish, and bugfixing. Plus, begining sparkle integration
mgorbach authored Jun 17, 2008
107 {
b49c291 Change IPC to using entirely distributed objects instead of distributed
mgorbach authored Mar 28, 2008
108 [stringData appendString:
109 [NSString stringWithFormat: @"%@ %@\n", headerStringForASLMessageDict([self.logMessages objectAtIndex: index]),
fd31161 Polish polish polish, and bugfixing. Plus, begining sparkle integration
mgorbach authored Jun 17, 2008
110 [[self.logMessages objectAtIndex: index] objectForKey: kMFLogKeyMessage]]];
111 index = [indexes indexGreaterThanIndex: index];
112 }
b49c291 Change IPC to using entirely distributed objects instead of distributed
mgorbach authored Mar 28, 2008
113 [pb setData: [stringData dataUsingEncoding: NSUTF8StringEncoding] forType: NSStringPboardType];
114 return;
115 }
116
117 - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
118 {
119 if ([item action] == @selector(copy:))
120 return YES;
121 else
122 return [super validateUserInterfaceItem: item];
123 }
124
af812d1 Adjust the API for submitting view controllers from plugins. Allow ad…
mgorbach authored Mar 31, 2008
125 # pragma mark Tooltip
126 - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
127 rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn
128 row:(NSInteger)row
129 mouseLocation:(NSPoint)mouseLocation
130 {
131 return [NSString stringWithFormat: @"%@", [self.logMessages objectAtIndex: row]];
132 }
b49c291 Change IPC to using entirely distributed objects instead of distributed
mgorbach authored Mar 28, 2008
133
134 @synthesize logMessages;
135 @end
Something went wrong with that request. Please try again.