RecentProjectsManager must use own storage file (because his roaming is disabled)

This commit is contained in:
Vladimir Krivosheev
2014-09-02 20:50:45 +02:00
parent 566cc8f4af
commit 7bf806b0dc
4 changed files with 19 additions and 22 deletions
@@ -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) {
@@ -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<HttpConfigurable>, ExportableApplicationComponent {
public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("idea.connection.timeout", 10000);
@@ -519,20 +519,6 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
return "Proxy Settings";
}
public static class StorageChooser implements StateStorageChooser<HttpConfigurable> {
@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;
@@ -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")
@@ -0,0 +1,10 @@
package com.intellij.openapi.components;
public final class LastStorageChooserForWrite implements StateStorageChooser<Object> {
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;
}
}