use of com.intellij.openapi.editor.event.EditorMouseEventArea in project intellij-community by JetBrains.
the class OpenInEditorWithMouseAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
InputEvent inputEvent = e.getInputEvent();
if (!(inputEvent instanceof MouseEvent)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (e.getProject() == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (e.getData(OpenInEditorAction.KEY) == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Component component = inputEvent.getComponent();
if (component == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Point point = ((MouseEvent) inputEvent).getPoint();
Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y);
if (!(componentAt instanceof EditorGutterComponentEx)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Editor editor = getEditor(componentAt);
if (editor == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), (MouseEvent) inputEvent, componentAt);
EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent);
if (area != EditorMouseEventArea.LINE_NUMBERS_AREA) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
Aggregations