aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPAppController.h2
-rw-r--r--Source/SPAppController.m15
-rw-r--r--Source/SPBundleEditorController.m50
-rw-r--r--Source/SPDatabaseDocument.m17
4 files changed, 83 insertions, 1 deletions
diff --git a/Source/SPAppController.h b/Source/SPAppController.h
index 2fb4aef2..8742607d 100644
--- a/Source/SPAppController.h
+++ b/Source/SPAppController.h
@@ -46,6 +46,7 @@
NSMutableDictionary *bundleItems;
NSMutableDictionary *bundleCategories;
+ NSMutableDictionary *bundleTriggers;
NSMutableArray *bundleUsedScopes;
NSMutableDictionary *bundleKeyEquivalents;
NSMutableDictionary *installedBundleUUIDs;
@@ -96,6 +97,7 @@
- (NSString *)contentOfFile:(NSString *)aPath;
- (NSArray *)bundleCategoriesForScope:(NSString*)scope;
- (NSArray *)bundleItemsForScope:(NSString*)scope;
+- (NSArray *)bundleCommandsForTrigger:(NSString*)trigger;
- (NSDictionary *)bundleKeyEquivalentsForScope:(NSString*)scope;
- (void)registerActivity:(NSDictionary*)commandDict;
- (void)removeRegisteredActivity:(NSInteger)pid;
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index d9fe64bb..3cd718db 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -54,6 +54,7 @@
bundleItems = [[NSMutableDictionary alloc] initWithCapacity:1];
bundleCategories = [[NSMutableDictionary alloc] initWithCapacity:1];
+ bundleTriggers = [[NSMutableDictionary alloc] initWithCapacity:1];
bundleUsedScopes = [[NSMutableArray alloc] initWithCapacity:1];
bundleKeyEquivalents = [[NSMutableDictionary alloc] initWithCapacity:1];
installedBundleUUIDs = [[NSMutableDictionary alloc] initWithCapacity:1];
@@ -1179,6 +1180,7 @@
[bundleItems removeAllObjects];
[bundleUsedScopes removeAllObjects];
[bundleCategories removeAllObjects];
+ [bundleTriggers removeAllObjects];
[bundleKeyEquivalents removeAllObjects];
[installedBundleUUIDs removeAllObjects];
@@ -1234,6 +1236,13 @@
[aDict setObject:[cmdData objectForKey:SPBundleFileNameKey] forKey:SPBundleInternLabelKey];
[aDict setObject:infoPath forKey:SPBundleInternPathToFileKey];
+ // Register trigger
+ if([cmdData objectForKey:SPBundleFileTriggerKey]) {
+ if(![bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]])
+ [bundleTriggers setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileTriggerKey]];
+ [[bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]] addObject:[NSString stringWithFormat:@"%@|%@", infoPath, [cmdData objectForKey:SPBundleFileScopeKey]]];
+ }
+
if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) {
NSString *theKey = [cmdData objectForKey:SPBundleFileKeyEquivalentKey];
NSString *theChar = [theKey substringFromIndex:[theKey length]-1];
@@ -1518,6 +1527,11 @@
return [bundleCategories objectForKey:scope];
}
+- (NSArray *)bundleCommandsForTrigger:(NSString*)trigger
+{
+ return [bundleTriggers objectForKey:trigger];
+}
+
- (NSArray *)bundleItemsForScope:(NSString*)scope
{
return [bundleItems objectForKey:scope];
@@ -1595,6 +1609,7 @@
if(bundleItems) [bundleItems release];
if(bundleUsedScopes) [bundleUsedScopes release];
if(bundleCategories) [bundleCategories release];
+ if(bundleTriggers) [bundleTriggers release];
if(bundleKeyEquivalents) [bundleKeyEquivalents release];
if(installedBundleUUIDs) [installedBundleUUIDs release];
if (runningActivitiesArray) [runningActivitiesArray release];
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 823feae8..60f95f3b 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -429,9 +429,30 @@
}
+/**
+ * Store trigger in bundle dict since it is not bound
+ * via key binding and update various GUI elements
+ */
- (IBAction)triggerButtonChanged:(id)sender
{
-
+
+ id currentDict = [self _currentSelectedObject];
+
+ NSMenu* senderMenu = [sender menu];
+
+ NSInteger selectedIndex = [senderMenu indexOfItem:sender];
+ NSString *input = SPBundleTriggerActionNone;
+ if(senderMenu == triggerGeneralPopUpMenu)
+ input = [triggerGeneralArray objectAtIndex:selectedIndex];
+ else if(senderMenu == triggerInputFieldPopUpMenu)
+ input = [triggerInputFieldArray objectAtIndex:selectedIndex];
+ else if(senderMenu == triggerDataTablePopUpMenu)
+ input = [triggerDataTableArray objectAtIndex:selectedIndex];
+
+ [currentDict setObject:input forKey:SPBundleFileTriggerKey];
+
+ [self _updateBundleDataView];
+
}
/**
@@ -1594,6 +1615,9 @@
NSString *scope = [currentDict objectForKey:SPBundleFileScopeKey];
if(!scope) scope = SPBundleScopeGeneral;
+ NSString *trigger = [currentDict objectForKey:SPBundleFileTriggerKey];
+ if(!trigger) trigger = SPBundleTriggerActionNone;
+
// Update the scope popup button
if([scope isEqualToString:SPBundleScopeGeneral])
[scopePopupButton selectItemWithTag:kGeneralScopeArrayIndex];
@@ -1609,40 +1633,64 @@
case kGeneralScopeArrayIndex: // General
[inputPopupButton setMenu:inputNonePopUpMenu];
[inputPopupButton selectItemAtIndex:0];
+
[outputPopupButton setMenu:outputGeneralScopePopUpMenu];
anIndex = [outputGeneralScopeArray indexOfObject:output];
if(anIndex == NSNotFound) anIndex = 0;
[outputPopupButton selectItemAtIndex:anIndex];
+
+ [triggerPopupButton setMenu:triggerGeneralPopUpMenu];
+ anIndex = [triggerGeneralArray indexOfObject:trigger];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [triggerPopupButton selectItemAtIndex:anIndex];
+
input = SPBundleInputSourceNone;
[inputFallbackPopupButton setHidden:YES];
[fallbackLabelField setHidden:YES];
+
break;
case kInputFieldScopeArrayIndex: // Input Field
[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];
+
+ [triggerPopupButton setMenu:triggerInputFieldPopUpMenu];
+ anIndex = [triggerInputFieldArray indexOfObject:trigger];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [triggerPopupButton selectItemAtIndex:anIndex];
+
break;
case kDataTableScopeArrayIndex: // Data Table
[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];
+
input = SPBundleInputSourceNone;
[inputFallbackPopupButton setHidden:YES];
[fallbackLabelField setHidden:YES];
+
+ [triggerPopupButton setMenu:triggerDataTablePopUpMenu];
+ anIndex = [triggerDataTableArray indexOfObject:trigger];
+ if(anIndex == NSNotFound) anIndex = 0;
+ [triggerPopupButton selectItemAtIndex:anIndex];
+
break;
case kDisabledScopeTag: // Disable command
break;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 309679fe..02889b5e 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -5301,6 +5301,23 @@
[[parentWindow onMainThread] makeFirstResponder:[tablesListInstance valueForKeyPath:@"tablesListView"]];
}
+ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionDatabaseChanged];
+ for(NSString* cmdPath in triggeredCommands) {
+ NSArray *data = [cmdPath componentsSeparatedByString:@"|"];
+ NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
+ [aMenuItem setTag:0];
+ [aMenuItem setToolTip:[data objectAtIndex:0]];
+ if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
+ ;
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
+ ;
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
+ ;
+ }
+ }
+
// If a the table has changed, update the selection
if (![targetItemName isEqualToString:[self table]]) {
if (targetItemName) {