mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RecentProjectsManager must use own storage file (because his roaming is disabled)
This commit is contained in:
@@ -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;
|
||||
|
||||
+3
@@ -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")
|
||||
|
||||
+10
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user