mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support for double shortcuts in shortcuts collector
This commit is contained in:
@@ -59,19 +59,34 @@ public class ShortcutsCollector implements PersistentStateComponent<ShortcutsCol
|
||||
}
|
||||
|
||||
public static void record(AnActionEvent event) {
|
||||
_record(event, false);
|
||||
}
|
||||
|
||||
public static void recordDoubleShortcut(AnActionEvent event) {
|
||||
_record(event, true);
|
||||
}
|
||||
|
||||
private static void _record(AnActionEvent event, boolean isDoubleShortcut) {
|
||||
InputEvent e = event.getInputEvent();
|
||||
if (e instanceof KeyEvent) {
|
||||
KeyboardShortcut shortcut = new KeyboardShortcut(KeyStroke.getKeyStrokeForEvent((KeyEvent)e), null);
|
||||
String key = KeymapUtil.getShortcutText(shortcut);
|
||||
ShortcutsCollector collector = getInstance();
|
||||
|
||||
if (collector == null) return; //no shortcuts stats for the IDE
|
||||
|
||||
Map<String, Integer> values = collector.getState().myValues;
|
||||
values.put(key, ContainerUtil.getOrElse(values, key, 0) + 1);
|
||||
if (isDoubleShortcut) {
|
||||
key = SystemInfo.isMac ? key + key : key + "+" + key;
|
||||
}
|
||||
incValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static void incValue(String key) {
|
||||
ShortcutsCollector collector = getInstance();
|
||||
|
||||
if (collector == null) return; //no shortcuts stats for the IDE
|
||||
|
||||
Map<String, Integer> values = collector.getState().myValues;
|
||||
values.put(key, ContainerUtil.getOrElse(values, key, 0) + 1);
|
||||
}
|
||||
|
||||
|
||||
private static ShortcutsCollector getInstance() {
|
||||
return ServiceManager.getService(ShortcutsCollector.class);
|
||||
|
||||
+2
@@ -17,6 +17,7 @@ package com.intellij.openapi.keymap.impl;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.internal.statistic.ShortcutsCollector;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
@@ -260,6 +261,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom
|
||||
myActionManagerEx.fireBeforeActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
action.actionPerformed(anActionEvent);
|
||||
myActionManagerEx.fireAfterActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
ShortcutsCollector.recordDoubleShortcut(anActionEvent);
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user