PageRenderTime 43ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/code-orchestra/code-orchestra-lcs
Java | 109 lines | 52 code | 18 blank | 39 comment | 18 complexity | c383ca3efe3d9031598b44275882c7cc MD5 | raw file
  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. @SuppressWarnings({"HardCodedStringLiteral", "UtilityClassWithoutPrivateConstructor"})
  18. public class SystemInfo {
  19. private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
  20. public static final String OS_VERSION = System.getProperty("os.version").toLowerCase();
  21. public static final String OS_ARCH = System.getProperty("os.arch");
  22. public static final String JAVA_VERSION = System.getProperty("java.version");
  23. public static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version");
  24. public static final String ARCH_DATA_MODEL = System.getProperty("sun.arch.data.model");
  25. public static final String SUN_DESKTOP = System.getProperty("sun.desktop");
  26. public static final boolean isWindows = OS_NAME.startsWith("windows");
  27. public static final boolean isWindowsNT = OS_NAME.startsWith("windows nt");
  28. public static final boolean isWindows2000 = OS_NAME.startsWith("windows 2000");
  29. public static final boolean isWindows2003 = OS_NAME.startsWith("windows 2003");
  30. public static final boolean isWindowsXP = OS_NAME.startsWith("windows xp");
  31. public static final boolean isWindowsVista = OS_NAME.startsWith("windows vista");
  32. public static final boolean isWindows7 = OS_NAME.startsWith("windows 7");
  33. public static final boolean isWindows9x = OS_NAME.startsWith("windows 9") || OS_NAME.startsWith("windows me");
  34. public static final boolean isOS2 = OS_NAME.startsWith("os/2") || OS_NAME.startsWith("os2");
  35. public static final boolean isMac = OS_NAME.startsWith("mac");
  36. public static final boolean isFreeBSD = OS_NAME.startsWith("freebsd");
  37. public static final boolean isLinux = OS_NAME.startsWith("linux");
  38. public static final boolean isUnix = !isWindows && !isOS2;
  39. public static final boolean isKDE = SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("kde") >= 0;
  40. public static final boolean isGnome = SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("gnome") >= 0;
  41. public static final boolean isMacSystemMenu = isMac && "true".equals(System.getProperty("apple.laf.useScreenMenuBar"));
  42. public static final boolean isFileSystemCaseSensitive = !isWindows && !isOS2 && !isMac;
  43. public static final boolean is32Bit = ARCH_DATA_MODEL == null || ARCH_DATA_MODEL.equals("32");
  44. public static final boolean is64Bit = !is32Bit;
  45. public static final boolean isAMD64 = "amd64".equals(OS_ARCH);
  46. /**
  47. * Whether IDEA is running under MacOS X version 10.4 or later.
  48. *
  49. * @since 5.0.2
  50. */
  51. public static final boolean isMacOSTiger = isTiger();
  52. /**
  53. * Whether IDEA is running under MacOS X on an Intel Machine
  54. *
  55. * @since 5.0.2
  56. */
  57. public static final boolean isIntelMac = isIntelMac();
  58. /**
  59. * Running under MacOS X version 10.5 or later;
  60. *
  61. * @since 7.0.2
  62. */
  63. public static final boolean isMacOSLeopard = isLeopard();
  64. /**
  65. * Running under MacOS X version 10.6 or later;
  66. *
  67. * @since 9.0
  68. */
  69. public static final boolean isMacOSSnowLeopard = isSnowLeopard();
  70. /**
  71. * Operating system is supposed to have middle mouse button click occupied by paste action.
  72. * @since 6.0
  73. */
  74. public static boolean X11PasteEnabledSystem = isUnix && !isMac;
  75. private static boolean isTiger() {
  76. return isMac &&
  77. !OS_VERSION.startsWith("10.0") &&
  78. !OS_VERSION.startsWith("10.1") &&
  79. !OS_VERSION.startsWith("10.2") &&
  80. !OS_VERSION.startsWith("10.3");
  81. }
  82. private static boolean isIntelMac() {
  83. return isMac && "i386".equals(OS_ARCH);
  84. }
  85. private static boolean isLeopard() {
  86. return isMac && isTiger() && !OS_VERSION.startsWith("10.4");
  87. }
  88. private static boolean isSnowLeopard() {
  89. return isMac && isLeopard() && !OS_VERSION.startsWith("10.5");
  90. }
  91. }