diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:07 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:28 -0700 |
commit | e782c57d74000722f9db4c9426317410520670c6 (patch) | |
tree | 6e5d3e8934107ffabb7661f8bfc0e1a08eb37faf /platform/platform-api/src/com/intellij/util | |
parent | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (diff) | |
download | idea-e782c57d74000722f9db4c9426317410520670c6.tar.gz |
Snapshot idea/138.2210 from git://git.jetbrains.org/idea/community.git
Change-Id: I8f0204d7887ee78cf1fd8c09f936c5afff0edd2f
Diffstat (limited to 'platform/platform-api/src/com/intellij/util')
4 files changed, 44 insertions, 50 deletions
diff --git a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java index 34238e57c635..ffcb0870dc3c 100644 --- a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java +++ b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 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. @@ -75,7 +75,7 @@ public class QueueProcessor<T> { * Constructs a QueueProcessor, which will autostart as soon as the first element is added to it. */ public QueueProcessor(@NotNull Consumer<T> processor) { - this(processor, Condition.FALSE); + this(processor, Conditions.alwaysFalse()); } /** 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<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; diff --git a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java index a1e36236c0e4..ff86990d7d16 100644 --- a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java +++ b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java @@ -1,8 +1,21 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.util.net.ssl; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.io.StreamUtil; -import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,55 +26,46 @@ import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; /** + * Names in constants match + * <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html">Standard Algorithm Name Documentation</a>. + * * @author Mikhail Golubev */ public class CertificateUtil { - private static final Logger LOG = Logger.getInstance(CertificateUtil.class); + public static final String X509 = "X.509"; + public static final String JKS = "JKS"; + public static final String PKCS12 = "PKCS12"; + public static final String PKIX = "PKIX"; + public static final String TLS = "TLS"; private static final CertificateFactory ourFactory = createFactory(); private static CertificateFactory createFactory() { try { - return CertificateFactory.getInstance("X509"); + return CertificateFactory.getInstance(X509); } catch (CertificateException e) { - throw new AssertionError("Can't initialize X509 certificate factory"); + throw new RuntimeException("Can't initialize X.509 certificate factory", e); } } - // Standard Names - // See complete reference at http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html - // certificate format - @Nls public static final String X509 = "X.509"; - // Java Key Store - standard type of keystores used by keytool utility - @Nls public static final String JKS = "JKS"; - // another standard type of keystore - @Nls public static final String PKCS12 = "PKCS12"; - // type of trust manager factory - @Nls public static final String PKIX = "PKIX"; - @Nls public static final String TLS = "TLS"; - - /** - * Utility class - */ - private CertificateUtil() { - // empty - } + private CertificateUtil() { } @Nullable public static X509Certificate loadX509Certificate(@NotNull String path) { - InputStream stream = null; try { - stream = new FileInputStream(path); - return (X509Certificate)ourFactory.generateCertificate(stream); + InputStream stream = new FileInputStream(path); + try { + return (X509Certificate)ourFactory.generateCertificate(stream); + } + finally { + stream.close(); + } } catch (Exception e) { - LOG.error("Can't add certificate for path: " + path, e); + Logger.getInstance(CertificateUtil.class).error("Can't add certificate for path: " + path, e); return null; } - finally { - StreamUtil.closeStream(stream); - } } /** diff --git a/platform/platform-api/src/com/intellij/util/ui/Animator.java b/platform/platform-api/src/com/intellij/util/ui/Animator.java index 94da2b15ba7a..55578fe8d994 100644 --- a/platform/platform-api/src/com/intellij/util/ui/Animator.java +++ b/platform/platform-api/src/com/intellij/util/ui/Animator.java @@ -64,7 +64,7 @@ public abstract class Animator implements Disposable { reset(); - if (ApplicationManager.getApplication() == null) { + if (noApplication()) { animationDone(); } } @@ -133,8 +133,7 @@ public abstract class Animator implements Disposable { } public void resume() { - final Application app = ApplicationManager.getApplication(); - if (app == null || app.isUnitTestMode()) { + if (noApplication()) { animationDone(); return; } @@ -164,6 +163,11 @@ public abstract class Animator implements Disposable { } } + protected boolean noApplication() { + Application app = ApplicationManager.getApplication(); + return app == null || app.isUnitTestMode(); + } + public abstract void paintNow(int frame, int totalFrames, int cycle); @Override |