Skip to main content
Jump to: navigation, search

Orion/Documentation/Developer Guide/User interface services

< Orion‎ | Documentation‎ | Developer Guide
Revision as of 16:17, 16 June 2011 by John arthorne.ca.ibm.com (Talk | contribs) (orion.page.command)

Overview of user interface services

orion.page.selection

The selection service tracks the selection in the current page. A client can use this service to get or set the current

selection, or to register a listener that will be notified of selection changes.

Here is an example of adding a listener to track selection changes:

 serviceRegistry.getService("orion.page.selection").then(function(service) {
   service.addEventListener("selectionChanged", function(fileURI) {
     //do something with the selection
   });
 });

See orion.selection.Selection in the client API reference for a complete list of functions available on the selection service.

orion.page.command

The command service is responsible for managing and rendering commands such as tool bar and menu items. A command represents a single clickable action for a user, such as a toolbar button or menu item. Here is an example of a simple command definition:

 define(['orion/commands'], function(mCommands) {
   var editCommand = new mCommands.Command({
     name: "Edit",
     image: "/images/editing_16.gif",
     id: "my.command.id",
     visibleWhen: function(item) {
       //return true if this command should be visible for 'item'
     },
     callback: function(item, commandId, domId, propertyIndex) {
       //execute the command
     })
   });
 });

After defining a command, you need to register both the command itself, and a command contribution, which is a visible representation of the command in some menu. This snippet registers the above command, and a corresponding command contribution:

 serviceRegistry.getService("orion.page.command").then(function(commandService) {
   // register commands with object scope
   commandService.addCommand(editPropertyCommand, "object");
   // declare the contribution to the ui
   commandService.registerCommandContribution("my.command.id", 1);
 });

See orion.commands.CommandService in the client API reference for a complete list of functions available on the command service.

orion.page.dialog

orion.page.message

orion.page.link

Back to the top