Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Core Data Editor/Core Data Editor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
4018D7842306011600A59D01 /* CDEUUIDAttributeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4018D7832306011600A59D01 /* CDEUUIDAttributeView.xib */; };
4018D7872306401100A59D01 /* CDEUUIDAttributeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4018D7862306401100A59D01 /* CDEUUIDAttributeViewController.m */; };
AB0181171997C805000FE094 /* NSDirectoryEnumerator+ProjectBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = AB0181161997C805000FE094 /* NSDirectoryEnumerator+ProjectBrowser.m */; };
AB06C0AF1854CB07002945CB /* CDEToOneRelationshipRequestDataCoordinator.m in Sources */ = {isa = PBXBuildFile; fileRef = AB06C0AE1854CB07002945CB /* CDEToOneRelationshipRequestDataCoordinator.m */; };
AB0927511768C6EC00FC59FB /* CDEEntitiesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB09274F1768C6EC00FC59FB /* CDEEntitiesViewController.m */; };
Expand Down Expand Up @@ -219,6 +221,9 @@

/* Begin PBXFileReference section */
2E25BCB4198D645100BBA0C0 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
4018D7832306011600A59D01 /* CDEUUIDAttributeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CDEUUIDAttributeView.xib; sourceTree = "<group>"; };
4018D7852306401100A59D01 /* CDEUUIDAttributeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDEUUIDAttributeViewController.h; sourceTree = "<group>"; };
4018D7862306401100A59D01 /* CDEUUIDAttributeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDEUUIDAttributeViewController.m; sourceTree = "<group>"; };
AB0181151997C805000FE094 /* NSDirectoryEnumerator+ProjectBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDirectoryEnumerator+ProjectBrowser.h"; sourceTree = "<group>"; };
AB0181161997C805000FE094 /* NSDirectoryEnumerator+ProjectBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDirectoryEnumerator+ProjectBrowser.m"; sourceTree = "<group>"; };
AB06C0AD1854CB07002945CB /* CDEToOneRelationshipRequestDataCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDEToOneRelationshipRequestDataCoordinator.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -599,6 +604,16 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4018D7882306401D00A59D01 /* UUID */ = {
isa = PBXGroup;
children = (
4018D7852306401100A59D01 /* CDEUUIDAttributeViewController.h */,
4018D7862306401100A59D01 /* CDEUUIDAttributeViewController.m */,
4018D7832306011600A59D01 /* CDEUUIDAttributeView.xib */,
);
name = UUID;
sourceTree = "<group>";
};
AB06C0AC1854CAD5002945CB /* To-One Relationship Request Coordinator */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1861,6 +1876,7 @@
ABEEA5BF178194B70096DE4C /* Date */,
ABEEA5C1178194C60096DE4C /* Number */,
ABEEA5C2178194CC0096DE4C /* Binary */,
4018D7882306401D00A59D01 /* UUID */,
ABC189F117809EDC00AF4F15 /* CDEAttributeViewControllerDelegate.h */,
ABC189F217809EDC00AF4F15 /* CDEAttributeViewController.h */,
ABC189F317809EDC00AF4F15 /* CDEAttributeViewController.m */,
Expand Down Expand Up @@ -2057,6 +2073,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = ABBEA7CD1765CB730024A9D2;
Expand Down Expand Up @@ -2103,6 +2120,7 @@
ABD5BCE317807B4F0050025B /* Relationship-ToMany.pdf in Resources */,
ABD5BCE417807B4F0050025B /* Relationship-ToOne.pdf in Resources */,
ABC18A1A17809EDC00AF4F15 /* CDEBooleanAttributeView.xib in Resources */,
4018D7842306011600A59D01 /* CDEUUIDAttributeView.xib in Resources */,
ABC18A1C17809EDC00AF4F15 /* CDEStringAttributeView.xib in Resources */,
ABC18A1F17809EDC00AF4F15 /* CDEDatePickerViewController.xib in Resources */,
ABC18A2117809EDC00AF4F15 /* CDEDateAttributeView.xib in Resources */,
Expand Down Expand Up @@ -2180,6 +2198,7 @@
AB22AC7A17664480004890AC /* NSBundle+CDEModelFinder.m in Sources */,
AB0927511768C6EC00FC59FB /* CDEEntitiesViewController.m in Sources */,
AB0927571768C81E00FC59FB /* CDEEditorViewController.m in Sources */,
4018D7872306401100A59D01 /* CDEUUIDAttributeViewController.m in Sources */,
AB0927631768E65200FC59FB /* NSURL+CDEAdditions.m in Sources */,
AB09276A1768F36100FC59FB /* CDEApplicationDelegate.m in Sources */,
AB09279B1768F73000FC59FB /* CDEManagedObjectsViewController.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "CDEBooleanAttributeViewController.h"
#import "CDEDateAttributeViewController.h"
#import "CDEBinaryAttributeViewController.h"
#import "CDEUUIDAttributeViewController.h"

const static NSString *CDEAttributeViewControllerResultingValueObservationContext = @"CDEAttributeViewControllerResultingValueObservationContext";

Expand Down Expand Up @@ -67,6 +68,9 @@ + (Class)attributeViewControllerClassForAttributeDescription:(NSAttributeDescrip
if([CDEManagedObjectsTableViewAttributeHelper attributeTypeIsNumber:[attributeDescription attributeType]]) {
return [CDENumberAttributeViewController class];
}
if([attributeDescription attributeType] == NSUUIDAttributeType) {
return [CDEUUIDAttributeViewController class];
}
return nil;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (IBAction)saveResultingValueAs:(id)sender {
NSSavePanel *panel = [NSSavePanel savePanel];
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) {
if(result != NSFileHandlingPanelOKButton) {
if(result != NSModalResponseOK) {
return;
}
if([[self resultingValue] isKindOfClass:[NSData class]] == NO) {
Expand All @@ -75,7 +75,7 @@ - (IBAction)setResultingValueFromFile:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) {
if(result != NSFileHandlingPanelOKButton) {
if(result != NSModalResponseOK) {
return;
}
// if([[self resultingValue] isKindOfClass:[NSData class]] == NO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (IBAction)saveObjectValueAs:(id)sender {
NSSavePanel *panel = [NSSavePanel savePanel];
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if(result != NSFileHandlingPanelOKButton) {
if(result != NSModalResponseOK) {
return;
}
if([self.objectValue isKindOfClass:[NSData class]] == NO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (IBAction)showOpenCSVFilePanel:(id)sender {
panel.allowedFileTypes = @[@"csv"];
panel.accessoryView = self.delimiterViewController.view;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
BOOL userChoseOKButton = (NSFileHandlingPanelOKButton == result);
BOOL userChoseOKButton = (NSModalResponseOK == result);
if(userChoseOKButton == NO) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (id)init {
- (IBAction)createNewStore:(id)sender {
NSSavePanel *panel = [NSSavePanel savePanel];
[panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) {
if(result != NSFileHandlingPanelOKButton) {
if(result != NSModalResponseOK) {
return;
}
NSURL *URL = [panel URL];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ - (IBAction)showImportCSVFileWindow:(id)sender {
}

#pragma mark - CDEEntitiesViewControllerDelegate
- (void)entitiesViewController:(CDEEntitiesViewController *)entitiesViewController didSelectEntitiyDescription:(NSEntityDescription *)entityDescription {
- (void)entitiesViewController:(CDEEntitiesViewController *)entitiesViewController didSelectEntityDescription:(NSEntityDescription *)entityDescription {

// Before assiging check for equality
CDEAutosaveInformation *persistentInformation = [[CDEAutosaveInformation alloc] initWithDictionaryRepresentation:self.configuration.autosaveInformationByEntityName];
Expand Down
4 changes: 2 additions & 2 deletions Core Data Editor/Core Data Editor/CDEEntitiesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
return;
}

if([self.delegate respondsToSelector:@selector(entitiesViewController:didSelectEntitiyDescription:)] == NO) {
if([self.delegate respondsToSelector:@selector(entitiesViewController:didSelectEntityDescription:)] == NO) {
return;
}

id selectedEntity = nil;
if ([self.outlineView selectedRow] != -1) {
selectedEntity = [self.outlineView itemAtRow:self.outlineView.selectedRow];
}
[self.delegate entitiesViewController:self didSelectEntitiyDescription:selectedEntity];
[self.delegate entitiesViewController:self didSelectEntityDescription:selectedEntity];
}

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
@protocol CDEEntitiesViewControllerDelegate <NSObject>

@required
- (void)entitiesViewController:(CDEEntitiesViewController *)entitiesViewController didSelectEntitiyDescription:(NSEntityDescription *)entityDescription;
- (void)entitiesViewController:(CDEEntitiesViewController *)entitiesViewController didSelectEntityDescription:(NSEntityDescription *)entityDescription;

@end
50 changes: 34 additions & 16 deletions Core Data Editor/Core Data Editor/CDEEntityRequestDataCoordinator.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,31 @@ - (void)prepare {
}
}
}

NSError *fetchError = nil;
NSString *entityName = self.request.entityDescription.name;
NSFetchRequest<NSManagedObject *> *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:entityName];
NSArray *objects = [self.request.managedObjectContext executeFetchRequest:fetchRequest error:&fetchError];
if(objects == nil) {
NSLog(@"error: %@", fetchError);
return;
}
self.filteringArray = [FilteringArray new];
[self.filteringArray addObjectsFromArray:objects];
[self.tableView reloadData];

[self executeFetchRequest];
[self.tableView reloadData];
}

-(void)executeFetchRequest {
if(self.filteringArray == nil) {
self.filteringArray = [FilteringArray new];
}
else {
[self.filteringArray removeAllObjects];
}
NSError *fetchError = nil;
NSString *entityName = self.request.entityDescription.name;
NSFetchRequest<NSManagedObject *> *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:entityName];
fetchRequest.sortDescriptors = self.request.sortDescriptors;
NSArray *objects = [self.request.managedObjectContext executeFetchRequest:fetchRequest error:&fetchError];
if(objects == nil) {
NSLog(@"error: %@", fetchError);
return;
}
[self.filteringArray addObjectsFromArray:objects];
}


- (void)invalidate {
}

Expand All @@ -101,13 +112,16 @@ - (NSManagedObject *)createAndAddManagedObject {
return object;
}

- (void)removeSelectedManagedObjects {
- (void)removeSelectedManagedObjects:(BOOL)andDeleteThem; // AH: passing YES removes AND deletes the objects. Passing NO only removes them.
{
NSIndexSet *indexes = [self indexesOfSelectedManagedObjects];
NSArray<NSManagedObject*>* objects = [self.filteringArray objectsAtIndexes:indexes];
[self.filteringArray removeObjectsAtIndexes:indexes];
for(NSManagedObject *object in objects) {
[self.request.managedObjectContext deleteObject:object];
}
if(andDeleteThem) {
for(NSManagedObject *object in objects) {
[self.request.managedObjectContext deleteObject:object];
}
}
[self.tableView reloadData];

}
Expand Down Expand Up @@ -136,6 +150,10 @@ - (BOOL)canPerformDelete {
return (self.tableView.selectedRow != -1);
}

- (BOOL)canPerformNullify {
return NO; // can't nullify an object. You can only delete it!
}

#pragma mark - Autosave
- (void)updateAutosaveInformation:(CDEAutosaveInformation *)autosaveInformation {
// do nothing by default
Expand Down
10 changes: 10 additions & 0 deletions Core Data Editor/Core Data Editor/CDEManagedObjectView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@interface CDEManagedObjectView()

#pragma mark Properties
@property (retain) NSTextField *objectIDTextField; // AH: to display the objectID of the to-one relationship.
@property (retain) NSMutableArray *attributeViewControllers;
@property (retain) NSDictionary *managedObjectBindingInfo;
@property (retain) CDEGenerateThumbnailsController *generateThumbnailsController;
Expand Down Expand Up @@ -118,6 +119,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N

- (void)refresh {
[[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

self.objectIDTextField = [NSTextField labelWithString:self.managedObject ? [NSString stringWithFormat:@"objectID: %@",[self.managedObject.objectID stringRepresentationForDisplay_cde]] : @"nil objectID"];
[self addSubview:self.objectIDTextField];

for(CDEAttributeViewController *attributeViewController in self.attributeViewControllers) {
attributeViewController.delegate = nil;
Expand Down Expand Up @@ -177,6 +181,12 @@ - (void)layoutAttributeViews {
CGFloat height = 10.0f;
CGFloat nameViewWidthScaleFactor = 0.35;
CGFloat valueViewWidthScaleFactor = 1.0 - nameViewWidthScaleFactor;

[self.objectIDTextField sizeToFit];
[self.objectIDTextField setFrameOrigin:NSMakePoint(nameViewWidthScaleFactor * NSWidth([self bounds]), height)];
height += NSHeight(self.objectIDTextField.frame);


for(CDEAttributeViewController *attributeViewController in self.attributeViewControllers) {
NSRect newValueFrame = NSMakeRect(nameViewWidthScaleFactor * NSWidth([self bounds]), height, valueViewWidthScaleFactor * NSWidth([self bounds]) - 10.0, NSHeight([[attributeViewController view] frame]));
if([attributeViewController attributeNameView] != nil) {
Expand Down
Loading