Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Orion/Client API
Orion client API can roughly be divided into services and library objects. Services are obtained via a service registry, rather than instantiated by the client code. All interaction with services are asynchronous. If there is a return value to be obtained from the service, it is provided via a callback object passed in by the client.
Library objects are either stateless objects providing utility functions, or statefull objects that are instantiated directly by each client that needs one. Library objects never contain shared state that is available to multiple plugins or services.
Contents
Services
Command Service
- eclipse.CommandService
- The command service manages the available commands.
- eclipse.Command
- A command is an object that describes an action a user can perform, as well as when and what it should look like when presented in various contexts.
- eclipse.KeyBinding
- A KeyBinding represents of a key code and a modifier state that can be triggered by the user using the keyboard.
Dialog Service
- eclipse.DialogService
- Common dialog services
Explorer Service
- eclipse.Explorer
- A table-based explorer component
- eclipse.Model
- Tree model used by eclipse.Explorer.
- eclipse.TreeModel
- Tree model used by eclipse.ExplorerTree.
File Service
- eclipse.FileService
- Provides operations on files, folders, and projects.
Getting directory contents
- Function
- getChildren(parentItem, updateFunction)
- Overview
- Get all the files and sub-directories of a directory.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise no return value.
- Example Code
this.registry.callService("IFileService", "getChildren", null, [parentItem,
dojo.hitch(this, function(parent, children) {
onComplete(children);
if(postExpandFunc)
postExpandFunc(args);
})]);
- Detailed Explanation
- This service uses server directory service.As shown in the example above , this service user uses the children to do something by the function onComplete. See also service registry.
Creating work space
- Function
- createWorkspace(name, onCreate)
- Overview
- Creates a new workspace with the given name , using server workspace service
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise jsonData.
- Example Code
this.createWorkspace("MyWorkspace", onLoad);
- Detailed Explanation
Loading work space
- Function
- loadWorkspace(location, onLoad)
- Overview
- Loads the workspace with the given id and sets it to be the current workspace.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise the response JSON representation from server workspace service.
- Example Code
this.registry.callService("IFileService", "loadWorkspace", null, [path, function(jsonData){//do something with jsonData}]);
- Detailed Explanation
- This service uses server workspace service.As shown in the example above , the service user uses the JSON representation to do something. See also service registry.
Creating folder
- Function
- createFolder(name, baseItem, updateFunction)
- Overview
- Creates a folder by given name under a base folder.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise the response JSON representation from server directory creation.
- Example Code
this.registry.callService("IFileService", "createFolder", null, [name, item, dojo.hitch(this, function(item){
this.registry.callService("IFileService", "getChildren", null, [item, dojo.hitch(this.myTree, this.myTree.refreshAndExpand)])}]);
- Detailed Explanation
- This service uses server directory creation. As shown in the example above , the service user uses the baseItem to call the Getting directorycontents to render the new folder , with its siblings. See also service registry.
Creating file
- Function
- createFile(fileName, baseItem, updateFunction)
- Overview
- Creates a file by given name under a base folder. See also folder creation
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise the response JSON representation from server file creation.
- Example Code
this.registry.callService("IFileService", "createFile", null, [name, item, dojo.hitch(this, function(item){
this.registry.callService("IFileService", "getChildren", null, [item, dojo.hitch(this.myTree, this.myTree.refreshAndExpand)])}]);
- Detailed Explanation
- This service uses server file creation. As shown in the example above , the service user uses the baseItem to call the Getting directory contents to render the new file , with its siblings. See also service registry.
Deleting a file or folder
- Function
- deleteFile(item, updateFunction)
- Overview
- Delete a file or folder by given item.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- Error response if fails otherwise the response JSON representation from server file deletion.
- Example Code
this.registry.callService("IFileService", "deleteFile", null, [name, item, dojo.hitch(this, function(item){
this.registry.callService("IFileService", "getChildren", null, [item, dojo.hitch(this.myTree, this.myTree.refreshAndExpand)])}]);
- Detailed Explanation
- This service uses server file deletion. As shown in the example above , the service user uses the item to call the Getting directory contents to render the item's parent in order to remove the file or folder visually. See also service registry.
Editing Services
- eclipse.InputService
- Services for editor inputs
- eclipse.SaveableService
- Service for saving things
Log Service
- eclipse.LogService
- Services for logging
- eclipse.StatusReportingService
- Service for reporting status
Preferences
- eclipse.Preferences
- A preference object provides functions for accessing and setting preferences
Getting preference
- Function
- get(key, onDone)
- Overview
- Retrieves the preference with the given key.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- A null value is returned if there is no preference defined or if there was an error retrieving the value.
- Example Code
this._registry.callService("IPreferenceService", "get", null, ["jsunit_test/configs", function(prefs) {
if (prefs) {
var prefJson = JSON.parse(prefs);
for (var i = 0 ; i < prefJson.length ; i++) {
var configValues = prefJson[i].value;
var config = {name:prefJson[i].name, value:[]};
}
}
}]);
- Detailed Explanation
- This service uses server preference API. As shown in the example above , the service user uses the prefs as JSON data . See also service registry.
Putting preference
- Function
- put(key, value)
- Overview
- Sets the preference with the given key to the provided value.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- no return value on success but error response on failure.
- Example Code
this._registry.callService("IPreferenceService", "put", null, ["jsunit_test/configs", JSON.stringify(storedConfigs)]);
- Detailed Explanation
- See also service registry.
Selection Service
- eclipse.SelectionService
- Service for providing selections
User Service
- eclipse.UserService
- Service for keeping track of the user
Library Objects
Editor
The following objects are related to the Orion rich text editor found in editor.js.
- eclipse.Editor
- A Editor is a user interface for editing text.
- eclipse.DestroyEvent
- This is the event sent when the editor is destroyed.
- eclipse.LineStyleEvent
- This is the event sent when the editor needs the style information for a line.
- eclipse.ModelChangedEvent
- This is the event sent when the text in the model has changed.
- eclipse.ModelChangingEvent
- This is the event sent when the text in the model is about to change.
- eclipse.ModifyEvent
- This is the event sent when the text is modified by the editor.
- eclipse.Ruler
- This interface represents a ruler for the editor.
- eclipse.ScrollEvent
- This is the event sent when the editor scrolls.
- eclipse.Selection
- A Selection represents a range of selected text in the editor.
- eclipse.SelectionEvent
- This is the event sent when the selection changes in the editor.
- eclipse.Style
- This object is used to define style information for the editor.
- eclipse.StyleRange
- This object is used to style range.
- eclipse.TextModel
- The TextModel is an interface that provides text for the editor.
- eclipse.VerifyEvent
- This is the event sent when the text is about to be modified by the editor.
Outliner
- eclipse.Outliner
- An Outliner provides an itemized overview of a resource and acts as a selection provider on that resource.
Search
- eclipse.Searcher
- Provides API for searching the workspace.
Service Registry
The service registry is somewhat unusual as a library object. Although a client can directly instantiate a private service registry and populate it with their own services, a registry is more typically passed into services and plug-ins upon construction. This avoids objects having to "reach out" and know who or what defines a given service.
The following objects are all related to the service registry:
- eclipse.Plugin
- A plugin is an object that is isolated in its own frame, and obtains and provides services via the asynchronous postMessage mechanism.
- eclipse.Registry
- The registry manages the set of available plugins.
- eclipse.Service
- Represents a concrete service instance.
- eclipse.ServiceProvider
- A Service Provider is an object that implements a Service Type
- eclipse.ServiceReference
- A ServiceReference enables services to be called and released.
Registering a local service
- Function
- registerLocalService(serviceType, id, serviceImpl, properties)
- Overview
- Registers a local service implementation in the service registry.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- No return value.
- Example Code
registry.registerLocalService("ITestConfigs", "TestConfigService", new eclipse.TestConfigService({serviceRegistry: registry}));
- Detailed Explanation
Calling a registered service
- Function
- callService(serviceType, methodName, callback, params, instanceId)
- Overview
- Registers a local service implementation in the service registry.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- No return value.
- Example Code
this.registry.callService("IFileService", "createFile", null, [name, item, dojo.hitch(this, this.changedItem)]);
- Detailed Explanation
Table tree
- eclipse.TableTree
- Generates an HTML table where one of the columns is indented according to depth of children.
Constructing A Table Tree
- Function
- TableTree (options)
- Overview
- Generates an HTML table where one of the columns is indented according to depth of children.
- Parameters
- Template:EclipseWeb/ParamHead
- Return Value
- No return value.
- Example Code
this._navTree = new eclipse.TableTree({id: this._navTreeId,model: this._navModel,showRoot: true,parent: this._navDivId,labelColumnIndex: 1,renderer: this._renderer});
- Detailed Explanation
- A renderer can be supplied which generates the HTML table row for each child. Custom rendering allows clients to use checkboxes, images, links, etc. to describe each element in the tree. Renderers handle all clicks and other behavior via their supplied row content.
Utilities
- eclipse.util
- eclipse.util holds stateless utility methods.