本文整理汇总了Java中com.intellij.openapi.keymap.KeymapManager类的典型用法代码示例。如果您正苦于以下问题:Java KeymapManager类的具体用法?Java KeymapManager怎么用?Java KeymapManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeymapManager类属于com.intellij.openapi.keymap包,在下文中一共展示了KeymapManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebound
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void rebound() {
final KeymapManager mgr = getKeymapManager();
if (mgr == null) return;
myActionId = ActionManager.getInstance().getId(myCopyFromAction);
if (myPresentation == null) {
myAction.copyFrom(myCopyFromAction);
} else {
myAction.getTemplatePresentation().copyFrom(myPresentation);
myAction.copyShortcutFrom(myCopyFromAction);
}
unregisterAll();
myKeymap = mgr.getActiveKeymap();
myKeymap.addShortcutChangeListener(myKeymapListener);
if (myActionId == null) return;
final Shortcut[] shortcuts = myKeymap.getShortcuts(myActionId);
myShortcutSet = new CustomShortcutSet(shortcuts);
myAction.registerCustomShortcutSet(myShortcutSet, myComponent);
}
示例2: getActivateToolWindowVKs
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的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);
}
示例3: init
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void init() {
setFocusable(false);
setBackground(ourBackgroundColor);
final Border border = JBUI.Borders.empty(5, 5, 0, 5);
setBorder(border);
updatePresentation();
apply(myDecorator.getWindowInfo());
addActionListener(this);
addMouseListener(new MyPopupHandler());
setRolloverEnabled(true);
setOpaque(false);
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(final MouseEvent e) {
processDrag(e);
}
});
KeymapManager.getInstance().addKeymapManagerListener(myKeymapListener, this);
}
示例4: EditorsSplitters
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的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);
}
示例5: getKeymapPresentableName
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
@Override
public String getKeymapPresentableName(@NotNull KeymapImpl keymap) {
final String name = keymap.getName();
if (getDefaultKeymapName().equals(name)) {
return "Default";
}
if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(name)) {
return "IntelliJ IDEA Classic" + (SystemInfo.isMac ? " (Windows)" : "");
}
if ("Mac OS X".equals(name)) {
return "IntelliJ IDEA Classic (OS X)";
}
return super.getKeymapPresentableName(keymap);
}
示例6: getInputEvent
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
public static InputEvent getInputEvent(String actionName) {
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionName);
KeyStroke keyStroke = null;
for (Shortcut each : shortcuts) {
if (each instanceof KeyboardShortcut) {
keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
break;
}
}
if (keyStroke != null) {
return new KeyEvent(JOptionPane.getRootFrame(),
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
keyStroke.getModifiers(),
keyStroke.getKeyCode(),
keyStroke.getKeyChar(),
KeyEvent.KEY_LOCATION_STANDARD);
} else {
return new MouseEvent(JOptionPane.getRootFrame(), MouseEvent.MOUSE_PRESSED, 0, 0, 0, 0, 1, false, MouseEvent.BUTTON1);
}
}
示例7: init
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void init() {
setVisible(myPresentation.isVisible());
setEnabled(myPresentation.isEnabled());
setMnemonic(myEnableMnemonics ? myPresentation.getMnemonic() : 0);
setText(myPresentation.getText());
final int mnemonicIndex = myEnableMnemonics ? myPresentation.getDisplayedMnemonicIndex() : -1;
if (getText() != null && mnemonicIndex >= 0 && mnemonicIndex < getText().length()) {
setDisplayedMnemonicIndex(mnemonicIndex);
}
AnAction action = myAction.getAction();
updateIcon(action);
String id = ActionManager.getInstance().getId(action);
if (id != null) {
setAcceleratorFromShortcuts(KeymapManager.getInstance().getActiveKeymap().getShortcuts(id));
}
else {
final ShortcutSet shortcutSet = action.getShortcutSet();
if (shortcutSet != null) {
setAcceleratorFromShortcuts(shortcutSet.getShortcuts());
}
}
}
示例8: getMnemonicForToolWindow
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的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;
}
示例9: createActionLabel
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
protected JLabel createActionLabel(AnAction anAction, String anActionName,
Color fg, Color bg,
Icon icon) {
LayeredIcon layeredIcon = new LayeredIcon(2);
layeredIcon.setIcon(EMPTY_ICON, 0);
if (icon != null && icon.getIconWidth() <= EMPTY_ICON.getIconWidth() && icon.getIconHeight() <= EMPTY_ICON.getIconHeight()) {
layeredIcon
.setIcon(icon, 1, (-icon.getIconWidth() + EMPTY_ICON.getIconWidth()) / 2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight()) / 2);
}
Shortcut shortcut = preferKeyboardShortcut(KeymapManager.getInstance().getActiveKeymap().getShortcuts(getActionId(anAction)));
String actionName = anActionName + (shortcut != null ? " (" + KeymapUtil.getShortcutText(shortcut) + ")" : "");
JLabel actionLabel = new JLabel(actionName, layeredIcon, SwingConstants.LEFT);
actionLabel.setBackground(bg);
actionLabel.setForeground(fg);
return actionLabel;
}
示例10: getShortcuts
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的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: setActivateAndroidToolWindowShortcut
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的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);
}
}
示例12: init
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void init() {
setFocusable(false);
setBackground(ourBackgroundColor);
final Border border = BorderFactory.createEmptyBorder(5, 5, 0, 5);
setBorder(border);
updateText();
updateState();
apply(myDecorator.getWindowInfo());
myDecorator.getToolWindow().addPropertyChangeListener(myToolWindowHandler);
addActionListener(this);
addMouseListener(new MyPopupHandler());
setRolloverEnabled(true);
setOpaque(false);
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(final MouseEvent e) {
processDrag(e);
}
});
KeymapManager.getInstance().addKeymapManagerListener(myKeymapListener);
}
示例13: includeSelectedAction
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void includeSelectedAction() {
final ChooseActionsDialog dlg = new ChooseActionsDialog(myActionsList, KeymapManager.getInstance().getActiveKeymap(), myAllQuickLists);
dlg.show();
if (dlg.isOK()) {
String[] ids = dlg.getTreeSelectedActionIds();
for (String id : ids) {
includeActionId(id);
}
DefaultListModel listModel = (DefaultListModel)myActionsList.getModel();
int size = listModel.getSize();
ListSelectionModel selectionModel = myActionsList.getSelectionModel();
if (size > 0) {
selectionModel.removeIndexInterval(0, size - 1);
}
for (String id1 : ids) {
int idx = listModel.lastIndexOf(id1);
if (idx >= 0) {
selectionModel.addSelectionInterval(idx, idx);
}
}
}
}
示例14: getInputEvent
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
public static InputEvent getInputEvent(String actionName) {
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionName);
KeyStroke keyStroke = null;
for (Shortcut each : shortcuts) {
if (each instanceof KeyboardShortcut) {
keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
if (keyStroke != null) break;
}
}
if (keyStroke != null) {
return new KeyEvent(JOptionPane.getRootFrame(),
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
keyStroke.getModifiers(),
keyStroke.getKeyCode(),
keyStroke.getKeyChar(),
KeyEvent.KEY_LOCATION_STANDARD);
} else {
return new MouseEvent(JOptionPane.getRootFrame(), MouseEvent.MOUSE_PRESSED, 0, 0, 0, 0, 1, false, MouseEvent.BUTTON1);
}
}
示例15: init
import com.intellij.openapi.keymap.KeymapManager; //导入依赖的package包/类
private void init() {
setVisible(myPresentation.isVisible());
setEnabled(myPresentation.isEnabled());
setMnemonic(myEnableMnemonics ? myPresentation.getMnemonic() : 0);
setText(myPresentation.getText());
final int mnemonicIndex = myEnableMnemonics ? myPresentation.getDisplayedMnemonicIndex() : -1;
if (getText() != null && mnemonicIndex >= 0 && mnemonicIndex < getText().length()) {
setDisplayedMnemonicIndex(mnemonicIndex);
}
AnAction action = myAction.getAction();
updateIcon(action);
String id = ActionManager.getInstance().getId(action);
if (id != null) {
Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(id);
setAcceleratorFromShortcuts(shortcuts);
}
else {
final ShortcutSet shortcutSet = action.getShortcutSet();
if (shortcutSet != null) {
setAcceleratorFromShortcuts(shortcutSet.getShortcuts());
}
}
}