script AppDelegate
property parent : class "NSObject"
property choiceMatrix : missing value -- outlet to left buttons
property shapeMatrix : missing value -- outlet to shape buttons
-- stored values
property vLocalBalance : missing value
property vCurrentBalance : missing value
property vAppliedParaStyle : missing value
property vAppliedParaStyleBalance : missing value
property vScopedBalance : missing value -- set in clickedChoiceButtons_
on applicationWillFinishLaunching_(aNotification)
-- get stuff
tell application id "com.adobe.InDesign" -- Adobe InDesign CS5.5.app
tell document 1
tell selection
set my vLocalBalance to object reference
set my vAppliedParaStyle to applied paragraph style
set my vCurrentBalance to balance ragged lines
set my vAppliedParaStyleBalance to balance ragged lines of applied paragraph style
end tell
end tell
end tell
-- set initial values
clickedChoiceButtons_(me)
end applicationWillFinishLaunching_
on clickedChoiceButtons_(sender) -- called when choice matrix clicked
if choiceMatrix's selectedRow() as integer = 0 then
set my vScopedBalance to vCurrentBalance
else
set my vScopedBalance to vAppliedParaStyleBalance
end if
tell application id "com.adobe.InDesign" -- Adobe InDesign CS5.5.app
if vScopedBalance is vee shape then
shapeMatrix's selectCellAtRow_column_(0, 0)
else if vScopedBalance is pyramid shape then
shapeMatrix's selectCellAtRow_column_(1, 0)
else if vScopedBalance is fully balanced then
shapeMatrix's selectCellAtRow_column_(2, 0)
else
shapeMatrix's selectCellAtRow_column_(3, 0)
end if
end tell
end clickedChoiceButtons_
on clickedOK_(sender)
set theChoice to choiceMatrix's selectedRow() as integer
if theChoice = 0 then
set theTarget to vLocalBalance
else
set theTarget to vAppliedParaStyle
end if
set theShape to shapeMatrix's selectedRow() as integer
tell application id "com.adobe.InDesign" -- Adobe InDesign CS5.5.app
tell document 1
if theShape = 0 then
set balance ragged lines of theTarget to vee shape
else if theShape = 1 then
set balance ragged lines of theTarget to pyramid shape
else if theShape = 2 then
set balance ragged lines of theTarget to fully balanced
else
set balance ragged lines of theTarget to false
end if
end tell
end tell
current application's NSApp's terminate_(me)
end clickedOK_
end script
Another couple of lines and you can have an Apply button for testing as well.