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

项目:intellij-ce-playground    文件:ProjectTypesList.java   
void installKeyAction(JComponent component) {
  new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      InputEvent event = e.getInputEvent();
      if (event instanceof KeyEvent) {
        int row = myList.getSelectedIndex();
         int toSelect;
         switch (((KeyEvent)event).getKeyCode()) {
           case KeyEvent.VK_UP:
             toSelect = row == 0 ? myList.getItemsCount() - 1 : row - 1;
             myList.setSelectedIndex(toSelect);
             myList.ensureIndexIsVisible(toSelect);
             break;
           case KeyEvent.VK_DOWN:
             toSelect = row < myList.getItemsCount() - 1 ? row + 1 : 0;
             myList.setSelectedIndex(toSelect);
             myList.ensureIndexIsVisible(toSelect);
             break;
         }
      }
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component);
}
项目:tools-idea    文件:TipManager.java   
public TipManager(final JComponent component, TipFactory factory) {
  myTipFactory = factory;
  myComponent = component;

  new UiNotifyConnector.Once(component, new Activatable() {
    public void showNotify() {
      installListeners();
    }

    public void hideNotify() {
    }
  });

  final HideTooltipAction hide = new HideTooltipAction();
  hide.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), myComponent);
  Disposer.register(this, new Disposable() {
    public void dispose() {
      hide.unregisterCustomShortcutSet(myComponent);
    }
  });
}
项目:tools-idea    文件:ProjectTypesList.java   
void installKeyAction(JComponent component) {
  new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      InputEvent event = e.getInputEvent();
      if (event instanceof KeyEvent) {
        int row = myList.getSelectedIndex();
         int toSelect;
         switch (((KeyEvent)event).getKeyCode()) {
           case KeyEvent.VK_UP:
             toSelect = row == 0 ? myList.getItemsCount() - 1 : row - 1;
             myList.setSelectedIndex(toSelect);
             myList.ensureIndexIsVisible(toSelect);
             break;
           case KeyEvent.VK_DOWN:
             toSelect = row < myList.getItemsCount() - 1 ? row + 1 : 0;
             myList.setSelectedIndex(toSelect);
             myList.ensureIndexIsVisible(toSelect);
             break;
         }
      }
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component);
}
项目:tools-idea    文件:AbstractFieldPanel.java   
protected JComponent createCenterPanel() {
  myTextArea = new JTextArea(10, 50);
  myTextArea.setText(getText());
  myTextArea.setWrapStyleWord(true);
  myTextArea.setLineWrap(true);
  myTextArea.getDocument().addDocumentListener(new DocumentAdapter() {
    public void textChanged(DocumentEvent event) {
      if (myChangeListener != null) {
        myChangeListener.run();
      }
    }
  });

  new AnAction() {
    public void actionPerformed(AnActionEvent e) {
      doOKAction();
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), myTextArea);

  return ScrollPaneFactory.createScrollPane(myTextArea);
}
项目:tools-idea    文件:CloseOnESCAction.java   
public CloseOnESCAction(EditorSearchComponent editorSearchComponent, JComponent textField) {
  super(editorSearchComponent);

  ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
  if (KeymapUtil.isEmacsKeymap()) {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK), null));
    textField.registerKeyboardAction(new ActionListener() {
                                       @Override
                                       public void actionPerformed(final ActionEvent e) {
                                         CloseOnESCAction.this.actionPerformed(null);
                                       }
                                     }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
  } else {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), null));
  }

  registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);
}
项目:consulo-ui-designer    文件:PaletteWindow.java   
public PaletteWindow(Project project)
{
    myProject = project;
    myProviders = Extensions.getExtensions(PaletteItemProvider.EP_NAME, project);

    setLayout(new GridLayout(1, 1));
    myScrollPane.addMouseListener(new MyScrollPanePopupHandler());
    myScrollPane.setBorder(null);
    KeyStroke escStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    new ClearActiveItemAction().registerCustomShortcutSet(new CustomShortcutSet(escStroke), myScrollPane);

    if(!ApplicationManager.getApplication().isHeadlessEnvironment())
    {
        DragSource.getDefaultDragSource().addDragSourceListener(myDragSourceListener);
    }
}
项目:consulo    文件:AbstractFieldPanel.java   
@Override
protected JComponent createCenterPanel() {
  myTextArea = new JTextArea(10, 50);
  myTextArea.setText(getText());
  myTextArea.setWrapStyleWord(true);
  myTextArea.setLineWrap(true);
  myTextArea.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      if (myChangeListener != null) {
        myChangeListener.run();
      }
    }
  });

  new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      doOKAction();
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), myTextArea);

  return ScrollPaneFactory.createScrollPane(myTextArea);
}
项目:idea-php-class-templates    文件:PhpNewExceptionClassDialog.java   
@Override
protected void subInit() {
    super.subInit();

    this.myMessageTextField = new EditorTextField("");
    this.myKindUpDownHint      = new JLabel();
    this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS);
    this.myKindUpDownHint.setToolTipText(PhpBundle.message("actions.new.php.base.arrows.kind.tooltip"));


    this.myKindComboBox = new ComboBox<String>();
    this.myKindComboBox.setMinimumAndPreferredWidth(400);
    this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() {
        public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) {
            this.setText((String)value.first);
            this.setIcon((Icon)value.second);
        }
    });
    ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) {
        protected String getElementText(Object element) {
            return (String)((Trinity)element).first;
        }
    };
    KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke)null);
    KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke)null);
    AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox);
    kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField);
    List<Trinity> exceptionTypes = this.getExceptionTypes();

    for(Trinity type : exceptionTypes) {
        this.myKindComboBox.addItem(type);
    }
}
项目:intellij-ce-playground    文件:ValueHint.java   
public static InspectDebuggerTree createInspectTree(final NodeDescriptorImpl descriptor, Project project) {
  final InspectDebuggerTree tree = new InspectDebuggerTree(project);
  final AnAction setValueAction = ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
  setValueAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), tree);
  Disposer.register(tree, new Disposable() {
    @Override
    public void dispose() {
      setValueAction.unregisterCustomShortcutSet(tree);
    }
  });
  tree.setInspectDescriptor(descriptor);
  DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
  tree.rebuild(context);
  return tree;
}
项目:intellij-ce-playground    文件:ImportUsageFilteringRuleProvider.java   
@Override
@NotNull
public AnAction[] createFilteringActions(@NotNull final UsageView view) {
  final UsageViewImpl impl = (UsageViewImpl)view;
  if (view.getPresentation().isCodeUsages()) {
    final JComponent component = view.getComponent();
    final ShowImportsAction showImportsAction = new ShowImportsAction(impl);
    showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view);
    return new AnAction[] { showImportsAction };
  }
  else {
    return AnAction.EMPTY_ARRAY;
  }
}
项目:intellij-ce-playground    文件:UsageGroupingRuleProviderImpl.java   
@Override
@NotNull
public AnAction[] createGroupingActions(UsageView view) {
  UsageViewImpl impl = (UsageViewImpl)view;
  JComponent component = impl.getComponent();

  GroupByModuleTypeAction groupByModuleTypeAction = supportsModuleRule() ? new GroupByModuleTypeAction(impl) : null;
  if (groupByModuleTypeAction != null) {
    groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl);
  }

  GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl);

  GroupByScopeAction groupByScopeAction = supportsScopesRule() ? new GroupByScopeAction(impl) : null;

  GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl);
  groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl);

  ArrayList<AnAction> result = ContainerUtil.newArrayList();

  if (view.getPresentation().isUsageTypeFilteringAvailable()) {
    GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
    groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl);

    ContainerUtil.addIfNotNull(result, groupByUsageTypeAction);
    ContainerUtil.addIfNotNull(result, groupByScopeAction);
    ContainerUtil.addIfNotNull(result, groupByModuleTypeAction);
    ContainerUtil.addIfNotNull(result, groupByPackageAction);
    ContainerUtil.addIfNotNull(result, groupByFileStructureAction);
  }
  else {
    ContainerUtil.addIfNotNull(result, groupByScopeAction);
    ContainerUtil.addIfNotNull(result, groupByModuleTypeAction);
    ContainerUtil.addIfNotNull(result, groupByPackageAction);
    ContainerUtil.addIfNotNull(result, groupByFileStructureAction);
  }
  return result.toArray(new AnAction[result.size()]);
}
项目:intellij-ce-playground    文件:UsageGroupingRuleProviderImpl.java   
public static GroupByFileStructureAction createGroupByFileStructureAction(UsageViewImpl impl) {
  final JComponent component = impl.getComponent();
  final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl);
  groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M,
                                                                                                    InputEvent.CTRL_DOWN_MASK)), component,
                                                       impl);

  return groupByFileStructureAction;
}
项目:intellij-ce-playground    文件:MnemonicHelper.java   
/**
 * Creates shortcut for mnemonic replacing standard Alt+Letter to Ctrl+Alt+Letter on Mac with jdk version newer than 6
 * @param ch mnemonic letter
 * @return shortcut for mnemonic
 */
public static CustomShortcutSet createShortcut(char ch) {
  Character mnemonic = Character.valueOf(ch);
  String shortcut = SystemInfo.isMac && SystemInfo.isJavaVersionAtLeast("1.7") ?
                    "control alt pressed " + mnemonic :
                    "alt pressed " + mnemonic;
  return CustomShortcutSet.fromString(shortcut);
}
项目:intellij-ce-playground    文件:QuickFixAction.java   
protected QuickFixAction(String text, Icon icon, KeyStroke keyStroke, @NotNull InspectionToolWrapper toolWrapper) {
  super(text, null, icon);
  myToolWrapper = toolWrapper;
  if (keyStroke != null) {
    registerCustomShortcutSet(new CustomShortcutSet(keyStroke), null);
  }
}
项目:intellij-ce-playground    文件:ContentEntryTreeEditor.java   
protected void createEditingActions() {
  for (final ModuleSourceRootEditHandler<?> editor : myEditHandlers) {
    ToggleSourcesStateAction action = new ToggleSourcesStateAction(myTree, this, editor);
    CustomShortcutSet shortcutSet = editor.getMarkRootShortcutSet();
    if (shortcutSet != null) {
      action.registerCustomShortcutSet(shortcutSet, myTree);
    }
    myEditingActionsGroup.add(action);
  }

  setupExcludedAction();
}
项目:intellij-ce-playground    文件:SearchTextArea.java   
public ShowHistoryAction(boolean search) {
  super((search ? "Search" : "Replace") + " History",
        (search ? "Search" : "Replace") + " history",
        IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/search.png", DarculaTextFieldUI.class, true));

  myShowSearchHistory = search;

  KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK);
  registerCustomShortcutSet(new CustomShortcutSet(new KeyboardShortcut(stroke, null)), myTextArea);
}
项目:intellij-ce-playground    文件:EditBookmarkDescriptionAction.java   
EditBookmarkDescriptionAction(Project project, JList list) {
  super(IdeBundle.message("action.bookmark.edit.description"),
        IdeBundle.message("action.bookmark.edit.description.description"), AllIcons.Actions.Edit);
  myProject = project;
  myList = list;
  registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(SystemInfo.isMac ? "meta ENTER" : "control ENTER")), list);
}
项目:intellij-ce-playground    文件:TemplateKindCombo.java   
public void registerUpDownHint(JComponent component) {
  new DumbAwareAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (e.getInputEvent() instanceof KeyEvent) {
        final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
        scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0);
      }
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component);
}
项目:intellij-ce-playground    文件:PyContentEntriesEditor.java   
@Override
protected void createEditingActions() {
  super.createEditingActions();
  for (PyRootTypeProvider provider : myRootTypeProviders) {
    ContentEntryEditingAction action = provider.createRootEntryEditingAction(myTree, myFilePointersDisposable, PyContentEntriesEditor.this, getModel());
    myEditingActionsGroup.add(action);
    CustomShortcutSet shortcut = provider.getShortcut();
    if (shortcut != null) {
      action.registerCustomShortcutSet(shortcut, myTree);
    }
  }
}
项目:intellij-ce-playground    文件:IpnbFileEditor.java   
private void registerHeadingActions() {
  new IpnbHeading1CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 1")), myIpnbFilePanel);
  new IpnbHeading2CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 2")), myIpnbFilePanel);
  new IpnbHeading3CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 3")), myIpnbFilePanel);
  new IpnbHeading4CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 4")), myIpnbFilePanel);
  new IpnbHeading5CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 5")), myIpnbFilePanel);
  new IpnbHeading6CellAction().registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("ctrl shift 6")), myIpnbFilePanel);
}
项目:intellij-ce-playground    文件:GitSkippedCommits.java   
@Override
protected void addActionsTo(DefaultActionGroup group) {
  super.addActionsTo(group);
  ShowAllAffectedGenericAction showCommit = ShowAllAffectedGenericAction.getInstance();
  showCommit.registerCustomShortcutSet(new CustomShortcutSet(
    CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myTree);
  group.addAction(showCommit);

}
项目:intellij-ce-playground    文件:GrTypeComboBox.java   
public static void registerUpDownHint(JComponent component, final GrTypeComboBox combo) {
  final AnAction arrow = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (e.getInputEvent() instanceof KeyEvent) {
        final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
        scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0, combo);
      }
    }
  };
  final KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK), null);
  final KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK), null);
  arrow.registerCustomShortcutSet(new CustomShortcutSet(up, down), component);
}
项目:tools-idea    文件:ImportUsageFilteringRuleProvider.java   
@Override
@NotNull
public AnAction[] createFilteringActions(@NotNull final UsageView view) {
  final UsageViewImpl impl = (UsageViewImpl)view;
  if (view.getPresentation().isCodeUsages()) {
    final JComponent component = view.getComponent();
    final ShowImportsAction showImportsAction = new ShowImportsAction(impl);
    showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view);
    return new AnAction[] { showImportsAction };
  }
  else {
    return AnAction.EMPTY_ARRAY;
  }
}
项目:tools-idea    文件:UsageGroupingRuleProviderImpl.java   
@Override
@NotNull
public AnAction[] createGroupingActions(UsageView view) {
  final UsageViewImpl impl = (UsageViewImpl)view;
  final JComponent component = impl.getComponent();

  final GroupByModuleTypeAction groupByModuleTypeAction = new GroupByModuleTypeAction(impl);
  groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl);

  final GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl);

  final GroupByScopeAction groupByScopeAction = new GroupByScopeAction(impl);

  final GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl);
  groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl);

  if(view.getPresentation().isCodeUsages()) {
    final GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
    groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl);
    return new AnAction[] {
      groupByUsageTypeAction,
      groupByScopeAction,
      groupByModuleTypeAction,
      groupByPackageAction,
      groupByFileStructureAction,
    };
  }
  else {
    return new AnAction[] {
      groupByScopeAction,
      groupByModuleTypeAction,
      groupByPackageAction,
      groupByFileStructureAction,
    };
  }
}
项目:tools-idea    文件:UsageGroupingRuleProviderImpl.java   
public static GroupByFileStructureAction createGroupByFileStructureAction(UsageViewImpl impl) {
  final JComponent component = impl.getComponent();
  final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl);
  groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M,
                                                                                                    InputEvent.CTRL_DOWN_MASK)), component,
                                                       impl);

  return groupByFileStructureAction;
}
项目:tools-idea    文件:QuickFixAction.java   
protected QuickFixAction(String text, Icon icon, KeyStroke keyStroke, @NotNull InspectionToolWrapper toolWrapper) {
  super(text, null, icon);
  myToolWrapper = toolWrapper;
  if (keyStroke != null) {
    registerCustomShortcutSet(new CustomShortcutSet(keyStroke), null);
  }
}
项目:tools-idea    文件:ContentEntryTreeEditor.java   
protected void createEditingActions() {
  if (myCanMarkSources) {
    ToggleSourcesStateAction markSourcesAction = new ToggleSourcesStateAction(myTree, this, false);
    markSourcesAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK)), myTree);
    myEditingActionsGroup.add(markSourcesAction);
  }

  if (myCanMarkTestSources) {
    setupTestsAction();
  }

  setupExcludedAction();
}
项目:tools-idea    文件:ReplaceOnEnterAction.java   
public ReplaceOnEnterAction(EditorSearchComponent editorSearchComponent, JComponent textField) {
  super(editorSearchComponent);
  ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
  shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), null));

  registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);
}
项目:tools-idea    文件:EditBookmarkDescriptionAction.java   
EditBookmarkDescriptionAction(Project project, JList list) {
  super(IdeBundle.message("action.bookmark.edit.description"),
        IdeBundle.message("action.bookmark.edit.description.description"), AllIcons.Actions.Edit);
  myProject = project;
  myList = list;
  registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(SystemInfo.isMac ? "meta ENTER" : "control ENTER")), list);
}
项目:tools-idea    文件:TemplateKindCombo.java   
public void registerUpDownHint(JComponent component) {
  new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (e.getInputEvent() instanceof KeyEvent) {
        final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
        scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0);
      }
    }
  }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component);
}
项目:tools-idea    文件:GitSkippedCommits.java   
@Override
protected void addActionsTo(DefaultActionGroup group) {
  super.addActionsTo(group);
  ShowAllAffectedGenericAction showCommit = ShowAllAffectedGenericAction.getInstance();
  showCommit.registerCustomShortcutSet(new CustomShortcutSet(
    CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myTree);
  group.addAction(showCommit);

}
项目:tools-idea    文件:GrTypeComboBox.java   
public static void registerUpDownHint(JComponent component, final GrTypeComboBox combo) {
  final AnAction arrow = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (e.getInputEvent() instanceof KeyEvent) {
        final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
        scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0, combo);
      }
    }
  };
  final KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK), null);
  final KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK), null);
  arrow.registerCustomShortcutSet(new CustomShortcutSet(up, down), component);
}
项目:guards    文件:ExtendedKeyboardActionDispatcher.java   
void install(JComponent component) {
    for( Object item : popup.getListStep().getValues() ) {
        if ( item instanceof PopupFactoryImpl.ActionItem ) {
            if ( ((PopupFactoryImpl.ActionItem)item).getAction() instanceof GuardPopupAction ) {
                ((GuardPopupAction)((PopupFactoryImpl.ActionItem)item).getAction())
                        .extendKeyboardActions(new Extender((PopupFactoryImpl.ActionItem)item));
            }
        }
    }
    for( Map.Entry<KeyStroke, Mapping> mapping : mappings.entrySet() ) {
        mapping.getValue().registerCustomShortcutSet(new CustomShortcutSet(mapping.getKey()), component);
    }
}
项目:guards    文件:AddGuardAction.java   
@Override
public void perform(@NotNull final AnActionEvent e) {
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(target.getElement().getProject());
    Document document = documentManager.getDocument(target.getElement().getContainingFile());
    if ( document == null ) {
        Diagnostics.notifyError(e, "Document is null");
        return;
    }
    if ( target.getElement().getModifierList() == null ) {
        Diagnostics.notifyError(e, "Modifier of list is null (Element: %s)", getView());
        return;
    }
    if ( getView().getElement().getQualifiedName() == null ) {
        Diagnostics.notifyError(e, "Anonymous guard type");
        return;
    }
    final PsiAnnotation psiAnnotation = target.getElement().getModifierList().addAnnotation(getView().getElement().getQualifiedName());
    JavaCodeStyleManager.getInstance(target.getElement().getProject()).shortenClassReferences(psiAnnotation);
    documentManager.doPostponedOperationsAndUnblockDocument(document);
    if ( getView().getAttributeMethods().iterator().hasNext() ) {
        new EditGuardAction(AddGuardAction.this,
                target.getGuards().firstMatch(new Predicate<PsiGuard>() {
                    @Override
                    public boolean apply(PsiGuard psiGuard) {
                        return psiGuard.getElement().equals(psiAnnotation);
                    }
                }).get()).actionPerformed(e);
    }
    //PsiDocumentManager.getInstance(getElement().getProject()).commitDocument();
    //new EditGuardAction()
    setShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0)));
    //getController().shopPopup(e.getDataContext(), SelectionKey.of(psiAnnotation, SelectionKey.Option.PULL_UP));
}
项目:ali-idea-plugin    文件:UndoAction.java   
public static void installUndoRedoSupport(JTextComponent textComponent) {
    final UndoManager undoManager = new UndoManager();
    Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    new UndoAction(undoManager).registerCustomShortcutSet(new CustomShortcutSet(keymap.getShortcuts("$Undo")), textComponent);
    new RedoAction(undoManager).registerCustomShortcutSet(new CustomShortcutSet(keymap.getShortcuts("$Redo")), textComponent);
    textComponent.getDocument().addUndoableEditListener(new UndoableEditListener() {
        public void undoableEditHappened(UndoableEditEvent event) {
            undoManager.addEdit(event.getEdit());
        }
    });
}
项目:consulo    文件:CoverageLineMarkerRenderer.java   
protected JComponent createActionsToolbar(final Editor editor, final int lineNumber) {

    final JComponent editorComponent = editor.getComponent();

    final DefaultActionGroup group = new DefaultActionGroup();
    final GotoPreviousCoveredLineAction prevAction = new GotoPreviousCoveredLineAction(editor, lineNumber);
    final GotoNextCoveredLineAction nextAction = new GotoNextCoveredLineAction(editor, lineNumber);

    group.add(prevAction);
    group.add(nextAction);

    prevAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)), editorComponent);
    nextAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)), editorComponent);

    final LineData lineData = getLineData(lineNumber);
    if (myCoverageByTestApplicable) {
      group.add(new ShowCoveringTestsAction(myClassName, lineData));
    }
    final AnAction byteCodeViewAction = ActionManager.getInstance().getAction("ByteCodeViewer");
    if (byteCodeViewAction != null) {
      group.add(byteCodeViewAction);
    }
    group.add(new EditCoverageColorsAction(editor, lineNumber));
    group.add(new HideCoverageInfoAction());

    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, group, true);
    final JComponent toolbarComponent = toolbar.getComponent();

    final Color background = ((EditorEx)editor).getBackgroundColor();
    final Color foreground = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
    toolbarComponent.setBackground(background);
    toolbarComponent.setBorder(new ColoredSideBorder(foreground, foreground, lineData == null || lineData.getStatus() == LineCoverage.NONE || mySubCoverageActive ? foreground : null, foreground, 1));
    toolbar.updateActionsImmediately();
    return toolbarComponent;
  }
项目:consulo    文件:ImportUsageFilteringRuleProvider.java   
@Override
@Nonnull
public AnAction[] createFilteringActions(@Nonnull final UsageView view) {
  final UsageViewImpl impl = (UsageViewImpl)view;
  if (view.getPresentation().isCodeUsages()) {
    final JComponent component = view.getComponent();
    final ShowImportsAction showImportsAction = new ShowImportsAction(impl);
    showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view);
    return new AnAction[] { showImportsAction };
  }
  else {
    return AnAction.EMPTY_ARRAY;
  }
}
项目:consulo    文件:UsageGroupingRuleProviderImpl.java   
@Override
@Nonnull
public AnAction[] createGroupingActions(UsageView view) {
  final UsageViewImpl impl = (UsageViewImpl)view;
  final JComponent component = impl.getComponent();

  final GroupByModuleTypeAction groupByModuleTypeAction = new GroupByModuleTypeAction(impl);
  groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl);

  final GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl);

  final GroupByScopeAction groupByScopeAction = new GroupByScopeAction(impl);

  final GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl);
  groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl);

  if(view.getPresentation().isCodeUsages()) {
    final GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
    groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl);
    return new AnAction[] {
      groupByUsageTypeAction,
      groupByScopeAction,
      groupByModuleTypeAction,
      groupByPackageAction,
      groupByFileStructureAction,
    };
  }
  else {
    return new AnAction[] {
      groupByScopeAction,
      groupByModuleTypeAction,
      groupByPackageAction,
      groupByFileStructureAction,
    };
  }
}
项目:consulo    文件:UsageGroupingRuleProviderImpl.java   
public static GroupByFileStructureAction createGroupByFileStructureAction(UsageViewImpl impl) {
  final JComponent component = impl.getComponent();
  final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl);
  groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M,
                                                                                                    InputEvent.CTRL_DOWN_MASK)), component,
                                                       impl);

  return groupByFileStructureAction;
}
项目:consulo    文件:MnemonicHelper.java   
/**
 * Creates shortcut for mnemonic replacing standard Alt+Letter to Ctrl+Alt+Letter on Mac with jdk version newer than 6
 * @param ch mnemonic letter
 * @return shortcut for mnemonic
 */
public static CustomShortcutSet createShortcut(char ch) {
  Character mnemonic = Character.valueOf(ch);
  String shortcut = SystemInfo.isMac && SystemInfo.isJavaVersionAtLeast("1.7") ?
                    "control alt pressed " + mnemonic :
                    "alt pressed " + mnemonic;
  return CustomShortcutSet.fromString(shortcut);
}