Search in sources :

Example 1 with AddinCommandBinding

use of org.rstudio.core.client.command.AddinCommandBinding in project rstudio by rstudio.

the class AddinsCommandManager method registerBindings.

private void registerBindings(final EditorKeyBindings bindings, final CommandWithArg<EditorKeyBindings> afterLoad) {
    List<Pair<List<KeySequence>, CommandBinding>> commands = new ArrayList<Pair<List<KeySequence>, CommandBinding>>();
    RAddins rAddins = MainWindowObject.rAddins().get();
    for (String id : bindings.iterableKeys()) {
        List<KeySequence> keyList = bindings.get(id).getKeyBindings();
        RAddin addin = rAddins.get(id);
        if (addin == null)
            continue;
        CommandBinding binding = new AddinCommandBinding(addin);
        commands.add(new Pair<List<KeySequence>, CommandBinding>(keyList, binding));
    }
    KeyMap map = ShortcutManager.INSTANCE.getKeyMap(KeyMapType.ADDIN);
    for (int i = 0; i < commands.size(); i++) {
        map.setBindings(commands.get(i).first, commands.get(i).second);
    }
    if (afterLoad != null)
        afterLoad.execute(bindings);
}
Also used : RAddin(org.rstudio.studio.client.workbench.addins.Addins.RAddin) RAddins(org.rstudio.studio.client.workbench.addins.Addins.RAddins) ArrayList(java.util.ArrayList) AddinCommandBinding(org.rstudio.core.client.command.AddinCommandBinding) CommandBinding(org.rstudio.core.client.command.KeyMap.CommandBinding) AddinCommandBinding(org.rstudio.core.client.command.AddinCommandBinding) ArrayList(java.util.ArrayList) List(java.util.List) KeySequence(org.rstudio.core.client.command.KeyboardShortcut.KeySequence) Pair(org.rstudio.core.client.Pair) KeyMap(org.rstudio.core.client.command.KeyMap)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Pair (org.rstudio.core.client.Pair)1 AddinCommandBinding (org.rstudio.core.client.command.AddinCommandBinding)1 KeyMap (org.rstudio.core.client.command.KeyMap)1 CommandBinding (org.rstudio.core.client.command.KeyMap.CommandBinding)1 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)1 RAddin (org.rstudio.studio.client.workbench.addins.Addins.RAddin)1 RAddins (org.rstudio.studio.client.workbench.addins.Addins.RAddins)1