From a810d89092c9c8dea66d74630b80c55f3dce9382 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 27 Dec 2010 10:57:53 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20first=20Default=20Bundle=20and=20pr?= =?UTF-8?q?ocedure=20to=20copy=20them=20into=20BUILD=5FPRODUCT/Contents/Sh?= =?UTF-8?q?aredSupport=20done=20in=20build.sh=20while=20compiling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/build.sh | 6 ++ .../Open Selected Table.spBundle/command.plist | 119 +++++++++++++++++++++ Source/SPAppController.m | 2 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 SharedSupport/Default Bundles/Open Selected Table.spBundle/command.plist diff --git a/Scripts/build.sh b/Scripts/build.sh index 82c788de..409ec419 100755 --- a/Scripts/build.sh +++ b/Scripts/build.sh @@ -42,6 +42,12 @@ then "${SRCROOT}/Scripts/trim-application.sh" -p "$BUILD_PRODUCT" -a fi +# Copy all Default Bundles to build product +rm -rf "${BUILD_PRODUCT}/Contents/SharedSupport/Default Bundles" +mkdir "${BUILD_PRODUCT}/Contents/SharedSupport" +mkdir "${BUILD_PRODUCT}/Contents/SharedSupport/Default Bundles" +cp -R "${SRCROOT}/SharedSupport/Default Bundles" "${BUILD_PRODUCT}/Contents/SharedSupport" + # Perform distribution specific tasks if this is a 'Distribution' build if [ "$CONFIGURATION" == 'Distribution' ] then diff --git a/SharedSupport/Default Bundles/Open Selected Table.spBundle/command.plist b/SharedSupport/Default Bundles/Open Selected Table.spBundle/command.plist new file mode 100644 index 00000000..6bf2c03f --- /dev/null +++ b/SharedSupport/Default Bundles/Open Selected Table.spBundle/command.plist @@ -0,0 +1,119 @@ + + + + + author + Hans-Jörg Bibiko + category + Open + command + +# Remove hand-shake files +rm -f "$SP_QUERY_RESULT_FILE" +rm -f "$SP_QUERY_FILE" +rm -f "$SP_QUERY_RESULT_STATUS_FILE" + + +# Check if one table is selected +if [ -z "$SP_SELECTED_TABLE" ]; then + echo "<font color=red>Please select a table.</font>" + exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP +fi + + +# Ask for desired application - modify the list if needed +open "sequelpro://$SP_PROCESS_ID@chooseItemFromList/Numbers/Microsoft Excel" + +# wait for Sequel Pro; status file will be written to disk if query was finished +while [ 1 ] +do + [[ -e "$SP_QUERY_RESULT_STATUS_FILE" ]] && break + sleep 0.01 +done + +# Read the chosen list item +APP=$(cat "$SP_QUERY_RESULT_FILE") + +# Check if user dismissed, if so bail (if $APP is empty := user pressed ESC) +if [ -z "$APP" ]; then + rm -f "$SP_QUERY_RESULT_FILE" + rm -f "$SP_QUERY_FILE" + rm -f "$SP_QUERY_RESULT_STATUS_FILE" + exit 0 +fi + +# Remove hand-shake files +rm -f "$SP_QUERY_RESULT_FILE" +rm -f "$SP_QUERY_FILE" +rm -f "$SP_QUERY_RESULT_STATUS_FILE" + + +# Query for desired data +echo "SELECT * FROM \`${SP_SELECTED_TABLE//\`/\`\`}\`" > "$SP_QUERY_FILE" +open "sequelpro://$SP_PROCESS_ID@passToDoc/ExecuteQuery/csv" + +# wait for Sequel Pro; status file will be written to disk if query +# was finished +while [ 1 ] +do + [[ -e "$SP_QUERY_RESULT_STATUS_FILE" ]] && break + sleep 0.1 +done + +# Check returned status 0 := no error; 1 := error +RES=$(cat "$SP_QUERY_RESULT_STATUS_FILE") +[[ ! -e "$SP_QUERY_RESULT_FILE" ]] && RES=1 + + +# No sql error +if [ "$RES" == "0" ]; then + DATAFILENAME=$(date "+sp_data%H%M%S.csv") + mv "$SP_QUERY_RESULT_FILE" ~/Desktop/$DATAFILENAME + open -a "$APP" ~/Desktop/$DATAFILENAME + echo "$APP is opening data file ~/Desktop/$DATAFILENAME." +else + # if error message will be saved in result file + echo "<font color=red>" + cat "$SP_QUERY_RESULT_FILE" + echo "</font>" + rm -f "$SP_QUERY_RESULT_FILE" + rm -f "$SP_QUERY_FILE" + rm -f "$SP_QUERY_RESULT_STATUS_FILE" + exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP +fi + +rm -f "$SP_QUERY_RESULT_FILE" +rm -f "$SP_QUERY_FILE" +rm -f "$SP_QUERY_RESULT_STATUS_FILE" + + contact + znvy@ovovxb.qr + description + If one table is selected in the Table List it will write the table data CSV formatted at "~/Desktop/sp_dataxxxxx.csv" to disk (xxxxx := timestamp) and asks for the application with which the data should be opened. + +Version 1.0 + internalKeyEquivalent + + characters + O + keyCode + 31 + modifierFlags + 1835008 + + keyEquivalent + ^~@o + name + Open selected table with… + output + showastexttooltip + scope + general + tooltip + Open selected table + uuid + 8F406B0A-23A4-4436-A348-E248A61BA59C + isDefaultBundle + + + diff --git a/Source/SPAppController.m b/Source/SPAppController.m index aa9bb824..25a181fa 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -1348,7 +1348,7 @@ NSArray *bundlePaths = [NSArray arrayWithObjects: ([[NSFileManager defaultManager] applicationSupportDirectoryForSubDirectory:SPBundleSupportFolder createIfNotExists:NO error:nil])?:@"", - [NSString stringWithFormat:@"%@/Contents/Resources/Default Bundles", [[NSBundle mainBundle] bundlePath]], + [NSString stringWithFormat:@"%@/Contents/SharedSupport/Default Bundles", [[NSBundle mainBundle] bundlePath]], nil]; BOOL processDefaultBundles = NO; -- cgit v1.2.3