aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-18 13:48:46 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-18 13:48:46 +0000
commit7449035e027814b807764d59ecd2428dbb43319d (patch)
treedf7f10183d36b2d6138ffc44a85e5e96aec4f370
parent94e6cbd84b96af04b0b3f7eec4b67b2b99cf62ad (diff)
downloadsequelpro-7449035e027814b807764d59ecd2428dbb43319d.tar.gz
sequelpro-7449035e027814b807764d59ecd2428dbb43319d.tar.bz2
sequelpro-7449035e027814b807764d59ecd2428dbb43319d.zip
• Bundle Editor
- input, input fallback, output implemented plus validation
-rw-r--r--Interfaces/English.lproj/BundleEditor.xib73
-rw-r--r--Source/SPBundleEditorController.h25
-rw-r--r--Source/SPBundleEditorController.m361
-rw-r--r--Source/SPConstants.h1
-rw-r--r--Source/SPConstants.m1
5 files changed, 440 insertions, 21 deletions
diff --git a/Interfaces/English.lproj/BundleEditor.xib b/Interfaces/English.lproj/BundleEditor.xib
index 27e1f812..5b9c62a3 100644
--- a/Interfaces/English.lproj/BundleEditor.xib
+++ b/Interfaces/English.lproj/BundleEditor.xib
@@ -23,8 +23,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="899"/>
- <integer value="730"/>
+ <integer value="686"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -949,6 +948,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{16, 11}, {134, 17}}</string>
<reference key="NSSuperview" ref="346382683"/>
+ <int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="176613618">
<int key="NSCellFlags">67239424</int>
@@ -973,6 +973,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{158, 11}, {134, 17}}</string>
<reference key="NSSuperview" ref="346382683"/>
+ <int key="NSTag">2</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="32494124">
<int key="NSCellFlags">67239424</int>
@@ -993,6 +994,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{300, 11}, {134, 17}}</string>
<reference key="NSSuperview" ref="346382683"/>
+ <int key="NSTag">4</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="670066090">
<int key="NSCellFlags">67239424</int>
@@ -1336,14 +1338,6 @@
<int key="connectionID">841</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">inputPopuButtonChanged:</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="117047836"/>
- </object>
- <int key="connectionID">845</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="965862131"/>
@@ -1691,6 +1685,46 @@
</object>
<int key="connectionID">910</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">inputPopupButtonChanged:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="117047836"/>
+ </object>
+ <int key="connectionID">911</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">scopeButtonChanged:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="799580933"/>
+ </object>
+ <int key="connectionID">912</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">scopeButtonChanged:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="126436931"/>
+ </object>
+ <int key="connectionID">913</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">scopeButtonChanged:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="594438970"/>
+ </object>
+ <int key="connectionID">914</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">inputFallbackPopupButtonChanged:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="1013555552"/>
+ </object>
+ <int key="connectionID">916</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2421,9 +2455,9 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{96, 115}, {655, 444}}</string>
+ <string>{{106, 275}, {655, 444}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{96, 115}, {655, 444}}</string>
+ <string>{{106, 275}, {655, 444}}</string>
<boolean value="NO"/>
<boolean value="YES"/>
<string>{726, 444}</string>
@@ -2580,7 +2614,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">910</int>
+ <int key="maxID">916</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2723,7 +2757,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>addCommandBundle:</string>
<string>duplicateCommandBundle:</string>
- <string>inputPopuButtonChanged:</string>
+ <string>inputFallbackPopupButtonChanged:</string>
+ <string>inputPopupButtonChanged:</string>
<string>removeCommandBundle:</string>
<string>revealCommandBundleInFinder:</string>
<string>saveAndCloseWindow:</string>
@@ -2740,6 +2775,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -2748,7 +2784,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>addCommandBundle:</string>
<string>duplicateCommandBundle:</string>
- <string>inputPopuButtonChanged:</string>
+ <string>inputFallbackPopupButtonChanged:</string>
+ <string>inputPopupButtonChanged:</string>
<string>removeCommandBundle:</string>
<string>revealCommandBundleInFinder:</string>
<string>saveAndCloseWindow:</string>
@@ -2766,7 +2803,11 @@
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
- <string key="name">inputPopuButtonChanged:</string>
+ <string key="name">inputFallbackPopupButtonChanged:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">inputPopupButtonChanged:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h
index c313668a..35a11ed6 100644
--- a/Source/SPBundleEditorController.h
+++ b/Source/SPBundleEditorController.h
@@ -54,9 +54,32 @@
NSString *oldBundleName;
BOOL isTableCellEditing;
+ NSMenu *inputEditorScopePopUpMenu;
+ NSMenu *inputInputFieldScopePopUpMenu;
+ NSMenu *inputDataTableScopePopUpMenu;
+ NSMenu *inputNonePopUpMenu;
+ NSMenu *outputEditorScopePopUpMenu;
+ NSMenu *outputInputFieldScopePopUpMenu;
+ NSMenu *outputDataTableScopePopUpMenu;
+ NSMenu *inputFallbackEditorScopePopUpMenu;
+ NSMenu *inputFallbackInputFieldScopePopUpMenu;
+
+ NSArray *inputEditorScopeArray;
+ NSArray *inputInputFieldScopeArray;
+ NSArray *inputDataTableScopeArray;
+ NSArray *outputEditorScopeArray;
+ NSArray *outputInputFieldScopeArray;
+ NSArray *outputDataTableScopeArray;
+ NSArray *inputFallbackEditorScopeArray;
+ NSArray *inputFallbackInputFieldScopeArray;
+
+
}
-- (IBAction)inputPopuButtonChanged:(id)sender;
+- (IBAction)inputPopupButtonChanged:(id)sender;
+- (IBAction)inputFallbackPopupButtonChanged:(id)sender;
+- (IBAction)outputPopupButtonChanged:(id)sender;
+- (IBAction)scopeButtonChanged:(id)sender;
- (IBAction)duplicateCommandBundle:(id)sender;
- (IBAction)addCommandBundle:(id)sender;
- (IBAction)removeCommandBundle:(id)sender;
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 15b2028a..b7e31aee 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -24,6 +24,11 @@
#import "SPBundleEditorController.h"
+@interface SPBundleEditorController (PrivateAPI)
+
+- (void)_updateInputPopupButton;
+
+@end
@implementation SPBundleEditorController
@@ -47,17 +52,256 @@
- (void)dealloc
{
+
+ [inputEditorScopePopUpMenu release];
+ [inputInputFieldScopePopUpMenu release];
+ [inputDataTableScopePopUpMenu release];
+ [outputEditorScopePopUpMenu release];
+ [outputInputFieldScopePopUpMenu release];
+ [outputDataTableScopePopUpMenu release];
+ [inputFallbackEditorScopePopUpMenu release];
+ [inputFallbackInputFieldScopePopUpMenu release];
+ [inputNonePopUpMenu release];
+
+ [inputEditorScopeArray release];
+ [inputInputFieldScopeArray release];
+ [inputDataTableScopeArray release];
+ [outputEditorScopeArray release];
+ [outputInputFieldScopeArray release];
+ [outputDataTableScopeArray release];
+ [inputFallbackEditorScopeArray release];
+ [inputFallbackInputFieldScopeArray release];
+
if(commandBundleArray) [commandBundleArray release], commandBundleArray = nil;
if(bundlePath) [bundlePath release], bundlePath = nil;
+
[super dealloc];
+
+}
+
+- (void)awakeFromNib
+{
+
+ inputEditorScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ inputInputFieldScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ inputDataTableScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ inputNonePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ outputEditorScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ outputInputFieldScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ outputDataTableScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ inputFallbackEditorScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+ inputFallbackInputFieldScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
+
+ inputEditorScopeArray = [[NSArray arrayWithObjects:SPBundleInputSourceNone, SPBundleInputSourceSelectedText, SPBundleInputSourceEntireContent, nil] retain];
+ inputInputFieldScopeArray = [[NSArray arrayWithObjects:SPBundleInputSourceNone, SPBundleInputSourceSelectedText, SPBundleInputSourceEntireContent, nil] retain];
+ inputDataTableScopeArray = [[NSArray arrayWithObjects:SPBundleInputSourceNone, SPBundleInputSourceSelectedTableRowsAsTab, SPBundleInputSourceSelectedTableRowsAsCsv, SPBundleInputSourceSelectedTableRowsAsSqlInsert, SPBundleInputSourceTableRowsAsTab, SPBundleInputSourceTableRowsAsCsv, SPBundleInputSourceTableRowsAsSqlInsert, nil] retain];
+ outputEditorScopeArray = [[NSArray arrayWithObjects:SPBundleOutputActionNone, SPBundleOutputActionInsertAsText, SPBundleOutputActionInsertAsSnippet, SPBundleOutputActionReplaceSelection, SPBundleOutputActionReplaceContent, SPBundleOutputActionShowAsTextTooltip, SPBundleOutputActionShowAsHTMLTooltip, nil] retain];
+ outputInputFieldScopeArray = [[NSArray arrayWithObjects:SPBundleOutputActionNone, SPBundleOutputActionInsertAsText, SPBundleOutputActionReplaceSelection, SPBundleOutputActionReplaceContent, SPBundleOutputActionShowAsTextTooltip, SPBundleOutputActionShowAsHTMLTooltip, nil] retain];
+ outputDataTableScopeArray = [[NSArray arrayWithObjects:SPBundleOutputActionNone, SPBundleOutputActionShowAsTextTooltip, SPBundleOutputActionShowAsHTMLTooltip, nil] retain];
+ inputFallbackEditorScopeArray = [[NSArray arrayWithObjects:SPBundleInputSourceNone, SPBundleInputSourceCurrentWord, SPBundleInputSourceCurrentLine, SPBundleInputSourceCurrentQuery, SPBundleInputSourceEntireContent, nil] retain];
+ inputFallbackInputFieldScopeArray = [[NSArray arrayWithObjects:SPBundleInputSourceNone, SPBundleInputSourceCurrentWord, SPBundleInputSourceCurrentLine, SPBundleInputSourceEntireContent, nil] retain];
+
+ NSMutableArray *allPopupScopeItems = [NSMutableArray array];
+ [allPopupScopeItems addObjectsFromArray:inputEditorScopeArray];
+ [allPopupScopeItems addObjectsFromArray:inputInputFieldScopeArray];
+ [allPopupScopeItems addObjectsFromArray:inputDataTableScopeArray];
+ [allPopupScopeItems addObjectsFromArray:outputEditorScopeArray];
+ [allPopupScopeItems addObjectsFromArray:outputInputFieldScopeArray];
+ [allPopupScopeItems addObjectsFromArray:outputDataTableScopeArray];
+ [allPopupScopeItems addObjectsFromArray:inputFallbackEditorScopeArray];
+ [allPopupScopeItems addObjectsFromArray:inputFallbackInputFieldScopeArray];
+
+ NSDictionary *menuItemTitles = [NSDictionary dictionaryWithObjects:
+ [NSArray arrayWithObjects:
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Selected Text", @"selected text menu item label"),
+ NSLocalizedString(@"Entire Content", @"entire content menu item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Selected Text", @"selected text menu item label"),
+ NSLocalizedString(@"Entire Content", @"entire content menu item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Selected Rows (TSV)", @"selected rows (TSV) menu item label"),
+ NSLocalizedString(@"Selected Rows (CSV)", @"selected rows (CSV) menu item label"),
+ NSLocalizedString(@"Selected Rows (SQL)", @"selected rows (SQL) menu item label"),
+ NSLocalizedString(@"Table Content (TSV)", @"table content (TSV) menu item label"),
+ NSLocalizedString(@"Table Content (CSV)", @"table content (CSV) menu item label"),
+ NSLocalizedString(@"Table Content (SQL)", @"table content (SQL) menu item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Insert as Text", @"insert as text item label"),
+ NSLocalizedString(@"Insert as Snippet", @"insert as snippet item label"),
+ NSLocalizedString(@"Replace Selection", @"replace selection item label"),
+ NSLocalizedString(@"Replace Entire Content", @"replace entire content item label"),
+ NSLocalizedString(@"Show as Text Tooltip", @"show as text tooltip item label"),
+ NSLocalizedString(@"Show as HTML Tooltip", @"show as html tooltip item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Insert as Text", @"insert as text item label"),
+ NSLocalizedString(@"Replace Selection", @"replace selection item label"),
+ NSLocalizedString(@"Replace Entire Content", @"replace entire content item label"),
+ NSLocalizedString(@"Show as Text Tooltip", @"show as text tooltip item label"),
+ NSLocalizedString(@"Show as HTML Tooltip", @"show as html tooltip item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Show as Text Tooltip", @"show as text tooltip item label"),
+ NSLocalizedString(@"Show as HTML Tooltip", @"show as html tooltip item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Current Word", @"current word item label"),
+ NSLocalizedString(@"Current Line", @"current line item label"),
+ NSLocalizedString(@"Current Query", @"current query item label"),
+ NSLocalizedString(@"Entire Content", @"entire content item label"),
+ NSLocalizedString(@"None", @"none menu item label"),
+ NSLocalizedString(@"Current Word", @"current word item label"),
+ NSLocalizedString(@"Current Line", @"current line item label"),
+ NSLocalizedString(@"Entire Content", @"entire content item label"),
+ nil]
+ forKeys:allPopupScopeItems];
+
+ NSMenuItem *anItem;
+ for(NSString* title in inputEditorScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(inputPopupButtonChanged:) keyEquivalent:@""];
+ [inputEditorScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in inputInputFieldScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(inputPopupButtonChanged:) keyEquivalent:@""];
+ [inputInputFieldScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in inputDataTableScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(inputPopupButtonChanged:) keyEquivalent:@""];
+ [inputDataTableScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in outputEditorScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(outputPopupButtonChanged:) keyEquivalent:@""];
+ [outputEditorScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in outputInputFieldScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(outputPopupButtonChanged:) keyEquivalent:@""];
+ [outputInputFieldScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in outputDataTableScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(outputPopupButtonChanged:) keyEquivalent:@""];
+ [outputDataTableScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in inputFallbackEditorScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(inputFallbackPopupButtonChanged:) keyEquivalent:@""];
+ [inputFallbackEditorScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ for(NSString* title in inputFallbackInputFieldScopeArray) {
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:title] action:@selector(inputFallbackPopupButtonChanged:) keyEquivalent:@""];
+ [inputFallbackInputFieldScopePopUpMenu addItem:anItem];
+ [anItem release];
+ }
+ anItem = [[NSMenuItem alloc] initWithTitle:[menuItemTitles objectForKey:SPBundleInputSourceNone] action:nil keyEquivalent:@""];
+ [inputNonePopUpMenu addItem:anItem];
+ [anItem release];
+
}
#pragma mark -
-- (IBAction)inputPopuButtonChanged:(id)sender
+- (IBAction)inputPopupButtonChanged:(id)sender
{
-
+
+ id currentDict = [commandBundleArray objectAtIndex:[commandsTableView selectedRow]];
+
+ NSMenu* senderMenu = [sender menu];
+
+ NSInteger selectedIndex = [senderMenu indexOfItem:sender];
+ NSString *input = SPBundleInputSourceNone;
+ if(senderMenu == inputEditorScopePopUpMenu)
+ input = [inputEditorScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == inputInputFieldScopePopUpMenu)
+ input = [inputInputFieldScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == inputDataTableScopePopUpMenu)
+ input = [inputDataTableScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == inputNonePopUpMenu)
+ input = SPBundleInputSourceNone;
+
+ [currentDict setObject:input forKey:SPBundleFileInputSourceKey];
+
+ [self _updateInputPopupButton];
+
+}
+
+- (IBAction)inputFallbackPopupButtonChanged:(id)sender
+{
+
+ id currentDict = [commandBundleArray objectAtIndex:[commandsTableView selectedRow]];
+
+ NSMenu* senderMenu = [sender menu];
+
+ NSInteger selectedIndex = [senderMenu indexOfItem:sender];
+ NSString *input = SPBundleInputSourceNone;
+ if(senderMenu == inputFallbackEditorScopePopUpMenu)
+ input = [inputFallbackEditorScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == inputFallbackInputFieldScopePopUpMenu)
+ input = [inputFallbackInputFieldScopeArray objectAtIndex:selectedIndex];
+
+ [currentDict setObject:input forKey:SPBundleFileInputSourceFallBackKey];
+
+}
+
+- (IBAction)outputPopupButtonChanged:(id)sender
+{
+
+ id currentDict = [commandBundleArray objectAtIndex:[commandsTableView selectedRow]];
+
+ NSMenu* senderMenu = [sender menu];
+
+ NSInteger selectedIndex = [senderMenu indexOfItem:sender];
+ NSString *output = SPBundleOutputActionNone;
+ if(senderMenu == outputEditorScopePopUpMenu)
+ output = [outputEditorScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == outputInputFieldScopePopUpMenu)
+ output = [outputInputFieldScopeArray objectAtIndex:selectedIndex];
+ else if(senderMenu == outputDataTableScopePopUpMenu)
+ output = [outputDataTableScopeArray objectAtIndex:selectedIndex];
+
+ [currentDict setObject:output forKey:SPBundleFileOutputActionKey];
+
+}
+
+- (IBAction)scopeButtonChanged:(id)sender
+{
+
+ id currentDict = [commandBundleArray objectAtIndex:[commandsTableView selectedRow]];
+ NSInteger inputMask = [[currentDict objectForKey:SPBundleScopeQueryEditor] intValue] * 1 +
+ [[currentDict objectForKey:SPBundleScopeInputField] intValue] * 2 +
+ [[currentDict objectForKey:SPBundleScopeDataTable] intValue] * 4;
+
+ if(inputMask < 1 || inputMask > 7) {
+ inputMask = 7;
+ NSNumber *on = [NSNumber numberWithInt:1];
+ [currentDict setObject:on forKey:SPBundleScopeQueryEditor];
+ [currentDict setObject:on forKey:SPBundleScopeInputField];
+ [currentDict setObject:on forKey:SPBundleScopeDataTable];
+ }
+
+ [currentDict setObject:[NSNumber numberWithInt:inputMask] forKey:@"inputMask"];
+
+ if(inputMask > 4) {
+ [currentDict setObject:SPBundleInputSourceNone forKey:SPBundleFileInputSourceKey];
+ [currentDict setObject:SPBundleInputSourceNone forKey:SPBundleFileInputSourceFallBackKey];
+ if(![[currentDict objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsTextTooltip]
+ && ![[currentDict objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTMLTooltip]) {
+ [currentDict setObject:SPBundleOutputActionNone forKey:SPBundleFileOutputActionKey];
+ }
+
+ }
+ if([[currentDict objectForKey:SPBundleFileInputSourceKey] isEqualToString:SPBundleInputSourceSelectedText]) {
+ if(inputMask > 1 && [[currentDict objectForKey:SPBundleFileInputSourceFallBackKey] isEqualToString:SPBundleInputSourceCurrentQuery])
+ [currentDict setObject:SPBundleInputSourceNone forKey:SPBundleFileInputSourceFallBackKey];
+ }
+ if((inputMask == 2 || inputMask == 3) && [[currentDict objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionInsertAsSnippet])
+ [currentDict setObject:SPBundleOutputActionInsertAsText forKey:SPBundleFileOutputActionKey];
+
+ [self _updateInputPopupButton];
+
}
- (IBAction)duplicateCommandBundle:(id)sender
@@ -182,12 +426,18 @@
[bundleCommand addEntriesFromDictionary:cmdData];
[bundleCommand setObject:[bundle stringByDeletingPathExtension] forKey:@"bundleName"];
+ NSInteger inputMask = 0;
+
+ // Handle stored scopes
NSArray *scopes = [[cmdData objectForKey:SPBundleFileScopeKey] componentsSeparatedByString:@" "];
for(NSString *scope in scopes) {
[bundleCommand setObject:[NSNumber numberWithInt:1] forKey:scope];
+ if([scope isEqualToString:SPBundleScopeQueryEditor]) inputMask += 1;
+ if([scope isEqualToString:SPBundleScopeInputField]) inputMask += 2;
+ if([scope isEqualToString:SPBundleScopeDataTable]) inputMask += 4;
+ [bundleCommand setObject:[NSNumber numberWithInt:inputMask] forKey:@"inputMask"];
}
-
[commandBundleArray addObject:bundleCommand];
}
if (cmdData) [cmdData release];
@@ -233,7 +483,7 @@
isDir = YES;
}
- // If aPath exists but it's not a folder bails
+ // If aPath exists but it's not a folder bail out
if(!isDir) return NO;
// The command.plist file path
@@ -261,6 +511,7 @@
// Remove unnecessary keys
[saveDict removeObjectsForKeys:[NSArray arrayWithObjects:
@"bundleName",
+ @"inputMask",
SPBundleScopeQueryEditor,
SPBundleScopeInputField,
SPBundleScopeDataTable,
@@ -286,6 +537,7 @@
if(isTableCellEditing) {
[commandsTableView abortEditing];
isTableCellEditing = NO;
+ [[self window] makeFirstResponder:commandsTableView];
return NO;
}
return YES;
@@ -340,6 +592,13 @@
return @"";
}
+- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
+{
+ if([aNotification object] != commandsTableView) return;
+
+ [self _updateInputPopupButton];
+}
+
/*
* Save spBundle name if inline edited (suppress empty names) and check for renaming and / in the name
*/
@@ -383,6 +642,9 @@
isTableCellEditing = NO;
}
+
+#pragma mark -
+
/**
* Sheet did end method
*/
@@ -507,3 +769,94 @@
}
@end
+
+@implementation SPBundleEditorController (PrivateAPI)
+
+- (void)_updateInputPopupButton
+{
+
+ NSInteger anIndex;
+
+ NSDictionary *currentDict = [commandBundleArray objectAtIndex:[commandsTableView selectedRow]];
+
+ NSString *input = [currentDict objectForKey:SPBundleFileInputSourceKey];
+ if(!input || ![input length]) input = SPBundleInputSourceNone;
+
+ NSString *inputfallback = [currentDict objectForKey:SPBundleFileInputSourceFallBackKey];
+ if(!inputfallback || ![inputfallback length]) inputfallback = SPBundleInputSourceNone;
+
+ NSString *output = [currentDict objectForKey:SPBundleFileOutputActionKey];
+ if(!output || ![output length]) output = SPBundleOutputActionNone;
+
+ NSInteger inputMask = [[currentDict objectForKey:@"inputMask"] intValue];
+ switch(inputMask) {
+ case 1:
+ [inputPopupButton setMenu:inputEditorScopePopUpMenu];
+ anIndex = [inputEditorScopeArray indexOfObject:input];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [inputPopupButton selectItemAtIndex:anIndex];
+ [inputFallbackPopupButton setMenu:inputFallbackEditorScopePopUpMenu];
+ anIndex = [inputFallbackEditorScopeArray indexOfObject:inputfallback];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [inputFallbackPopupButton selectItemAtIndex:anIndex];
+ [outputPopupButton setMenu:outputEditorScopePopUpMenu];
+ anIndex = [outputEditorScopeArray indexOfObject:output];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [outputPopupButton selectItemAtIndex:anIndex];
+ break;
+ case 2:
+ case 3:
+ [inputPopupButton setMenu:inputInputFieldScopePopUpMenu];
+ anIndex = [inputInputFieldScopeArray indexOfObject:input];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [inputPopupButton selectItemAtIndex:anIndex];
+ [inputFallbackPopupButton setMenu:inputFallbackInputFieldScopePopUpMenu];
+ anIndex = [inputFallbackInputFieldScopeArray indexOfObject:inputfallback];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [inputFallbackPopupButton selectItemAtIndex:anIndex];
+ [outputPopupButton setMenu:outputInputFieldScopePopUpMenu];
+ anIndex = [outputInputFieldScopeArray indexOfObject:output];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [outputPopupButton selectItemAtIndex:anIndex];
+ break;
+ case 4:
+ [inputPopupButton setMenu:inputDataTableScopePopUpMenu];
+ anIndex = [inputDataTableScopeArray indexOfObject:input];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [inputPopupButton selectItemAtIndex:anIndex];
+ [outputPopupButton setMenu:outputDataTableScopePopUpMenu];
+ anIndex = [outputDataTableScopeArray indexOfObject:output];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [outputPopupButton selectItemAtIndex:anIndex];
+ break;
+ case 5:
+ case 6:
+ case 7:
+ [inputPopupButton setMenu:inputNonePopUpMenu];
+ [inputPopupButton selectItemAtIndex:0];
+ [outputPopupButton setMenu:outputDataTableScopePopUpMenu];
+ anIndex = [outputDataTableScopeArray indexOfObject:output];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [outputPopupButton selectItemAtIndex:anIndex];
+ break;
+ default:
+ [inputPopupButton setMenu:inputNonePopUpMenu];
+ [inputPopupButton selectItemAtIndex:0];
+ [outputPopupButton setMenu:outputDataTableScopePopUpMenu];
+ anIndex = [outputDataTableScopeArray indexOfObject:output];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [outputPopupButton selectItemAtIndex:anIndex];
+ }
+
+ if([input isEqualToString:SPBundleInputSourceSelectedText]) {
+ [inputFallbackPopupButton setHidden:NO];
+ [fallbackLabelField setHidden:NO];
+ } else {
+ [inputFallbackPopupButton setHidden:YES];
+ [fallbackLabelField setHidden:YES];
+ }
+
+}
+
+@end
+
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index da17cf78..0284cfc8 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -456,6 +456,7 @@ extern NSString *SPBundleFileInputSourceFallBackKey;
extern NSString *SPBundleFileOutputActionKey;
extern NSString *SPBundleFileKeyEquivalentKey;
extern NSString *SPBundleFileTooltipKey;
+extern NSString *SPBundleFileDisabledKey;
extern NSString *SPBundleInternLabelKey;
extern NSString *SPBundleInternPathToFileKey;
extern NSString *SPBundleInternKeyEquivalentKey;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 892941cf..12e46bfe 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -275,6 +275,7 @@ NSString *SPBundleFileInputSourceFallBackKey = @"input_fallback";
NSString *SPBundleFileOutputActionKey = @"output";
NSString *SPBundleFileKeyEquivalentKey = @"keyEquivalent";
NSString *SPBundleFileTooltipKey = @"tooltip";
+NSString *SPBundleFileDisabledKey = @"disabled";
NSString *SPBundleInternLabelKey = @"label";
NSString *SPBundleInternPathToFileKey = @"path";
NSString *SPBundleInternKeyEquivalentKey = @"keyEquivalent";