Search in sources :

Example 1 with ExecuteUserCommandEvent

use of org.rstudio.studio.client.server.remote.ExecuteUserCommandEvent in project rstudio by rstudio.

the class UserCommandManager method onRegisterUserCommand.

private void onRegisterUserCommand(RegisterUserCommandEvent event) {
    final String name = event.getData().getName();
    JsArrayString shortcutStrings = event.getData().getShortcuts();
    for (int i = 0; i < shortcutStrings.length(); i++) {
        String shortcutString = shortcutStrings.get(i);
        KeySequence sequence = KeySequence.fromShortcutString(shortcutString);
        assert sequence != null : "Failed to parse string '" + shortcutString + "'";
        KeyboardShortcut shortcut = new KeyboardShortcut(sequence);
        UserCommand command = new UserCommand(name, new Command() {

            @Override
            public void execute() {
                events_.fireEvent(new ExecuteUserCommandEvent(name));
            }
        });
        commandMap_.put(shortcut, command);
    }
}
Also used : Command(com.google.gwt.user.client.Command) ExecuteUserCommandEvent(org.rstudio.studio.client.server.remote.ExecuteUserCommandEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) KeySequence(org.rstudio.core.client.command.KeyboardShortcut.KeySequence)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)1 Command (com.google.gwt.user.client.Command)1 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)1 ExecuteUserCommandEvent (org.rstudio.studio.client.server.remote.ExecuteUserCommandEvent)1