mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dumb-aware GutterIconRenderer (EA-66681 - INRE: FileBasedIndexImpl.handleDumbMode)
This commit is contained in:
+5
-2
@@ -26,10 +26,13 @@ import javax.swing.*;
|
||||
/**
|
||||
* Interface which should be implemented in order to draw icons in the gutter area and handle events
|
||||
* for them. Gutter icons are drawn to the left of the folding area and can be used, for example,
|
||||
* to mark implemented or overridden methods.
|
||||
* to mark implemented or overridden methods.<p/>
|
||||
*
|
||||
* Daemon code analyzer checks newly arrived gutter icon renderer against the old one and if they are equal, does not redraw the icon.
|
||||
* So it is highly advisable to override hashCode()/equals() methods to avoid icon flickering when old gutter renderer gets replaced with the new.
|
||||
* So it is highly advisable to override hashCode()/equals() methods to avoid icon flickering when old gutter renderer gets replaced with the new.<p/>
|
||||
*
|
||||
* During indexing, click handlers are only invoked for renderers implementing {@link com.intellij.openapi.project.DumbAware}.
|
||||
*
|
||||
* @author max
|
||||
* @see RangeHighlighter#setGutterIconRenderer(GutterIconRenderer)
|
||||
*/
|
||||
|
||||
+20
-19
@@ -45,7 +45,7 @@ import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -1379,31 +1379,32 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
}
|
||||
|
||||
GutterIconRenderer renderer = getGutterRenderer(e);
|
||||
final Project project = myEditor.getProject();
|
||||
if (project != null && DumbService.isDumb(project) && !DumbService.isDumbAware(renderer)) {
|
||||
DumbService.getInstance(project).showDumbModeNotification("Navigation is not available during indexing");
|
||||
return;
|
||||
}
|
||||
|
||||
AnAction clickAction = null;
|
||||
if (renderer != null && e.getButton() < 4) {
|
||||
clickAction = (InputEvent.BUTTON2_MASK & e.getModifiers()) > 0
|
||||
? renderer.getMiddleButtonClickAction()
|
||||
: renderer.getClickAction();
|
||||
}
|
||||
try {
|
||||
if (clickAction != null) {
|
||||
clickAction.actionPerformed(new AnActionEvent(e, myEditor.getDataContext(), "ICON_NAVIGATION", clickAction.getTemplatePresentation(),
|
||||
ActionManager.getInstance(),
|
||||
e.getModifiers()));
|
||||
e.consume();
|
||||
repaint();
|
||||
}
|
||||
else {
|
||||
ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
|
||||
if (lineRenderer != null) {
|
||||
lineRenderer.doAction(myEditor, e);
|
||||
} else {
|
||||
fireEventToTextAnnotationListeners(e);
|
||||
}
|
||||
}
|
||||
if (clickAction != null) {
|
||||
clickAction.actionPerformed(new AnActionEvent(e, myEditor.getDataContext(), "ICON_NAVIGATION", clickAction.getTemplatePresentation(),
|
||||
ActionManager.getInstance(),
|
||||
e.getModifiers()));
|
||||
e.consume();
|
||||
repaint();
|
||||
}
|
||||
catch (IndexNotReadyException e1) {
|
||||
DumbService.getInstance(myEditor.getProject()).showDumbModeNotification("Navigation is not available during indexing");
|
||||
else {
|
||||
ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
|
||||
if (lineRenderer != null) {
|
||||
lineRenderer.doAction(myEditor, e);
|
||||
} else {
|
||||
fireEventToTextAnnotationListeners(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user