diff --git a/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java b/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java index bb42a1bc8661..e2437960004f 100644 --- a/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java +++ b/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java @@ -16,10 +16,7 @@ package com.intellij.ide; import com.intellij.ide.impl.ProjectUtil; -import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.components.*; import com.intellij.openapi.project.Project; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; @@ -28,9 +25,10 @@ import org.jetbrains.annotations.NotNull; name = "RecentProjectsManager", roamingType = RoamingType.DISABLED, storages = { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/other.xml" - )} + @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml"), + @Storage(file = StoragePathMacros.APP_CONFIG + "/recentProjects.xml") + }, + storageChooser = LastStorageChooserForWrite.class ) public class RecentProjectsManager extends RecentProjectsManagerBase { public RecentProjectsManager(MessageBus messageBus) { diff --git a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java index 0f9855001b63..757706127a38 100644 --- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java +++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java @@ -61,7 +61,7 @@ import java.util.*; @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml"), @Storage(file = StoragePathMacros.APP_CONFIG + "/proxy.settings.xml") }, - storageChooser = HttpConfigurable.StorageChooser.class + storageChooser = LastStorageChooserForWrite.class ) public class HttpConfigurable implements PersistentStateComponent, ExportableApplicationComponent { public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("idea.connection.timeout", 10000); @@ -519,20 +519,6 @@ public class HttpConfigurable implements PersistentStateComponent { - @Override - public Storage[] selectStorages(Storage[] storages, HttpConfigurable component, StateStorageOperation operation) { - if (operation == StateStorageOperation.WRITE) { - for (Storage storage : storages) { - if (storage.file().equals(StoragePathMacros.APP_CONFIG + "/proxy.settings.xml")) { - return new Storage[] {storage}; - } - } - } - return storages; - } - } - public static class ProxyInfo { public boolean myStore; public String myUsername; diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java index 892a00b5ce43..dac48586b70d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java @@ -331,6 +331,9 @@ public abstract class ComponentStoreImpl implements IComponentStore { if (storageChooserClass == defaultClass) { return defaultStateStorageChooser.selectStorages(storages, persistentStateComponent, operation); } + else if (storageChooserClass == LastStorageChooserForWrite.class) { + return LastStorageChooserForWrite.INSTANCE.selectStorages(storages, persistentStateComponent, operation); + } else { try { @SuppressWarnings("unchecked") diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/LastStorageChooserForWrite.java b/platform/projectModel-api/src/com/intellij/openapi/components/LastStorageChooserForWrite.java new file mode 100644 index 000000000000..f9206dee03e3 --- /dev/null +++ b/platform/projectModel-api/src/com/intellij/openapi/components/LastStorageChooserForWrite.java @@ -0,0 +1,10 @@ +package com.intellij.openapi.components; + +public final class LastStorageChooserForWrite implements StateStorageChooser { + public static final LastStorageChooserForWrite INSTANCE = new LastStorageChooserForWrite(); + + @Override + public Storage[] selectStorages(Storage[] storages, Object component, StateStorageOperation operation) { + return operation == StateStorageOperation.WRITE ? new Storage[]{storages[storages.length - 1]} : storages; + } +} \ No newline at end of file