1919#import " GetInfoSheetController.h"
2020#import " FetchRequestInfoController.h"
2121#import " ObjectInfoController.h"
22+ #import " MFLUtils.h"
2223
2324@interface OutlineViewNode : NSObject
2425@property (strong ) OutlineViewNode *parent;
@@ -143,14 +144,9 @@ - (void)addTableColumnWithIdentifier:(NSString *)ident
143144 [[newColumn headerCell ] setTextColor: [NSColor darkGrayColor ]];
144145 [[newColumn headerCell ] setAlignment: NSCenterTextAlignment ];
145146
146-
147- CGFloat defaultColWidth = [newColumn width ];
147+ // CGFloat defaultColWidth = [newColumn width];
148148 [newColumn sizeToFit ];
149- if ([newColumn width ] < defaultColWidth)
150- {
151- [newColumn setMinWidth: defaultColWidth];
152- }
153-
149+
154150 [[self entityContentTable ] addTableColumn: newColumn];
155151
156152 // TODO: we should set the cells up with proper types when we allow users to edit data
@@ -253,6 +249,8 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
253249- (void )onEntitySelected {
254250 if ([self .dataSourceList selectedRow ] >= 0 )
255251 {
252+ NSTimeInterval startTime = [[NSDate date ] timeIntervalSince1970 ];
253+
256254 [self removeColumns ];
257255 [self .coreDataIntrospection clearEntityData ];
258256 [self .entityContentTable reloadData ];
@@ -262,7 +260,6 @@ - (void)onEntitySelected {
262260
263261 NSInteger selected = selectedNode.index ;
264262 NSInteger section = selectedNode.parent .index ;
265- NSLog (@" Selected idx=%ld " , selected);
266263 if (selected >= 0 && section == 0 )
267264 {
268265 [self .coreDataIntrospection loadEntityDataAtIndex: selected];
@@ -272,7 +269,8 @@ - (void)onEntitySelected {
272269 [self addTableColumnWithIdentifier: name];
273270 }
274271
275- [self .coreDataIntrospection loadEntityDataAtIndex: selected];
272+ // TODO - why was this called twice?
273+ // [self.coreDataIntrospection loadEntityDataAtIndex:selected];
276274 [self .coreDataIntrospection updateCoreDataHistory: [self .coreDataIntrospection entityAtIndex: selected] predicate: nil objectType: MFLObjectTypeEntity];
277275
278276 } else if (selected >= 0 && section == 1 )
@@ -291,6 +289,7 @@ - (void)onEntitySelected {
291289 [self .entityContentTable reloadData ];
292290
293291 [self enableDisableHistorySegmentedControls ];
292+ NSLog (@" Selected %@ , selected=%d , section:%d , %@ ms" , selectedNode.title , (int )selected, (int )section, [MFLUtils duration: startTime]);
294293 }
295294}
296295
@@ -353,24 +352,9 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
353352
354353- (id )getValueObjFromDataRows : (NSTableView *)tableView : (NSInteger )row : (NSTableColumn *)tableColumn
355354{
356- NSArray * dataRow;
357355 NSInteger normalizedRow = [self sortOrderedRow: tableView row: row];
358-
359- id valueObj = nil ;
360- @try
361- {
362- dataRow = [self .coreDataIntrospection getDataAtRow: normalizedRow];
363-
364- valueObj = [dataRow valueForKey: [tableColumn identifier ]];
365- }
366- @catch (NSException *exception)
367- {
368- // Not sure what is going on here. This happens sometimes. We need to sort this one out...
369- NSLog (@" Row=%ld , normalizedRow=%ld , numRows=%ld , entityCount=%ld " , row, normalizedRow, [self .entityContentTable numberOfRows ], [self .coreDataIntrospection entityDataCount ]);
370- NSLog (@" Row[%ld ]: Caught Exception: %@ [%@ ], %@ " ,row, exception, tableColumn, dataRow);
371- valueObj = nil ;
372- }
373-
356+ NSArray *dataRow = [self .coreDataIntrospection getDataAtRow: (NSUInteger )normalizedRow];
357+ id valueObj = [dataRow valueForKey: [tableColumn identifier ]];
374358 return valueObj;
375359}
376360
@@ -384,6 +368,10 @@ - (NSInteger) sortOrderedRow:(NSTableView *)tableView row:(NSInteger) row {
384368 return normalizedRow;
385369}
386370
371+ - (CGFloat)tableView : (NSTableView *)tableView heightOfRow : (NSInteger )row {
372+ return 20 ;
373+ }
374+
387375- (NSView *)tableView : (NSTableView *)tableView viewForTableColumn : (NSTableColumn *)tableColumn row : (NSInteger )row
388376{
389377 if (tableView == [self dataSourceList ])
@@ -399,11 +387,9 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
399387
400388 return entityCell;
401389 }
402-
403- if (tableView == [self entityContentTable ])
390+ else if (tableView == [self entityContentTable ])
404391 {
405392 id valueObj = [self getValueObjFromDataRows: tableView :row :tableColumn];
406-
407393 if (valueObj == nil )
408394 {
409395 MFLTextTableCellView* textCell = [MFLCellBuilder nullCell: tableView owner: self ];
@@ -414,6 +400,7 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
414400 NSString * cellText = [NSString stringWithFormat: @" %@ " , valueObj];
415401 if ([cellText hasPrefix: @" http" ]) {
416402 MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
403+ buttonCell.wantsLayer = YES ;
417404 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
418405 [[buttonCell infoField ] setStringValue: cellText];
419406 return buttonCell;
@@ -428,24 +415,23 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
428415 NSURL * url = (NSURL *) valueObj;
429416 NSString * cellText = [NSString stringWithFormat: @" %@ " , [url absoluteString ]];
430417 MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
418+ buttonCell.wantsLayer = YES ;
431419 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
432420 [[buttonCell infoField ] setStringValue: cellText];
433421 return buttonCell;
434- // MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString:tableView textToSet:cellText owner:self];
435- // return textCell;
436422 }
437423 else if ([valueObj isKindOfClass: [NSDate class ]])
438424 {
439425 [self setupDateFormatter ];
440426 NSString *cellText = [self .dateFormatter stringFromDate: valueObj];
441427 MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
442-
443428 return textCell;
444429 }
445430 else if ([valueObj isKindOfClass: [NSData class ]])
446431 {
447432 NSString * cellText = [NSString stringWithFormat: @" %ld " , [valueObj length ]];
448433 MFLTextTableCellView* textCell = [MFLCellBuilder numberCellWithString: tableView textToSet: cellText owner: self ];
434+ textCell.wantsLayer = YES ;
449435 return textCell;
450436 }
451437 else if ([valueObj isKindOfClass: [NSNumber class ]])
@@ -460,14 +446,14 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
460446 cellText = [NSString stringWithFormat: @" %@ " , valueObj];
461447 }
462448 MFLTextTableCellView* textCell = [MFLCellBuilder numberCellWithString: tableView textToSet: cellText owner: self ];
449+ textCell.wantsLayer = YES ;
463450 return textCell;
464451 }
465-
466- // Button Cells
467452 else if ([valueObj isKindOfClass: [NSManagedObject class ]])
468453 {
469454 NSString * cellText = [NSString stringWithFormat: @" %@ " , [[valueObj entity ] name ]];
470455 MFLButtonTableViewCell* buttonCell = [MFLCellBuilder objectCellWithString: tableView textToSet: cellText owner: self ];
456+ buttonCell.wantsLayer = YES ;
471457 return buttonCell;
472458 }
473459 else if ([valueObj isKindOfClass: [NSSet class ]])
@@ -480,6 +466,7 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
480466 NSString *cellText = [NSString stringWithFormat: @" %@ [%ld ]" , [[object entity ] name ], [valueObj count ]];
481467
482468 MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
469+ buttonCell.wantsLayer = YES ;
483470 [[buttonCell infoField ] setAlignment: NSRightTextAlignment ];
484471 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
485472 [[buttonCell infoField ] setStringValue: cellText];
@@ -506,13 +493,15 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
506493 NSString *cellText = [NSString stringWithFormat: @" %@ [%ld ]" , [[object entity ] name ], [valueObj count ]];
507494
508495 MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
496+ buttonCell.wantsLayer = YES ;
509497 [[buttonCell infoField ] setAlignment: NSRightTextAlignment ];
510498 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
511499 [[buttonCell infoField ] setStringValue: cellText];
512500 return buttonCell;
513501 } else {
514502 NSString *cellText = [NSString stringWithFormat: @" %@ " , valueObj];
515503 MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
504+ textCell.wantsLayer = YES ;
516505 return textCell;
517506 }
518507 }
@@ -524,7 +513,6 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
524513 }
525514 else if ([valueObj isKindOfClass: [NSOrderedSet class ]])
526515 {
527-
528516 if ([valueObj count ] > 0 )
529517 {
530518 id obj = [valueObj firstObject ];
@@ -533,13 +521,15 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
533521 NSString *cellText = [NSString stringWithFormat: @" %@ [%ld ]" , [[object entity ] name ], [valueObj count ]];
534522
535523 MFLButtonTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_BUTTON_CELL owner: self ];
524+ buttonCell.wantsLayer = YES ;
536525 [[buttonCell infoField ] setAlignment: NSRightTextAlignment ];
537526 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
538527 [[buttonCell infoField ] setStringValue: cellText];
539528 return buttonCell;
540529 } else {
541530 NSString *cellText = [NSString stringWithFormat: @" %@ " , valueObj];
542531 MFLTextTableCellView* textCell = [MFLCellBuilder textCellWithString: tableView textToSet: cellText owner: self ];
532+ textCell.wantsLayer = YES ;
543533 return textCell;
544534 }
545535 }
@@ -553,23 +543,22 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
553543 {
554544 NSString * cellText = [NSString stringWithFormat: @" %@ " , @" NSDictionary Data" ];
555545 TransformableDataTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_TRANSFORM_CELL owner: self ];
546+ buttonCell.wantsLayer = YES ;
556547 [[buttonCell infoField ] setAlignment: NSRightTextAlignment ];
557548 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
558549 [[buttonCell infoField ] setStringValue: cellText];
559-
560550 return buttonCell;
561551 }
562552 // Unhandled types of content
563553 else
564554 {
565- NSLog (@" is Other" );
566-
555+ NSLog (@" Unknown content: %@ " , valueObj);
567556 NSString * cellText = [NSString stringWithFormat: @" ??? %@ ???" , [valueObj class ]];
568557 TransformableDataTableViewCell* buttonCell = [tableView makeViewWithIdentifier: MFL_TRANSFORM_CELL owner: self ];
558+ buttonCell.wantsLayer = YES ;
569559 [[buttonCell infoField ] setAlignment: NSRightTextAlignment ];
570560 [[buttonCell infoField ] setTextColor: [NSColor blackColor ]];
571561 [[buttonCell infoField ] setStringValue: cellText];
572-
573562 return buttonCell;
574563 }
575564 }
0 commit comments