本文整理汇总了Java中com.intellij.openapi.keymap.Keymap类的典型用法代码示例。如果您正苦于以下问题:Java Keymap类的具体用法?Java Keymap怎么用?Java Keymap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Keymap类属于com.intellij.openapi.keymap包,在下文中一共展示了Keymap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyboardShortcutsText
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
/**
* Uses an actionID to access the key-map of IDEA and find possible short-cuts
* @param myIdeaActionID ActionID to look the shortcut up
* @return a string combining one or more shortcuts
*/
static String getKeyboardShortcutsText(String myIdeaActionID) {
final Keymap activeKeymap = keyMapManager.getActiveKeymap();
Shortcut[] shortcuts = activeKeymap.getShortcuts(myIdeaActionID);
if (shortcuts.length == 0) {
return "";
}
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < shortcuts.length; i++) {
Shortcut shortcut = shortcuts[i];
if (i > 0) {
buffer.append(" or ");
}
buffer.append("'").append(KeymapUtil.getShortcutText(shortcut)).append("'");
}
return buffer.toString();
}
示例2: 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);
}
}
}
示例3: 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;
}
示例4: getActivateToolWindowVKs
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
public static Set<Integer> getActivateToolWindowVKs() {
if (ApplicationManager.getApplication() == null) return new HashSet<Integer>();
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
Shortcut[] baseShortcut = keymap.getShortcuts("ActivateProjectToolWindow");
int baseModifiers = 0;
for (Shortcut each : baseShortcut) {
if (each instanceof KeyboardShortcut) {
KeyStroke keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
baseModifiers = keyStroke.getModifiers();
if (baseModifiers > 0) {
break;
}
}
}
return QuickAccessSettings.getModifiersVKs(baseModifiers);
}
示例5: EditorsSplitters
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
EditorsSplitters(final FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) {
super(new BorderLayout());
myManager = manager;
myFocusWatcher = new MyFocusWatcher();
setFocusTraversalPolicy(new MyFocusTraversalPolicy());
clear();
if (createOwnDockableContainer) {
DockableEditorTabbedContainer dockable = new DockableEditorTabbedContainer(myManager.getProject(), this, false);
Disposer.register(manager.getProject(), dockable);
dockManager.register(dockable);
}
KeymapManagerListener keymapListener = new KeymapManagerListener() {
@Override
public void activeKeymapChanged(Keymap keymap) {
invalidate();
repaint();
}
};
KeymapManager.getInstance().addKeymapManagerListener(keymapListener, this);
UISettings.getInstance().addUISettingsListener(this, this);
}
示例6: reset
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
private void reset(@NotNull Keymap keymap, @NotNull QuickList[] allQuickLists, String filter, @Nullable KeyboardShortcut shortcut) {
myKeymap = keymap;
final PathsKeeper pathsKeeper = new PathsKeeper();
pathsKeeper.storePaths();
myRoot.removeAllChildren();
ActionManager actionManager = ActionManager.getInstance();
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent));
Group mainGroup = ActionsTreeUtil.createMainGroup(project, keymap, allQuickLists, filter, true,
ActionsTreeUtil.isActionFiltered(actionManager, keymap, shortcut, filter, true));
if ((filter != null && filter.length() > 0 || shortcut != null) && mainGroup.initIds().isEmpty()){
mainGroup = ActionsTreeUtil.createMainGroup(project, keymap, allQuickLists, filter, false,
ActionsTreeUtil.isActionFiltered(actionManager, keymap, shortcut, filter, false));
}
myRoot = ActionsTreeUtil.createNode(mainGroup);
myMainGroup = mainGroup;
MyModel model = (MyModel)myTree.getModel();
model.setRoot(myRoot);
model.nodeStructureChanged(myRoot);
pathsKeeper.restorePaths();
}
示例7: isActionFiltered
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
public static Condition<AnAction> isActionFiltered(final ActionManager actionManager,
final Keymap keymap,
final KeyboardShortcut keyboardShortcut) {
return new Condition<AnAction>() {
public boolean value(final AnAction action) {
if (keyboardShortcut == null) return true;
if (action == null) return false;
final Shortcut[] actionShortcuts =
keymap.getShortcuts(action instanceof ActionStub ? ((ActionStub)action).getId() : actionManager.getId(action));
for (Shortcut shortcut : actionShortcuts) {
if (shortcut instanceof KeyboardShortcut) {
final KeyboardShortcut keyboardActionShortcut = (KeyboardShortcut)shortcut;
if (Comparing.equal(keyboardActionShortcut, keyboardShortcut)) {
return true;
}
}
}
return false;
}
};
}
示例8: ChooseActionsDialog
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
super(parent, true);
myKeymap = keymap;
myQuicklists = quicklists;
myActionsTree = new ActionsTree();
myActionsTree.reset(keymap, quicklists);
myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent e) {
doOKAction();
return true;
}
}.installOn(myActionsTree.getTree());
myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());
setTitle("Add Actions to Quick List");
init();
}
示例9: getMnemonicForToolWindow
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
/**
* @return mnemonic for action if it has Alt+digit/Meta+digit shortcut.
* Otherwise the method returns <code>-1</code>. Meta mask is OK for
* Mac OS X user, because Alt+digit types strange characters into the
* editor.
*/
public static int getMnemonicForToolWindow(String id) {
Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id));
for (Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
int modifiers = keyStroke.getModifiers();
if (
modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) ||
modifiers == InputEvent.ALT_MASK ||
modifiers == InputEvent.ALT_DOWN_MASK ||
modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) ||
modifiers == InputEvent.META_MASK ||
modifiers == InputEvent.META_DOWN_MASK
) {
int keyCode = keyStroke.getKeyCode();
if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) {
char c = (char)('0' + keyCode - KeyEvent.VK_0);
return (int)c;
}
}
}
}
return -1;
}
示例10: getShortcuts
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
@NotNull
private static Set<KeyStroke> getShortcuts(@NotNull String actionId) {
Set<KeyStroke> result = new HashSet<KeyStroke>();
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
Shortcut[] shortcuts = keymap.getShortcuts(actionId);
if (shortcuts == null) {
return result;
}
for (Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
result.add(keyboardShortcut.getFirstKeyStroke());
}
}
return result;
}
示例11: patchKeymap
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
private static void patchKeymap() {
Set<String> droppedActions = ContainerUtil.newHashSet(
"AddToFavoritesPopup",
"DatabaseView.ImportDataSources",
"CompileDirty", "Compile",
// hidden
"AddNewFavoritesList", "EditFavorites", "RenameFavoritesList", "RemoveFavoritesList");
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
if (keymap.canModify()) continue;
KeymapImpl keymapImpl = (KeymapImpl)keymap;
for (String id : keymapImpl.getOwnActionIds()) {
if (droppedActions.contains(id)) keymapImpl.clearOwnActionsId(id);
}
}
}
示例12: 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);
}
}
}
示例13: 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;
}
示例14: setActivateAndroidToolWindowShortcut
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
private static void setActivateAndroidToolWindowShortcut() {
// The IntelliJ keymap implementation behaves as follows:
// - getting a shortcut from a keymap gets the shortcut only from that keymap, and not from its parent, unless no shortcuts
// are defined in the keymap itself
// - however, adding a shortcut to a keymap explicitly copies all the shortcuts for that action from the parent keymap to this keymap
// The upshot of all this is that to add a shortcut, we should do so in all the child keymaps first, then the parent keymap.
// The following code does a simplified implementation of this behavior by changing the default keymap last after all the other
// keymaps have been changed.
Keymap defaultKeymap = null;
for (Keymap keymap: KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(keymap.getName())) {
defaultKeymap = keymap;
continue;
}
setActivateAndroidToolWindowShortcut(keymap);
}
if (defaultKeymap != null) {
setActivateAndroidToolWindowShortcut(defaultKeymap);
}
}
示例15: reset
import com.intellij.openapi.keymap.Keymap; //导入依赖的package包/类
private void reset(final Keymap keymap, final QuickList[] allQuickLists, String filter, @Nullable KeyboardShortcut shortcut) {
myKeymap = keymap;
final PathsKeeper pathsKeeper = new PathsKeeper();
pathsKeeper.storePaths();
myRoot.removeAllChildren();
ActionManager actionManager = ActionManager.getInstance();
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent));
Group mainGroup = ActionsTreeUtil.createMainGroup(project, myKeymap, allQuickLists, filter, true, filter != null && filter.length() > 0 ?
ActionsTreeUtil.isActionFiltered(filter, true) :
(shortcut != null ? ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut) : null));
if ((filter != null && filter.length() > 0 || shortcut != null) && mainGroup.initIds().isEmpty()){
mainGroup = ActionsTreeUtil.createMainGroup(project, myKeymap, allQuickLists, filter, false, filter != null && filter.length() > 0 ?
ActionsTreeUtil.isActionFiltered(filter, false) :
ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut));
}
myRoot = ActionsTreeUtil.createNode(mainGroup);
myMainGroup = mainGroup;
MyModel model = (MyModel)myTree.getModel();
model.setRoot(myRoot);
model.nodeStructureChanged(myRoot);
pathsKeeper.restorePaths();
}