orion.edit.outliner | ||
---|---|---|
![]() |
![]() |
|
orion.edit.occurrences | orion.edit.validator |
An orion.edit.outliner
service provides an overview of a file being edited. The overview is given as a tree, which the Orion UI renders in the left-hand pane alongside the file you are editing. Items in the tree can be links that take you to the appropriate position in the file, or to another URL entirely.
A provider implements the computeOutline
method, whose signature is as follows:
ObjectReference
The
Editor Context object.
Object
String
The
Content Type ID of the file being edited.
The return value (or fulfillment value) is an Array of top-level OutlineElement objects, which will be displayed in the outline pane.
Each OutlineElement has these properties:
String
Text to be shown in the UI for this element.String
Optional A space-separated list of CSS class names to be applied to this element in the UI.String
Optional Text to be shown in the UI, prior to the label text.String
Optional A space-separated list of CSS class names to be applied to the labelPre element. Can be used to add an image before the label text.String
Optional Text to be shown in the UI, after the label text.String
Optional A space-separated list of CSS class names to be applied to the labelPost element.OutlineElement[]
Optional Array of child OutlineElements of this element. Children may be nested to an arbitrary depth.Number
Optional The line number within the file to use as the link for this element in the UI. Line numbers begin counting from 1.
orion.util.hashFromPosition()
documentation in the Client API reference for details about these parameters.)String
Optional When line is omitted, the href property provides a URL to use as the link.Implementations of orion.edit.outliner
must define the following attributes:
String[]
An array of
Content Type IDs giving the types of files that this outliner can provide an outline for.
String
A unique identifier for this outline provider.String
A user-readable name for this outline provider. If a nameKey is provided, name is optional.String
Optional. Path to an NLS bundle that the Orion NLS framework will load to obtain translated strings for this provider.
String
Optional. The NLS key used to look up the translated name of this provider in the message bundle given by the nls field.
This example shows an outline provider that runs on .txt files. It finds Mediawiki-style =Section Headings=
and generates a flat outline from them. (A more elaborate implementation might also find subsections and include them as children of the top-level sections.)
var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.edit.outliner", { getOutline: function(contents, title) { var outline = []; var lines = contents.split(/\r?\n/); for (var i=0; i < lines.length; i++) { var line = lines[i]; var match = /^=\s*(.+?)\s*=$/.exec(line); if (match) { outline.push({ label: match[1], line: i+1 // lines are numbered from 1 }); } } return outline; } }, { contentType: ["text/plain"], name: "Headings", id: "orion.outliner.example.headings" }); provider.connect();
![]() |
![]() |
![]() |
orion.edit.occurrences | orion.edit.validator |