From 7c0e19ddea57a362e9ec6bbc22a2b57b97a758f4 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 22 Dec 2010 05:08:12 +0000 Subject: =?UTF-8?q?=E2=80=A2=20implemented=20undeletion=20of=20default=20B?= =?UTF-8?q?undles=20=E2=80=A2=20made=20usage=20of=20constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/BundleEditor.xib | 485 +++++++++++++++++++++++++++++- Source/SPAppController.m | 22 +- Source/SPBundleEditorController.h | 7 + Source/SPBundleEditorController.m | 84 +++++- Source/SPConstants.h | 2 + Source/SPConstants.m | 2 + 6 files changed, 581 insertions(+), 21 deletions(-) diff --git a/Interfaces/English.lproj/BundleEditor.xib b/Interfaces/English.lproj/BundleEditor.xib index 25be786e..0997b4f8 100644 --- a/Interfaces/English.lproj/BundleEditor.xib +++ b/Interfaces/English.lproj/BundleEditor.xib @@ -117,7 +117,7 @@ 3 MC4zMzMzMzI5ODU2AA - + 6 System headerTextColor @@ -166,7 +166,7 @@ MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA - + 6 System gridColor @@ -371,6 +371,16 @@ _popUpItemAction: + + + Undelete Default Bundles… + + 2147483647 + + + _popUpItemAction: + + Reload Bundles without Saving @@ -1491,6 +1501,219 @@ + + 27 + 2 + {{140, 260}, {341, 198}} + 611844096 + Window + NSPanel + + {3.40282e+38, 3.40282e+38} + {341, 198} + + + 256 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 256 + {341, 121} + + + YES + + + 256 + {341, 17} + + + + + + + -2147483392 + {{224, 0}, {16, 17}} + + + + + YES + + 338 + 40 + 1000 + + 75628096 + 2048 + + + + 3 + MC4zMzMzMzI5ODU2AA + + + + + 337772096 + 2048 + Text Cell + + + + + + 3 + YES + YES + + + + 3 + 2 + + 6 + System + _sourceListBackgroundColor + + 1 + MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA + + + + 17 + 1111490560 + + + 4 + 15 + 0 + YES + 1 + 1 + + + {{1, 17}, {341, 121}} + + + + + + 4 + + + + -2147483392 + {{224, 17}, {15, 102}} + + + + _doScroller: + 0.99180328845977783 + + + + -2147483392 + {{1, 119}, {223, 15}} + + + 1 + + _doScroller: + 0.99707603454589844 + + + + 2304 + + YES + + + {{1, 0}, {341, 17}} + + + + + + 4 + + + + {{-1, 60}, {343, 139}} + + + + 562 + + + + + + QSAAAEEgAABBmAAAQZgAAA + + + + 289 + {{213, 12}, {114, 32}} + + + 1 + YES + + 67239424 + 134217728 + Undelete + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + + 289 + {{99, 12}, {114, 32}} + + + YES + + 67239424 + 134217728 + Close + + + -2038284033 + 129 + + Gw + 200 + 25 + + + + {341, 198} + + + + {{0, 0}, {1280, 778}} + {341, 214} + {3.40282e+38, 3.40282e+38} + YES @@ -2281,6 +2504,78 @@ 1098 + + + undeleteDefaultBundles: + + + + 1100 + + + + undeleteTableView + + + + 1116 + + + + dataSource + + + + 1119 + + + + delegate + + + + 1120 + + + + undeleteSheet + + + + 1123 + + + + closeUndeleteDefaultBundlesSheet: + + + + 1124 + + + + closeUndeleteDefaultBundlesSheet: + + + + 1125 + + + + delegate + + + + 1126 + + + + initialFirstResponder + + + + 1127 + @@ -2417,6 +2712,7 @@ + @@ -3134,6 +3430,110 @@ + + 1099 + + + + + 1101 + + + YES + + + + Undelete Default Bundles Sheet + + + 1102 + + + YES + + + + + + + + 1103 + + + YES + + + + + + + + + 1104 + + + + + 1105 + + + + + 1106 + + + YES + + + + + + 1108 + + + YES + + + + + + 1111 + + + + + 1112 + + + YES + + + + + + 1113 + + + + + 1114 + + + YES + + + + + + 1115 + + + + + 1118 + + + @@ -3176,6 +3576,25 @@ 1092.IBPluginDependency 1093.IBEditorWindowLastContentRect 1093.IBPluginDependency + 1099.IBPluginDependency + 1101.IBEditorWindowLastContentRect + 1101.IBPluginDependency + 1101.IBWindowTemplateEditedContentRect + 1101.NSWindowTemplate.visibleAtLaunch + 1101.windowTemplate.hasMinSize + 1101.windowTemplate.minSize + 1102.IBPluginDependency + 1103.IBPluginDependency + 1104.IBPluginDependency + 1105.IBPluginDependency + 1106.IBPluginDependency + 1108.IBPluginDependency + 1111.IBPluginDependency + 1112.IBAttributePlaceholdersKey + 1112.IBPluginDependency + 1113.IBPluginDependency + 1114.IBPluginDependency + 1115.IBPluginDependency 521.IBEditorWindowLastContentRect 521.IBPluginDependency 521.IBWindowTemplateEditedContentRect @@ -3358,9 +3777,35 @@ com.apple.InterfaceBuilder.CocoaPlugin {{430, 598}, {167, 4}} com.apple.InterfaceBuilder.CocoaPlugin - {{172, 298}, {691, 444}} com.apple.InterfaceBuilder.CocoaPlugin - {{172, 298}, {691, 444}} + {{175, 541}, {341, 198}} + com.apple.InterfaceBuilder.CocoaPlugin + {{175, 541}, {341, 198}} + + + {341, 198} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Undelete selected default Bundles (↩) + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{149, 231}, {691, 444}} + com.apple.InterfaceBuilder.CocoaPlugin + {{149, 231}, {691, 444}} {691, 444} @@ -3433,7 +3878,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit - {{222, 223}, {243, 98}} + {{199, 139}, {243, 115}} com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit com.apple.InterfaceBuilder.CocoaPlugin @@ -3602,7 +4047,7 @@ - 1098 + 1127 @@ -3747,6 +4192,7 @@ YES addCommandBundle: + closeUndeleteDefaultBundlesSheet: duplicateCommandBundle: inputFallbackPopupButtonChanged: inputPopupButtonChanged: @@ -3761,6 +4207,7 @@ scopeButtonChanged: showHelp: triggerButtonChanged: + undeleteDefaultBundles: withBlobButtonChanged: @@ -3781,6 +4228,8 @@ id id id + id + id @@ -3788,6 +4237,7 @@ YES addCommandBundle: + closeUndeleteDefaultBundlesSheet: duplicateCommandBundle: inputFallbackPopupButtonChanged: inputPopupButtonChanged: @@ -3802,6 +4252,7 @@ scopeButtonChanged: showHelp: triggerButtonChanged: + undeleteDefaultBundles: withBlobButtonChanged: @@ -3810,6 +4261,10 @@ addCommandBundle: id + + closeUndeleteDefaultBundlesSheet: + id + duplicateCommandBundle: id @@ -3866,6 +4321,10 @@ triggerButtonChanged: id + + undeleteDefaultBundles: + id + withBlobButtonChanged: id @@ -3908,6 +4367,8 @@ showHideMetaButton tooltipTextField triggerPopupButton + undeleteSheet + undeleteTableView withBlobLabelField withBlobPopupButton @@ -3945,6 +4406,8 @@ NSButton NSTextField NSPopUpButton + id + NSTableView NSTextField NSPopUpButton @@ -3985,6 +4448,8 @@ showHideMetaButton tooltipTextField triggerPopupButton + undeleteSheet + undeleteTableView withBlobLabelField withBlobPopupButton @@ -4118,6 +4583,14 @@ triggerPopupButton NSPopUpButton + + undeleteSheet + id + + + undeleteTableView + NSTableView + withBlobLabelField NSTextField 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]; + + } + } } @@ -1131,6 +1177,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 @@ -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"; -- cgit v1.2.3