PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/platform/util/src/com/intellij/openapi/util/SystemInfo.java

https://github.com/jexp/idea2
Java | 114 lines | 56 code | 19 blank | 39 comment | 18 complexity | 58cb5c001bf769ebbbaf6dbe13c8a15b MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2000-2009 JetBrains s.r.o.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.intellij.openapi.util;
  17. import com.intellij.openapi.util.text.StringUtil;
  18. @SuppressWarnings({"HardCodedStringLiteral"})
  19. public class SystemInfo {
  20. private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
  21. public static final String OS_VERSION = System.getProperty("os.version").toLowerCase();
  22. public static final String OS_ARCH = System.getProperty("os.arch");
  23. public static final String JAVA_VERSION = System.getProperty("java.version");
  24. public static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version");
  25. public static final String ARCH_DATA_MODEL = System.getProperty("sun.arch.data.model");
  26. public static final String SUN_DESKTOP = System.getProperty("sun.desktop");
  27. public static final boolean isWindows = OS_NAME.startsWith("windows");
  28. public static final boolean isWindowsNT = OS_NAME.startsWith("windows nt");
  29. public static final boolean isWindows2000 = OS_NAME.startsWith("windows 2000");
  30. public static final boolean isWindows2003 = OS_NAME.startsWith("windows 2003");
  31. public static final boolean isWindowsXP = OS_NAME.startsWith("windows xp");
  32. public static final boolean isWindowsVista = OS_NAME.startsWith("windows vista");
  33. public static final boolean isWindows7 = OS_NAME.startsWith("windows 7");
  34. public static final boolean isWindows9x = OS_NAME.startsWith("windows 9") || OS_NAME.startsWith("windows me");
  35. public static final boolean isOS2 = OS_NAME.startsWith("os/2") || OS_NAME.startsWith("os2");
  36. public static final boolean isMac = OS_NAME.startsWith("mac");
  37. public static final boolean isFreeBSD = OS_NAME.startsWith("freebsd");
  38. public static final boolean isLinux = OS_NAME.startsWith("linux");
  39. public static final boolean isUnix = !isWindows && !isOS2;
  40. public static final boolean isKDE = SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("kde") >= 0;
  41. public static final boolean isGnome = SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("gnome") >= 0;
  42. public static final boolean isMacSystemMenu = isMac && "true".equals(System.getProperty("apple.laf.useScreenMenuBar"));
  43. public static final boolean isFileSystemCaseSensitive = !isWindows && !isOS2 && !isMac;
  44. public static final boolean is32Bit = ARCH_DATA_MODEL == null || ARCH_DATA_MODEL.equals("32");
  45. public static final boolean is64Bit = !is32Bit;
  46. public static final boolean isAMD64 = "amd64".equals(OS_ARCH);
  47. /**
  48. * Whether IDEA is running under MacOS X version 10.4 or later.
  49. *
  50. * @since 5.0.2
  51. */
  52. public static final boolean isMacOSTiger = isTiger();
  53. /**
  54. * Whether IDEA is running under MacOS X on an Intel Machine
  55. *
  56. * @since 5.0.2
  57. */
  58. public static final boolean isIntelMac = isIntelMac();
  59. /**
  60. * Running under MacOS X version 10.5 or later;
  61. *
  62. * @since 7.0.2
  63. */
  64. public static final boolean isMacOSLeopard = isLeopard();
  65. /**
  66. * Running under MacOS X version 10.5 or later;
  67. *
  68. * @since 9.0
  69. */
  70. public static final boolean isMacOSSnowLeopard = isSnowLeopard();
  71. /**
  72. * Operating system is supposed to have middle mouse button click occupied by paste action.
  73. * @since 6.0
  74. */
  75. public static boolean X11PasteEnabledSystem = isUnix && !isMac;
  76. private static boolean isTiger() {
  77. return isMac &&
  78. !OS_VERSION.startsWith("10.0") &&
  79. !OS_VERSION.startsWith("10.1") &&
  80. !OS_VERSION.startsWith("10.2") &&
  81. !OS_VERSION.startsWith("10.3");
  82. }
  83. private static boolean isIntelMac() {
  84. return isMac && "i386".equals(OS_ARCH);
  85. }
  86. private static boolean isLeopard() {
  87. return isMac && isTiger() && !OS_VERSION.startsWith("10.4");
  88. }
  89. private static boolean isSnowLeopard() {
  90. return isMac && isLeopard() && !OS_VERSION.startsWith("10.5");
  91. }
  92. public static boolean isJavaVersionAtLeast(String v) {
  93. return StringUtil.compareVersionNumbers(JAVA_RUNTIME_VERSION, v) >= 0;
  94. }
  95. }