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

 
can children inherit text from parent? Thread Tools Search this Thread Display Modes
Say I have a parent topic named "Opportunities"

And it has the following children:

Jobs
Grants
Offers


Is there a way I can make these children automatically include the parent's name? something like this--

Opportunities: Jobs
Opportunities: Grants
Opportunities: Offers

without having to type in opportunities.


Thanks for your help
 
You can run this simple script while selecting the parent rows.

(It will, however, remove any text formatting from the children which receive the prefix ...)

Code:
tell application id "com.omnigroup.OmniOutlinerPro3"
	tell front document
		set lstSeldParents to (selected rows where its children is not children of its children)
		repeat with oRow in lstSeldParents
			set strTopic to (topic of oRow)
			repeat with oChild in children of oRow
				set strChildTopic to topic of oChild
				if strChildTopic does not start with strTopic then
					set the topic of oChild to strTopic & ": " & strChildTopic
				end if
			end repeat
		end repeat
	end tell
end tell
 
Quote:
Originally Posted by RobTrew View Post
You can run this simple script while selecting the parent rows.

(It will, however, remove any text formatting from the children which receive the prefix ...)
It's a pretty rare opportunity to improve on a script by RobTrew, so I'm going to grab it :-)

If you want your children to retain their formatting, and have the prefix from the parent rows retain its formatting as well, this mashup of Rob's script and the Merge Selected Rows script should do the trick. It won't win any programming style competitions, though!

Code:
tell application id "com.omnigroup.OmniOutlinerPro3"
	tell front document
		set lstSeldParents to (selected rows where its children is not children of its children)
		if ((count of lstSeldParents) < 1) then
			display dialog "You need to select at least one parent row to use this script." buttons "Cancel" default button "Cancel"
		end if
		repeat with oRow in lstSeldParents
			set strTopic to (topic of oRow)
			if ((count of characters of (topic of oRow)) > 0) then
				duplicate last character of (topic of oRow) to after last character of (topic of oRow)
				set text of last character of (topic of oRow) to ":"
				duplicate last character of (topic of oRow) to after last character of (topic of oRow)
				set text of last character of (topic of oRow) to " "
			end if
			
			repeat with oChild in children of oRow
				set strChildTopic to topic of oChild
				if strChildTopic does not start with strTopic then
					duplicate topic of oRow to before first character of topic of oChild
				end if
			end repeat
			delete last character of (topic of oRow)
			delete last character of (topic of oRow)
		end repeat
	end tell
end tell
 
Thank you ! (I tried and failed to find the right target for the duplication - a relief to see that it is possible).

I shall add it to my list of enlightening scripts :-)
 
As a PS, if formatting is an issue, and the parent format differs from the child format, you can choose between copying the formatting of the parent row to the prefix for the child, or preserving the formatting of the child.

Whpalmer4 's script already works very well for the former option. (A bold row with italic children will confer a bold prefix on each child, preserving the italic formatting of their main text).

If, however, you wanted the children to simply inherit the prefix text from the parent row, preserving their own formatting for prefix as well as main text, you could try the following variant on whpalmer's script:

Code:
-- Variant in which both prefix and main text of each child row preserve child row formatting
-- (For cases where parent and child row formatting differ)

tell application id "com.omnigroup.OmniOutlinerPro3"
	tell front document
		set refSeldParents to (a reference to (selected rows where its children is not children of its children))
		if ((count of refSeldParents) < 1) then
			display dialog "You need to select at least one parent row to use this script." buttons "Cancel" default button "Cancel"
		end if
		
		repeat with oRow in refSeldParents
			set strTopic to (topic of oRow as string) & ": "
			set lngChars to length of strTopic
			
			-- Duplicate the parent text as a prefix for first child 
			-- (character by character retaining child formatting)
			set refChiln to children of oRow
			set oChild to first item of refChiln
			set refChildTopic to (a reference to topic of oChild)
			if refChildTopic does not start with strTopic then
				set refFirst to (a reference to first character of refChildTopic)
				repeat with iChar from lngChars to 1 by -1
					duplicate refFirst to before refFirst
					set text of refFirst to character iChar of strTopic
				end repeat
			end if
			
			-- Now duplicate the prefix of the first child to the start of any siblings
			-- (a bit faster)
			set lngChildren to count of refChiln
			if lngChildren > 1 then
				set refTemplate to (a reference to characters 1 thru lngChars of refChildTopic)
				repeat with iSibling from 2 to lngChildren
					set refSibTopic to (a reference to topic of item iSibling of refChiln)
					if refSibTopic does not start with strTopic then 
						duplicate refTemplate to before first character of refSibTopic
				end repeat
			end if
		end repeat
	end tell
end tell

Last edited by RobTrew; 2010-10-17 at 10:49 PM..
 
i haven't had a chance to try these yet, but damn guys. impressive! thank you very much for the help.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can children actions of an action group be unaffected by the parent flag and due date julienl OmniFocus 1 for Mac 1 2012-02-17 02:31 PM
Printing PDF always integrating parent with children coolmemin OmniOutliner 3 for Mac 1 2010-11-20 09:23 AM
want pasted text to inherit row level style trurl OmniOutliner 3 for Mac 1 2010-02-04 03:12 AM
Context view and Parent/Children Actions apeman88 OmniFocus 1 for Mac 2 2008-07-02 06:35 PM
Dropping text on parent random1destiny OmniOutliner 3 for Mac 0 2007-10-07 08:52 AM


All times are GMT -8. The time now is 02:07 AM.


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