From 11a49080d54767dc6e7bcd99578a7174a44ff93e Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 28 Jan 2016 12:10:42 +0100 Subject: [PATCH] =?UTF-8?q?XPathView.XPathViewPlugin=20=E2=80=94=20store?= =?UTF-8?q?=20in=20own=20xpath.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use OptionsBundle to get name if plugin vendor is JetBrains and no resource bundle --- .../src/ExportSettingsAction.kt | 89 ++++++++++--------- .../src/messages/OptionsBundle.properties | 3 +- .../plugins/xpathView/XPathAppComponent.java | 11 ++- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/platform/configuration-store-impl/src/ExportSettingsAction.kt b/platform/configuration-store-impl/src/ExportSettingsAction.kt index 249ddfb03858..40c1f96fdaaf 100644 --- a/platform/configuration-store-impl/src/ExportSettingsAction.kt +++ b/platform/configuration-store-impl/src/ExportSettingsAction.kt @@ -165,7 +165,7 @@ fun getExportableComponentsMap(onlyExisting: Boolean, } } - @Suppress("DEPRECATED_SYMBOL_WITH_MESSAGE") + @Suppress("DEPRECATION") ApplicationManager.getApplication().getComponents(ExportableApplicationComponent::class.java).forEach(processor) ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent::class.java).forEach(processor) @@ -189,43 +189,41 @@ fun getExportableComponentsMap(onlyExisting: Boolean, result.keys.removeAll(::isSkipFile) } - ServiceManagerImpl.processAllImplementationClasses(ApplicationManager.getApplication() as ApplicationImpl, object : PairProcessor, PluginDescriptor> { - override fun process(aClass: Class<*>, pluginDescriptor: PluginDescriptor?): Boolean { - val stateAnnotation = StoreUtil.getStateSpec(aClass) - if (stateAnnotation == null || stateAnnotation.name.isNullOrEmpty() || ExportableComponent::class.java.isAssignableFrom(aClass)) { - return true - } - - val storage = sortStoragesByDeprecated(stateAnnotation.storages).firstOrNull() ?: return true - if (!(storage.roamingType != RoamingType.DISABLED && storage.storageClass == StateStorage::class && storage.scheme == StorageScheme.DEFAULT && !storage.file.isNullOrEmpty())) { - return true - } - - var additionalExportFile: File? = null - var additionalExportPath = stateAnnotation.additionalExportFile - if (additionalExportPath.isNotEmpty()) { - // backward compatibility - path can contain macro - if (additionalExportPath[0] != '$') { - additionalExportPath = "$ROOT_CONFIG/$additionalExportPath" - } - additionalExportFile = File(storageManager.expandMacros(additionalExportPath)) - if (isSkipFile(additionalExportFile)) { - additionalExportFile = null - } - } - - val file = File(storageManager.expandMacros(storage.file)) - val isFileIncluded = !isSkipFile(file) - if (isFileIncluded || additionalExportFile != null) { - val files = if (additionalExportFile == null) listOf(file) else if (isFileIncluded) listOf(file, additionalExportFile) else listOf(additionalExportFile) - val item = ExportableItem(files, if (computePresentableNames) getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor) else "", storage.roamingType) - result.putValue(file, item) - if (additionalExportFile != null) { - result.putValue(additionalExportFile, item) - } - } - return true + ServiceManagerImpl.processAllImplementationClasses(ApplicationManager.getApplication() as ApplicationImpl, PairProcessor, PluginDescriptor> { aClass, pluginDescriptor -> + val stateAnnotation = StoreUtil.getStateSpec(aClass) + if (stateAnnotation == null || stateAnnotation.name.isNullOrEmpty() || ExportableComponent::class.java.isAssignableFrom(aClass)) { + return@PairProcessor true } + + val storage = sortStoragesByDeprecated(stateAnnotation.storages).firstOrNull() ?: return@PairProcessor true + if (!(storage.roamingType != RoamingType.DISABLED && storage.storageClass == StateStorage::class && storage.scheme == StorageScheme.DEFAULT && !storage.file.isNullOrEmpty())) { + return@PairProcessor true + } + + var additionalExportFile: File? = null + var additionalExportPath = stateAnnotation.additionalExportFile + if (additionalExportPath.isNotEmpty()) { + // backward compatibility - path can contain macro + if (additionalExportPath[0] != '$') { + additionalExportPath = "$ROOT_CONFIG/$additionalExportPath" + } + additionalExportFile = File(storageManager.expandMacros(additionalExportPath)) + if (isSkipFile(additionalExportFile)) { + additionalExportFile = null + } + } + + val file = File(storageManager.expandMacros(storage.file)) + val isFileIncluded = !isSkipFile(file) + if (isFileIncluded || additionalExportFile != null) { + val files = if (additionalExportFile == null) listOf(file) else if (isFileIncluded) listOf(file, additionalExportFile) else listOf(additionalExportFile) + val item = ExportableItem(files, if (computePresentableNames) getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor) else "", storage.roamingType) + result.putValue(file, item) + if (additionalExportFile != null) { + result.putValue(additionalExportFile, item) + } + } + true }) return result } @@ -242,12 +240,21 @@ private fun getComponentPresentableName(state: State, aClass: Class<*>, pluginDe } val defaultName = state.name - val resourceBundleName = (if (pluginDescriptor is IdeaPluginDescriptor && "com.intellij" != pluginDescriptor.pluginId.idString) { - pluginDescriptor.resourceBundleBaseName + var resourceBundleName: String? + if (pluginDescriptor is IdeaPluginDescriptor && "com.intellij" != pluginDescriptor.pluginId.idString) { + resourceBundleName = pluginDescriptor.resourceBundleBaseName + if (resourceBundleName == null) { + if (pluginDescriptor.vendor == "JetBrains") { + resourceBundleName = OptionsBundle.PATH_TO_BUNDLE + } + else { + return defaultName + } + } } else { - OptionsBundle.PATH_TO_BUNDLE - }) ?: return defaultName + resourceBundleName = OptionsBundle.PATH_TO_BUNDLE + } var classLoader = pluginDescriptor?.pluginClassLoader ?: aClass.classLoader if (classLoader != null) { diff --git a/platform/platform-resources-en/src/messages/OptionsBundle.properties b/platform/platform-resources-en/src/messages/OptionsBundle.properties index 31903fd5d34b..c191528fee18 100644 --- a/platform/platform-resources-en/src/messages/OptionsBundle.properties +++ b/platform/platform-resources-en/src/messages/OptionsBundle.properties @@ -340,4 +340,5 @@ exportable.ExportableFileTemplateSettings.presentable.name=File templates exportable.ProjectManager.presentable.name=Default project exportable.com.intellij.ide.ui.customization.CustomActionsSchema.presentable.name=Menus and toolbars customization exportable.ActionMacroManager.presentable.name=Macros -exportable.ImportFilteringUsageViewSetting.presentable.name=Usage View: Imports \ No newline at end of file +exportable.ImportFilteringUsageViewSetting.presentable.name=Usage View: Imports +exportable.XPathView.XPathViewPlugin.presentable.name=XPath Viewer \ No newline at end of file diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/XPathAppComponent.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/XPathAppComponent.java index 6ddd26eec233..0f2f30583514 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/XPathAppComponent.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/XPathAppComponent.java @@ -21,7 +21,10 @@ import com.intellij.codeInsight.hint.HintUtil; import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.markup.RangeHighlighter; @@ -49,9 +52,9 @@ import java.util.List; @State( name = "XPathView.XPathViewPlugin", storages = { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/other.xml" - )} + @Storage(file = "xpath.xml"), + @Storage(file = "other.xml", deprecated = true) + } ) public class XPathAppComponent implements ApplicationComponent, PersistentStateComponent, DefaultLiveTemplatesProvider { private static final String ACTION_FIND_NEXT = "FindNext";