The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Choose expansion level from Absolute/Relative list Thread Tools Search this Thread Display Modes
A variant of the expand & collapse scripts in an earlier post which offers a list of expansion options for the front document.

Options are listed in both relative and absolute terms.

(The default selection shows the deepest current level of expansion).



Can also be used through LaunchBar. Choose the script with a LaunchBar abbreviation, and tap the space-bar to pass arguments like 1, 2, 3 etc. to increase the level of expansion by one two or three levels, or -1, -2, -3 etc to collapse by some degree.

Code:
property pTitle : "Expand / Collapse Outline"
property pVer : "Ver .03"

-- For use from LaunchBar to increase or decrease expansion level
on handle_string(strChange) -- e.g.  1, 2, 3 or -1, -2 -3 etc
	try
		set lngDelta to strChange as integer
	on error
		return
	end try
	AdjustExpansion(lngDelta)
end handle_string

-- For use through a dialogue
on run
	AdjustExpansion(GetDelta())
end run

on GetDelta()
	tell application id "OOut"
		set oDoc to front document
		set lngDeepest to (my DeepestLevel(oDoc, false))
		set lngDeepestExpanded to (my DeepestLevel(oDoc, true))
		set lstOptions to {}
		repeat with i from 1 to (lngDeepest)
			set lngDelta to (i - lngDeepestExpanded) - 1
			set strDelta to lngDelta as string
			if lngDelta > 0 then
				set strOption to ("+" & strDelta & "    (Level " & i as string) & ")"
			else if lngDelta = 0 then
				set strOption to ("0      (Level " & i as string) & ")"
				set strDefault to strOption
			else
				set strOption to (strDelta & "    (Level " & i as string) & ")"
			end if
			set end of lstOptions to strOption
		end repeat
		lstOptions
		set varChoice to choose from list lstOptions with title pTitle & "  " & pVer with prompt "Choose level of expansion" default items {strDefault}
		if varChoice is false then return 0
		set my text item delimiters to space
		(first text item of (first item of varChoice)) as integer
	end tell
end GetDelta

on AdjustExpansion(lngDelta)
	tell application id "OOut"
		if (count of documents) < 1 then return
		set oDoc to front document
		set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta
		tell oDoc
			set expanded of (rows where level ≤ lngNewMax) to true
			set expanded of (rows where level > lngNewMax) to false
		end tell
	end tell
end AdjustExpansion

on DeepestLevel(oDoc, blnExpandedOnly)
	set lngMax to 0
	tell application id "OOut"
		if blnExpandedOnly then
			set lstLevel to level of rows of oDoc where expanded is true
		else
			set lstLevel to level of rows of oDoc
		end if
		repeat with oLevel in lstLevel
			if oLevel > lngMax then set lngMax to oLevel
		end repeat
	end tell
	lngMax as integer
end DeepestLevel

Last edited by RobTrew; 2012-02-01 at 02:26 PM..
 
Or a version which loops, keeping the dialog visible, and displaying an updated version of the expansion level (and executing changes to it), until the user clicks the cancel button.

--

Last edited by RobTrew; 2011-07-05 at 07:46 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Image on an Object in a Relative Positon So It Maintains Relative Position but no Resize acowan OmniGraffle General 5 2013-01-08 01:04 PM
Restore Expansion (Automatic Expansion?) DrJJWMac OmniFocus 1 for Mac 3 2012-06-26 01:00 PM
Script to toggle expansion of notes RobTrew OmniOutliner 3 for Mac 0 2010-08-16 09:14 PM
SP12: FogBUGZ snippet expansion corrupts multiline text fields dnanian OmniWeb Bug Reports 3 2006-06-07 04:41 AM


All times are GMT -8. The time now is 12:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.