Example usage for org.eclipse.jface.bindings BindingManager getDefinedSchemes

List of usage examples for org.eclipse.jface.bindings BindingManager getDefinedSchemes

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings BindingManager getDefinedSchemes.

Prototype

public Scheme[] getDefinedSchemes() 

Source Link

Document

Returns the array of schemes that are defined.

Usage

From source file:org.eclipse.ui.internal.keys.BindingPersistence.java

License:Open Source License

/**
 * Reads all of the scheme definitions from the registry.
 * /*from   www .j  av  a 2 s.  c o  m*/
 * @param configurationElements
 *            The configuration elements in the commands extension point;
 *            must not be <code>null</code>, but may be empty.
 * @param configurationElementCount
 *            The number of configuration elements that are really in the
 *            array.
 * @param bindingManager
 *            The binding manager to which the schemes should be added; must
 *            not be <code>null</code>.
 */
private static final void readSchemesFromRegistry(final IConfigurationElement[] configurationElements,
        final int configurationElementCount, final BindingManager bindingManager) {
    // Undefine all the previous handle objects.
    final HandleObject[] handleObjects = bindingManager.getDefinedSchemes();
    if (handleObjects != null) {
        for (int i = 0; i < handleObjects.length; i++) {
            handleObjects[i].undefine();
        }
    }

    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
        final IConfigurationElement configurationElement = configurationElements[i];

        // Read out the attributes.
        final String id = readRequired(configurationElement, ATT_ID, warningsToLog, "Schemes need an id"); //$NON-NLS-1$
        if (id == null) {
            continue;
        }
        final String name = readRequired(configurationElement, ATT_NAME, warningsToLog, "A scheme needs a name", //$NON-NLS-1$
                id);
        if (name == null) {
            continue;
        }
        final String description = readOptional(configurationElement, ATT_DESCRIPTION);

        String parentId = configurationElement.getAttribute(ATT_PARENT_ID);
        if ((parentId != null) && (parentId.length() == 0)) {
            parentId = configurationElement.getAttribute(ATT_PARENT);
            if ((parentId != null) && (parentId.length() == 0)) {
                parentId = null;
            }
        }

        // Define the scheme.
        final Scheme scheme = bindingManager.getScheme(id);
        scheme.define(name, description, parentId);
    }

    logWarnings(warningsToLog,
            "Warnings while parsing the key bindings from the 'org.eclipse.ui.bindings', 'org.eclipse.ui.acceleratorConfigurations' and 'org.eclipse.ui.commands' extension point"); //$NON-NLS-1$
}

From source file:org.eclipse.ui.internal.keys.model.SchemeModel.java

License:Open Source License

/**
 * @param bindingManager// w  w w  . ja  v  a2  s.  com
 */
public void init(BindingManager bindingManager) {
    schemes = new ArrayList();
    Scheme[] definedSchemes = bindingManager.getDefinedSchemes();
    for (int i = 0; i < definedSchemes.length; i++) {
        SchemeElement se = new SchemeElement(controller);
        se.init(definedSchemes[i]);
        se.setParent(this);
        schemes.add(se);
        if (definedSchemes[i] == bindingManager.getActiveScheme()) {
            setSelectedElement(se);
        }
    }
}