mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable Export/Import actions if Settings Repository plugin active
This commit is contained in:
@@ -39,6 +39,12 @@ import java.util.*
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
internal fun isImportExportActionApplicable(): Boolean {
|
||||
val app = ApplicationManager.getApplication()
|
||||
val storageManager = app.stateStore.storageManager as? StateStorageManagerImpl ?: return true
|
||||
return !storageManager.isStreamProviderEnabled
|
||||
}
|
||||
|
||||
// for Rider purpose
|
||||
open class ExportSettingsAction : AnAction(), DumbAware {
|
||||
protected open fun getExportableComponents(): Map<Path, List<ExportableItem>> = getExportableComponentsMap(true, true)
|
||||
@@ -48,6 +54,10 @@ open class ExportSettingsAction : AnAction(), DumbAware {
|
||||
exportSettings(exportFiles, saveFile.outputStream(), FileUtilRt.toSystemIndependentName(PathManager.getConfigPath()))
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = isImportExportActionApplicable()
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
ApplicationManager.getApplication().saveSettings()
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ import java.util.zip.ZipInputStream
|
||||
|
||||
// for Rider purpose
|
||||
open class ImportSettingsAction : AnAction(), DumbAware {
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = isImportExportActionApplicable()
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val dataContext = e.dataContext
|
||||
val component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext)
|
||||
|
||||
@@ -45,6 +45,9 @@ open class StateStorageManagerImpl(private val rootTagName: String,
|
||||
|
||||
val compoundStreamProvider: CompoundStreamProvider = CompoundStreamProvider()
|
||||
|
||||
val isStreamProviderEnabled: Boolean
|
||||
get() = compoundStreamProvider.enabled
|
||||
|
||||
override fun addStreamProvider(provider: StreamProvider, first: Boolean) {
|
||||
if (first) {
|
||||
compoundStreamProvider.providers.add(0, provider)
|
||||
|
||||
Reference in New Issue
Block a user