Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Orion/Documentation/Developer Guide/Plugging into the settings page"

(Examples)
(Examples)
Line 26: Line 26:
  
 
== Examples ==
 
== 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, with the second option "Open links in a same tab" selected by default.
+
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) {
 
  define(['orion/plugin'], function(PluginProvider) {
Line 46: Line 46:
 
                               {  label: "Open links in same tab",
 
                               {  label: "Open links in same tab",
 
                                 value: false
 
                                 value: false
                               },
+
                               }
 
                           ]
 
                           ]
 
                       }
 
                       }

Revision as of 11:02, 11 September 2012

Overview

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

A Setting is a combination of two more basic configuration elements:

  • A PID (persistent identifier), which uniquely identifies the configuration data for the setting.
  • 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).

orion.core.setting

The orion.core.setting service contributes one or more settings.

Service properties

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

settings
Setting[]. Defines Settings.
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
PropertyType[]. Gives the properties that make up this setting. The shape of the PropertyType 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.

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();
});

See also

Back to the top