Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove setting default keyboard shortcut for 'Refresh all external projects' #277

Merged
merged 2 commits into from
Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/prepare-ci-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi

# we will use Community ids to download plugins.
export SCALA_PLUGIN_ID="org.intellij.scala"
export SCALA_PLUGIN_MD5="a14d5bc0dfea64e7af9d520a4094afef" # 2016.3.8
export SCALA_PLUGIN_MD5="51a78f9f4d185e614bf51704fac29f4f" # 2016.3.9

export INTELLIJ_PLUGINS_HOME="$CWD/.cache/intellij/$FULL_IJ_BUILD_NUMBER/plugins"
export INTELLIJ_HOME="$CWD/.cache/intellij/$FULL_IJ_BUILD_NUMBER/idea-dist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,23 @@
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.twitter.intellij.pants.components.PantsInitComponent;
import com.twitter.intellij.pants.compiler.actions.PantsCompileAllTargetsAction;
import com.twitter.intellij.pants.compiler.actions.PantsCompileAllTargetsInModuleAction;
import com.twitter.intellij.pants.compiler.actions.PantsRebuildAction;
import com.twitter.intellij.pants.components.PantsInitComponent;
import com.twitter.intellij.pants.metrics.PantsMetrics;
import com.twitter.intellij.pants.ui.PantsOverrideAction;
import com.twitter.intellij.pants.compiler.actions.PantsRebuildAction;
import com.twitter.intellij.pants.util.PantsConstants;
import com.twitter.intellij.pants.util.PantsUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.event.HyperlinkEvent;
import java.io.File;

public class PantsInitComponentImpl implements PantsInitComponent {
Expand All @@ -55,11 +46,9 @@ public void initComponent() {
final String basePath = System.getProperty("pants.plugin.base.path");
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId(PantsConstants.PLUGIN_ID));
if (StringUtil.isNotEmpty(basePath) && plugin instanceof IdeaPluginDescriptorImpl) {
((IdeaPluginDescriptorImpl)plugin).setPath(new File(basePath));
((IdeaPluginDescriptorImpl) plugin).setPath(new File(basePath));
}

registerRefreshKey();

registerPantsActions();
}

Expand Down Expand Up @@ -105,32 +94,4 @@ private void registerPantsActions() {
actionManager.registerAction(IdeActions.ACTION_COMPILE, pantsDisableCompileAction);
actionManager.registerAction(IdeActions.ACTION_COMPILE_PROJECT, pantsRebuildAction);
}


private void registerRefreshKey() {
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
KeyboardShortcut keyboardShortcut = KeyboardShortcut.fromString("shift meta pressed R");

// Add (Cmd Shift R) as shortcut to refresh the project if there is no shortcut for that action yet.
// Shows error message if conflicting shortcut exists
if (KeymapManager.getInstance().getActiveKeymap().getShortcuts("ExternalSystem.RefreshAllProjects").length == 0 &&
keymap.getActionIds(keyboardShortcut).length > 0) {

Notification notification = new Notification(
"Keymap Error",
"Keymap Error",
"Conflict found assigning '⌘+Shift+R' to 'Refresh all external projects'. Please set it manually in " +
"<a href='#'>Keymap settings</a>.",
NotificationType.WARNING,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
ShowSettingsUtil.getInstance().showSettingsDialog(null, "Keymap");
}
}
);
Notifications.Bus.notify(notification);
keymap.addShortcut("ExternalSystem.RefreshAllProjects", keyboardShortcut);
}
}
}