aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-22 05:08:12 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-22 05:08:12 +0000
commit7c0e19ddea57a362e9ec6bbc22a2b57b97a758f4 (patch)
tree2131eb270ad7f4e0fe582b4a57b7dce451ce4686 /Source
parent55fb563d473c25c0ea917898001b7ab4c4e09633 (diff)
downloadsequelpro-7c0e19ddea57a362e9ec6bbc22a2b57b97a758f4.tar.gz
sequelpro-7c0e19ddea57a362e9ec6bbc22a2b57b97a758f4.tar.bz2
sequelpro-7c0e19ddea57a362e9ec6bbc22a2b57b97a758f4.zip
• implemented undeletion of default Bundles
• made usage of constants
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m22
-rw-r--r--Source/SPBundleEditorController.h7
-rw-r--r--Source/SPBundleEditorController.m84
-rw-r--r--Source/SPConstants.h2
-rw-r--r--Source/SPConstants.m2
5 files changed, 102 insertions, 15 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index cbadfb85..268b7d14 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -1356,13 +1356,13 @@
NSArray *deletedDefaultBundles;
NSMutableArray *updatedDefaultBundles = [NSMutableArray array];
- if([[NSUserDefaults standardUserDefaults] objectForKey:@"deletedDefaultBundles"]) {
- deletedDefaultBundles = [[[NSUserDefaults standardUserDefaults] objectForKey:@"deletedDefaultBundles"] retain];
+ if([[NSUserDefaults standardUserDefaults] objectForKey:SPBundleDeletedDefaultBundlesKey]) {
+ deletedDefaultBundles = [[[NSUserDefaults standardUserDefaults] objectForKey:SPBundleDeletedDefaultBundlesKey] retain];
} else {
deletedDefaultBundles = [[NSArray array] retain];
}
- if([[NSUserDefaults standardUserDefaults] objectForKey:@"updatedDefaultBundles"]) {
- [updatedDefaultBundles setArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"updatedDefaultBundles"]];
+ if([[NSUserDefaults standardUserDefaults] objectForKey:SPBundleUpdatedDefaultBundlesKey]) {
+ [updatedDefaultBundles setArray:[[NSUserDefaults standardUserDefaults] objectForKey:SPBundleUpdatedDefaultBundlesKey]];
}
NSMutableString *infoAboutUpdatedDefaultBundles = [NSMutableString string];
@@ -1406,8 +1406,16 @@
if(processDefaultBundles) {
// Skip deleted default Bundles
- if([deletedDefaultBundles containsObject:[cmdData objectForKey:SPBundleFileUUIDKey]])
- continue;
+ BOOL bundleWasDeleted = NO;
+ if([deletedDefaultBundles count]) {
+ for(NSArray* item in deletedDefaultBundles) {
+ if([[item objectAtIndex:0] isEqualToString:[cmdData objectForKey:SPBundleFileUUIDKey]]) {
+ bundleWasDeleted = YES;
+ break;
+ }
+ }
+ }
+ if(bundleWasDeleted) continue;
// If default Bundle is already install check for possible update,
// if so duplicate the modified one by appending (user) and updated it
@@ -1618,7 +1626,7 @@
[deletedDefaultBundles release];
// Synchronize updated Bundles
- [[NSUserDefaults standardUserDefaults] setObject:updatedDefaultBundles forKey:@"updatedDefaultBundles"];
+ [[NSUserDefaults standardUserDefaults] setObject:updatedDefaultBundles forKey:SPBundleUpdatedDefaultBundlesKey];
// Inform user about default Bundle updates which were modified by the user and re-run Reload Bundles
if([infoAboutUpdatedDefaultBundles length]) {
diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h
index d586e5bc..ac4c9e6b 100644
--- a/Source/SPBundleEditorController.h
+++ b/Source/SPBundleEditorController.h
@@ -65,6 +65,9 @@
IBOutlet NSScrollView *commandScrollView;
IBOutlet NSScrollView *descriptionScrollView;
+ IBOutlet id undeleteSheet;
+ IBOutlet NSTableView *undeleteTableView;
+
IBOutlet NSTreeController *commandBundleTreeController;
NSMutableArray *touchedBundleArray;
NSMutableDictionary *commandBundleTree;
@@ -108,6 +111,8 @@
NSArray *shellVariableSuggestions;
+ NSMutableArray *deletedDefaultBundles;
+
}
- (IBAction)inputPopupButtonChanged:(id)sender;
@@ -126,6 +131,8 @@
- (IBAction)reloadBundles:(id)sender;
- (IBAction)metaButtonChanged:(id)sender;
- (IBAction)performClose:(id)sender;
+- (IBAction)undeleteDefaultBundles:(id)sender;
+- (IBAction)closeUndeleteDefaultBundlesSheet:(id)sender;
- (BOOL)saveBundle:(NSDictionary*)bundle atPath:(NSString*)aPath;
- (BOOL)cancelRowEditing;
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 785618d2..f3d41dff 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -62,6 +62,7 @@
draggedFilePath = nil;
oldBundleName = nil;
isTableCellEditing = NO;
+ deletedDefaultBundles = [[NSMutableArray alloc] initWithCapacity:1];
}
return self;
@@ -96,6 +97,7 @@
[withBlobDataTableArray release];
[shellVariableSuggestions release];
+ [deletedDefaultBundles release];
if(touchedBundleArray) [touchedBundleArray release], touchedBundleArray = nil;
if(commandBundleTree) [commandBundleTree release], commandBundleTree = nil;
@@ -350,6 +352,10 @@
nil
] retain];
+ if([[NSUserDefaults standardUserDefaults] objectForKey:SPBundleDeletedDefaultBundlesKey]) {
+ [deletedDefaultBundles setArray:[[NSUserDefaults standardUserDefaults] objectForKey:SPBundleDeletedDefaultBundlesKey]];
+ }
+
[self _initTree];
}
@@ -800,6 +806,27 @@
[self close];
}
+- (IBAction)undeleteDefaultBundles:(id)sender
+{
+ [NSApp beginSheet:undeleteSheet
+ modalForWindow:[self window]
+ modalDelegate:self
+ didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
+ contextInfo:@"undeleteSelectedDefaultBundles"];
+}
+
+- (IBAction)closeUndeleteDefaultBundlesSheet:(id)sender
+{
+
+ [NSApp endSheet:[sender window] returnCode:[sender tag]];
+
+ if ([sender respondsToSelector:@selector(orderOut:)])
+ [sender orderOut:nil];
+ else if ([sender respondsToSelector:@selector(window)])
+ [[sender window] orderOut:nil];
+
+}
+
/**
* Save all touched bundles to disk and close the Bundle Editor window
*/
@@ -989,12 +1016,8 @@
break;
}
if([obj objectForKey:SPBundleFileIsDefaultBundleKey]) {
- NSMutableArray *deletedBundles = [NSMutableArray array];
- [deletedBundles setArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"deletedDefaultBundles"]];
- if(![deletedBundles containsObject:[obj objectForKey:SPBundleFileUUIDKey]]) {
- [deletedBundles addObject:[obj objectForKey:SPBundleFileUUIDKey]];
- [[NSUserDefaults standardUserDefaults] setObject:deletedBundles forKey:@"deletedDefaultBundles"];
- }
+ [deletedDefaultBundles addObject:[NSArray arrayWithObjects:[obj objectForKey:SPBundleFileUUIDKey], [obj objectForKey:SPBundleFileNameKey], nil]];
+ [[NSUserDefaults standardUserDefaults] setObject:deletedDefaultBundles forKey:SPBundleDeletedDefaultBundlesKey];
}
[commandsOutlineView reloadData];
}
@@ -1014,7 +1037,8 @@
[addButton setEnabled:([[commandBundleTreeController selectionIndexPath] length] > 1)];
}
- } else if([contextInfo isEqualToString:@"saveBundle"]) {
+ }
+ else if([contextInfo isEqualToString:@"saveBundle"]) {
if (returnCode == NSOKButton) {
id aBundle = [self _currentSelectedObject];
@@ -1045,6 +1069,28 @@
}
}
}
+ else if([contextInfo isEqualToString:@"undeleteSelectedDefaultBundles"]) {
+ if(returnCode == 1) {
+
+ NSIndexSet *selectedRows = [undeleteTableView selectedRowIndexes];
+
+ if(![selectedRows count]) return;
+
+ NSInteger rowIndex;
+ NSMutableArray *stillUndeletedBundles = [NSMutableArray array];
+ for(rowIndex = 0; rowIndex < [deletedDefaultBundles count]; rowIndex++) {
+ if(![selectedRows containsIndex:rowIndex])
+ [stillUndeletedBundles addObject:[deletedDefaultBundles objectAtIndex:rowIndex]];
+ }
+ [deletedDefaultBundles setArray:stillUndeletedBundles];
+ [undeleteTableView reloadData];
+ [[NSUserDefaults standardUserDefaults] setObject:stillUndeletedBundles forKey:SPBundleDeletedDefaultBundlesKey];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ [[NSApp delegate] reloadBundles:nil];
+ [self reloadBundles:self];
+
+ }
+ }
}
@@ -1132,6 +1178,24 @@
}
#pragma mark -
+#pragma mark TableView delegates
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
+{
+ return [deletedDefaultBundles count];
+}
+
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ return [[deletedDefaultBundles objectAtIndex:rowIndex] objectAtIndex:1];
+}
+
+- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ return NO;
+}
+
+#pragma mark -
#pragma mark outline delegates
- (BOOL)outlineView:(id)outlineView isItemExpandable:(id)item
@@ -1286,7 +1350,7 @@
}
#pragma mark -
-#pragma mark TableView delegate
+#pragma mark TableView (outline) delegate
/**
* Traps enter and esc and edit/cancel without entering next row
@@ -1422,6 +1486,10 @@
return ([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey]);
}
+ if ( action == @selector(undeleteDefaultBundles:) ) {
+ return ([deletedDefaultBundles count]) ? YES : NO;
+ }
+
return YES;
}
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 92aa0786..33b7b3a5 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -374,6 +374,8 @@ extern NSString *SPUniqueSchemaDelimiter;
extern NSString *SPLastImportIntoNewTableEncoding;
extern NSString *SPLastImportIntoNewTableType;
extern NSString *SPGlobalValueHistory;
+extern NSString *SPBundleDeletedDefaultBundlesKey;
+extern NSString *SPBundleUpdatedDefaultBundlesKey;
// URLs
extern NSString *SPDonationsURL;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 4d7c8850..ae803424 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -186,6 +186,8 @@ NSString *SPUniqueSchemaDelimiter = @"￸"; // U+FFF8
NSString *SPLastImportIntoNewTableEncoding = @"LastImportIntoNewTableEncoding";
NSString *SPLastImportIntoNewTableType = @"LastImportIntoNewTableType";
NSString *SPGlobalValueHistory = @"GlobalValueHistory";
+NSString *SPBundleDeletedDefaultBundlesKey = @"deletedDefaultBundles";
+NSString *SPBundleUpdatedDefaultBundlesKey = @"updatedDefaultBundles";
// URLs
NSString *SPDonationsURL = @"http://www.sequelpro.com/donate.html";