TreeNode

According to Wikipedia a “tree” is a widely used abstract data type that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes. A TreeNode is one element in the chain of nodes that make up a tree.

Some of the terms used by both the TreeNode and Item classes incorporate terms that define hierarchical human relationships mixed with those terms defining the elements of actual trees. Here is a list of common terms used by both classes:

However, in terms of Omni Automation and OmniOutliner, a TreeNode represents a row in an OmniOutliner outline document. The following documentation describes the properties and functions of the TreeNode class.

TreeNode Properties

Here are the properties of an instance of the TreeNode class:

TreeNode Methods (functions)

Here are the methods used with an instance of the TreeNode class:

Here are two script that use the rootNode property of the Editor class to expand or collapse the top-level items in an outline:

editor = document.editors[0] editor.rootNode.children.forEach(function(node){ if(node.canExpand){node.expand()} })
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2ErootNode%2Echildren%2EforEach%28function%28node%29%7B%0A%09if%28node%2EcanExpand%29%7Bnode%2Eexpand%28%29%7D%0A%7D%29
editor = document.editors[0] editor.rootNode.children.forEach(function(node){ if(node.canCollapse){node.collapse()} })
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2ErootNode%2Echildren%2EforEach%28function%28node%29%7B%0A%09if%28node%2EcanCollapse%29%7Bnode%2Ecollapse%28%29%7D%0A%7D%29
 

ItemTreeNode

An ItemTreeNode is an instance of a TreeNode. The ItemTreeNode class is designed to serve as an mechanism for retrieving and setting the values for the state property and the contents of columns, providing parity with the functionality of the Item class.

Here are the properties of an instance of the ItemTreeNode class:

The State properties are the value for the state property of the ItemTreeNode class:

node = document.editors[0].selectedNodes[0] if(node.state === State.Checked){ message = "Selected row status is checked." } else if (node.state === State.Mixed){ message = "Selected row status is mixed." } else { message = "Selected row status is unchecked." } new Alert('STATUS',message).show(function(result){})
omnioutliner:///omnijs-run?script=node%20%3D%20document%2Eeditors%5B0%5D%2EselectedNodes%5B0%5D%0Aif%28node%2Estate%20%3D%3D%3D%20State%2EChecked%29%7B%0A%09message%20%3D%20%22Selected%20row%20status%20is%20checked%2E%22%0A%7D%20else%20if%20%28node%2Estate%20%3D%3D%3D%20State%2EMixed%29%7B%0A%09message%20%3D%20%22Selected%20row%20status%20is%20mixed%2E%22%0A%7D%20else%20%7B%0A%09message%20%3D%20%22Selected%20row%20status%20is%20unchecked%2E%22%0A%7D%0Anew%20Alert%28%27STATUS%27%2Cmessage%29%2Eshow%28function%28result%29%7B%7D%29

Here are the methods used with an instance of the ItemTreeNode class:

An example script using the Editor’s selection property to get the topic text of the first selected node:

editor = document.editors[0] topicColumn = document.outline.outlineColumn node = editor.selection.nodes[0] topic = node.valueForColumn(topicColumn) if(topic === null){topic = ''} else {topic = topic.string}

An example script using the Editor’s selectedNodes property to get the topic text of the first selected node:

editor = document.editors[0] topicColumn = document.outline.outlineColumn node = editor.selectedNodes[0] topic = node.valueForColumn(topicColumn) if(topic === null){topic = ''} else {topic = topic.string}

An example script for appending to the note of the first selected node:

editor = document.editors[0] notesColumn = document.outline.noteColumn node = editor.selection.nodes[0] note = node.valueForColumn(notesColumn) if (note === null){ newNote = "How now brown cow." } else { newNote = note.string + " " + "How now brown cow." } node.setValueForColumn(newNote, notesColumn)
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0AnotesColumn%20%3D%20document%2Eoutline%2EnoteColumn%0Anode%20%3D%20editor%2Eselection%2Enodes%5B0%5D%0Anote%20%3D%20node%2EvalueForColumn%28notesColumn%29%0Aif%20%28note%20%3D%3D%3D%20null%29%7B%0A%09newNote%20%3D%20%22How%20now%20brown%20cow%2E%22%0A%7D%20else%20%7B%0A%09newNote%20%3D%20note%2Estring%20%2B%20%22%20%22%20%2B%20%22How%20now%20brown%20cow%2E%22%0A%7D%0Anode%2EsetValueForColumn%28newNote%2C%20notesColumn%29
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER