Skip to content

Commit

Permalink
Merge pull request #42 from ChristianKienle/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Christian Kienle authored Nov 20, 2016
2 parents ecf66a4 + 5196715 commit 81027e0
Show file tree
Hide file tree
Showing 24 changed files with 534 additions and 985 deletions.
37 changes: 6 additions & 31 deletions Core Data Editor/Core Data Editor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
AB3B07C91775FCE2000855B0 /* CDEBoolValueTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = AB3B07C81775FCE2000855B0 /* CDEBoolValueTableCellView.m */; };
AB3B07CB1775FCF2000855B0 /* CDEBoolValueTableCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB3B07CA1775FCF2000855B0 /* CDEBoolValueTableCellView.xib */; };
AB3B07CE17760E23000855B0 /* NSTableCellView+JKNibLoading.m in Sources */ = {isa = PBXBuildFile; fileRef = AB3B07CD17760E23000855B0 /* NSTableCellView+JKNibLoading.m */; };
AB4068FA1DE1C5DE001F83E9 /* FilteringArray.m in Sources */ = {isa = PBXBuildFile; fileRef = AB4068F91DE1C5DE001F83E9 /* FilteringArray.m */; };
AB531222179953B300529EF7 /* NSTableColumn+CDERequestDataCoordinator.m in Sources */ = {isa = PBXBuildFile; fileRef = AB531221179953B300529EF7 /* NSTableColumn+CDERequestDataCoordinator.m */; };
AB5583A5176751AE005C002C /* icon.iconset in Resources */ = {isa = PBXBuildFile; fileRef = AB5583A4176751AE005C002C /* icon.iconset */; };
AB59DA401DDF42AA00A19963 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB59DA3F1DDF42AA00A19963 /* Main.storyboard */; };
Expand Down Expand Up @@ -99,7 +100,6 @@
ABBEA7ED1765CB730024A9D2 /* CDEDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA7EC1765CB730024A9D2 /* CDEDocument.m */; };
ABBEA7F01765CB730024A9D2 /* CDEDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = ABBEA7EE1765CB730024A9D2 /* CDEDocument.xib */; };
ABBEA7F31765CB730024A9D2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = ABBEA7F11765CB730024A9D2 /* MainMenu.xib */; };
ABBEA7F61765CB730024A9D2 /* CDEDocument.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA7F41765CB730024A9D2 /* CDEDocument.xcdatamodeld */; };
ABBEA8241765D5AC0024A9D2 /* CDEPathActionLabelController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA7FE1765D5AA0024A9D2 /* CDEPathActionLabelController.m */; };
ABBEA8251765D5AC0024A9D2 /* CDENewConfigurationSummaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8001765D5AA0024A9D2 /* CDENewConfigurationSummaryViewController.m */; };
ABBEA8261765D5AC0024A9D2 /* CDENewConfigurationSummaryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ABBEA8011765D5AA0024A9D2 /* CDENewConfigurationSummaryViewController.xib */; };
Expand All @@ -121,7 +121,6 @@
ABBEA8951765F3320024A9D2 /* NSBundle+CDEApplicationAnalyzer.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8941765F3320024A9D2 /* NSBundle+CDEApplicationAnalyzer.m */; };
ABBEA8A01765FC230024A9D2 /* NSURL+CDEApplicationAnalyzer.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA89F1765FC230024A9D2 /* NSURL+CDEApplicationAnalyzer.m */; };
ABBEA8A4176602B60024A9D2 /* NSString+CDEPersistentStore.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8A3176602B60024A9D2 /* NSString+CDEPersistentStore.m */; };
ABBEA8B517660AB30024A9D2 /* _CDEConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8B217660AB30024A9D2 /* _CDEConfiguration.m */; };
ABBEA8B617660AB30024A9D2 /* CDEConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8B417660AB30024A9D2 /* CDEConfiguration.m */; };
ABBEA8BB1766153A0024A9D2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = ABBEA8B91766153A0024A9D2 /* Localizable.strings */; };
ABBEA8D41766212A0024A9D2 /* NSPasteboard-CDEAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBEA8D31766212A0024A9D2 /* NSPasteboard-CDEAdditions.m */; };
Expand Down Expand Up @@ -318,6 +317,8 @@
AB3B07CA1775FCF2000855B0 /* CDEBoolValueTableCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CDEBoolValueTableCellView.xib; sourceTree = "<group>"; };
AB3B07CC17760E22000855B0 /* NSTableCellView+JKNibLoading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTableCellView+JKNibLoading.h"; sourceTree = "<group>"; };
AB3B07CD17760E23000855B0 /* NSTableCellView+JKNibLoading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTableCellView+JKNibLoading.m"; sourceTree = "<group>"; };
AB4068F81DE1C5DE001F83E9 /* FilteringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilteringArray.h; sourceTree = "<group>"; };
AB4068F91DE1C5DE001F83E9 /* FilteringArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilteringArray.m; sourceTree = "<group>"; };
AB531220179953B300529EF7 /* NSTableColumn+CDERequestDataCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTableColumn+CDERequestDataCoordinator.h"; sourceTree = "<group>"; };
AB531221179953B300529EF7 /* NSTableColumn+CDERequestDataCoordinator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTableColumn+CDERequestDataCoordinator.m"; sourceTree = "<group>"; };
AB5583A4176751AE005C002C /* icon.iconset */ = {isa = PBXFileReference; lastKnownFileType = folder.iconset; path = icon.iconset; sourceTree = "<group>"; };
Expand Down Expand Up @@ -378,7 +379,6 @@
ABBEA7EC1765CB730024A9D2 /* CDEDocument.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDEDocument.m; sourceTree = "<group>"; };
ABBEA7EF1765CB730024A9D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/CDEDocument.xib; sourceTree = "<group>"; };
ABBEA7F21765CB730024A9D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
ABBEA7F51765CB730024A9D2 /* CDEDocument.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CDEDocument.xcdatamodel; sourceTree = "<group>"; };
ABBEA7FD1765D5AA0024A9D2 /* CDEPathActionLabelController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDEPathActionLabelController.h; sourceTree = "<group>"; };
ABBEA7FE1765D5AA0024A9D2 /* CDEPathActionLabelController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDEPathActionLabelController.m; sourceTree = "<group>"; };
ABBEA7FF1765D5AA0024A9D2 /* CDENewConfigurationSummaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDENewConfigurationSummaryViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -421,8 +421,6 @@
ABBEA89F1765FC230024A9D2 /* NSURL+CDEApplicationAnalyzer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+CDEApplicationAnalyzer.m"; sourceTree = "<group>"; };
ABBEA8A2176602B60024A9D2 /* NSString+CDEPersistentStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CDEPersistentStore.h"; sourceTree = "<group>"; };
ABBEA8A3176602B60024A9D2 /* NSString+CDEPersistentStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+CDEPersistentStore.m"; sourceTree = "<group>"; };
ABBEA8B117660AB30024A9D2 /* _CDEConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _CDEConfiguration.h; sourceTree = "<group>"; };
ABBEA8B217660AB30024A9D2 /* _CDEConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _CDEConfiguration.m; sourceTree = "<group>"; };
ABBEA8B317660AB30024A9D2 /* CDEConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDEConfiguration.h; sourceTree = "<group>"; };
ABBEA8B417660AB30024A9D2 /* CDEConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDEConfiguration.m; sourceTree = "<group>"; };
ABBEA8BA1766153A0024A9D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -840,6 +838,8 @@
children = (
AB15E73F177B690B00FA113E /* CDEEntityRequestDataCoordinator.h */,
AB15E740177B690B00FA113E /* CDEEntityRequestDataCoordinator.m */,
AB4068F81DE1C5DE001F83E9 /* FilteringArray.h */,
AB4068F91DE1C5DE001F83E9 /* FilteringArray.m */,
);
name = "Entity Coordinator";
sourceTree = "<group>";
Expand Down Expand Up @@ -1223,7 +1223,6 @@
ABBEA7EE1765CB730024A9D2 /* CDEDocument.xib */,
ABBEA7F11765CB730024A9D2 /* MainMenu.xib */,
AB59DA3F1DDF42AA00A19963 /* Main.storyboard */,
ABBEA7F41765CB730024A9D2 /* CDEDocument.xcdatamodeld */,
ABBEA7E01765CB730024A9D2 /* Supporting Files */,
);
path = "Core Data Editor";
Expand Down Expand Up @@ -1439,20 +1438,10 @@
AB23E43C17A6C1F5001C19A7 /* Autosave Information */,
ABBEA8B317660AB30024A9D2 /* CDEConfiguration.h */,
ABBEA8B417660AB30024A9D2 /* CDEConfiguration.m */,
ABBEA8B717660FC00024A9D2 /* Machine */,
);
name = Model;
sourceTree = "<group>";
};
ABBEA8B717660FC00024A9D2 /* Machine */ = {
isa = PBXGroup;
children = (
ABBEA8B117660AB30024A9D2 /* _CDEConfiguration.h */,
ABBEA8B217660AB30024A9D2 /* _CDEConfiguration.m */,
);
name = Machine;
sourceTree = "<group>";
};
ABBEA8B817660FD40024A9D2 /* Shared */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2166,7 +2155,6 @@
ABBEA7E61765CB730024A9D2 /* main.m in Sources */,
ABDA4235181BFF2C0054A226 /* CDEMenuWindowItemBadgeView.m in Sources */,
ABBEA7ED1765CB730024A9D2 /* CDEDocument.m in Sources */,
ABBEA7F61765CB730024A9D2 /* CDEDocument.xcdatamodeld in Sources */,
ABDA4282181C068F0054A226 /* CDEManagedObjectsTableViewController.m in Sources */,
ABBEA8241765D5AC0024A9D2 /* CDEPathActionLabelController.m in Sources */,
ABBEA8251765D5AC0024A9D2 /* CDENewConfigurationSummaryViewController.m in Sources */,
Expand All @@ -2187,7 +2175,6 @@
ABBEA8951765F3320024A9D2 /* NSBundle+CDEApplicationAnalyzer.m in Sources */,
ABBEA8A01765FC230024A9D2 /* NSURL+CDEApplicationAnalyzer.m in Sources */,
ABBEA8A4176602B60024A9D2 /* NSString+CDEPersistentStore.m in Sources */,
ABBEA8B517660AB30024A9D2 /* _CDEConfiguration.m in Sources */,
ABBEA8B617660AB30024A9D2 /* CDEConfiguration.m in Sources */,
ABBEA8D41766212A0024A9D2 /* NSPasteboard-CDEAdditions.m in Sources */,
AB22AC7A17664480004890AC /* NSBundle+CDEModelFinder.m in Sources */,
Expand Down Expand Up @@ -2301,6 +2288,7 @@
ABB225D717B92B230024FE4F /* CDEProjectBrowserWindowController.m in Sources */,
ABB225DC17B939E60024FE4F /* CDEProjectBrowserItem.m in Sources */,
ABB225DF17B940CE0024FE4F /* CDEProjectBrowserItemTableCellView.m in Sources */,
AB4068FA1DE1C5DE001F83E9 /* FilteringArray.m in Sources */,
AB36447E17BA47D4004ADAAC /* CDESetupWindowController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -2480,19 +2468,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
ABBEA7F41765CB730024A9D2 /* CDEDocument.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
ABBEA7F51765CB730024A9D2 /* CDEDocument.xcdatamodel */,
);
currentVersion = ABBEA7F51765CB730024A9D2 /* CDEDocument.xcdatamodel */;
path = CDEDocument.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = ABBEA7CE1765CB730024A9D2 /* Project object */;
}
69 changes: 3 additions & 66 deletions Core Data Editor/Core Data Editor/CDEApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,65 +51,20 @@ - (IBAction)showProjectBrowser:(id)sender {
if(self.projectBrowserWindowController == nil) {
self.projectBrowserWindowController = [CDEProjectBrowserWindowController new];
}
[self.projectBrowserWindowController showWithProjectDirectoryURL:self.iPhoneSimulatorDirectory];
}

#pragma mark - Helper
#pragma mark - Helper / Security Scoped Resources
- (BOOL)startAccessingCoreDataEditorSecurityScopedResources {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

BOOL iPhoneSimulatorSuccess = YES;

if(defaults.simulatorDirectory_cde != nil) {
self.iPhoneSimulatorDirectory = defaults.simulatorDirectory_cde;
iPhoneSimulatorSuccess = [self.iPhoneSimulatorDirectory startAccessingSecurityScopedResource];
}

BOOL buildProductsDirectorySuccess = YES;

if(defaults.buildProductsDirectory_cde != nil) {
self.derivedDataDirectory = defaults.buildProductsDirectory_cde;
buildProductsDirectorySuccess = [self.derivedDataDirectory startAccessingSecurityScopedResource];
if(buildProductsDirectorySuccess == NO) {
// we have bookmark data but we cannot start accessing it!
NSAlert *alert = [NSAlert new];
alert.messageText = @"Failed to access Derived Data Directory";
[alert addButtonWithTitle:@"Set Directory…"];
[alert addButtonWithTitle:@"Cancel"];
alert.informativeText = @"You have set a Xcode derived data directory in the preferences but Core Data Editor failed to access the contents of the directory. If you want to continue to use this feature you should set a new directory now.";
NSUInteger returnCode = [alert runModal];
if(returnCode == NSAlertFirstButtonReturn) {
assert(false);
// [self.preferencesWindowController showAutomaticProjectCreationPreferencesWithCompletionHandler:nil];
}
}
}

return (iPhoneSimulatorSuccess && buildProductsDirectorySuccess);
[self.projectBrowserWindowController showWithProjectDirectoryURL:defaults.simulatorDirectory_cde];
}

#pragma mark NSApplicationDelegate
- (void)applicationWillFinishLaunching:(NSNotification *)notification {

// Start accessing security scoped resources here because this delegate method is called
// before applicationDidFinishLaunching: and before application:openFile:
// Since we need access to the resources in both cases...
[self startAccessingCoreDataEditorSecurityScopedResources];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"HELLO" forKey:@"AAAAAAAAAAAAAA"];
[[NSNotificationCenter defaultCenter] addObserverForName:CDEUserDefaultsNotifications.didChangeSimulatorDirectory object:defaults queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self.iPhoneSimulatorDirectory stopAccessingSecurityScopedResource];
self.iPhoneSimulatorDirectory = defaults.simulatorDirectory_cde;
[self.iPhoneSimulatorDirectory startAccessingSecurityScopedResource];
[self.projectBrowserWindowController updateProjectDirectoryURL:self.iPhoneSimulatorDirectory];
}];

[[NSNotificationCenter defaultCenter] addObserverForName:CDEUserDefaultsNotifications.didChangeBuildProductsDirectory object:defaults queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self.derivedDataDirectory stopAccessingSecurityScopedResource];
self.derivedDataDirectory = defaults.buildProductsDirectory_cde;
[self.derivedDataDirectory startAccessingSecurityScopedResource];
}];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
Expand All @@ -125,10 +80,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {
}

self.aboutWindowController = [[CDEAboutWindowController alloc] initWithWindowNibName:@"CDEAboutWindowController"];
// Create prefs if needed
// if(self.preferencesWindowController == nil) {
// self.preferencesWindowController = [CDEPreferencesWindowController new];
// }
}

- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
Expand All @@ -146,10 +97,6 @@ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {
}

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
// Need to create prefs?
// if(self.preferencesWindowController == nil) {
// self.preferencesWindowController = [CDEPreferencesWindowController new];
// }
if([filename.pathExtension isEqualToString:@"coredataeditor5"]) {
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:[NSURL fileURLWithPath:filename] display:YES completionHandler:^(NSDocument * _Nullable document, BOOL documentWasAlreadyOpen, NSError * _Nullable error) {

Expand All @@ -169,8 +116,6 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
if(buildProductsDirectory == nil) {
NSLog(@"no build products directory.");
assert(false);
#pragma mark warn bla
// [self.preferencesWindowController showAutomaticProjectCreationPreferencesAndDisplayInfoSheetWithCompletionHandler:nil];
return YES;
}

Expand Down Expand Up @@ -211,17 +156,9 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
// We have found something!
NSLog(@"%@ is compatible with %@", storeURL.lastPathComponent, modelURL);
CDEDocument *document = [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:NO error:NULL];
CDEConfiguration *c = [document createConfiguration];
error = nil;
BOOL set = [c setBookmarkDataWithApplicationBundleURL:nil storeURL:storeURL modelURL:modelURL error:&error];
if(!set) {
NSLog(@"error: %@", error);
}
CDEConfiguration *configuration = [document createConfiguration];
[configuration setApplicationBundleURL:nil storeURL:storeURL modelURL:modelURL];
error = nil;
BOOL setup = [document setupAndStartAccessingConfigurationRelatedURLsAndGetError:&error];
if(!setup) {
NSLog(@"error: %@", error);
}
[document makeWindowControllers];
[document showWindows];
return YES;
Expand Down
21 changes: 13 additions & 8 deletions Core Data Editor/Core Data Editor/CDEConfiguration.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#import "_CDEConfiguration.h"
@interface CDEConfiguration : NSObject

@interface CDEConfiguration : _CDEConfiguration

#pragma mark - Getting the only Configuration object
+ (CDEConfiguration *)fetchedConfigurationInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext error:(NSError **)error;
+ (BOOL)configurationExistsInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext error:(NSError **)error;
#pragma mark - Properties
@property (nullable, readonly) NSURL *storeURL, *modelURL, *applicationBundleURL;
@property (nullable, copy) NSString *applicationBundlePath;
@property (nullable, strong) NSDictionary *autosaveInformationByEntityName;
@property (nullable, copy) NSNumber *isMacApplication;
@property (nullable, copy) NSString *modelPath;
@property (nullable, copy) NSString *storePath;

#pragma mark - Properties
@property (nonatomic, readonly, getter = isValid) BOOL isValid;

#pragma mark - Setting Bookmark Data in Batch
- (BOOL)setBookmarkDataWithApplicationBundleURL:(NSURL *)applicationBundleURL storeURL:(NSURL *)storeURL modelURL:(NSURL *)modelURL error:(NSError **)error;
#pragma mark - Setting URLs
- (void)setApplicationBundleURL:(nullable NSURL *)applicationBundleURL storeURL:(nullable NSURL *)storeURL modelURL:(nullable NSURL *)modelURL;

- (NSData * _Nonnull )data;
- (nullable instancetype)initWithData:(NSData * _Nullable )data;

@end
Loading

0 comments on commit 81027e0

Please sign in to comment.