### Schemes

Schemes are used to represent a general style or theme of bindings. For example, the Workbench provides a "Default" scheme and an "Emacs" scheme. Only one scheme is active at any given time. End users control which one is active using the General > Keys preference page.

From an implementation point of view, schemes are simply named groupings of bindings. A scheme won't accomplish anything on its own unless there are bindings associated with it.

Let's look again at the workbench markup for org.eclipse.ui.bindings to find the binding definitions and how a scheme gets associated with a binding.

    ...
    <key
           sequence="Ctrl+S"
           commandId="org.eclipse.ui.file.save"
           schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
    </key>
    ...
    <key
           sequence="Ctrl+X Ctrl+S"
           commandId="org.eclipse.ui.file.save"
           schemeId="org.eclipse.ui.emacsAcceleratorConfiguration">
    </key>
    ...

There are two different key bindings defined for the "org.eclipse.ui.file.save" command. Note that each one has a different schemeId defined. When the default scheme is active, the "Ctrl+S" key binding will invoke the command. When the emacs scheme is active, the sequence "Ctrl+X Ctrl+S" will invoke the command.

#### Defining new schemes

When your plug-in defines a binding, it will most likely assign it to an existing scheme. However, your plug-in may want to define a completely new style of scheme. If this is the case, you can define a new type of scheme inside the org.eclipse.ui.bindings definition. The workbench markup that defines the default and emacs key configurations are shown below:

    ...
    <scheme
           name="%keyConfiguration.default.name"
           description="%keyConfiguration.default.description"
           id="org.eclipse.ui.defaultAcceleratorConfiguration">
    </scheme>
    <scheme
           name="%keyConfiguration.emacs.name"
           parentId="org.eclipse.ui.defaultAcceleratorConfiguration"
           description="%keyConfiguration.emacs.description"
           id="org.eclipse.ui.emacsAcceleratorConfiguration">
    </scheme>
    ...

Note that the name defined here is the one used in the preferences page in the list of schemes.

#### Activating a scheme

The user controls the active scheme via the preferences page. However, you can define the default active scheme as a part of the "plugin_customization.ini" file. It is a preference:

    org.eclipse.ui/KEY_CONFIGURATION_ID=org.eclipse.ui.defaultAcceleratorConfiguration