disable Export/Import actions if Settings Repository plugin active

This commit is contained in:
Vladimir Krivosheev
2018-07-02 15:06:38 +02:00
parent be0c1af558
commit c23dd65a2d
3 changed files with 17 additions and 0 deletions
@@ -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)