本文整理汇总了Java中com.intellij.openapi.keymap.Keymap.addShortcut方法的典型用法代码示例。如果您正苦于以下问题:Java Keymap.addShortcut方法的具体用法?Java Keymap.addShortcut怎么用?Java Keymap.addShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.keymap.Keymap
的用法示例。
在下文中一共展示了Keymap.addShortcut方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addShortcut
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private void addShortcut(@NotNull final String actionIdString, @NotNull final String[] shortcuts) {
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
if (pairs == null) {
pairs = new ArrayList<>();
myDeletedShortcuts.put(keymap, pairs);
}
for (String shortcutString : shortcuts) {
Shortcut studyActionShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(shortcutString), null);
String[] actionsIds = keymap.getActionIds(studyActionShortcut);
for (String actionId : actionsIds) {
pairs.add(Pair.create(actionId, shortcutString));
keymap.removeShortcut(actionId, studyActionShortcut);
}
keymap.addShortcut(actionIdString, studyActionShortcut);
}
}
}
示例2: projectClosed
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@Override
public void projectClosed() {
final Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course != null) {
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).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 = myDeletedShortcuts.get(keymap);
if (pairs != null && !pairs.isEmpty()) {
for (Pair<String, String> actionShortcut : pairs) {
keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
}
}
}
}
myListener = null;
}
示例3: addShortcut
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private void addShortcut(@NotNull final String actionIdString, @NotNull final String[] shortcuts) {
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
if (pairs == null) {
pairs = new ArrayList<Pair<String, String>>();
myDeletedShortcuts.put(keymap, pairs);
}
for (String shortcutString : shortcuts) {
Shortcut studyActionShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(shortcutString), null);
String[] actionsIds = keymap.getActionIds(studyActionShortcut);
for (String actionId : actionsIds) {
pairs.add(Pair.create(actionId, shortcutString));
keymap.removeShortcut(actionId, studyActionShortcut);
}
keymap.addShortcut(actionIdString, studyActionShortcut);
}
}
}
示例4: projectClosed
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@Override
public void projectClosed() {
final Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course != null) {
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
if (toolWindow != null) {
toolWindow.getContentManager().removeAllContents(false);
}
final ToolWindow progressToolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(StudyProgressToolWindowFactory.ID);
if (progressToolWindow != null) {
progressToolWindow.getContentManager().removeAllContents(false);
}
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
if (pairs != null && !pairs.isEmpty()) {
for (Pair<String, String> actionShortcut : pairs) {
keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
}
}
}
}
myListener = null;
}
示例5: processMouseShortcutNode
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private static void processMouseShortcutNode(Element element, String actionId, PluginId pluginId) {
String keystrokeString = element.getAttributeValue(KEYSTROKE_ATTR_NAME);
if (keystrokeString == null || keystrokeString.trim().isEmpty()) {
reportActionError(pluginId, "\"keystroke\" attribute must be specified for action with id=" + actionId);
return;
}
MouseShortcut shortcut;
try {
shortcut = KeymapUtil.parseMouseShortcut(keystrokeString);
}
catch (Exception ex) {
reportActionError(pluginId, "\"keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
String keymapName = element.getAttributeValue(KEYMAP_ATTR_NAME);
if (keymapName == null || keymapName.isEmpty()) {
reportActionError(pluginId, "attribute \"keymap\" should be defined");
return;
}
Keymap keymap = KeymapManager.getInstance().getKeymap(keymapName);
if (keymap == null) {
reportActionError(pluginId, "keymap \"" + keymapName + "\" not found");
return;
}
final String removeOption = element.getAttributeValue(REMOVE_SHORTCUT_ATTR_NAME);
if (Boolean.valueOf(removeOption)) {
keymap.removeShortcut(actionId, shortcut);
} else {
keymap.addShortcut(actionId, shortcut);
}
}
示例6: doWithAltClickShortcut
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private static void doWithAltClickShortcut(ThrowableRunnable runnable) throws Throwable {
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
MouseShortcut shortcut = new MouseShortcut(1, InputEvent.ALT_DOWN_MASK, 1);
try {
keymap.addShortcut(IdeActions.ACTION_EDITOR_ADD_OR_REMOVE_CARET, shortcut);
runnable.run();
}
finally {
keymap.removeShortcut(IdeActions.ACTION_EDITOR_ADD_OR_REMOVE_CARET, shortcut);
}
}
示例7: processMouseShortcutNode
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private static void processMouseShortcutNode(Element element, String actionId, PluginId pluginId) {
String keystrokeString = element.getAttributeValue(KEYSTROKE_ATTR_NAME);
if (keystrokeString == null || keystrokeString.trim().length() == 0) {
reportActionError(pluginId, "\"keystroke\" attribute must be specified for action with id=" + actionId);
return;
}
MouseShortcut shortcut;
try {
shortcut = KeymapUtil.parseMouseShortcut(keystrokeString);
}
catch (Exception ex) {
reportActionError(pluginId, "\"keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
String keymapName = element.getAttributeValue(KEYMAP_ATTR_NAME);
if (keymapName == null || keymapName.length() == 0) {
reportActionError(pluginId, "attribute \"keymap\" should be defined");
return;
}
Keymap keymap = KeymapManager.getInstance().getKeymap(keymapName);
if (keymap == null) {
reportActionError(pluginId, "keymap \"" + keymapName + "\" not found");
return;
}
final String removeOption = element.getAttributeValue(REMOVE_SHORTCUT_ATTR_NAME);
if (Boolean.valueOf(removeOption)) {
keymap.removeShortcut(actionId, shortcut);
}
else {
keymap.addShortcut(actionId, shortcut);
}
}
示例8: processKeyboardShortcutNode
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private void processKeyboardShortcutNode(Element element, String actionId, PluginId pluginId) {
String firstStrokeString = element.getAttributeValue(FIRST_KEYSTROKE_ATTR_NAME);
if (firstStrokeString == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute must be specified for action with id=" + actionId);
return;
}
KeyStroke firstKeyStroke = getKeyStroke(firstStrokeString);
if (firstKeyStroke == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
KeyStroke secondKeyStroke = null;
String secondStrokeString = element.getAttributeValue(SECOND_KEYSTROKE_ATTR_NAME);
if (secondStrokeString != null) {
secondKeyStroke = getKeyStroke(secondStrokeString);
if (secondKeyStroke == null) {
reportActionError(pluginId, "\"second-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
}
String keymapName = element.getAttributeValue(KEYMAP_ATTR_NAME);
if (keymapName == null || keymapName.trim().isEmpty()) {
reportActionError(pluginId, "attribute \"keymap\" should be defined");
return;
}
Keymap keymap = myKeymapManager.getKeymap(keymapName);
if (keymap == null) {
reportActionWarning(pluginId, "keymap \"" + keymapName + "\" not found");
return;
}
final String removeOption = element.getAttributeValue(REMOVE_SHORTCUT_ATTR_NAME);
final KeyboardShortcut shortcut = new KeyboardShortcut(firstKeyStroke, secondKeyStroke);
final String replaceOption = element.getAttributeValue(REPLACE_SHORTCUT_ATTR_NAME);
if (Boolean.valueOf(removeOption)) {
keymap.removeShortcut(actionId, shortcut);
}
if (Boolean.valueOf(replaceOption)) {
keymap.removeAllActionShortcuts(actionId);
}
if (!Boolean.valueOf(removeOption)) {
keymap.addShortcut(actionId, shortcut);
}
}
示例9: setActivateAndroidToolWindowShortcut
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private static void setActivateAndroidToolWindowShortcut(Keymap keymap) {
KeyboardShortcut shortcut = removeFirstKeyboardShortcut(keymap, TODO_TOOLWINDOW_ACTION_ID);
if (shortcut != null) {
keymap.addShortcut(ANDROID_TOOLWINDOW_ACTION_ID, shortcut);
}
}
示例10: initComponent
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
public void initComponent(){
final Keymap keymap = KeymapManagerImpl.getInstance().getActiveKeymap();
keymap.addShortcut("generateTestMethod", new KeyboardShortcut(KeyStroke.getKeyStroke('U', InputEvent.CTRL_MASK + InputEvent.ALT_MASK), KeyStroke.getKeyStroke('U', 0)));
}
示例11: processKeyboardShortcutNode
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private void processKeyboardShortcutNode(Element element, String actionId, PluginId pluginId) {
String firstStrokeString = element.getAttributeValue(FIRST_KEYSTROKE_ATTR_NAME);
if (firstStrokeString == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute must be specified for action with id=" + actionId);
return;
}
KeyStroke firstKeyStroke = getKeyStroke(firstStrokeString);
if (firstKeyStroke == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
KeyStroke secondKeyStroke = null;
String secondStrokeString = element.getAttributeValue(SECOND_KEYSTROKE_ATTR_NAME);
if (secondStrokeString != null) {
secondKeyStroke = getKeyStroke(secondStrokeString);
if (secondKeyStroke == null) {
reportActionError(pluginId, "\"second-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
}
String keymapName = element.getAttributeValue(KEYMAP_ATTR_NAME);
if (keymapName == null || keymapName.trim().isEmpty()) {
reportActionError(pluginId, "attribute \"keymap\" should be defined");
return;
}
Keymap keymap = myKeymapManager.getKeymap(keymapName);
if (keymap == null) {
reportActionError(pluginId, "keymap \"" + keymapName + "\" not found");
return;
}
final String removeOption = element.getAttributeValue(REMOVE_SHORTCUT_ATTR_NAME);
final KeyboardShortcut shortcut = new KeyboardShortcut(firstKeyStroke, secondKeyStroke);
final String replaceOption = element.getAttributeValue(REPLACE_SHORTCUT_ATTR_NAME);
if (Boolean.valueOf(removeOption)) {
keymap.removeShortcut(actionId, shortcut);
}
if (Boolean.valueOf(replaceOption)) {
keymap.removeAllActionShortcuts(actionId);
}
if (!Boolean.valueOf(removeOption)) {
keymap.addShortcut(actionId, shortcut);
}
}
示例12: processKeyboardShortcutNode
import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private void processKeyboardShortcutNode(Element element, String actionId, PluginId pluginId) {
String firstStrokeString = element.getAttributeValue(FIRST_KEYSTROKE_ATTR_NAME);
if (firstStrokeString == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute must be specified for action with id=" + actionId);
return;
}
KeyStroke firstKeyStroke = getKeyStroke(firstStrokeString);
if (firstKeyStroke == null) {
reportActionError(pluginId, "\"first-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
KeyStroke secondKeyStroke = null;
String secondStrokeString = element.getAttributeValue(SECOND_KEYSTROKE_ATTR_NAME);
if (secondStrokeString != null) {
secondKeyStroke = getKeyStroke(secondStrokeString);
if (secondKeyStroke == null) {
reportActionError(pluginId, "\"second-keystroke\" attribute has invalid value for action with id=" + actionId);
return;
}
}
String keymapName = element.getAttributeValue(KEYMAP_ATTR_NAME);
if (keymapName == null || keymapName.trim().length() == 0) {
reportActionError(pluginId, "attribute \"keymap\" should be defined");
return;
}
Keymap keymap = myKeymapManager.getKeymap(keymapName);
if (keymap == null) {
reportActionError(pluginId, "keymap \"" + keymapName + "\" not found");
return;
}
final String removeOption = element.getAttributeValue(REMOVE_SHORTCUT_ATTR_NAME);
final KeyboardShortcut shortcut = new KeyboardShortcut(firstKeyStroke, secondKeyStroke);
final String replaceOption = element.getAttributeValue(REPLACE_SHORTCUT_ATTR_NAME);
if (Boolean.valueOf(removeOption)) {
keymap.removeShortcut(actionId, shortcut);
}
if (Boolean.valueOf(replaceOption)) {
keymap.removeAllActionShortcuts(actionId);
}
if (!Boolean.valueOf(removeOption)) {
keymap.addShortcut(actionId, shortcut);
}
}