mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-162371 Duplicate "Editor Colors" entry in export settings
This commit is contained in:
@@ -67,12 +67,12 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
myShowFilePath = showFilePath;
|
||||
Map<ExportableItem, ComponentElementProperties> componentToContainingListElement = new LinkedHashMap<>();
|
||||
for (List<ExportableItem> list : fileToComponents.values()) {
|
||||
for (ExportableItem component : list) {
|
||||
if (!addToExistingListElement(component, componentToContainingListElement, fileToComponents)) {
|
||||
for (ExportableItem item : list) {
|
||||
if (!addToExistingListElement(item, componentToContainingListElement, fileToComponents)) {
|
||||
ComponentElementProperties componentElementProperties = new ComponentElementProperties();
|
||||
componentElementProperties.addComponent(component);
|
||||
componentElementProperties.items.add(item);
|
||||
|
||||
componentToContainingListElement.put(component, componentElementProperties);
|
||||
componentToContainingListElement.put(item, componentElementProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
for (ComponentElementProperties componentElementProperty : new LinkedHashSet<>(componentToContainingListElement.values())) {
|
||||
myChooser.addElement(componentElementProperty, true, componentElementProperty);
|
||||
}
|
||||
myChooser.sort((o1, o2) -> o1.toString().compareTo(o2.toString()));
|
||||
myChooser.sort(Comparator.comparing(ComponentElementProperties::toString));
|
||||
|
||||
final ActionListener browseAction = new ActionListener() {
|
||||
@Override
|
||||
@@ -136,27 +136,27 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
private static boolean addToExistingListElement(@NotNull ExportableItem component,
|
||||
@NotNull Map<ExportableItem, ComponentElementProperties> componentToContainingListElement,
|
||||
@NotNull Map<Path, List<ExportableItem>> fileToComponents) {
|
||||
Path file = null;
|
||||
for (Path exportFile : component.getFiles()) {
|
||||
List<ExportableItem> list = fileToComponents.get(exportFile);
|
||||
if (!ContainerUtil.isEmpty(list)) {
|
||||
for (ExportableItem tiedComponent : list) {
|
||||
if (tiedComponent == component) {
|
||||
continue;
|
||||
}
|
||||
private static boolean addToExistingListElement(@NotNull ExportableItem item,
|
||||
@NotNull Map<ExportableItem, ComponentElementProperties> itemToContainingListElement,
|
||||
@NotNull Map<Path, List<ExportableItem>> fileToItem) {
|
||||
List<ExportableItem> list = fileToItem.get(item.getFile());
|
||||
if (ContainerUtil.isEmpty(list)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ComponentElementProperties elementProperties = componentToContainingListElement.get(tiedComponent);
|
||||
if (elementProperties != null && exportFile != file) {
|
||||
LOG.assertTrue(file == null, "Component " + component + " serialize itself into " + file + " and " + exportFile);
|
||||
// found
|
||||
elementProperties.addComponent(component);
|
||||
componentToContainingListElement.put(component, elementProperties);
|
||||
file = exportFile;
|
||||
}
|
||||
}
|
||||
Path file = null;
|
||||
for (ExportableItem tiedItem : list) {
|
||||
if (tiedItem == item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final ComponentElementProperties elementProperties = itemToContainingListElement.get(tiedItem);
|
||||
if (elementProperties != null && item.getFile() != file) {
|
||||
LOG.assertTrue(file == null, "Component " + item + " serialize itself into " + file + " and " + item.getFile());
|
||||
// found
|
||||
elementProperties.items.add(item);
|
||||
itemToContainingListElement.put(item, elementProperties);
|
||||
file = item.getFile();
|
||||
}
|
||||
}
|
||||
return file != null;
|
||||
@@ -229,17 +229,13 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
Set<ExportableItem> getExportableComponents() {
|
||||
Set<ExportableItem> components = new THashSet<>();
|
||||
for (ComponentElementProperties elementProperties : myChooser.getMarkedElements()) {
|
||||
components.addAll(elementProperties.myComponents);
|
||||
components.addAll(elementProperties.items);
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
private static class ComponentElementProperties implements ElementsChooser.ElementProperties {
|
||||
private final Set<ExportableItem> myComponents = new HashSet<>();
|
||||
|
||||
private boolean addComponent(ExportableItem component) {
|
||||
return myComponents.add(component);
|
||||
}
|
||||
private final Set<ExportableItem> items = new THashSet<>();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -255,7 +251,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
|
||||
public String toString() {
|
||||
Set<String> names = new LinkedHashSet<>();
|
||||
for (ExportableItem component : myComponents) {
|
||||
for (ExportableItem component : items) {
|
||||
names.add(component.getPresentableName());
|
||||
}
|
||||
return StringUtil.join(ArrayUtil.toStringArray(names), ", ");
|
||||
|
||||
@@ -127,7 +127,7 @@ private class MyZipOutputStream(out: OutputStream) : ZipOutputStream(out) {
|
||||
}
|
||||
}
|
||||
|
||||
data class ExportableItem(val files: List<Path>, val presentableName: String, val roamingType: RoamingType = RoamingType.DEFAULT)
|
||||
data class ExportableItem(val file: Path, val presentableName: String, val roamingType: RoamingType = RoamingType.DEFAULT)
|
||||
|
||||
private fun exportInstalledPlugins(zipOut: MyZipOutputStream) {
|
||||
val plugins = ArrayList<String>()
|
||||
@@ -156,15 +156,17 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
|
||||
storageManager: StateStorageManager = ApplicationManager.getApplication().stateStore.stateStorageManager,
|
||||
onlyPaths: Set<String>? = null): Map<Path, List<ExportableItem>> {
|
||||
val result = LinkedHashMap<Path, MutableList<ExportableItem>>()
|
||||
@Suppress("DEPRECATION")
|
||||
val processor = { component: ExportableComponent ->
|
||||
val item = ExportableItem(component.exportFiles.map { it.toPath() }, component.presentableName, RoamingType.DEFAULT)
|
||||
for (exportFile in item.files) {
|
||||
result.putValue(exportFile, item)
|
||||
for (file in component.exportFiles) {
|
||||
val item = ExportableItem(file.toPath(), component.presentableName, RoamingType.DEFAULT)
|
||||
result.putValue(item.file, item)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
ApplicationManager.getApplication().getComponents(ExportableApplicationComponent::class.java).forEach(processor)
|
||||
@Suppress("DEPRECATION")
|
||||
ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent::class.java).forEach(processor)
|
||||
|
||||
val configPath = storageManager.expandMacros(ROOT_CONFIG)
|
||||
@@ -191,6 +193,7 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
|
||||
|
||||
ServiceManagerImpl.processAllImplementationClasses(ApplicationManager.getApplication() as ApplicationImpl, PairProcessor<Class<*>, PluginDescriptor> { aClass, pluginDescriptor ->
|
||||
val stateAnnotation = StoreUtil.getStateSpec(aClass)
|
||||
@Suppress("DEPRECATION")
|
||||
if (stateAnnotation == null || stateAnnotation.name.isNullOrEmpty() || ExportableComponent::class.java.isAssignableFrom(aClass)) {
|
||||
return@PairProcessor true
|
||||
}
|
||||
@@ -227,10 +230,10 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
|
||||
|
||||
val presentableName = if (computePresentableNames) getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor) else ""
|
||||
if (isFileIncluded) {
|
||||
result.putValue(file, ExportableItem(listOf(file), presentableName, storage.roamingType))
|
||||
result.putValue(file, ExportableItem(file, presentableName, storage.roamingType))
|
||||
}
|
||||
if (additionalExportFile != null) {
|
||||
result.putValue(additionalExportFile, ExportableItem(listOf(additionalExportFile), presentableName, RoamingType.DEFAULT))
|
||||
result.putValue(additionalExportFile, ExportableItem(additionalExportFile, "$presentableName (schemes)", RoamingType.DEFAULT))
|
||||
}
|
||||
}
|
||||
true
|
||||
@@ -241,7 +244,7 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
|
||||
if (it.roamingType != RoamingType.DISABLED && it.fileSpec.getOrNull(0) != '$') {
|
||||
val file = Paths.get(storageManager.expandMacros(ROOT_CONFIG), it.fileSpec)
|
||||
if (!result.containsKey(file) && !isSkipFile(file)) {
|
||||
result.putValue(file, ExportableItem(listOf(file), it.presentableName ?: "", it.roamingType))
|
||||
result.putValue(file, ExportableItem(file, it.presentableName ?: "", it.roamingType))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +110,8 @@ private class ImportSettingsAction : AnAction(), DumbAware {
|
||||
private fun getRelativeNamesToExtract(chosenComponents: Set<ExportableItem>): Set<String> {
|
||||
val result = THashSet<String>()
|
||||
val root = Paths.get(PathManager.getConfigPath())
|
||||
for ((files) in chosenComponents) {
|
||||
for (exportFile in files) {
|
||||
result.add(root.relativize(exportFile).systemIndependentPath)
|
||||
}
|
||||
for (item in chosenComponents) {
|
||||
result.add(root.relativize(item.file).systemIndependentPath)
|
||||
}
|
||||
|
||||
result.add(PluginManager.INSTALLED_TXT)
|
||||
|
||||
@@ -134,10 +134,10 @@ internal class ApplicationStoreTest {
|
||||
}
|
||||
|
||||
test(ExportableItem(Paths.get(optionsPath, "filetypes.xml"), "File types", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(rootConfigPath, "filetypes"), "File types", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(rootConfigPath, "filetypes"), "File types (schemes)", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(optionsPath, "customization.xml"), "Menus and toolbars customization", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(optionsPath, "templates.xml"), "Live templates", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(rootConfigPath, "templates"), "Live templates", RoamingType.DEFAULT))
|
||||
test(ExportableItem(Paths.get(rootConfigPath, "templates"), "Live templates (schemes)", RoamingType.DEFAULT))
|
||||
}
|
||||
|
||||
@Test fun `import settings`() {
|
||||
@@ -175,7 +175,7 @@ internal class ApplicationStoreTest {
|
||||
val componentKey = A::class.java.name
|
||||
picoContainer.registerComponent(InstanceComponentAdapter(componentKey, component))
|
||||
try {
|
||||
assertThat(getExportableComponentsMap(false, false, storageManager, relativePaths)).containsOnly(componentFile.to(listOf(ExportableItem(componentFile, ""))), additionalFile.to(listOf(ExportableItem(additionalFile, ""))))
|
||||
assertThat(getExportableComponentsMap(false, false, storageManager, relativePaths)).containsOnly(componentFile.to(listOf(ExportableItem(componentFile, ""))), additionalFile.to(listOf(ExportableItem(additionalFile, " (schemes)"))))
|
||||
}
|
||||
finally {
|
||||
picoContainer.unregisterComponent(componentKey)
|
||||
|
||||
@@ -31,8 +31,8 @@ import java.nio.file.Path
|
||||
fun copyLocalConfig(storageManager: StateStorageManagerImpl = ApplicationManager.getApplication()!!.stateStore.stateStorageManager as StateStorageManagerImpl) {
|
||||
val streamProvider = StreamProviderWrapper.getOriginalProvider(storageManager.streamProvider)!! as IcsManager.IcsStreamProvider
|
||||
|
||||
val fileToComponents = getExportableComponentsMap(true, false, storageManager)
|
||||
fileToComponents.keys.forEachGuaranteed { file ->
|
||||
val fileToItems = getExportableComponentsMap(true, false, storageManager)
|
||||
fileToItems.keys.forEachGuaranteed { file ->
|
||||
var fileSpec: String
|
||||
try {
|
||||
val absolutePath = file.toAbsolutePath().systemIndependentPath
|
||||
@@ -49,7 +49,7 @@ fun copyLocalConfig(storageManager: StateStorageManagerImpl = ApplicationManager
|
||||
return@forEachGuaranteed
|
||||
}
|
||||
|
||||
val roamingType = getRoamingType(fileToComponents.get(file)!!)
|
||||
val roamingType = fileToItems.get(file)?.firstOrNull()?.roamingType ?: RoamingType.DEFAULT
|
||||
if (file.isFile()) {
|
||||
val fileBytes = file.readBytes()
|
||||
streamProvider.doSave(fileSpec, fileBytes, fileBytes.size, roamingType)
|
||||
@@ -73,22 +73,4 @@ private fun saveDirectory(parent: Path, parentFileSpec: String, roamingType: Roa
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRoamingType(components: Collection<ExportableItem>): RoamingType {
|
||||
for (component in components) {
|
||||
if (component is ExportableItem) {
|
||||
return component.roamingType
|
||||
}
|
||||
// else if (component is PersistentStateComponent<*>) {
|
||||
// val stateAnnotation = component.javaClass.getAnnotation(State::class.java)
|
||||
// if (stateAnnotation != null) {
|
||||
// val storages = stateAnnotation.storages
|
||||
// if (!storages.isEmpty()) {
|
||||
// return storages[0].roamingType
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return RoamingType.DEFAULT
|
||||
}
|
||||
@@ -523,7 +523,6 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.codeInsight.folding.JavaCodeFoldingSettings"
|
||||
serviceImplementation="com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl"/>
|
||||
<exportable serviceInterface="com.intellij.codeInsight.folding.JavaCodeFoldingSettings"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.psi.impl.source.tree.injected.JavaConcatenationInjectorManager"
|
||||
serviceImplementation="com.intellij.psi.impl.source.tree.injected.JavaConcatenationInjectorManager"/>
|
||||
|
||||
Reference in New Issue
Block a user