From 36c3c224a32275bd80f76955b54f8057a7ccda21 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 24 Nov 2010 07:55:17 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Bundle=20Editor=20-=20hide=20Bundles=20main?= =?UTF-8?q?=20menu=20since=20the=20Bundle=20table=20view=20will=20be=20ref?= =?UTF-8?q?ractored=20completely=20to=20OutlineView=20-=20fixed=20validati?= =?UTF-8?q?on=20of=20RemoveButton=20(thanks=20to=20avenjamin)=20-=20fixed?= =?UTF-8?q?=20storing=20the=20very=20first=20Bundle=20command=20-=20added?= =?UTF-8?q?=20Reload=20Bundles=20to=20Gear=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPBundleEditorController.m | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'Source/SPBundleEditorController.m') diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 80707d4d..11c8ad87 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -83,6 +83,8 @@ - (void)awakeFromNib { + commandBundleArray = [[NSMutableArray alloc] initWithCapacity:1]; + // Init all needed menus inputGeneralScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""]; inputInputFieldScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""]; @@ -316,7 +318,6 @@ { NSMutableDictionary *bundle; NSUInteger insertIndex; - BOOL wasDuplicated = NO; // Store pending changes in Query [[self window] makeFirstResponder:nameTextField]; @@ -363,7 +364,6 @@ return; } - wasDuplicated = YES; [bundle setObject:newFileName forKey:@"bundleName"]; } @@ -389,10 +389,11 @@ [commandsTableView scrollRowToVisible:[commandsTableView selectedRow]]; [removeButton setEnabled:([commandsTableView numberOfSelectedRows] > 0)]; + + [self _updateInputPopupButton]; + [[self window] makeFirstResponder:commandsTableView]; - [self scopeButtonChanged:nil]; - if(!wasDuplicated && [commandsTableView numberOfSelectedRows] > 0) - [commandsTableView editColumn:0 row:insertIndex withEvent:nil select:YES]; + } - (IBAction)removeCommandBundle:(id)sender @@ -445,11 +446,16 @@ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:NSLocalizedString(@"http://www.sequelpro.com/docs/Bundle_Editor", @"Localized help page for bundle editor - do not localize if no translated webpage is available")]]; } +- (IBAction)reloadBundles:(id)sender +{ + [self showWindow:self]; +} + - (IBAction)showWindow:(id)sender { // Suppress parsing if window is already opened - if([[self window] isVisible]) { + if(sender != self && [[self window] isVisible]) { [super showWindow:sender]; return; } @@ -460,8 +466,8 @@ [super showWindow:sender]; // Re-init commandBundleArray - if(commandBundleArray) [commandBundleArray release], commandBundleArray = nil; - commandBundleArray = [[NSMutableArray alloc] init]; + [commandBundleArray removeAllObjects]; + [commandsTableView reloadData]; // Load all installed bundle items if(bundlePath) { @@ -501,6 +507,8 @@ } } + [removeButton setEnabled:([commandsTableView numberOfSelectedRows] > 0)]; + [commandBundleArrayController setContent:commandBundleArray]; [commandBundleArrayController rearrangeObjects]; [commandsTableView reloadData]; @@ -561,6 +569,8 @@ if(![bundle objectForKey:@"bundleName"] || ![[bundle objectForKey:@"bundleName"] length]) { return NO; } + if(!bundlePath) + bundlePath = [[[NSFileManager defaultManager] applicationSupportDirectoryForSubDirectory:SPBundleSupportFolder createIfNotExists:YES error:nil] retain]; aPath = [NSString stringWithFormat:@"%@/%@.%@", bundlePath, [bundle objectForKey:@"bundleName"], SPUserBundleFileExtension]; } @@ -703,8 +713,9 @@ - (void)windowWillClose:(NSNotification *)notification { - // Release commandBundleArray if window will close to save memory - if(commandBundleArray) [commandBundleArray release], commandBundleArray = nil; + // Clear commandBundleArray if window will close to save memory + [commandBundleArray removeAllObjects]; + [commandsTableView reloadData]; // Remove temporary drag file if any if(draggedFilePath) { @@ -771,11 +782,15 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { + if(![commandBundleArray count]) return @""; + if([[aTableColumn identifier] isEqualToString:@"name"]) { if(![[commandBundleArray objectAtIndex:rowIndex] objectForKey:@"name"]) return @"..."; return [[commandBundleArray objectAtIndex:rowIndex] objectForKey:@"bundleName"]; } + return @""; + } - (void)tableViewSelectionDidChange:(NSNotification *)aNotification -- cgit v1.2.3