This commit is contained in:
Roman Shevchenko
2012-03-27 21:34:41 +02:00
parent 3143d7001f
commit 8ddfe2b308
4 changed files with 34 additions and 20 deletions
@@ -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;
@@ -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);
}
}
@@ -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;
}
}
@@ -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) +