diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java index fac049f3440d..1a916c6d69b2 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -20,13 +20,13 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.impl.content.GraphicsConfig; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; +import com.intellij.util.SystemProperties; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.BaseButtonBehavior; import com.intellij.util.ui.TimedDeadzone; @@ -52,7 +52,7 @@ import java.util.List; * User: spLeaner */ public class ConfigurationErrorsComponent extends JPanel implements Disposable, ListDataListener { - private static final int MAX_ERRORS_TO_SHOW = SystemInfo.getIntProperty("idea.project.structure.max.errors.to.show", 100); + private static final int MAX_ERRORS_TO_SHOW = SystemProperties.getIntProperty("idea.project.structure.max.errors.to.show", 100); private static final boolean ONE_LINE = true; private static final boolean MULTI_LINE = false; diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 4022b3210a61..10c7490d2cf7 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -16,6 +16,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -211,15 +212,8 @@ public class SystemInfo extends SystemInfoRt { return StringUtil.compareVersionNumbers(JAVA_RUNTIME_VERSION, v) >= 0; } + /** @deprecated use {@linkplain SystemProperties#getIntProperty(String, int)} (to remove in IDEA 13) */ public static int getIntProperty(@NotNull final String key, final int defaultValue) { - final String value = System.getProperty(key); - if (value != null) { - try { - return Integer.parseInt(value); - } - catch (NumberFormatException ignored) { } - } - - return defaultValue; + return SystemProperties.getIntProperty(key, defaultValue); } } diff --git a/platform/util/src/com/intellij/util/SystemProperties.java b/platform/util/src/com/intellij/util/SystemProperties.java index 5b3180cfd88a..6f7750c5d982 100644 --- a/platform/util/src/com/intellij/util/SystemProperties.java +++ b/platform/util/src/com/intellij/util/SystemProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -15,6 +15,7 @@ */ package com.intellij.util; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -22,13 +23,11 @@ import org.jetbrains.annotations.Nullable; * * @author yole */ - @SuppressWarnings({"HardCodedStringLiteral"}) public class SystemProperties { private static String ourTestUserName; - private SystemProperties() { - } + private SystemProperties() { } /** * Returns the value of the user.home system property. @@ -91,4 +90,24 @@ public class SystemProperties { public static String getJavaHome() { return System.getProperty("java.home"); } + + /** + * Returns the value of given property as integer. + * Returns {@code defaultValue} if property is not specified or malformed. + * + * @param key the property name + * @param defaultValue default value + * @return the property value as integer, or default value. + */ + public static int getIntProperty(@NotNull final String key, final int defaultValue) { + final String value = System.getProperty(key); + if (value != null) { + try { + return Integer.parseInt(value); + } + catch (NumberFormatException ignored) { } + } + + return defaultValue; + } } diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java index 4cf6dfbde294..8be638b4636f 100644 --- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java +++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -18,6 +18,7 @@ package com.intellij.util.io; import com.intellij.openapi.Forceable; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.SystemProperties; import com.intellij.util.containers.hash.LinkedHashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -51,15 +52,15 @@ public class PagedFileStorage implements Forceable { final int lower = 100; final int upper = SystemInfo.is64Bit && !PersistentEnumeratorDelegate.useBtree() ? 500 : 200; - BUFFER_SIZE = Math.max(1, SystemInfo.getIntProperty("idea.paged.storage.page.size", 10)) * MB; + BUFFER_SIZE = Math.max(1, SystemProperties.getIntProperty("idea.paged.storage.page.size", 10)) * MB; if (ByteBufferWrapper.NO_MMAP) { final long max = VM.maxDirectMemory() - 2 * BUFFER_SIZE; LOWER_LIMIT = (int)Math.min(lower * MB, max); - UPPER_LIMIT = (int)Math.min(Math.max(LOWER_LIMIT, SystemInfo.getIntProperty("idea.max.paged.storage.cache", upper) * MB), max); + UPPER_LIMIT = (int)Math.min(Math.max(LOWER_LIMIT, SystemProperties.getIntProperty("idea.max.paged.storage.cache", upper) * MB), max); } else { LOWER_LIMIT = lower * MB; - UPPER_LIMIT = Math.max(LOWER_LIMIT, SystemInfo.getIntProperty("idea.max.paged.storage.cache", upper) * MB); + UPPER_LIMIT = Math.max(LOWER_LIMIT, SystemProperties.getIntProperty("idea.max.paged.storage.cache", upper) * MB); } LOG.info("lower=" + (LOWER_LIMIT / MB) +