void (final ReplaceContext replaceContext) { final AbstractAction replaceAllAction = new AbstractAction(FindBundle.message("find.replace.all.action")) { { KeyStroke altShiftEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); putValue(ACCELERATOR_KEY, altShiftEnter); putValue(SHORT_DESCRIPTION, KeymapUtil.getKeystrokeText(altShiftEnter)); } @Override public void actionPerformed(ActionEvent e) { UsageView usageView = replaceContext.getUsageView(); Set<Usage> usages = new HashSet<>(usageView.getUsages()); usages.removeAll(usageView.getExcludedUsages()); if (usages.isEmpty()) return; Set<VirtualFile> files = getFiles(usages); if (files.size() < 2 || showReplaceAllConfirmDialog( String.valueOf(usages.size()), replaceContext.getFindModel().getStringToFind(), String.valueOf(files.size()), replaceContext.getFindModel().getStringToReplace())) { replaceUsagesUnderCommand(replaceContext, usages, true); } } @Override public boolean isEnabled() { return !replaceContext.getUsageView().getUsages().isEmpty(); } }; replaceContext.getUsageView().addButtonToLowerPane(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction() { { KeyStroke altEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK); putValue(ACCELERATOR_KEY, altEnter); putValue(LONG_DESCRIPTION, KeymapUtil.getKeystrokeText(altEnter)); putValue(SHORT_DESCRIPTION, KeymapUtil.getKeystrokeText(altEnter)); } @Override public void actionPerformed(ActionEvent e) { replaceUsagesUnderCommand(replaceContext, getSelectedUsages(), false); } @Override public Object getValue(String key) { return Action.NAME.equals(key) ? FindBundle.message("find.replace.selected.action", getSelectedUsages().size()) : super.getValue(key); } @Override public boolean isEnabled() { return !getSelectedUsages().isEmpty(); } private Set<Usage> getSelectedUsages() { UsageView usageView = replaceContext.getUsageView(); Set<Usage> selectedUsages = usageView.getSelectedUsages(); selectedUsages.removeAll(usageView.getExcludedUsages()); return selectedUsages; } }; replaceContext.getUsageView().addButtonToLowerPane(replaceSelectedAction); }