From efacd0106f2ebe601b01d93d2a8cf50bd0ae065f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 10 Apr 2014 11:46:55 +0200 Subject: [PATCH] IDEA-123615 (Proxy settings are not exported) --- .../intellij/util/net/HttpConfigurable.java | 41 ++++++++++++++++--- .../impl/stores/DefaultStateSerializer.java | 9 +--- 2 files changed, 38 insertions(+), 12 deletions(-) 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 685d814fe02e..4dfec8669bf9 100644 --- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java +++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.util.net; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ShowSettingsUtil; @@ -40,6 +41,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.*; @@ -55,10 +57,13 @@ import java.util.*; @State( name = "HttpConfigurable", storages = { - @Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml") - } + @Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml" ), + @Storage( file = StoragePathMacros.APP_CONFIG + "/proxy.settings.xml" ) + }, + storageChooser = HttpConfigurable.StorageChooser.class ) -public class HttpConfigurable implements PersistentStateComponent, ApplicationComponent, JDOMExternalizable { +public class HttpConfigurable implements PersistentStateComponent, ApplicationComponent, JDOMExternalizable, + ExportableApplicationComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.util.net.HttpConfigurable"); public boolean PROXY_TYPE_IS_SOCKS = false; public boolean USE_HTTP_PROXY = false; @@ -329,7 +334,7 @@ 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/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DefaultStateSerializer.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DefaultStateSerializer.java index 890d77578a81..d6cc3b2cc4e7 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DefaultStateSerializer.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DefaultStateSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import com.intellij.openapi.components.StorageId; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.xmlb.Accessor; import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; @@ -93,11 +92,7 @@ class DefaultStateSerializer { //assert mergeInto == null; return (T)stateElement; } - else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) { - if (mergeInto != null) { - String elementText = JDOMUtil.writeElement(stateElement, "\n"); - LOG.error("State is " + stateClass.getName() + ", merge into is " + mergeInto.toString() + ", state element text is " + elementText); - } + else if (JDOMExternalizable.class.isAssignableFrom(stateClass) && mergeInto == null) { try { final T t = stateClass.newInstance(); try {