always prefer getRightButtonClickAction to allow extra breakpoint actions in getPopupMenuActions for IDEA-125463

This commit is contained in:
Egor Ushakov
2018-05-07 14:26:50 +03:00
parent 64e52ed0ae
commit 37fdcb69ff
2 changed files with 19 additions and 28 deletions
@@ -1,18 +1,4 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor.markup;
import com.intellij.codeInsight.daemon.GutterMark;
@@ -42,6 +28,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
* displayed when the icon is right-clicked.
*
* @return the group of actions for the context menu, or null if no context menu is required.
* @see #getRightButtonClickAction()
*/
@Nullable
public ActionGroup getPopupMenuActions() {
@@ -79,6 +66,12 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
return null;
}
/**
* Returns the action executed when the icon is right-clicked.
*
* @return the action instance, or null to show the popup menu
* @see #getPopupMenuActions()
*/
@Nullable
public AnAction getRightButtonClickAction() {
return null;
@@ -1863,22 +1863,20 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
else {
GutterIconRenderer renderer = getGutterRenderer(e);
if (renderer != null) {
ActionGroup actionGroup = renderer.getPopupMenuActions();
if (actionGroup != null) {
if (checkDumbAware(actionGroup)) {
ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN,
actionGroup);
popupMenu.getComponent().show(this, e.getX(), e.getY());
}
else {
notifyNotDumbAware();
}
AnAction rightButtonAction = renderer.getRightButtonClickAction();
if (rightButtonAction != null) {
performAction(rightButtonAction, e, "ICON_NAVIGATION_SECONDARY_BUTTON", myEditor.getDataContext());
e.consume();
}
else {
AnAction rightButtonAction = renderer.getRightButtonClickAction();
if (rightButtonAction != null) {
performAction(rightButtonAction, e, "ICON_NAVIGATION_SECONDARY_BUTTON", myEditor.getDataContext());
ActionGroup actionGroup = renderer.getPopupMenuActions();
if (actionGroup != null) {
if (checkDumbAware(actionGroup)) {
actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, actionGroup).getComponent().show(this, e.getX(), e.getY());
}
else {
notifyNotDumbAware();
}
e.consume();
}
}