@@ -62,6 +62,7 @@ @interface MFLMainWindowController ()
6262@property (strong ) NSArray * baseRowTemplates;
6363@property (weak ) IBOutlet NSPredicateEditor *predicateEditor;
6464@property (strong ) OutlineViewNode *rootNode;
65+ @property NSDateFormatter *dateFormatter;
6566
6667@end
6768
@@ -411,22 +412,32 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
411412 else if ([valueObj isKindOfClass: [NSString class ]])
412413 {
413414 NSString * cellText = [NSString stringWithFormat: @" %@ " , valueObj];
414- MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
415- return textCell;
415+ if ([cellText hasPrefix: @" http" ]) {
416+ MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
417+ [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
418+ [[buttonCell infoField ] setStringValue: cellText];
419+ return buttonCell;
420+ }
421+ else {
422+ MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
423+ return textCell;
424+ }
416425 }
417426 else if ([valueObj isKindOfClass: [NSURL class ]])
418427 {
419428 NSURL * url = (NSURL *) valueObj;
420429 NSString * cellText = [NSString stringWithFormat: @" %@ " , [url absoluteString ]];
421- MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
422- return textCell;
430+ MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
431+ [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
432+ [[buttonCell infoField ] setStringValue: cellText];
433+ return buttonCell;
434+ // MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString:tableView textToSet:cellText owner:self];
435+ // return textCell;
423436 }
424437 else if ([valueObj isKindOfClass: [NSDate class ]])
425438 {
426- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc ] init ];
427- [dateFormatter setDateStyle: self .dateStyle];
428- [dateFormatter setTimeStyle: self .dateStyle];
429- NSString *cellText = [dateFormatter stringFromDate: valueObj];
439+ [self setupDateFormatter ];
440+ NSString *cellText = [self .dateFormatter stringFromDate: valueObj];
430441 MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
431442
432443 return textCell;
@@ -439,7 +450,15 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
439450 }
440451 else if ([valueObj isKindOfClass: [NSNumber class ]])
441452 {
442- NSString * cellText = [NSString stringWithFormat: @" %@ " , valueObj];
453+ NSString * cellText;
454+ NSNumber *number = valueObj;
455+ // get 'type' of NSNumber to determine if this is a Boolean data type
456+ if (strcmp (number.objCType , @encode (BOOL )) == 0 ) {
457+ cellText = [NSString stringWithFormat: @" %@ " , number.boolValue ? @" YES" : @" NO" ];
458+ }
459+ else {
460+ cellText = [NSString stringWithFormat: @" %@ " , valueObj];
461+ }
443462 MFLTextTableCellView* textCell = [MFLCellBuilder numberCellWithString: tableView textToSet: cellText owner: self ];
444463 return textCell;
445464 }
@@ -558,6 +577,25 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
558577 return nil ;
559578}
560579
580+ - (void )setupDateFormatter {
581+ if (self.dateFormatter == nil ) {
582+ self.dateFormatter = [[NSDateFormatter alloc ] init ];
583+ }
584+ switch (self.dateStyle ) {
585+ case NSDateFormatterShortStyle:
586+ [self .dateFormatter setDateFormat: @" M/d/YY h:mm a" ];
587+ break ;
588+ case NSDateFormatterMediumStyle:
589+ [self .dateFormatter setDateFormat: @" MM/dd/YY hh:mm a" ];
590+ break ;
591+ default :
592+ // use original formatting
593+ [self .dateFormatter setDateStyle: self .dateStyle];
594+ [self .dateFormatter setTimeStyle: self .dateStyle];
595+ break ;
596+ }
597+ }
598+
561599#pragma mark - Outline view
562600
563601- (NSInteger )outlineView : (NSOutlineView *)outlineView numberOfChildrenOfItem : (id )item {
@@ -995,6 +1033,16 @@ - (IBAction)entityCellButtonClicked:(id)sender
9951033 [self .coreDataIntrospection updateCoreDataHistory: [[[set firstObject ] entity ] name ] predicate: predicate objectType: MFLObjectTypeEntity];
9961034 [self enableDisableHistorySegmentedControls ];
9971035 }
1036+ else if ([valueObj isKindOfClass: [NSString class ]]) {
1037+ NSString *string = valueObj;
1038+ if ([string hasPrefix: @" http" ]) {
1039+ [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: string]];
1040+ }
1041+ }
1042+ else if ([valueObj isKindOfClass: [NSURL class ]]) {
1043+ NSURL *url = valueObj;
1044+ [[NSWorkspace sharedWorkspace ] openURL: url];
1045+ }
9981046 }
9991047}
10001048
0 commit comments