当前位置: 首页>>代码示例>>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;未经允许,请勿转载。