diff-preview: extract Esc handler setup to common editor customizer
[idea/community.git] / platform / diff-impl / src / com / intellij / diff / util / FileEditorBase.kt
1 // Copyright 2000-2021 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.
2 package com.intellij.diff.util
3
4 import com.intellij.codeHighlighting.BackgroundEditorHighlighter
5 import com.intellij.openapi.fileEditor.*
6 import com.intellij.openapi.util.UserDataHolderBase
7 import com.intellij.ui.docking.impl.DockManagerImpl
8 import java.beans.PropertyChangeListener
9 import java.beans.PropertyChangeSupport
10
11 abstract class FileEditorBase : UserDataHolderBase(), FileEditor {
12
13   init {
14     configureDefaults()
15   }
16
17   private fun configureDefaults() {
18     putUserData(FileEditorManager.USE_MAIN_WINDOW, true)
19     putUserData(DockManagerImpl.SHOW_NORTH_PANEL, false)
20   }
21
22   protected val propertyChangeSupport = PropertyChangeSupport(this)
23
24   override fun dispose() {}
25   override fun isValid(): Boolean = true
26
27   override fun selectNotify() {}
28   override fun deselectNotify() {}
29
30   fun firePropertyChange(propName: String, oldValue: Boolean, newValue: Boolean) {
31     propertyChangeSupport.firePropertyChange(propName, oldValue, newValue)
32   }
33
34   override fun addPropertyChangeListener(listener: PropertyChangeListener) {
35     propertyChangeSupport.addPropertyChangeListener(listener)
36   }
37
38   override fun removePropertyChangeListener(listener: PropertyChangeListener) {
39     propertyChangeSupport.removePropertyChangeListener(listener)
40   }
41
42   //
43   // Unused
44   //
45
46   override fun getState(level: FileEditorStateLevel): FileEditorState = FileEditorState.INSTANCE
47   override fun setState(state: FileEditorState) {}
48   override fun isModified(): Boolean = false
49
50   override fun getBackgroundHighlighter(): BackgroundEditorHighlighter? = null
51   override fun getCurrentLocation(): FileEditorLocation? = null
52 }