當前位置: 首頁>>代碼示例>>Java>>正文


Java SystemInfo類代碼示例

本文整理匯總了Java中com.intellij.openapi.util.SystemInfo的典型用法代碼示例。如果您正苦於以下問題:Java SystemInfo類的具體用法?Java SystemInfo怎麽用?Java SystemInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SystemInfo類屬於com.intellij.openapi.util包,在下文中一共展示了SystemInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: log

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
private void log(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo) {
  IdeaLoggingEvent ideaEvent = events[0];
  if (ideaEvent.getThrowable() == null) {
    return;
  }
  LinkedHashMap<String, Object> customData = new LinkedHashMap<>();
  customData.put(TAG_PLATFORM_VERSION, ApplicationInfo.getInstance().getBuild().asString());
  customData.put(TAG_OS, SystemInfo.OS_NAME);
  customData.put(TAG_OS_VERSION, SystemInfo.OS_VERSION);
  customData.put(TAG_OS_ARCH, SystemInfo.OS_ARCH);
  customData.put(TAG_JAVA_VERSION, SystemInfo.JAVA_VERSION);
  customData.put(TAG_JAVA_RUNTIME_VERSION, SystemInfo.JAVA_RUNTIME_VERSION);
  if (additionalInfo != null) {
    customData.put(EXTRA_ADDITIONAL_INFO, additionalInfo);
  }
  if (events.length > 1) {
    customData.put(EXTRA_MORE_EVENTS,
        Stream.of(events).map(Object::toString).collect(Collectors.joining("\n")));
  }
  rollbar.codeVersion(getPluginVersion()).log(ideaEvent.getThrowable(), customData);
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:22,代碼來源:RollbarErrorReportSubmitter.java

示例2: setUp

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
@BeforeMethod
public void setUp() throws Exception {
  super.setUp();
  m = new Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};
  myInfo = m.mock(PowerShellInfo.class);
  final PowerShellEdition edition = SystemInfo.isWindows ? PowerShellEdition.DESKTOP : PowerShellEdition.CORE;
  m.checking(new Expectations() {{
    allowing(myInfo).getEdition();
    will(returnValue(edition));
  }});

  myProvider = new PowerShellCommandLineProvider();
  myScriptsRootDir = createTempDir();
  myScriptFile = new File(myScriptsRootDir, SCRIPT_FILE_NAME);
  myScriptFile.createNewFile();
  super.registerAsTempFile(myScriptFile);
}
 
開發者ID:JetBrains,項目名稱:teamcity-powershell,代碼行數:22,代碼來源:CommandLineProviderTest.java

示例3: winShellScriptQuoting

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Test
public void winShellScriptQuoting() throws Exception {
  assumeTrue(SystemInfo.isWindows);

  String scriptPrefix = "my_script";
  for (String scriptExt : new String[]{".cmd", ".bat"}) {
    File script = ExecUtil.createTempExecutableScript(scriptPrefix, scriptExt, "@echo %1\n");
    String param = "a&b";
    GeneralCommandLine commandLine = new GeneralCommandLine(script.getAbsolutePath(), param);
    String text = commandLine.getPreparedCommandLine(Platform.WINDOWS);
    assertEquals(commandLine.getExePath() + "\n" + StringUtil.wrapWithDoubleQuote(param), text);
    try {
      String output = execAndGetOutput(commandLine);
      assertEquals(StringUtil.wrapWithDoubleQuote(param), output.trim());
    }
    finally {
      FileUtil.delete(script);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:GeneralCommandLineTest.java

示例4: testDeleteSubstRoots

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
public void testDeleteSubstRoots() throws Exception {
  if (!SystemInfo.isWindows) return;

  File tempDirectory = FileUtil.createTempDirectory(getTestName(false), null);
  File substRoot = IoTestUtil.createSubst(tempDirectory.getPath());
  VirtualFile subst = myLocalFs.refreshAndFindFileByIoFile(substRoot);
  assertNotNull(subst);

  try {
    final File[] children = substRoot.listFiles();
    assertNotNull(children);
  }
  finally {
    IoTestUtil.deleteSubst(substRoot.getPath());
  }
  subst.refresh(false, true);

  VirtualFile[] roots = myFs.getRoots(myLocalFs);
  for (VirtualFile root : roots) {
    String rootPath = root.getPath();
    String prefix = StringUtil.commonPrefix(rootPath, substRoot.getPath());
    assertEmpty(prefix);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:PersistentFsTest.java

示例5: windowsDriveExists

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
public static boolean windowsDriveExists(@NotNull String path) {
  if (!SystemInfo.isWindows) return true;
  
  if (path.length() > 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') {
    final char driveLetter = Character.toUpperCase(path.charAt(0));
    final Boolean driveExists = myWindowsDrivesMap.getIfPresent(driveLetter);
    if (driveExists != null) {
      return driveExists;
    }
    else {
      final long t0 = System.currentTimeMillis();
      boolean exists = new File(driveLetter + ":" + File.separator).exists();
      if (System.currentTimeMillis() - t0 > FILE_EXISTS_MAX_TIMEOUT_MILLIS) {
        exists = false; // may be a slow network drive
      }

      myWindowsDrivesMap.put(driveLetter, exists);
      return exists;
    }
  }

  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:LocalFileFinder.java

示例6: getAttributes

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Override
protected FileAttributes getAttributes(@NotNull String path) throws Exception {
  Memory buffer = new Memory(256);
  int res = SystemInfo.isLinux ? myLibC.__lxstat64(STAT_VER, path, buffer) : myLibC.lstat(path, buffer);
  if (res != 0) return null;

  int mode = getModeFlags(buffer) & LibC.S_MASK;
  boolean isSymlink = (mode & LibC.S_IFMT) == LibC.S_IFLNK;
  if (isSymlink) {
    if (!loadFileStatus(path, buffer)) {
      return FileAttributes.BROKEN_SYMLINK;
    }
    mode = getModeFlags(buffer) & LibC.S_MASK;
  }

  boolean isDirectory = (mode & LibC.S_IFMT) == LibC.S_IFDIR;
  boolean isSpecial = !isDirectory && (mode & LibC.S_IFMT) != LibC.S_IFREG;
  long size = buffer.getLong(myOffsets[OFF_SIZE]);
  long mTime1 = SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME]) : buffer.getLong(myOffsets[OFF_TIME]);
  long mTime2 = myCoarseTs ? 0 : SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME] + 4) : buffer.getLong(myOffsets[OFF_TIME] + 8);
  long mTime = mTime1 * 1000 + mTime2 / 1000000;

  boolean writable = ownFile(buffer) ? (mode & LibC.WRITE_MASK) != 0 : myLibC.access(path, LibC.W_OK) == 0;

  return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:FileSystemUtil.java

示例7: checkTargetJPDAInstalled

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
private static void checkTargetJPDAInstalled(JavaParameters parameters) throws ExecutionException {
  final Sdk jdk = parameters.getJdk();
  if (jdk == null) {
    throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
  }
  final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  String versionString = jdk.getVersionString();
  if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) {
    throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString));
  }
  if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) {
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
      throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString));
    }
    //noinspection HardCodedStringLiteral
    File dllFile = new File(
      homeDirectory.getPath().replace('/', File.separatorChar) + File.separator + "bin" + File.separator + "jdwp.dll"
    );
    if (!dllFile.exists()) {
      GetJPDADialog dialog = new GetJPDADialog();
      dialog.show();
      throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing"));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:DebuggerManagerImpl.java

示例8: drawDottedLine

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
private void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2) {
  /*
  // TODO!!!
  final Color color = g.getColor();
  g.setColor(getBackground());
  g.setColor(color);
  for (int i = x1 / 2 * 2; i < x2; i += 2) {
    g.drawRect(i, y1, 0, 0);
  }
  */
  final Stroke saved = g.getStroke();
  if (!SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
    g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, DASH, y1 % 2));
  }

  if (UIUtil.isUnderDarcula()) {
    UIUtil.drawDottedLine(g, x1, y1, x2, y2, null, g.getColor());
  } else {
    UIUtil.drawLine(g, x1, y1, x2, y2);
  }

  g.setStroke(saved);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:ContentRootPanel.java

示例9: getCondaExecutable

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Nullable
public static String getCondaExecutable(@NotNull final String condaName) {
  final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(SystemProperties.getUserHome().replace('\\', '/'));
  if (userHome != null) {
    for (String root : VirtualEnvSdkFlavor.CONDA_DEFAULT_ROOTS) {
      VirtualFile condaFolder = userHome.findChild(root);
      String executableFile = findExecutable(condaName, condaFolder);
      if (executableFile != null) return executableFile;
      if (SystemInfo.isWindows) {
        condaFolder = LocalFileSystem.getInstance().findFileByPath("C:\\" + root);
        executableFile = findExecutable(condaName, condaFolder);
        if (executableFile != null) return executableFile;
      }
      else {
        final String systemWidePath = "/opt/anaconda";
        condaFolder = LocalFileSystem.getInstance().findFileByPath(systemWidePath);
        executableFile = findExecutable(condaName, condaFolder);
        if (executableFile != null) return executableFile;
      }
    }
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:PyCondaPackageService.java

示例10: findErrorSolution

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Nullable
private static String findErrorSolution(@NotNull PyExecutionException e, @Nullable String cause, @Nullable Sdk sdk) {
  if (cause != null) {
    if (StringUtil.containsIgnoreCase(cause, "SyntaxError")) {
      final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(sdk);
      return "Make sure that you use a version of Python supported by this package. Currently you are using Python " +
             languageLevel + ".";
    }
  }

  if (SystemInfo.isLinux && (containsInOutput(e, "pyconfig.h") || containsInOutput(e, "Python.h"))) {
    return "Make sure that you have installed Python development packages for your operating system.";
  }

  if ("pip".equals(e.getCommand()) && sdk != null) {
    return "Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' " +
           "installed for your Python interpreter located at '" + sdk.getHomePath() + "'.";
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:PyPackageManagementService.java

示例11: performSelection

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
public static void performSelection(InputTool tool, RadComponent component) {
  if ((SystemInfo.isMac ? tool.myInputEvent.isMetaDown() : tool.myInputEvent.isControlDown())) {
    if (tool.myArea.isSelected(component)) {
      tool.myArea.deselect(component);
    }
    else {
      tool.myArea.appendSelection(component);
    }
  }
  else if (tool.myInputEvent.isShiftDown()) {
    tool.myArea.appendSelection(component);
  }
  else {
    tool.myArea.select(component);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:SelectionTracker.java

示例12: renameToTempFileOrDelete

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Nullable
private static File renameToTempFileOrDelete(@NotNull File file) {
  String tempDir = getTempDirectory();
  boolean isSameDrive = true;
  if (SystemInfo.isWindows) {
    String tempDirDrive = tempDir.substring(0, 2);
    String fileDrive = file.getAbsolutePath().substring(0, 2);
    isSameDrive = tempDirDrive.equalsIgnoreCase(fileDrive);
  }

  if (isSameDrive) {
    // the optimization is reasonable only if destination dir is located on the same drive
    final String originalFileName = file.getName();
    File tempFile = getTempFile(originalFileName, tempDir);
    if (file.renameTo(tempFile)) {
      return tempFile;
    }
  }

  delete(file);

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FileUtil.java

示例13: findInterpreter

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
@Nullable
private static String findInterpreter(VirtualFile dir) {
  for (VirtualFile child : dir.getChildren()) {
    if (!child.isDirectory()) {
      final String childName = child.getName().toLowerCase();
      for (String name : NAMES) {
        if (SystemInfo.isWindows) {
          if (childName.equals(name)) {
            return FileUtil.toSystemDependentName(child.getPath());
          }
        }
        else {
          if (childName.startsWith(name) || PYTHON_RE.matcher(childName).matches()) {
            if (!childName.endsWith("-config")) {
              return child.getPath();
            }
          }
        }
      }
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:VirtualEnvSdkFlavor.java

示例14: isPath

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
public static boolean isPath(@Nullable String s) {
  if (!StringUtil.isEmpty(s)) {
    s = ObjectUtils.assertNotNull(s);
    s = FileUtil.toSystemIndependentName(s);
    final List<String> components = StringUtil.split(s, "/");
    for (String name : components) {
      if (name == components.get(0) && SystemInfo.isWindows && name.endsWith(":")) {
        continue;
      }
      if (!PathUtil.isValidFileName(name)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:PythonStringUtil.java

示例15: findProblemPackages

import com.intellij.openapi.util.SystemInfo; //導入依賴的package包/類
/**
 * Find packages that might not be able to be installed while studio is running.
 * Currently this means packages that are upgrades on windows systems, since windows locks files that are in use.
 * @return
 */
private Set<IPkgDesc> findProblemPackages() {
  Set<IPkgDesc> result = Sets.newHashSet();
  if (!SystemInfo.isWindows) {
    return result;
  }
  SdkState state = SdkState.getInstance(AndroidSdkUtils.tryToChooseAndroidSdk());
  state.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, false);
  Set<String> available = Sets.newHashSet();
  for (UpdatablePkgInfo update : state.getPackages().getUpdatedPkgs()) {
    if (update.hasRemote(false)) {
      available.add(update.getRemote(false).getPkgDesc().getInstallId());
    }
    if (update.hasPreview()) {
      available.add(update.getRemote(true).getPkgDesc().getInstallId());
    }
  }
  for (IPkgDesc request : myRequestedPackages) {
    if (available.contains(request.getInstallId())) {
      // This is an update
      result.add(request);
    }
  }
  return result;

}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:SdkQuickfixWizard.java


注:本文中的com.intellij.openapi.util.SystemInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。