in code_samples/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java [64:72]
public void update(@NotNull final AnActionEvent e) {
// Get required data keys
final Project project = e.getProject();
final Editor editor = e.getData(CommonDataKeys.EDITOR);
// Set visibility and enable only in case of an existing project and editor and if a selection exists
e.getPresentation().setEnabledAndVisible(
project != null && editor != null && editor.getSelectionModel().hasSelection()
);
}