Hi, I’m working on a program that will take files and process each one using two user inputs, an IP address and a password. More specifically, it is for sideloading .bar files to a blackberry playbook.
I had created an apple script but I wanted to simplify the process by creating a UI, that’s where AppleScriptObjC comes in. I found this site, but I cant figure out how to add the files to be processed. I used a simple table to hold the files, but I don’t yet know how to code it.
The program uses a .jar file to connect to the playbook and load the files, so I’d also need to direct the application to the the directory where the terminal command will be run. Can anyone help me with this? My code is included below:
--
-- oBarLoadAppDelegate.applescript
-- oBarLoad
--
-- Created by Mikel Calderon on 2/12/12.
-- Copyright (c) 2012 NeuronApps. All rights reserved.
--
property NSMutableArray: class "NSMutableArray"
script AppDelegate
property parent : class "NSObject"
--IB_Outlets
--Developer Mode Settings
property textField : missing value
property secureTextField : missing value
--BarFiles to load
property theDataSource : {}
--IB_Bindings
property pbDevIp : ""
property pbDevPass : ""
property pbToolsPath : ""
--Begin Actions
on applicationWillFinishLaunching_(aNotification)
end applicationWillFinishLaunching_
--Record user IP and Password to use when processing files
on updateDeveloperSettings_(sender)
set pbDevIp to (textField's stringValue()) as string
set pbDevPass to (secureTextField's stringValue()) as string
end updateDeveloperSettings_
--Add .bar files to table list
on addFile_(sender)
end addFile_
on loadBar_(sender)
if pbDevIp as boolean is 0 then
display dialog "Required developer IP is missing" with title "oBarLoad Warning"
else if pbDevPass as boolean is 0 then
display dialog "Required password is missing" with title "oBarLoad Warning"
else if addFile as boolean is 0 then
display dialog "Please select a .Bar file!"
else
display dialog " Attempting .Bar Load"
end if
end loadBar_
--This is the part where I'm stuck, every time i build the application I get an error
(* set filecount to 0
on ButtonClicked_(sender)
(repeat with i in loadBar_
set filecount to 1
tell application "Terminal"
set currentTab to do script "cd /Users/username/location/Playbook_Tools" -- replace what is inside the quotes with the directory where BarDeploy.jar is saved within the bundle
--To set path to bundle contents
--current application's NSBundle's mainBundle()'s bundlePath()'s stringByAppendingPathComponent_("Contents")
set filename to POSIX path of i
do script "java -Xmx512M -jar \"BarDeploy.jar\" -installApp -device " & pbDevIp & " -password" & pbDevPass & " " & filename in currentTab
do script "exit" in currentTab
delay 10
end tell
end repeat)
end ButtonClicked_
if filecount < 1 then
tell application "Terminal"
do script "exit"
end tell
end if *)
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script