aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-09 20:54:16 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-09 20:54:16 +0000
commit3187b984cc76491bf1aabacdf8b2deb5046eaf0a (patch)
tree1c8c6a4a17faf280d16531b52767a094a0ed48f3 /Source
parent34eac092acd118620c2653731e283ca8aa7fc383 (diff)
downloadsequelpro-3187b984cc76491bf1aabacdf8b2deb5046eaf0a.tar.gz
sequelpro-3187b984cc76491bf1aabacdf8b2deb5046eaf0a.tar.bz2
sequelpro-3187b984cc76491bf1aabacdf8b2deb5046eaf0a.zip
• Bundle Commands
- added shell vars SP_CURRENT_EDITED_COLUMN_NAME, SP_CURRENT_EDITED_TABLE for Input Field scoped commands if invoked from a table cell field editor - added shell var SP_TABLE_DATA_SOURCE (content or query) - fixed table row change trigger for custom query tableView
Diffstat (limited to 'Source')
-rw-r--r--Source/SPBundleEditorController.m3
-rw-r--r--Source/SPConstants.h5
-rw-r--r--Source/SPConstants.m5
-rw-r--r--Source/SPCopyTable.m4
-rw-r--r--Source/SPCustomQuery.m48
-rw-r--r--Source/SPDatabaseDocument.m2
-rw-r--r--Source/SPStringAdditions.m3
-rw-r--r--Source/SPTextViewAdditions.m25
8 files changed, 93 insertions, 2 deletions
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 4091e606..1aced5e8 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -327,12 +327,15 @@
@"SP_BUNDLE_INPUT_TABLE_METADATA",
@"SP_BUNDLE_PATH",
@"SP_BUNDLE_SCOPE",
+ @"SP_CURRENT_EDITED_COLUMN_NAME",
+ @"SP_CURRENT_EDITED_TABLE",
@"SP_CURRENT_HOST",
@"SP_CURRENT_LINE",
@"SP_CURRENT_PORT",
@"SP_CURRENT_QUERY",
@"SP_CURRENT_USER",
@"SP_CURRENT_WORD",
+ @"SP_DATA_TABLE_SOURCE",
@"SP_DATABASE_ENCODING",
@"SP_ICON_FILE",
@"SP_PROCESS_ID",
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 1e48f2c2..d6a0ee5f 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -502,6 +502,11 @@ extern NSString *SPBundleShellVariableQueryResultStatusFile;
extern NSString *SPBundleShellVariableQueryResultMetaFile;
extern NSString *SPBundleShellVariableInputTableMetaData;
extern NSString *SPBundleShellVariableScope;
+extern NSString *SPBundleShellVariableUsedQueryForTable;
+extern NSString *SPBundleShellVariableCurrentEditedColumnName;
+extern NSString *SPBundleShellVariableSelectedTable;
+extern NSString *SPBundleShellVariableCurrentEditedTable;
+extern NSString *SPBundleShellVariableDataTableSource;
extern const NSInteger SPBundleRedirectActionNone;
extern const NSInteger SPBundleRedirectActionReplaceSection;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index cd683a5b..67c51b53 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -315,6 +315,11 @@ NSString *SPBundleShellVariableQueryResultStatusFile = @"SP_QUERY_RESULT_
NSString *SPBundleShellVariableQueryResultMetaFile = @"SP_QUERY_RESULT_META_FILE";
NSString *SPBundleShellVariableInputTableMetaData = @"SP_BUNDLE_INPUT_TABLE_METADATA";
NSString *SPBundleShellVariableScope = @"SP_BUNDLE_SCOPE";
+NSString *SPBundleShellVariableUsedQueryForTable = @"SP_USED_QUERY_FOR_TABLE";
+NSString *SPBundleShellVariableCurrentEditedColumnName = @"SP_CURRENT_EDITED_COLUMN_NAME";
+NSString *SPBundleShellVariableSelectedTable = @"SP_SELECTED_TABLE";
+NSString *SPBundleShellVariableCurrentEditedTable = @"SP_CURRENT_EDITED_TABLE";
+NSString *SPBundleShellVariableDataTableSource = @"SP_DATA_TABLE_SOURCE";
const NSInteger SPBundleRedirectActionNone = 200;
const NSInteger SPBundleRedirectActionReplaceSection = 201;
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 58339976..3c665693 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -1150,7 +1150,7 @@ NSInteger kBlobAsImageFile = 4;
[env setObject:bundleInputFilePath forKey:SPBundleShellVariableInputFilePath];
if([[self delegate] respondsToSelector:@selector(usedQuery)] && [[self delegate] usedQuery])
- [env setObject:[[self delegate] usedQuery] forKey:@"SP_USED_QUERY_FOR_TABLE"];
+ [env setObject:[[self delegate] usedQuery] forKey:SPBundleShellVariableUsedQueryForTable];
[env setObject:bundleInputTableMetaDataFilePath forKey:SPBundleShellVariableInputTableMetaData];
[env setObject:SPBundleScopeDataTable forKey:SPBundleShellVariableScope];
@@ -1223,6 +1223,7 @@ NSInteger kBlobAsImageFile = 4;
NSMutableString *tableMetaData = [NSMutableString string];
if([[self delegate] isKindOfClass:[SPCustomQuery class]]) {
+ [env setObject:@"query" forKey:SPBundleShellVariableDataTableSource];
NSArray *defs = [[self delegate] dataColumnDefinitions];
for(NSDictionary* col in defs) {
[tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]];
@@ -1235,6 +1236,7 @@ NSInteger kBlobAsImageFile = 4;
}
}
else if([[self delegate] isKindOfClass:[SPTableContent class]]) {
+ [env setObject:@"content" forKey:SPBundleShellVariableDataTableSource];
NSArray *defs = [[self delegate] dataColumnDefinitions];
for(NSDictionary* col in defs) {
[tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]];
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index ef38461c..c313edaf 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -2386,6 +2386,54 @@
#pragma mark TableView notifications
/**
+ * Check triggering of Bundle command for row selection changes
+ */
+- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
+{
+
+ // Check our notification object is our table content view
+ if ([aNotification object] != customQueryView) return;
+
+ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableRowChanged];
+ for(NSString* cmdPath in triggeredCommands) {
+ NSArray *data = [cmdPath componentsSeparatedByString:@"|"];
+ NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
+ [aMenuItem setTag:0];
+ [aMenuItem setToolTip:[data objectAtIndex:0]];
+
+ // For HTML output check if corresponding window already exists
+ BOOL stopTrigger = NO;
+ if([[data objectAtIndex:2] length]) {
+ BOOL correspondingWindowFound = NO;
+ NSString *uuid = [data objectAtIndex:2];
+ for(id win in [NSApp windows]) {
+ if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) {
+ if([[[win delegate] windowUUID] isEqualToString:uuid]) {
+ correspondingWindowFound = YES;
+ break;
+ }
+ }
+ }
+ if(!correspondingWindowFound) stopTrigger = YES;
+ }
+ if(!stopTrigger) {
+ if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
+ [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
+ if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
+ if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ }
+ }
+ }
+
+}
+
+/**
* Saves the new column size in the preferences for columns which map to fields
*/
- (void)tableViewColumnDidResize:(NSNotification *)aNotification
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 5f05573c..216a3004 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -4823,7 +4823,7 @@
[env setObject:[tablesListInstance selectedDatabase] forKey:@"SP_SELECTED_DATABASE"];
if ([tablesListInstance tableName])
- [env setObject:[tablesListInstance tableName] forKey:@"SP_SELECTED_TABLE"];
+ [env setObject:[tablesListInstance tableName] forKey:SPBundleShellVariableSelectedTable];
if ([tablesListInstance selectedTableItems])
[env setObject:[[tablesListInstance selectedTableItems] componentsJoinedByString:@"\t"] forKey:@"SP_SELECTED_TABLES"];
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index 012f365c..4b06a028 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -567,6 +567,9 @@
if([doc shellVariables])
[theEnv addEntriesFromDictionary:[doc shellVariables]];
+ if([theEnv objectForKey:SPBundleShellVariableCurrentEditedColumnName] && [[theEnv objectForKey:SPBundleShellVariableDataTableSource] isEqualToString:@"content"])
+ [theEnv setObject:[theEnv objectForKey:SPBundleShellVariableSelectedTable] forKey:SPBundleShellVariableCurrentEditedTable];
+
}
if(theEnv != nil && [theEnv count])
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 6ca111b5..c85b5c51 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -578,6 +578,31 @@
[env setObject:bundleInputFilePath forKey:SPBundleShellVariableInputFilePath];
[env setObject:SPBundleScopeInputField forKey:SPBundleShellVariableScope];
+
+ id tableSource = [self delegate];
+ if([[[tableSource class] description] isEqualToString:@"SPCopyTable"]) {
+ NSInteger editedCol = [tableSource editedColumn];
+ if(editedCol > -1) {
+ NSString *colName = [[[[tableSource tableColumns] objectAtIndex:editedCol] headerCell] stringValue];
+ if([[[[tableSource dataSource] class] description] hasSuffix:@"Content"]) {
+ [env setObject:[colName description] forKey:SPBundleShellVariableCurrentEditedColumnName];
+ [env setObject:@"content" forKey:SPBundleShellVariableDataTableSource];
+ } else {
+ NSArray *defs = [[tableSource delegate] dataColumnDefinitions];
+ for(NSDictionary* col in defs) {
+ if([[col objectForKey:@"name"] isEqualToString:colName]) {
+ [env setObject:[col objectForKey:@"org_name"] forKey:SPBundleShellVariableCurrentEditedColumnName];
+ [env setObject:[col objectForKey:@"org_table"] forKey:SPBundleShellVariableCurrentEditedTable];
+ break;
+ }
+ }
+ [env setObject:@"query" forKey:SPBundleShellVariableDataTableSource];
+ }
+ if([[tableSource delegate] respondsToSelector:@selector(usedQuery)] && [[tableSource delegate] usedQuery])
+ [env setObject:[[tableSource delegate] usedQuery] forKey:SPBundleShellVariableUsedQueryForTable];
+ }
+ }
+
if(selfIsQueryEditor && [[self delegate] currentQueryRange].length)
[env setObject:[[self string] substringWithRange:[[self delegate] currentQueryRange]] forKey:@"SP_CURRENT_QUERY"];