From c352ef02ae0e81496c9db2b8973a8cdd43669366 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 14 Jan 2011 16:25:50 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20for=20default=20Bundles=20i?= =?UTF-8?q?f=20category=20or=20key=20equivalent=20was=20changed=20by=20the?= =?UTF-8?q?=20user=20=E2=80=A2=20improved=20Format=20SQL=20Bundle=20-=20ad?= =?UTF-8?q?ded=20checking=20for=20empty=20passed=20SQL=20string=20-=20chan?= =?UTF-8?q?ged=20category=20to=20Format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Format SQL.spBundle/command.plist | 14 ++- Source/SPAppController.m | 124 +++++++++++---------- 2 files changed, 76 insertions(+), 62 deletions(-) diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist index 219cc2c7..f6472de5 100644 --- a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -5,11 +5,19 @@ author Hans-Jörg Bibiko category - Query Editor + Format command + +# check for empty STDIN +SQL=$(cat) +if [ -z "$SQL" ]; then + echo "No SQL statements passed." + exit $SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP +fi + # check if connected to the internet and if server is up -connected=$(/sbin/ping -t 3 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) +connected=$(/sbin/ping -t 5 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) if [ $connected -eq "0" ]; then echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP @@ -81,7 +89,7 @@ cat <<HTML <div id="sqlpanel"> <div id="sp_inputsql"> <textarea id ="inputsql" name="inputsql" cols="1" rows="1" wrap="off"> - `cat` + $SQL </textarea> </div> <div id="sp_submit"> diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 3a381fdb..a0e47137 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -1581,6 +1581,8 @@ YY_BUFFER_STATE yy_scan_string (const char *); && [cmdData objectForKey:SPBundleFileScopeKey]) { + BOOL defaultBundleWasUpdated = NO; + if([cmdData objectForKey:SPBundleFileUUIDKey] && [[cmdData objectForKey:SPBundleFileUUIDKey] length]) { if(processDefaultBundles) { @@ -1690,8 +1692,13 @@ YY_BUFFER_STATE yy_scan_string (const char *); continue; } infoPath = [NSString stringWithString:newInfoPath]; + + defaultBundleWasUpdated = YES; + } + if(!defaultBundleWasUpdated) continue; + } [installedBundleUUIDs setObject:[NSDictionary dictionaryWithObjectsAndKeys: @@ -1704,71 +1711,70 @@ YY_BUFFER_STATE yy_scan_string (const char *); continue; } - // Register Bundle - do it for default Bundles only while processDefaultBundles - if(![cmdData objectForKey:SPBundleFileIsDefaultBundleKey] || processDefaultBundles) { - NSString *scope = [cmdData objectForKey:SPBundleFileScopeKey]; + // Register Bundle + NSString *scope = [cmdData objectForKey:SPBundleFileScopeKey]; - // Register scope/category menu structure - if(![bundleUsedScopes containsObject:scope]) { - [bundleUsedScopes addObject:scope]; - [bundleItems setObject:[NSMutableArray array] forKey:scope]; - [bundleCategories setObject:[NSMutableArray array] forKey:scope]; - [bundleKeyEquivalents setObject:[NSMutableDictionary dictionary] forKey:scope]; - } - if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length] && ![[bundleCategories objectForKey:scope] containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]]) - [[bundleCategories objectForKey:scope] addObject:[cmdData objectForKey:SPBundleFileCategoryKey]]; - - NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; - [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], - ([[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTML])?[cmdData objectForKey:SPBundleFileUUIDKey]:@""]]; - } + // Register scope/category menu structure + if(![bundleUsedScopes containsObject:scope]) { + [bundleUsedScopes addObject:scope]; + [bundleItems setObject:[NSMutableArray array] forKey:scope]; + [bundleCategories setObject:[NSMutableArray array] forKey:scope]; + [bundleKeyEquivalents setObject:[NSMutableDictionary dictionary] forKey:scope]; + } + if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length] && ![[bundleCategories objectForKey:scope] containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]]) + [[bundleCategories objectForKey:scope] addObject:[cmdData objectForKey:SPBundleFileCategoryKey]]; + + NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; + [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], + ([[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTML])?[cmdData objectForKey:SPBundleFileUUIDKey]:@""]]; + } - // Register key equivalent - if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) { - - NSString *theKey = [cmdData objectForKey:SPBundleFileKeyEquivalentKey]; - NSString *theChar = [theKey substringFromIndex:[theKey length]-1]; - NSString *theMods = [theKey substringToIndex:[theKey length]-1]; - NSUInteger mask = 0; - if([theMods rangeOfString:@"^"].length) mask = mask | NSControlKeyMask; - if([theMods rangeOfString:@"@"].length) mask = mask | NSCommandKeyMask; - if([theMods rangeOfString:@"~"].length) mask = mask | NSAlternateKeyMask; - if([theMods rangeOfString:@"$"].length) mask = mask | NSShiftKeyMask; - - if(![[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]]) - [[bundleKeyEquivalents objectForKey:scope] setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]]; - - [[[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]] addObject: - [NSDictionary dictionaryWithObjectsAndKeys: - infoPath, @"path", - [cmdData objectForKey:SPBundleFileNameKey], @"title", - ([cmdData objectForKey:SPBundleFileTooltipKey]) ?: @"", @"tooltip", - nil]]; - - [aDict setObject:[NSArray arrayWithObjects:theChar, [NSNumber numberWithInteger:mask], nil] forKey:SPBundleInternKeyEquivalentKey]; - } + // Register key equivalent + if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) { + + NSString *theKey = [cmdData objectForKey:SPBundleFileKeyEquivalentKey]; + NSString *theChar = [theKey substringFromIndex:[theKey length]-1]; + NSString *theMods = [theKey substringToIndex:[theKey length]-1]; + NSUInteger mask = 0; + if([theMods rangeOfString:@"^"].length) mask = mask | NSControlKeyMask; + if([theMods rangeOfString:@"@"].length) mask = mask | NSCommandKeyMask; + if([theMods rangeOfString:@"~"].length) mask = mask | NSAlternateKeyMask; + if([theMods rangeOfString:@"$"].length) mask = mask | NSShiftKeyMask; + + if(![[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]]) + [[bundleKeyEquivalents objectForKey:scope] setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]]; + + [[[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]] addObject: + [NSDictionary dictionaryWithObjectsAndKeys: + infoPath, @"path", + [cmdData objectForKey:SPBundleFileNameKey], @"title", + ([cmdData objectForKey:SPBundleFileTooltipKey]) ?: @"", @"tooltip", + nil]]; + + [aDict setObject:[NSArray arrayWithObjects:theChar, [NSNumber numberWithInteger:mask], nil] forKey:SPBundleInternKeyEquivalentKey]; + } - if([cmdData objectForKey:SPBundleFileTooltipKey] && [[cmdData objectForKey:SPBundleFileTooltipKey] length]) - [aDict setObject:[cmdData objectForKey:SPBundleFileTooltipKey] forKey:SPBundleFileTooltipKey]; + if([cmdData objectForKey:SPBundleFileTooltipKey] && [[cmdData objectForKey:SPBundleFileTooltipKey] length]) + [aDict setObject:[cmdData objectForKey:SPBundleFileTooltipKey] forKey:SPBundleFileTooltipKey]; - if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) - [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:SPBundleFileCategoryKey]; + if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) + [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:SPBundleFileCategoryKey]; - if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) - [aDict setObject:[cmdData objectForKey:SPBundleFileKeyEquivalentKey] forKey:@"key"]; + if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) + [aDict setObject:[cmdData objectForKey:SPBundleFileKeyEquivalentKey] forKey:@"key"]; + + [[bundleItems objectForKey:scope] addObject:aDict]; - [[bundleItems objectForKey:scope] addObject:aDict]; - } } } -- cgit v1.2.3