vcs: avoid rewriting ShortcutSet for global actions while registering local shortcuts

this fixes issues like IDEA-119375
This commit is contained in:
Aleksey Pivovarov
2015-04-23 18:13:51 +03:00
parent d3447ca2cb
commit 6095a02ede
10 changed files with 29 additions and 32 deletions
@@ -212,7 +212,7 @@ public class PushLog extends JPanel implements DataProvider {
myChangesBrowser =
new ChangesBrowser(project, null, Collections.<Change>emptyList(), null, false, true, null, ChangesBrowser.MyUseCase.LOCAL_CHANGES,
null);
myChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myTree);
myChangesBrowser.getDiffAction().registerCustomShortcutSet(myChangesBrowser.getDiffAction().getShortcutSet(), myTree);
final EditSourceForDialogAction editSourceAction = new EditSourceForDialogAction(myChangesBrowser);
editSourceAction.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myChangesBrowser);
myChangesBrowser.addToolbarAction(editSourceAction);
@@ -79,6 +79,11 @@ public final class EmptyAction extends AnAction {
}
}
public static void registerWithShortcutSet(@NotNull String id, @NotNull ShortcutSet shortcutSet, @NotNull JComponent component) {
AnAction newAction = wrap(ActionManager.getInstance().getAction(id));
newAction.registerCustomShortcutSet(shortcutSet, component);
}
public static AnAction wrap(final AnAction action) {
return action instanceof ActionGroup ? new ActionGroup() {
{
@@ -22,7 +22,8 @@
*/
package com.intellij.openapi.vcs.changes;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.DiffPlaces;
import com.intellij.diff.util.DiffUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ide.CommonActionsManager;
import com.intellij.ide.TreeExpander;
@@ -40,9 +41,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.*;
import com.intellij.diff.util.DiffPlaces;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsBundle;
@@ -202,17 +200,13 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
DefaultActionGroup group = (DefaultActionGroup) ActionManager.getInstance().getAction("ChangesViewToolbar");
ActionManager.getInstance().getAction("ChangesView.Refresh").registerCustomShortcutSet(CommonShortcuts.getRerun(), panel);
ActionManager.getInstance().getAction("ChangesView.NewChangeList").registerCustomShortcutSet(CommonShortcuts.getNew(), panel);
ActionManager.getInstance().getAction("ChangesView.RemoveChangeList").registerCustomShortcutSet(CommonShortcuts.getDelete(), panel);
AnAction moveToChangeList = ActionManager.getInstance().getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST);
moveToChangeList.registerCustomShortcutSet(new CompositeShortcutSet(moveToChangeList.getShortcutSet(),
CommonShortcuts.getMove()), panel);
ActionManager.getInstance().getAction("ChangesView.Rename").registerCustomShortcutSet(CommonShortcuts.getRename(), panel);
ActionManager.getInstance().getAction("ChangesView.SetDefault").registerCustomShortcutSet(
new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.ALT_DOWN_MASK | ctrlMask())), panel);
ActionManager.getInstance().getAction("ChangesView.Diff").registerCustomShortcutSet(CommonShortcuts.getDiff(), panel);
EmptyAction.registerWithShortcutSet("ChangesView.Refresh", CommonShortcuts.getRerun(), panel);
EmptyAction.registerWithShortcutSet("ChangesView.NewChangeList", CommonShortcuts.getNew(), panel);
EmptyAction.registerWithShortcutSet("ChangesView.RemoveChangeList", CommonShortcuts.getDelete(), panel);
EmptyAction.registerWithShortcutSet(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), panel);
EmptyAction.registerWithShortcutSet("ChangesView.Rename",CommonShortcuts.getRename() , panel);
EmptyAction.registerWithShortcutSet("ChangesView.SetDefault", new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.ALT_DOWN_MASK | ctrlMask())), panel);
EmptyAction.registerWithShortcutSet("ChangesView.Diff", CommonShortcuts.getDiff(), panel);
JPanel toolbarPanel = new JPanel(new BorderLayout());
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, group, false);
@@ -226,9 +220,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
visualActionsGroup.add(CommonActionsManager.getInstance().createCollapseAllAction(expander, panel));
ToggleShowFlattenAction showFlattenAction = new ToggleShowFlattenAction();
showFlattenAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P,
ctrlMask())),
panel);
showFlattenAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, ctrlMask())), panel);
visualActionsGroup.add(showFlattenAction);
visualActionsGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY));
visualActionsGroup.add(new ToggleShowIgnoredAction());
@@ -172,7 +172,7 @@ public class CommittedChangesBrowser extends JPanel {
selectFirstIfAny();
myChangesView.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myChangeListsView);
myChangesView.getDiffAction().registerCustomShortcutSet(myChangesView.getDiffAction().getShortcutSet(), myChangeListsView);
}
public void selectFirstIfAny() {
@@ -121,9 +121,8 @@ public class CommittedChangesPanel extends JPanel implements TypeSafeDataProvide
} else {
myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList());
}
final AnAction anAction = ActionManager.getInstance().getAction("CommittedChanges.Refresh");
anAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);
EmptyAction.registerWithShortcutSet("CommittedChanges.Refresh", CommonShortcuts.getRerun(), this);
myBrowser.addFilter(myFilterComponent);
myIfNotCachedReloader = myLocation == null ? null : new Consumer<String>() {
@Override
@@ -10,6 +10,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Splitter;
@@ -110,9 +111,9 @@ public class CommittedChangesTreeBrowser extends JPanel implements TypeSafeDataP
updateBySelectionChange();
ActionManager.getInstance().getAction("CommittedChanges.Details").registerCustomShortcutSet(
new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_QUICK_JAVADOC)),
this);
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
CustomShortcutSet quickdocShortcuts = new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_QUICK_JAVADOC));
EmptyAction.registerWithShortcutSet("CommittedChanges.Details", quickdocShortcuts, this);
myCopyProvider = new TreeCopyProvider(myChangesTree);
myTreeExpander = new DefaultTreeExpander(myChangesTree);
@@ -120,7 +121,7 @@ public class CommittedChangesTreeBrowser extends JPanel implements TypeSafeDataP
myHelpId = ourHelpId;
myDetailsView.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myChangesTree);
myDetailsView.getDiffAction().registerCustomShortcutSet(myDetailsView.getDiffAction().getShortcutSet(), myChangesTree);
myConnection = myProject.getMessageBus().connect();
myConnection.subscribe(ITEMS_RELOADED, new CommittedChangesReloadListener() {
@@ -125,9 +125,9 @@ public class ShelvedChangesViewManager implements ProjectComponent {
new TreeLinkMouseListener(new ShelfTreeCellRenderer(project, myMoveRenameInfo)).installOn(myTree);
final AnAction showDiffAction = ActionManager.getInstance().getAction("ShelvedChanges.Diff");
showDiffAction.registerCustomShortcutSet(CommonShortcuts.getDiff(), myTree);
showDiffAction.registerCustomShortcutSet(showDiffAction.getShortcutSet(), myTree);
final EditSourceAction editSourceAction = new EditSourceAction();
editSourceAction.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myTree);
editSourceAction.registerCustomShortcutSet(editSourceAction.getShortcutSet(), myTree);
PopupHandler.installPopupHandler(myTree, "ShelvedChangesPopupMenu", ActionPlaces.UNKNOWN);
@@ -83,7 +83,7 @@ public class MainFrame extends JPanel implements TypeSafeDataProvider {
myDetailsPanel = new DetailsPanel(logDataHolder, myGraphTable, vcsLogUI.getColorManager(), initialDataPack);
myChangesBrowser = new RepositoryChangesBrowser(project, null, Collections.<Change>emptyList(), null);
myChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), getGraphTable());
myChangesBrowser.getDiffAction().registerCustomShortcutSet(myChangesBrowser.getDiffAction().getShortcutSet(), getGraphTable());
myChangesBrowser.getEditSourceAction().registerCustomShortcutSet(CommonShortcuts.getEditSource(), getGraphTable());
setDefaultEmptyText(myChangesBrowser);
myChangesLoadingPane = new JBLoadingPanel(new BorderLayout(), project);
@@ -102,7 +102,7 @@ public class GitCommitListPanel extends JPanel implements TypeSafeDataProvider {
* Registers the diff action which will be called when the diff shortcut is pressed in the table.
*/
public void registerDiffAction(@NotNull AnAction diffAction) {
diffAction.registerCustomShortcutSet(CommonShortcuts.getDiff(), myTable);
diffAction.registerCustomShortcutSet(diffAction.getShortcutSet(), myTable);
}
// Make changes available for diff action
@@ -350,7 +350,7 @@ public class ToBeMergedDialog extends DialogWrapper implements MergeDialogI {
flatModel.fireTableDataChanged();
myRepositoryChangesBrowser = new RepositoryChangesBrowser(myProject, Collections.<CommittedChangeList>emptyList(), Collections.<Change>emptyList(), null);
myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myRevisionsList);
myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
setChangesDecorator();
mySplitter.setSecondComponent(myRepositoryChangesBrowser);
mySplitter.setDividerWidth(2);