Editors

To change how an outline looks or is organized, scripts use Editors. An element of the Document class, an instance of the Editor class is the entity that controls the display of the outline and its items. By addressing an editor, a script can select, expand, and collapse rows, as well as control the display of columns. (see below)

editor = document.editors[0] tree = document.outline editor.setVisibilityOfColumn(tree.outlineColumn,true) editor.setVisibilityOfColumn(tree.statusColumn,false) editor.setVisibilityOfColumn(tree.noteColumn,false)
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Atree%20%3D%20document%2Eoutline%0Aeditor%2EsetVisibilityOfColumn%28tree%2EoutlineColumn%2Ctrue%29%0Aeditor%2EsetVisibilityOfColumn%28tree%2EstatusColumn%2Cfalse%29%0Aeditor%2EsetVisibilityOfColumn%28tree%2EnoteColumn%2Cfalse%29

In terms of an Editor, the individual items of the outline column are called nodes, and references to them are used with commands like the select command that accepts an array of node references as the objects to select:

item = rootItem.children[2] editor = document.editors[0] node = editor.nodeForItem(item) editor.select([node])
omnioutliner:///omnijs-run?script=item%20%3D%20rootItem%2Echildren%5B2%5D%0Aeditor%20%3D%20document%2Eeditors%5B0%5D%0Anode%20%3D%20editor%2EnodeForItem%28item%29%0Aeditor%2Eselect%28%5Bnode%5D%29

In the following example, the top-level items of the outline (children) are examined to determine the state of their corresponding status checkboxes. If selected, the item is expanded to reveal its descendants, otherwise the item is collapsed.

tree = document.outline var editor = document.editors[0] editor.setVisibilityOfColumn(tree.statusColumn,true) rootItem.children.forEach(function(item){ node = editor.nodeForItem(item) if(item.state == State.Checked){ node.expand() } else { node.collapse() } })
omnioutliner:///omnijs-run?script=tree%20%3D%20document%2Eoutline%0Avar%20editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EsetVisibilityOfColumn%28tree%2EstatusColumn%2Ctrue%29%0ArootItem%2Echildren%2EforEach%28function%28item%29%7B%0A%09node%20%3D%20editor%2EnodeForItem%28item%29%0A%09if%28item%2Estate%20%3D%3D%20State%2EChecked%29%7B%0A%09%09node%2Eexpand%28%29%0A%09%7D%20else%20%7B%0A%09%09node%2Ecollapse%28%29%0A%09%7D%0A%7D%29

A useful feature of OmniOutliner is the ability to focus the outline display to only show specific items, temporarily hiding the other elements of the outline. Omni Automation scripts have the ability to focus and unfocuse the outline display.

function focusSelectedItems(){ editor = document.editors[0] nodes = editor.selectedNodes items = nodes.map(function(node){return node.object}) editor.focusedItems = items }
omnioutliner:///omnijs-run?script=function%20focusSelectedItems%28%29%7B%0A%09editor%20%3D%20document%2Eeditors%5B0%5D%0A%09nodes%20%3D%20editor%2EselectedNodes%0A%09items%20%3D%20nodes%2Emap%28function%28node%29%7Breturn%20node%2Eobject%7D%29%0A%09editor%2EfocusedItems%20%3D%20items%0A%7D%0AfocusSelectedItems%28%29
function unfocus(){ if (document.editors[0].focusedItems != []){ document.editors[0].focusedItems = [] } }
omnioutliner:///omnijs-run?script=function%20unfocus%28%29%7B%0A%09if%20%28document%2Eeditors%5B0%5D%2EfocusedItems%20%21%3D%20%5B%5D%29%7B%0A%09%09document%2Eeditors%5B0%5D%2EfocusedItems%20%3D%20%5B%5D%0A%09%7D%0A%7D%0Aunfocus%28%29

Editor Properties

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

Editor Methods (functions)

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

 

EditorColumnPosition

Instances of the EditorColumnPosition class are generated by using one of the following methods with an instance of the Editor class:

columnPosition = document.editors[0].afterColumn(document.outline.outlineColumn)
 

SortOrdering Properties

The SortOrdering properties are the value for the sorting methods sortOrderingForColumn and setSortOrderingForColumn of the Editor class:

editor = document.editors[0] column = document.outline.outlineColumn sortStatus = editor.sortOrderingForColumn(column) if (sortStatus != SortOrdering.Descending){ editor.setSortOrderingForColumn(column, SortOrdering.Descending) }
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Acolumn%20%3D%20document%2Eoutline%2EoutlineColumn%0AsortStatus%20%3D%20editor%2EsortOrderingForColumn%28column%29%0Aif%20%28sortStatus%20%21%3D%20SortOrdering%2EDescending%29%7B%0A%09editor%2EsetSortOrderingForColumn%28column%2C%20SortOrdering%2EDescending%29%0A%7D
 

NoteDisplay Properties

The NoteDisplay properties are the value for the noteDisplay property (note lowercase n) of the Editor class:

Editors can be used to control the manner in which notes are displayed:

var alert = new Alert("NOTES DISPLAY", "Display item notes inline or at the bottom of the pane?") alert.addOption("Inline") alert.addOption("Pane") alert.show(function(result){ if (result == 0){ document.editors[0].noteDisplay = NoteDisplay.Inline } else { document.editors[0].noteDisplay = NoteDisplay.Pane } })
omnioutliner:///omnijs-run?script=var%20alert%20%3D%20new%20Alert%28%22NOTES%20DISPLAY%22%2C%20%22Display%20item%20notes%20inline%20or%20at%20the%20bottom%20of%20the%20pane%3F%22%29%0Aalert%2EaddOption%28%22Inline%22%29%0Aalert%2EaddOption%28%22Pane%22%29%0Aalert%2Eshow%28function%28result%29%7B%0A%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09document%2Eeditors%5B0%5D%2EnoteDisplay%20%3D%20NoteDisplay%2EInline%0A%09%7D%20else%20%7B%0A%09%09document%2Eeditors%5B0%5D%2EnoteDisplay%20%3D%20NoteDisplay%2EPane%0A%09%7D%0A%7D%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