Orion provides a number of basic infrastructure services that can be used by client scripts for performing various tasks. These services have no user interface component and can be used within any page of a client application. This section of the guide outlines what services are available, along with simple examples of how to use them.

Orion provides a number of basic infrastructure services that can be used by client scripts for performing various tasks. These services have no user interface component and can be used within any page of a client application. This section of the guide outlines what services are available, along with simple examples of how to use them.

+

+

= orion.core.contentTypeRegistry =

+

+

The <tt>orion.core.contentTypeRegistry</tt> service provides information about the [[Orion/Documentation/Developer Guide/Plugging into the navigator#orion.core.contenttype|Content Types]] that have been registered with Orion.

+

+

Here is an example usage showing how to query all registered content types and print them to the console:

See <tt>orion.favorites.FavoritesService</tt> in the Orion client API reference for a complete list of functions available on the favorite service.

See <tt>orion.favorites.FavoritesService</tt> in the Orion client API reference for a complete list of functions available on the favorite service.

Line 20:

Line 37:

The <tt>orion.core.file</tt> service is used to provide file system contents for the Orion workspace. For example a plug-in can use this service to include content from one server into a workspace on another server. Each file service is displayed as a root element in the Orion <b>Navigator</b> page.

The <tt>orion.core.file</tt> service is used to provide file system contents for the Orion workspace. For example a plug-in can use this service to include content from one server into a workspace on another server. Each file service is displayed as a root element in the Orion <b>Navigator</b> page.

The above code will contribute a top level node to the Navigator named "Sample File System". The parameter "service" in the API above must provide the functions specified by the Orion file client API. Refer to <tt>orion.fileClient.FileClient</tt> in the client API reference for further details. For more information on client-server interaction, see Orion [http://wiki.eclipse.org/Orion/Server_API/File_API File Server API]. For an complete file system example, see the [https://github.com/eclipse/orion.client/blob/master/bundles/org.eclipse.orion.client.core/web/plugins/sampleFilePlugin.html sample file plugin] in the Orion Git repository.

The above code will contribute a top level node to the Navigator named "Sample File System". The parameter "service" in the API above must provide the functions specified by the Orion file client API. Refer to <tt>orion.fileClient.FileClient</tt> in the client API reference for further details. For more information on client-server interaction, see Orion [http://wiki.eclipse.org/Orion/Server_API/File_API File Server API]. For an complete file system example, see the [https://github.com/eclipse/orion.client/blob/master/bundles/org.eclipse.orion.client.core/web/plugins/sampleFilePlugin.html sample file plugin] in the Orion Git repository.

: Loads the workspace with the given id and sets it to be the current workspace for the IDE. The workspace is created if none already exists.<br />Called by the Orion navigator when navigating to the root of the file system.<br />NOTE: The returned file object should have a zero-length 'Parents' array to designate it as the root of the filesystem (see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=392374 bug 392374]).

+

; createProject (url, projectName, serverPath, create)

+

: Adds a project to a workspace.<br />TODO -- the Orion IDE never calls this function for third-party file systems.

+

; createFolder (parentLocation, folderName)

+

: Creates a folder.<br />Invoked when using the '''New Folder''' command in the Orion navigator.

+

; createFile (parentLocation, fileName)

+

: Create a new file in a specified location.<br />Invoked when using the '''New File''' command in the Orion navigator.

+

; deleteFile (location)

+

: Deletes a file, directory, or project.<br />Invoked when using the '''Delete''' command in the Orion navigator.

+

; moveFile (sourceLocation, targetLocation, name)

+

: Moves a file or directory.<br />Invoked when using the '''Move''' and '''Cut..Paste''' commands in the Orion navigator.

+

; copyFile (sourceLocation, targetLocation)

+

: Copies a file or directory.<br />Invoked when using the '''Copy..Paste''' commands in the Orion navigator.

: Performs a search with the given query.<br />Invoked by various search widgets that appear in the Orion UI.

+

+

This API is asynchronous: in other words, every API method is expected to return a promise that eventually resolves with the result object, or rejects if an error occurred.

= orion.core.marker =

= orion.core.marker =

Line 31:

Line 82:

The marker service is used to store problems found by a builder or syntax validator. A client can register with this service for notification when markers are changed. Here is an example of a component that is registering for notification of marker changes:

The marker service is used to store problems found by a builder or syntax validator. A client can register with this service for notification when markers are changed. Here is an example of a component that is registering for notification of marker changes:

Orion plugins can define ''settings'' using the <code>orion.core.setting</code> service. A setting defines some persistent information that is provided to one of the plugin's services. Defined settings appear on Orion's <b>Settings</b> page, and their values can be changed using an automatically-generated UI.

* [[Orion/Documentation/Developer Guide/Configuration services#Meta Typing|''Metatype'' information]], which defines the "shape" of the setting. Specifically, it defines what named properties appear in the setting and what data type they have (string, boolean, number, etc). The Settings page uses this Metatype information to generate appropriate UI widgets (for example, text field, checkbox, etc).

+

+

== Service properties ==

+

To contribute one or more settings, the '''settings''' service property is used:

+

; settings

+

: <code>Setting[]</code>. Defines Settings. Each <code>Setting</code> element has the following shape:

+

:; pid

+

:: <code>String</code>. The PID for this setting. This PID occupies the same namespace as the PIDs contributed by [[Orion/Documentation/Developer Guide/Configuration services#Managed Services|Managed Services]], and must be unique in that respect.

+

:; name

+

:: <code>String</code>. Human-readable name of this setting.

+

:; tags

+

:: <code>String[]</code>. ''Optional.'' List of tags applying to this setting.

+

:; properties

+

:: <code>AttributeDefinition[]</code>. Gives the properties that make up this setting. The shape of the <code>AttributeDefinition</code> element is explained in [[Orion/Documentation/Developer Guide/Configuration services#Define an OCD|Metatype documentation]].

+

+

== Service methods ==

+

None. This service is completely declarative.

+

+

== Examples ==

+

This example shows how to define a Setting with PID <code>example.navconfig</code>. This Setting has a single property <code>newtab</code>, which is boolean-typed. Because we've enumerated the property's possible values using an '''options''', the generated UI presentation will show a drop-down menu. Since we've provided a '''defaultValue''' of <code>false</code>, the second option "Open links in a same tab" will selected by default.

+

+

define(['orion/plugin'], function(PluginProvider) {

+

var pluginProvider = new PluginProvider();

+

pluginProvider.registerService('orion.core.setting',

+

{},

+

{ settings: [

+

{ pid: 'example.navconfig',

+

name: 'Navigation settings',

+

properties: [

+

{ id: 'newtab',

+

name: 'Links',

+

type: 'boolean',

+

defaultValue: false,

+

options: [

+

{ label: "Open links in a new tab",

+

value: true

+

},

+

{ label: "Open links in same tab",

+

value: false

+

}

+

]

+

}

+

]

+

}

+

]

+

});

+

provider.connect();

+

});

+

+

When a user visits the Orion Settings page, they'll see an automatically-generated UI containing a drop-down menu, similar to the one shown below. Manipulating the drop-down menu causes the setting's value to change, and causes any Managed Services registered against the <code>example.navconfig</code> PID to have their [[Orion/Documentation/Developer Guide/Configuration services#Service methods|<code>updated()</code> methods]] invoked.

The text link service scans text for segments that could be interpreted as hyperlinks, and inserts appropriate anchor elements representing each link. For example the service could scan for email addresses in a piece of text and convert them to mailto: links.

+

+

Here is an example of using the text link service:

+

+

var divWithLinks = linkService.addLinks(someText);

+

dojo.place(divWithLinks, body, "first");

+

+

The text link service makes use of [[Orion/Documentation/Developer_Guide/Plugging_into_Orion_pages#orion.core.linkScanner| link scanners]] contributed by plugins to perform the analysis and replacement of text with links. If no link scanners are available, the text link service simply returns a DOM element containing the entire input text.

Overview of core client services

Orion provides a number of basic infrastructure services that can be used by client scripts for performing various tasks. These services have no user interface component and can be used within any page of a client application. This section of the guide outlines what services are available, along with simple examples of how to use them.

orion.core.contentTypeRegistry

The orion.core.contentTypeRegistry service provides information about the Content Types that have been registered with Orion.

Here is an example usage showing how to query all registered content types and print them to the console:

See orion.core.ContentTypeRegistry in the Orion client API reference for a complete list of functions available.

orion.core.favorite

The orion.core.favorite service is used to access and store the user's bookmarks or favorites. While a user may opt to use their own browser's bookmark mechanism instead, there are some specific advantages to using Orion's favorite service instead:

Favorites are persisted on the server, so the user can switch to another client computer or browser and access their familiar bookmarks

Favorites are associated with a specific Orion application and user, so favorites from different users or applications are not all mixed into a single place.

Favorites are used to suggest file and folder based parameters for other actions in Orion, such as moving and copying files to a location, or finding specific files.

See orion.favorites.FavoritesService in the Orion client API reference for a complete list of functions available on the favorite service.

orion.core.file

The orion.core.file service is used to provide file system contents for the Orion workspace. For example a plug-in can use this service to include content from one server into a workspace on another server. Each file service is displayed as a root element in the Orion Navigator page.

The above code will contribute a top level node to the Navigator named "Sample File System". The parameter "service" in the API above must provide the functions specified by the Orion file client API. Refer to orion.fileClient.FileClient in the client API reference for further details. For more information on client-server interaction, see Orion File Server API. For an complete file system example, see the sample file plugin in the Orion Git repository.

Loads the workspace with the given id and sets it to be the current workspace for the IDE. The workspace is created if none already exists.Called by the Orion navigator when navigating to the root of the file system.NOTE: The returned file object should have a zero-length 'Parents' array to designate it as the root of the filesystem (see bug 392374).

createProject (url, projectName, serverPath, create)

Adds a project to a workspace.TODO -- the Orion IDE never calls this function for third-party file systems.

createFolder (parentLocation, folderName)

Creates a folder.Invoked when using the New Folder command in the Orion navigator.

createFile (parentLocation, fileName)

Create a new file in a specified location.Invoked when using the New File command in the Orion navigator.

deleteFile (location)

Deletes a file, directory, or project.Invoked when using the Delete command in the Orion navigator.

moveFile (sourceLocation, targetLocation, name)

Moves a file or directory.Invoked when using the Move and Cut..Paste commands in the Orion navigator.

copyFile (sourceLocation, targetLocation)

Copies a file or directory.Invoked when using the Copy..Paste commands in the Orion navigator.

Performs a search with the given query.Invoked by various search widgets that appear in the Orion UI.

This API is asynchronous: in other words, every API method is expected to return a promise that eventually resolves with the result object, or rejects if an error occurred.

orion.core.marker

The marker service is used to store problems found by a builder or syntax validator. A client can register with this service for notification when markers are changed. Here is an example of a component that is registering for notification of marker changes:

serviceRegistry.getService("orion.core.marker").addEventListener("problemsChanged",
function(problems) {
//do something with the new problems
});

Each marker is a simple JSON object with the following properties:

reason

A string stating the description of the problem or marker

line

The line number of the marker

character

The column position of the marker

orion.core.preference

The preferences service manages a hierarchical set of preference nodes. Nodes are identified by a path string, where segments are delimited by the slash character ('/'). Each node is a JSON object with string keys and values that are String, Boolean, or Number.

Here is an example of retrieving a preference storing the list of recently used projects:

orion.core.setting

Orion plugins can define settings using the orion.core.setting service. A setting defines some persistent information that is provided to one of the plugin's services. Defined settings appear on Orion's Settings page, and their values can be changed using an automatically-generated UI.

Metatype information, which defines the "shape" of the setting. Specifically, it defines what named properties appear in the setting and what data type they have (string, boolean, number, etc). The Settings page uses this Metatype information to generate appropriate UI widgets (for example, text field, checkbox, etc).

Service properties

To contribute one or more settings, the settings service property is used:

settings

Setting[]. Defines Settings. Each Setting element has the following shape:

pid

String. The PID for this setting. This PID occupies the same namespace as the PIDs contributed by Managed Services, and must be unique in that respect.

name

String. Human-readable name of this setting.

tags

String[]. Optional. List of tags applying to this setting.

properties

AttributeDefinition[]. Gives the properties that make up this setting. The shape of the AttributeDefinition element is explained in Metatype documentation.

Service methods

None. This service is completely declarative.

Examples

This example shows how to define a Setting with PID example.navconfig. This Setting has a single property newtab, which is boolean-typed. Because we've enumerated the property's possible values using an options, the generated UI presentation will show a drop-down menu. Since we've provided a defaultValue of false, the second option "Open links in a same tab" will selected by default.

When a user visits the Orion Settings page, they'll see an automatically-generated UI containing a drop-down menu, similar to the one shown below. Manipulating the drop-down menu causes the setting's value to change, and causes any Managed Services registered against the example.navconfig PID to have their updated() methods invoked.

See also

orion.core.textlink

The text link service scans text for segments that could be interpreted as hyperlinks, and inserts appropriate anchor elements representing each link. For example the service could scan for email addresses in a piece of text and convert them to mailto: links.

The text link service makes use of link scanners contributed by plugins to perform the analysis and replacement of text with links. If no link scanners are available, the text link service simply returns a DOM element containing the entire input text.