IDEA-131134 Support multiple breakpoints within on single line - extra shortcut for...
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 18 Jun 2015 13:58:32 +0000 (16:58 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 18 Jun 2015 13:59:49 +0000 (16:59 +0300)
java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java

index f39eb4b336fdf7ac10e2a5ed8a4bcb100fc6bf37..e917fb2a1df77f5552839c0ecb47c8a9801ae996 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,9 @@ import com.intellij.debugger.engine.BasicStepMethodFilter;
 import com.intellij.debugger.engine.LambdaMethodFilter;
 import com.intellij.debugger.engine.MethodFilter;
 import com.intellij.debugger.impl.DebuggerSession;
-import com.intellij.openapi.actionSystem.ActionManager;
-import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.fileEditor.TextEditor;
-import com.intellij.openapi.keymap.KeymapUtil;
-import com.intellij.openapi.ui.popup.ListPopup;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.ui.awt.RelativePoint;
@@ -38,10 +34,8 @@ import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import java.awt.event.ActionEvent;
 import java.util.Collections;
 import java.util.List;
 
@@ -78,27 +72,9 @@ public abstract class JvmSmartStepIntoHandler {
             session.stepInto(true, createMethodFilter(chosenTarget));
           }
         });
-        final ListPopup popup = new ListPopupImpl(popupStep) {
-          @Override
-          protected JComponent createContent() {
-            registerExtraHandleShortcuts(XDebuggerActions.STEP_INTO);
-            registerExtraHandleShortcuts(XDebuggerActions.SMART_STEP_INTO);
-            return super.createContent();
-          }
-
-          private void registerExtraHandleShortcuts(String actionName) {
-            AnAction action = ActionManager.getInstance().getAction(actionName);
-            KeyStroke stroke = KeymapUtil.getKeyStroke(action.getShortcutSet());
-            if (stroke != null) {
-              registerAction("handleSelection " + stroke, stroke, new AbstractAction() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                  handleSelect(true);
-                }
-              });
-            }
-          }
-        };
+        ListPopupImpl popup = new ListPopupImpl(popupStep);
+        DebuggerUIUtil.registerExtraHandleShortcuts(popup, XDebuggerActions.STEP_INTO);
+        DebuggerUIUtil.registerExtraHandleShortcuts(popup, XDebuggerActions.SMART_STEP_INTO);
         popup.addListSelectionListener(new ListSelectionListener() {
           public void valueChanged(ListSelectionEvent e) {
             popupStep.getScopeHighlighter().dropHighlight();
index f55e80100183a197ce8f1165e380c8aab61d91e1..2be5184b0d2af2eec4fab5942c9408d8b0852874 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl;
 import com.intellij.lang.Language;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.IdeActions;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.application.WriteAction;
@@ -34,8 +35,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.ListPopup;
 import com.intellij.openapi.ui.popup.PopupStep;
 import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
 import com.intellij.openapi.util.AsyncResult;
@@ -46,6 +45,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.popup.list.ListPopupImpl;
 import com.intellij.util.DocumentUtil;
 import com.intellij.util.Processor;
 import com.intellij.util.SmartList;
@@ -205,7 +205,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
               final int defaultIndex = defaultVariant != null ? variants.indexOf(defaultVariant) : 0;
 
               final MySelectionListener selectionListener = new MySelectionListener();
-              ListPopup popup = JBPopupFactory.getInstance().createListPopup(
+              ListPopupImpl popup = new ListPopupImpl(
                 new BaseListPopupStep<XLineBreakpointType.XLineBreakpointVariant>("Create breakpoint for", variants) {
                   @NotNull
                   @Override
@@ -241,6 +241,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
                     return defaultIndex;
                   }
                 });
+              DebuggerUIUtil.registerExtraHandleShortcuts(popup, IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT);
               popup.addListSelectionListener(selectionListener);
               popup.show(relativePoint);
               result.setResult(res);
index 626b22e068f02d6e39d6e64b097e9b0540c5b834..8210e45f17da59be13b2e0eb5b7536ee133eb222 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.breakpoints;
 import com.intellij.execution.impl.ConsoleViewUtil;
 import com.intellij.ide.startup.StartupManagerEx;
 import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.IdeActions;
 import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
@@ -298,7 +299,7 @@ public class XLineBreakpointManager {
               @Override
               public void run() {
                 if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) {
-                  ActionManagerEx.getInstanceEx().fireBeforeActionPerformed("ToggleLineBreakpoint", e.getMouseEvent());
+                  ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent());
 
                   AsyncResult<XLineBreakpoint> result = XBreakpointUtil.toggleLineBreakpoint(
                     myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false);
index 1d7dc8c0e92e4737ef6fd6986064bf5931465b9e..35b98b6fc5cb1e65a31168fe1e9be3b994743a91 100644 (file)
 package com.intellij.xdebugger.impl.ui;
 
 import com.intellij.codeInsight.hint.HintUtil;
+import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.LogicalPosition;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.colors.EditorColorsUtil;
+import com.intellij.openapi.keymap.KeymapUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.*;
 import com.intellij.openapi.util.Computable;
@@ -33,6 +36,7 @@ import com.intellij.ui.AppUIUtil;
 import com.intellij.ui.EditorTextField;
 import com.intellij.ui.ScreenUtil;
 import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.popup.list.ListPopupImpl;
 import com.intellij.xdebugger.XDebuggerManager;
 import com.intellij.xdebugger.breakpoints.XBreakpoint;
 import com.intellij.xdebugger.breakpoints.XBreakpointAdapter;
@@ -361,4 +365,17 @@ public class DebuggerUIUtil {
     }
     return true;
   }
+
+  public static void registerExtraHandleShortcuts(final ListPopupImpl popup, String actionName) {
+    AnAction action = ActionManager.getInstance().getAction(actionName);
+    KeyStroke stroke = KeymapUtil.getKeyStroke(action.getShortcutSet());
+    if (stroke != null) {
+      popup.registerAction("handleSelection " + stroke, stroke, new AbstractAction() {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+          popup.handleSelect(true);
+        }
+      });
+    }
+  }
 }