Skip to content

Commit

Permalink
Errors in xcodecapp-cocoa now show up in their own panel. Should we k…
Browse files Browse the repository at this point in the history
…eep growl?
  • Loading branch information
Randall Luecke committed Jul 17, 2011
1 parent da6d8c8 commit 2ccbf5d
Show file tree
Hide file tree
Showing 4 changed files with 435 additions and 19 deletions.
11 changes: 11 additions & 0 deletions Tools/xcodecapp-cocoa/AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
IBOutlet NSMenuItem *menuItemStop;
IBOutlet NSMenuItem *menuItemOpenXCode;

IBOutlet NSPanel *errorsPanel;
IBOutlet NSTableView *errorsTable;

NSFileManager *fm;
NSMutableArray *modifiedXIBs;
NSMutableArray *errorList;
NSMutableDictionary *pathModificationDates;
NSDate *appStartedTimestamp;
NSNumber *lastEventId;
Expand Down Expand Up @@ -74,5 +78,12 @@
- (IBAction)openXCode:(id)aSender;
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem;

- (void)updateErrorTable;
- (IBAction)clearErrors:(id)sender;
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(int)aRow;

@end

58 changes: 56 additions & 2 deletions Tools/xcodecapp-cocoa/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ - (id)init

if (self)
{
errorList = [NSMutableArray arrayWithCapacity:10];

if (!growlDelegateRef)
growlDelegateRef = [[[PRHEmptyGrowlDelegate alloc] init] autorelease];

Expand Down Expand Up @@ -260,6 +262,12 @@ - (void)handleFileModification:(NSString*)path ignoreDate:(BOOL)shouldIgnoreDate
isSticky:NO
clickContext:nil];
NSLog(@"Error in conversion: return message is %@", response);

//if (![GrowlApplicationBridge isGrowlRunning])
{
[errorList addObject:response];
[self updateErrorTable];
}
}
}
}
Expand All @@ -274,7 +282,8 @@ - (BOOL)isObjJFile:(NSString *)path

- (BOOL)isXIBFile:(NSString *)path
{
return [[[path pathExtension] uppercaseString] isEqual:@"XIB"];
path = [[path pathExtension] uppercaseString];
return [path isEqual:@"XIB"] || [path isEqual:@"NIB"];
}

- (BOOL)prepareXCodeSupportProject
Expand Down Expand Up @@ -492,6 +501,18 @@ - (IBAction)openXCode:(id)aSender
}


- (void)updateErrorTable
{
[errorsTable reloadData];
[errorsPanel orderFront:self];
NSLog(@"update?");
}

- (IBAction)clearErrors:(id)sender
{
[errorList removeAllObjects];
[errorsTable reloadData];
}
#pragma mark -
#pragma mark Delegates

Expand All @@ -502,7 +523,7 @@ - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisible
return YES;
}

- (BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
- (BOOL)validateMenuItem:(NSMenuItem *)aMenuItem
{
if (aMenuItem == menuItemStart)
return !currentProjectURL;
Expand All @@ -512,4 +533,37 @@ - (BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
return YES;
}


- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [errorList count];
}
- (id)tableView:(NSTableView*)aTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
return [errorList objectAtIndex:row];
}

- (void)tableViewColumnDidResize:(NSNotification *)tableView
{
[errorsTable noteHeightOfRowsWithIndexesChanged:
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [errorList count])]];
}

- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(int)aRow
{
// Get column you want - first in this case:
NSTableColumn *tabCol = [[tableView tableColumns] objectAtIndex:0];
float width = [tabCol width];
NSRect r = NSMakeRect(0,0,width,1000.0);
NSCell *cell = [tabCol dataCellForRow:aRow];
NSString *content = [errorList objectAtIndex:aRow];
[cell setObjectValue:content];
float height = [cell cellSizeForBounds:r].height;

if (height <= 0)
height = 16.0; // Ensure miniumum height is 16.0

return height;

}
@end
Loading

0 comments on commit 2ccbf5d

Please sign in to comment.