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.
A provider implements the getOutline
method, whose signature is as follows:
String
The contents of the file being edited.
String
The path and filename of the file being edited.
Returns 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.Array
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:
Array
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.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 |