Java 类com.intellij.openapi.actionSystem.MouseShortcut 实例源码

项目:intellij-ce-playground    文件:MouseShortcutDialog.java   
/**
 * @return created/edited shortcut. Returns <code>null</code> if shortcut is invalid.
 */
public MouseShortcut getMouseShortcut(){
  if (myButton > 3 && myButton != MouseShortcut.BUTTON_WHEEL_UP && myButton != MouseShortcut.BUTTON_WHEEL_DOWN && getClickCount() == 2) {
    return null;
  }

  if(myButton!=-1 && myModifiers!=-1){
    return new MouseShortcut(myButton,myModifiers,getClickCount());
  }else{
    return null;
  }
}
项目:intellij-ce-playground    文件:MacOSDefaultKeymap.java   
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
项目:intellij-ce-playground    文件:DefaultKeymapImpl.java   
public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException {
  super.readExternal(keymapElement, existingKeymaps);

  if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) {
    addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1));
  }
}
项目:intellij-ce-playground    文件:EditorMultiCaretTest.java   
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);
  }
}
项目:tools-idea    文件:MouseShortcutDialog.java   
/**
 * @return created/edited shortcut. Returns <code>null</code> if shortcut is invalid.
 */
public MouseShortcut getMouseShortcut(){
  if (myButton > 3 && getClickCount() == 2) {
    return null;
  }

  if(myButton!=-1 && myModifiers!=-1){
    return new MouseShortcut(myButton,myModifiers,getClickCount());
  }else{
    return null;
  }
}
项目:tools-idea    文件:MacOSDefaultKeymap.java   
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
项目:tools-idea    文件:DefaultKeymapImpl.java   
public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException {
  super.readExternal(keymapElement, existingKeymaps);

  if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) {
    addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1));
  }
}
项目:tools-idea    文件:CtrlMouseHandler.java   
private static boolean matchMouseShortcut(final Keymap activeKeymap, @JdkConstants.InputEventMask int modifiers, final String actionId) {
  final MouseShortcut syntheticShortcut = new MouseShortcut(MouseEvent.BUTTON1, modifiers, 1);
  for (Shortcut shortcut : activeKeymap.getShortcuts(actionId)) {
    if (shortcut instanceof MouseShortcut) {
      final MouseShortcut mouseShortcut = (MouseShortcut)shortcut;
      if (mouseShortcut.getModifiers() == syntheticShortcut.getModifiers()) {
        return true;
      }
    }
  }
  return false;
}
项目:consulo    文件:MouseShortcutDialog.java   
/**
 * @return created/edited shortcut. Returns <code>null</code> if shortcut is invalid.
 */
public MouseShortcut getMouseShortcut(){
  if (myButton > 3 && getClickCount() == 2) {
    return null;
  }

  if(myButton!=-1 && myModifiers!=-1){
    return new MouseShortcut(myButton,myModifiers,getClickCount());
  }else{
    return null;
  }
}
项目:consulo    文件:MouseShortcutPanel.java   
private MouseShortcut toMouseShortcut(MouseEvent event) {
  int button = MouseShortcut.getButton(event);
  int clickCount = event instanceof MouseWheelEvent ? 1 : event.getClickCount();
  if (0 <= button && clickCount <= myClickCount) {
    int modifiers = event.getModifiersEx();
    return new MouseShortcut(button, modifiers, clickCount);
  }
  return null;
}
项目:consulo    文件:MacOSDefaultKeymap.java   
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
项目:consulo    文件:DefaultKeymapImpl.java   
public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException {
  super.readExternal(keymapElement, existingKeymaps);

  if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) {
    addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1));
  }
}
项目:intellij-ce-playground    文件:MouseShortcutDialog.java   
/**
 * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>null</code>
 * if dialog is used to create new mouse shortcut.
 */
public MouseShortcutDialog(
  JComponent parentComponent,
  MouseShortcut shortcut,
  @NotNull Keymap keymap,
  @NotNull String actiondId,
  @NotNull Group mainGroup,
  @NotNull ShortcutRestrictions restrictions
){
  super(parentComponent,true);
  setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

  myKeymap=keymap;
  myActionId=actiondId;
  myMainGroup=mainGroup;

  myRbSingleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
  myRbDoubleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
  ButtonGroup buttonGroup=new ButtonGroup();
  buttonGroup.add(myRbSingleClick);
  buttonGroup.add(myRbDoubleClick);

  myLblPreview=new JLabel(" ");

  myClickPad=new MyClickPad();

  myTarConflicts=new JTextArea();
  myTarConflicts.setFocusable(false);
  myTarConflicts.setEditable(false);
  myTarConflicts.setBackground(UIUtil.getPanelBackground());
  myTarConflicts.setLineWrap(true);
  myTarConflicts.setWrapStyleWord(true);

  if(shortcut!=null){
    if(shortcut.getClickCount()==1){
      myRbSingleClick.setSelected(true);
    }else{
      myRbDoubleClick.setSelected(true);
    }
    myButton=shortcut.getButton();
    myModifiers=shortcut.getModifiers();
  }else{
    myRbSingleClick.setSelected(true);
    myButton=-1;
    myModifiers=-1;
  }

  myRbDoubleClick.setEnabled(restrictions.allowMouseDoubleClick);

  updatePreviewAndConflicts();

  init();
}
项目:intellij-ce-playground    文件:MouseShortcutDialog.java   
/**
 * Updates all UI controls
 */
private void updatePreviewAndConflicts(){
  if(myButton==-1||myModifiers==-1){
    return;
  }

  myTarConflicts.setText(null);

  // Set text into preview area

  // empty string should have same height
  myLblPreview.setText(KeymapUtil.getMouseShortcutText(myButton,myModifiers,getClickCount()) + " ");

  // Detect conflicts

  final MouseShortcut mouseShortcut=new MouseShortcut(myButton,myModifiers,getClickCount());

  if (myButton > 3 && getClickCount() == 2) {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.side.buttons.with.double.click", myButton));
    return;
  }

  StringBuilder buffer = new StringBuilder();
  String[] actionIds = myKeymap.getActionIds(mouseShortcut);
  for (String actionId : actionIds) {
    if (actionId.equals(myActionId)) {
      continue;
    }

    String actionPath = myMainGroup.getActionQualifiedPath(actionId);
    // actionPath == null for editor actions having corresponding $-actions
    if (actionPath == null) {
      continue;
    }

    Shortcut[] shortcuts = myKeymap.getShortcuts(actionId);
    for (Shortcut shortcut1 : shortcuts) {
      if (!(shortcut1 instanceof MouseShortcut)) {
        continue;
      }

      MouseShortcut shortcut = (MouseShortcut)shortcut1;

      if (shortcut.getButton() != mouseShortcut.getButton() || shortcut.getModifiers() != mouseShortcut.getModifiers()) {
        continue;
      }

      if (buffer.length() > 1) {
        buffer.append('\n');
      }
      buffer.append('[');
      buffer.append(actionPath);
      buffer.append(']');
      break;
    }
  }

  if (buffer.length() == 0) {
    myTarConflicts.setForeground(UIUtil.getTextAreaForeground());
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.no.conflicts.area"));
  }
  else {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.assigned.to.area", buffer.toString()));
  }
}
项目:intellij-ce-playground    文件:MacOSDefaultKeymap.java   
protected String[] getParentActionIds(MouseShortcut shortcut) {
  return super.getParentActionIds(convertMouseShortcut(shortcut));
}
项目:intellij-ce-playground    文件:MacOSDefaultKeymap.java   
private static MouseShortcut convertMouseShortcut(MouseShortcut macShortcut) {
  return new MouseShortcut(macShortcut.getButton(),
                           mapModifiers(macShortcut.getModifiers()),
                           macShortcut.getClickCount());
}
项目:tools-idea    文件:MouseShortcutDialog.java   
/**
 * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>null</code>
 * if dialog is used to create new mouse shortcut.
 */
public MouseShortcutDialog(
  JComponent parentComponent,
  MouseShortcut shortcut,
  @NotNull Keymap keymap,
  @NotNull String actiondId,
  @NotNull Group mainGroup
){
  super(parentComponent,true);
  setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

  myKeymap=keymap;
  myActionId=actiondId;
  myMainGroup=mainGroup;

  myRbSingleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
  myRbDoubleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
  ButtonGroup buttonGroup=new ButtonGroup();
  buttonGroup.add(myRbSingleClick);
  buttonGroup.add(myRbDoubleClick);

  myLblPreview=new JLabel(" ");

  myClickPad=new MyClickPad();

  myTarConflicts=new JTextArea();
  myTarConflicts.setFocusable(false);
  myTarConflicts.setEditable(false);
  myTarConflicts.setBackground(UIUtil.getPanelBackground());
  myTarConflicts.setLineWrap(true);
  myTarConflicts.setWrapStyleWord(true);

  if(shortcut!=null){
    if(shortcut.getClickCount()==1){
      myRbSingleClick.setSelected(true);
    }else{
      myRbDoubleClick.setSelected(true);
    }
    myButton=shortcut.getButton();
    myModifiers=shortcut.getModifiers();
  }else{
    myRbSingleClick.setSelected(true);
    myButton=-1;
    myModifiers=-1;
  }

  updatePreviewAndConflicts();

  init();
}
项目:tools-idea    文件:MouseShortcutDialog.java   
/**
 * Updates all UI controls
 */
private void updatePreviewAndConflicts(){
  if(myButton==-1||myModifiers==-1){
    return;
  }

  myTarConflicts.setText(null);

  // Set text into preview area

  // empty string should have same height
  myLblPreview.setText(KeymapUtil.getMouseShortcutText(myButton,myModifiers,getClickCount()) + " ");

  // Detect conflicts

  final MouseShortcut mouseShortcut=new MouseShortcut(myButton,myModifiers,getClickCount());

  if (myButton > 3 && getClickCount() == 2) {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.side.buttons.with.double.click", myButton));
    return;
  }

  StringBuilder buffer = new StringBuilder();
  String[] actionIds = myKeymap.getActionIds(mouseShortcut);
  for (String actionId : actionIds) {
    if (actionId.equals(myActionId)) {
      continue;
    }

    String actionPath = myMainGroup.getActionQualifiedPath(actionId);
    // actionPath == null for editor actions having corresponding $-actions
    if (actionPath == null) {
      continue;
    }

    Shortcut[] shortcuts = myKeymap.getShortcuts(actionId);
    for (Shortcut shortcut1 : shortcuts) {
      if (!(shortcut1 instanceof MouseShortcut)) {
        continue;
      }

      MouseShortcut shortcut = (MouseShortcut)shortcut1;

      if (shortcut.getButton() != mouseShortcut.getButton() || shortcut.getModifiers() != mouseShortcut.getModifiers()) {
        continue;
      }

      if (buffer.length() > 1) {
        buffer.append('\n');
      }
      buffer.append('[');
      buffer.append(actionPath);
      buffer.append(']');
      break;
    }
  }

  if (buffer.length() == 0) {
    myTarConflicts.setForeground(UIUtil.getTextAreaForeground());
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.no.conflicts.area"));
  }
  else {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.assigned.to.area", buffer.toString()));
  }
}
项目:tools-idea    文件:MacOSDefaultKeymap.java   
protected String[] getParentActionIds(MouseShortcut shortcut) {
  return super.getParentActionIds(convertMouseShortcut(shortcut));
}
项目:tools-idea    文件:MacOSDefaultKeymap.java   
private static MouseShortcut convertMouseShortcut(MouseShortcut macShortcut) {
  return new MouseShortcut(macShortcut.getButton(),
                           mapModifiers(macShortcut.getModifiers()),
                           macShortcut.getClickCount());
}
项目:consulo    文件:MouseShortcutDialog.java   
/**
 * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>null</code>
 * if dialog is used to create new mouse shortcut.
 */
public MouseShortcutDialog(
        JComponent parentComponent,
        MouseShortcut shortcut,
        @Nonnull Keymap keymap,
        @Nonnull String actiondId,
        @Nonnull Group mainGroup,
        @Nonnull ShortcutRestrictions restrictions
){
  super(parentComponent,true);
  setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

  myKeymap=keymap;
  myActionId=actiondId;
  myMainGroup=mainGroup;

  myRbSingleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
  myRbDoubleClick=new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
  ButtonGroup buttonGroup=new ButtonGroup();
  buttonGroup.add(myRbSingleClick);
  buttonGroup.add(myRbDoubleClick);

  myLblPreview=new JLabel(" ");

  myClickPad=new MyClickPad();

  myTarConflicts=new JTextArea();
  myTarConflicts.setFocusable(false);
  myTarConflicts.setEditable(false);
  myTarConflicts.setBackground(UIUtil.getPanelBackground());
  myTarConflicts.setLineWrap(true);
  myTarConflicts.setWrapStyleWord(true);

  if(shortcut!=null){
    if(shortcut.getClickCount()==1){
      myRbSingleClick.setSelected(true);
    }else{
      myRbDoubleClick.setSelected(true);
    }
    myButton=shortcut.getButton();
    myModifiers=shortcut.getModifiers();
  }else{
    myRbSingleClick.setSelected(true);
    myButton=-1;
    myModifiers=-1;
  }

  myRbDoubleClick.setEnabled(restrictions.allowMouseDoubleClick);

  updatePreviewAndConflicts();

  init();
}
项目:consulo    文件:MouseShortcutDialog.java   
/**
 * Updates all UI controls
 */
private void updatePreviewAndConflicts(){
  if(myButton==-1||myModifiers==-1){
    return;
  }

  myTarConflicts.setText(null);

  // Set text into preview area

  // empty string should have same height
  myLblPreview.setText(KeymapUtil.getMouseShortcutText(myButton,myModifiers,getClickCount()) + " ");

  // Detect conflicts

  final MouseShortcut mouseShortcut=new MouseShortcut(myButton,myModifiers,getClickCount());

  if (myButton > 3 && getClickCount() == 2) {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.side.buttons.with.double.click", myButton));
    return;
  }

  StringBuilder buffer = new StringBuilder();
  String[] actionIds = myKeymap.getActionIds(mouseShortcut);
  for (String actionId : actionIds) {
    if (actionId.equals(myActionId)) {
      continue;
    }

    String actionPath = myMainGroup.getActionQualifiedPath(actionId);
    // actionPath == null for editor actions having corresponding $-actions
    if (actionPath == null) {
      continue;
    }

    Shortcut[] shortcuts = myKeymap.getShortcuts(actionId);
    for (Shortcut shortcut1 : shortcuts) {
      if (!(shortcut1 instanceof MouseShortcut)) {
        continue;
      }

      MouseShortcut shortcut = (MouseShortcut)shortcut1;

      if (shortcut.getButton() != mouseShortcut.getButton() || shortcut.getModifiers() != mouseShortcut.getModifiers()) {
        continue;
      }

      if (buffer.length() > 1) {
        buffer.append('\n');
      }
      buffer.append('[');
      buffer.append(actionPath);
      buffer.append(']');
      break;
    }
  }

  if (buffer.length() == 0) {
    myTarConflicts.setForeground(UIUtil.getTextAreaForeground());
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.no.conflicts.area"));
  }
  else {
    myTarConflicts.setForeground(JBColor.RED);
    myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.assigned.to.area", buffer.toString()));
  }
}
项目:consulo    文件:MouseShortcutPanel.java   
public void setShortcut(MouseShortcut shortcut) {
  MouseShortcut old = getShortcut();
  if (old != null || shortcut != null) {
    super.setShortcut(shortcut);
  }
}
项目:consulo    文件:MouseShortcutPanel.java   
private void setShortcutIfNeeded(MouseShortcut shortcut) {
  if (shortcut != null) setShortcut(shortcut);
}
项目:consulo    文件:MacOSDefaultKeymap.java   
@Override
protected String[] getParentActionIds(MouseShortcut shortcut) {
  return super.getParentActionIds(convertMouseShortcut(shortcut));
}
项目:consulo    文件:MacOSDefaultKeymap.java   
private static MouseShortcut convertMouseShortcut(MouseShortcut macShortcut) {
  return new MouseShortcut(macShortcut.getButton(),
                           mapModifiers(macShortcut.getModifiers()),
                           macShortcut.getClickCount());
}
项目:intellij-ce-playground    文件:Keymap.java   
/**
 * @return all actions with specified mouse shortcut.  If there are no
 * such action then the method returns an empty array.
 */
String[] getActionIds(MouseShortcut shortcut);
项目:tools-idea    文件:Keymap.java   
/**
 * @return all actions with specified mouse shortcut.  If there are no
 * such action then the method returns an empty array.
 */
String[] getActionIds(MouseShortcut shortcut);
项目:consulo    文件:Keymap.java   
/**
 * @return all actions with specified mouse shortcut.  If there are no
 * such action then the method returns an empty array.
 */
String[] getActionIds(MouseShortcut shortcut);