override fun collectNotificationData()

in src/main/kotlin/com/intellij/ideolog/file/LogFileFormatNotificationProvider.kt [27:68]


  override fun collectNotificationData(project: Project, file: VirtualFile): Function<in FileEditor, out JComponent?> {
    return Function {
      if (it !is LogFileEditor) return@Function null
      val editor = (it as TextEditor).editor

      val propertiesComponent = PropertiesComponent.getInstance()
      val logFormat = detectLogFileFormat(editor)

      if (propertiesComponent.getBoolean(DONT_SHOW_AGAIN_KEY) || editor.getUserData(HIDDEN_KEY) != null)
        return@Function null

      val formatDetected = logFormat.myRegexLogParser != null
      if (formatDetected && PlatformUtils.isPhpStorm()) {
        return@Function null
      }

      val panel = EditorNotificationPanel().apply {
        if (formatDetected) {
          val formatName = logFormat.myRegexLogParser.otherParsingSettings.name
          text(IdeologBundle.message("label.log.format.recognized", formatName))
        } else {
          createActionLabel(IdeologBundle.message("link.label.configure.log.formats")) {
            ShowSettingsUtil.getInstance().editConfigurable(project, LogHighlightingConfigurable())
            update(file, project)
          }
          text(IdeologBundle.message("label.log.format.not.recognized"))
        }
        createActionLabel(IdeologBundle.message("link.label.hide.notification")) {
          editor.putUserData(HIDDEN_KEY, HIDDEN_KEY)

          update(file, project)
        }
        createActionLabel(IdeologBundle.message("link.label.don.t.show.again")) {
          propertiesComponent.setValue(DONT_SHOW_AGAIN_KEY, true)

          update(file, project)
        }
      }

      return@Function panel
    }
  }