use of com.intellij.openapi.keymap.Keymap in project intellij-community by JetBrains.
the class ActionsWithoutUpdateMethodTest method testActionsWithShortcuts.
public void testActionsWithShortcuts() throws Exception {
Set<String> ids = new HashSet<>();
for (String id : ((ActionManagerImpl) ActionManager.getInstance()).getActionIds()) {
for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
if (keymap.getShortcuts(id).length > 0 && !PLATFORM_WIDE_ACTIONS.contains(id)) {
ids.add(id);
}
}
}
ActionManager mgr = ActionManager.getInstance();
ArrayList<AnAction> failed = new ArrayList<>();
for (String id : ids) {
AnAction action = mgr.getAction(id);
if (action == null) {
System.out.println("Can't find action: " + id);
continue;
}
Method updateMethod = action.getClass().getMethod("update", AnActionEvent.class);
if (updateMethod.getDeclaringClass() == AnAction.class) {
failed.add(action);
}
}
for (AnAction action : failed) {
System.out.println(action + " ID: " + mgr.getId(action) + " Class: " + action.getClass());
}
assertEmpty("The following actions have shortcuts, but don't have update() method redefined", failed);
}
use of com.intellij.openapi.keymap.Keymap in project intellij-community by JetBrains.
the class MavenShortcutsManagerTest method assignShortcut.
private void assignShortcut(VirtualFile pomFile, String goal, String shortcut) {
MavenProject mavenProject = myProjectsManager.findProject(pomFile);
assert mavenProject != null;
String actionId = myShortcutsManager.getActionId(mavenProject.getPath(), goal);
assert actionId != null;
AnAction action = ActionManager.getInstance().getAction(actionId);
if (action == null) {
MavenKeymapExtension.getOrRegisterAction(mavenProject, actionId, goal);
}
Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
activeKeymap.addShortcut(actionId, KeyboardShortcut.fromString(shortcut));
}
use of com.intellij.openapi.keymap.Keymap in project intellij-plugins by StepicOrg.
the class StudyProjectComponent method projectClosed.
@Override
public void projectClosed() {
if (!StepikProjectManager.isStepikProject(project)) {
return;
}
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
if (toolWindow != null) {
toolWindow.getContentManager().removeAllContents(false);
}
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
List<Pair<String, String>> pairs = deletedShortcuts.get(keymap);
if (pairs != null && !pairs.isEmpty()) {
for (Pair<String, String> actionShortcut : pairs) {
keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
}
}
}
}
Aggregations