Java 类com.intellij.openapi.util.SystemInfo 实例源码

项目:bamboo-soy    文件:RollbarErrorReportSubmitter.java   
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);
}
项目:teamcity-powershell    文件:CommandLineProviderTest.java   
@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);
}
项目:intellij-ce-playground    文件:GeneralCommandLineTest.java   
@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);
    }
  }
}
项目:intellij-ce-playground    文件:PersistentFsTest.java   
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);
  }
}
项目:intellij-ce-playground    文件:LocalFileFinder.java   
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;
}
项目:intellij-ce-playground    文件:FileSystemUtil.java   
@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);
}
项目:intellij-ce-playground    文件:DebuggerManagerImpl.java   
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"));
    }
  }
}
项目:intellij-ce-playground    文件:ContentRootPanel.java   
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);
}
项目:intellij-ce-playground    文件:PyCondaPackageService.java   
@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;
}
项目:intellij-ce-playground    文件:PyPackageManagementService.java   
@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;
}
项目:intellij-ce-playground    文件:SelectionTracker.java   
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);
  }
}
项目:intellij-ce-playground    文件:FileUtil.java   
@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;
}
项目:intellij-ce-playground    文件:VirtualEnvSdkFlavor.java   
@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;
}
项目:intellij-ce-playground    文件:PythonStringUtil.java   
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;
}
项目:intellij-ce-playground    文件:SdkQuickfixWizard.java   
/**
 * 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;

}
项目:intellij-ce-playground    文件:KeymapUtil.java   
private static String getModifiersText(@JdkConstants.InputEventMask int modifiers) {
  if (SystemInfo.isMac) {
    //try {
    //  Class appleLaf = Class.forName(APPLE_LAF_AQUA_LOOK_AND_FEEL_CLASS_NAME);
    //  Method getModifiers = appleLaf.getMethod(GET_KEY_MODIFIERS_TEXT_METHOD, int.class, boolean.class);
    //  return (String)getModifiers.invoke(appleLaf, modifiers, Boolean.FALSE);
    //}
    //catch (Exception e) {
    //  if (SystemInfo.isMacOSLeopard) {
    //    return getKeyModifiersTextForMacOSLeopard(modifiers);
    //  }
    //
    //  // OK do nothing here.
    //}
    return MacKeymapUtil.getModifiersText(modifiers);
  }

  final String keyModifiersText = KeyEvent.getKeyModifiersText(modifiers);
  if (keyModifiersText.isEmpty()) {
    return keyModifiersText;
  }
  else {
    return keyModifiersText + "+";
  }
}
项目:intellij-ce-playground    文件:VfsUtil.java   
/**
 * @return correct URL, must be used only for external communication
 */
@NotNull
public static URI toUri(@NotNull VirtualFile file) {
  String path = file.getPath();
  try {
    String protocol = file.getFileSystem().getProtocol();
    if (file.isInLocalFileSystem()) {
      if (SystemInfo.isWindows && path.charAt(0) != '/') {
        path = '/' + path;
      }
      return new URI(protocol, "", path, null, null);
    }
    if (URLUtil.HTTP_PROTOCOL.equals(protocol)) {
      return new URI(URLUtil.HTTP_PROTOCOL + URLUtil.SCHEME_SEPARATOR + path);
    }
    return new URI(protocol, path, null);
  }
  catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
}
项目:intellij-ce-playground    文件:Change.java   
public Type getType() {
  if (myType == null) {
    if (myBeforeRevision == null) {
      myType = Type.NEW;
      return myType;
    }

    if (myAfterRevision == null) {
      myType = Type.DELETED;
      return myType;
    }

    if ((! Comparing.equal(myBeforeRevision.getFile(), myAfterRevision.getFile())) ||
        ((! SystemInfo.isFileSystemCaseSensitive) && VcsFilePathUtil
          .caseDiffers(myBeforeRevision.getFile().getPath(), myAfterRevision.getFile().getPath()))) {
      myType = Type.MOVED;
      return myType;
    }

    myType = Type.MODIFICATION;
  }
  return myType;
}
项目:intellij-ce-playground    文件:TextWithMarkupProcessor.java   
Context(@NotNull CharSequence charSequence, @NotNull EditorColorsScheme scheme, int indentSymbolsToStrip) {
  myText = charSequence;
  myDefaultForeground = scheme.getDefaultForeground();
  myDefaultBackground = scheme.getDefaultBackground();

  // Java assumes screen resolution of 72dpi when calculating font size in pixels. External applications are supposedly using correct
  // resolution, so we need to adjust font size for copied text to look the same in them.
  // (See https://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/java2d.html#gdlwn)
  // Java on Mac is not affected by this issue.
  int javaFontSize = scheme.getEditorFontSize();
  float fontSize = SystemInfo.isMac || ApplicationManager.getApplication().isHeadlessEnvironment() ? 
                   javaFontSize : 
                   javaFontSize * 72f / Toolkit.getDefaultToolkit().getScreenResolution();

  builder = new SyntaxInfo.Builder(myDefaultForeground, myDefaultBackground, fontSize);
  myIndentSymbolsToStrip = indentSymbolsToStrip;
}
项目:intellij-ce-playground    文件:MacUtil.java   
public static void adjustFocusTraversal(@NotNull Disposable disposable) {
  if (!SystemInfo.isMacOSSnowLeopard) return;
  final AWTEventListener listener = new AWTEventListener() {
    @Override
    public void eventDispatched(AWTEvent event) {
      if (event instanceof KeyEvent
          && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_TAB
          && (!(event.getSource() instanceof JTextComponent))
          && (!(event.getSource() instanceof JList))
          && !isFullKeyboardAccessEnabled())
        ((KeyEvent)event).consume();
    }
  };
  Disposer.register(disposable, new Disposable() {
    @Override
    public void dispose() {
      Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
    }
  });
  Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
}
项目:react-native-console    文件:NotificationUtils.java   
/**
 * python提示
 */
public static void pythonNotFound() {
    String tip = "command 'python' not found. ";
    if (SystemInfo.isWindows) {
        tip += "  if first installation python or Set Environment variable, Please restart your computer";
    }
    errorNotification(tip);
}
项目:react-native-console    文件:NotificationUtils.java   
/**
 * package.json error message
 */
public static void packageJsonNotFound() {
    String tip = "File 'package.json' not found.\n Make sure that you have run `npm install` and that you are inside a react-native project.";//找不到有效的React Native目录, 命令将停止执行
    if (SystemInfo.isWindows) {
        tip += "  if first installation React Native or Set Environment variable, Please restart your computer";
    }
    errorNotification(tip);
}
项目:react-native-console    文件:NotificationUtils.java   
/**
 * build.gradle error message
 */
public static void gradleFileNotFound() {
    String tip = "File 'build.gradle' not found.\n Make sure that you have run `npm install` and that you are inside a android project.";
    if (SystemInfo.isWindows) {
        tip += "  if first installation React Native or Set Environment variable, Please restart your computer";
    }
    errorNotification(tip);
}
项目:AppleScript-IDEA    文件:ApplicationNameCompletionContributor.java   
public ApplicationNameCompletionContributor() {
  final PsiElementPattern.Capture<PsiElement> inAppReferenceString = psiElement().withSuperParent(1, AppleScriptApplicationReference.class);

  extend(CompletionType.BASIC,
      inAppReferenceString,
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(@NotNull CompletionParameters parameters,
                                      ProcessingContext context,
                                      @NotNull CompletionResultSet result) {

          AppleScriptSystemDictionaryRegistryService systemDictionaryRegistry = ServiceManager.getService
              (AppleScriptSystemDictionaryRegistryService.class);
          if (systemDictionaryRegistry != null) {
            List<String> appNameList = new ArrayList<>();
            if (SystemInfo.isMac) {
              appNameList.addAll(systemDictionaryRegistry.getDiscoveredApplicationNames());
              appNameList.removeAll(systemDictionaryRegistry.getNotScriptableApplicationList());
              appNameList.removeAll(systemDictionaryRegistry.getScriptingAdditions());
              appNameList.remove(ApplicationDictionary.SCRIPTING_ADDITIONS_LIBRARY);
              appNameList.remove(ApplicationDictionary.COCOA_STANDARD_LIBRARY);
            } else {
              appNameList.addAll(systemDictionaryRegistry.getCachedApplicationNames());
            }
            for (String appName : appNameList) {
              result.addElement(LookupElementBuilder.create(appName));
            }
          }
        }
      });

}
项目:teamcity-powershell    文件:PowerShellServiceFactory.java   
@NotNull
public CommandLineBuildService createService() {
  if (SystemInfo.isWindows) {
    return new PowerShellServiceWindows(myInfoProvider, myGenerator, myCmdProvider, myCommands);
  } else {
    return new PowerShellServiceUnix(myInfoProvider, myGenerator, myCmdProvider, myCommands);
  }
}
项目:CopyCurrentActivity    文件:CopyCurrentActivityAction.java   
@NotNull
private String getAdbPath(String androidSdkPath) {
    String adb;
    if (SystemInfo.isWindows) {
        adb = ADB_WINDOWS;
    } else {
        adb = ADB_UNIX;
    }

    return androidSdkPath + ADB_SUBPATH + adb;
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  final Project project = ProjectManager.getInstance().getDefaultProject();
  PyConfigurableInterpreterList instance = PyConfigurableInterpreterList.getInstance(project);
  if (instance == null) {
    return null;
  }
  final List<Sdk> sdks = instance.getAllPythonSdks();
  VirtualEnvProjectFilter.removeAllAssociated(sdks);
  // by default we create new virtual env in project, we need to add this non-existing sdk to sdk list
  ProjectJdkImpl fakeSdk = createFakeSdk(selectedCourse);
  if (fakeSdk != null) {
    sdks.add(0, fakeSdk);
  }
  PythonSdkChooserCombo combo = new PythonSdkChooserCombo(project, sdks, sdk -> true);
  if (fakeSdk != null) {
    patchRenderer(fakeSdk, combo);
    combo.getComboBox().setSelectedItem(fakeSdk);
  }
  if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
    combo.putClientProperty("JButton.buttonType", null);
  }
  combo.setButtonIcon(PythonIcons.Python.InterpreterGear);
  combo.addChangedListener(e -> {
    Sdk selectedSdk = (Sdk)combo.getComboBox().getSelectedItem();
    mySettings.setSdk(selectedSdk == fakeSdk ? null : selectedSdk);
  });
  return LabeledComponent.create(combo, "Interpreter", BorderLayout.WEST);
}
项目:intellij-ce-playground    文件:FontUtil.java   
@NotNull
public static Font getFontAbleToDisplay(@NotNull String s, @NotNull Font defaultFont) {
  if (SystemInfo.isMac          // On Macs, all fonts can display all the characters because the system renders using fallback fonts.
      || isExtendedAscii(s)) {  // Assume that default font can handle ASCII
    return defaultFont;
  }

  Set<Font> fonts = Sets.newHashSetWithExpectedSize(10);

  FontPreferences fontPreferences = EditorColorsManager.getInstance().getGlobalScheme().getFontPreferences();
  for (int i = 0; i < s.length(); i++) {
    if (s.charAt(i) > 255) {
      fonts.add(ComplementaryFontsRegistry.getFontAbleToDisplay(s.charAt(i), Font.PLAIN, fontPreferences).getFont());
    }
  }

  if (fonts.isEmpty()) {
    return defaultFont;
  }

  // find the font the can handle the most # of characters
  Font bestFont = defaultFont;
  int max = 0;
  for (Font f : fonts) {
    int supportedChars = 0;
    for (int i = 0; i < s.length(); i++) {
      if (f.canDisplay(s.charAt(i))) {
        supportedChars++;
      }
    }

    if (supportedChars > max) {
      max = supportedChars;
      bestFont = f;
    }
  }

  return bestFont;
}
项目:intellij-ce-playground    文件:IdeEventQueue.java   
private static AWTEvent changeSourceIfNeeded(AWTEvent awtEvent) {
  if (SystemInfo.isMac && Registry.is("ide.inertial.mouse.fix") && awtEvent instanceof MouseWheelEvent) {
    MouseWheelEvent mwe = (MouseWheelEvent) awtEvent;
    if (mwe.getWhen() - lastMouseWheel > MOUSE_WHEEL_RESTART_THRESHOLD) {
      wheelDestinationComponent = SwingUtilities.getDeepestComponentAt(mwe.getComponent(), mwe.getX(), mwe.getY());
    }
    lastMouseWheel = System.currentTimeMillis();

    int modifiers = mwe.getModifiers() | mwe.getModifiersEx();
    return MouseEventAdapter.convert(mwe, wheelDestinationComponent, mwe.getID(), lastMouseWheel, modifiers, mwe.getX(), mwe.getY());
  }
  return awtEvent;
}
项目:intellij-ce-playground    文件:JavaCoverageRunner.java   
protected static File createTempFile() throws IOException {
  File tempFile = FileUtil.createTempFile("coverage", "args");
  if (!SystemInfo.isWindows && tempFile.getAbsolutePath().contains(" ")) {
    tempFile = FileUtil.createTempFile(new File(PathManager.getSystemPath(), "coverage"), "coverage", "args", true);
    if (tempFile.getAbsolutePath().contains(" ")) {
      final String userDefined = System.getProperty(COVERAGE_AGENT_PATH);
      if (userDefined != null && new File(userDefined).isDirectory()) {
        tempFile = FileUtil.createTempFile(new File(userDefined), "coverage", "args", true);
      }
    }
  }
  return tempFile;
}
项目:intellij-ce-playground    文件:FirstRunWizardHost.java   
private static void setMargin(JButton button) {
  // Aqua LnF does a good job of setting proper margin between buttons. Setting them specifically causes them be 'square' style instead of
  // 'rounded', which is expected by apple users.
  if (!SystemInfo.isMac && BUTTON_MARGINS != null) {
    button.setMargin(BUTTON_MARGINS);
  }
}
项目:intellij-ce-playground    文件:DirectoryChooser.java   
@Nullable
private String getCommonFragment(int count) {
  String commonFragment = null;
  for (String[] path : myPaths) {
    int index = getFragmentIndex(path, count);
    if (index == -1) return null;
    if (commonFragment == null) {
      commonFragment = path[index];
      continue;
    }
    if (!Comparing.strEqual(commonFragment, path[index], SystemInfo.isFileSystemCaseSensitive)) return null;
  }
  return commonFragment;
}
项目:intellij-ce-playground    文件:ExternalSystemJdkComboBox.java   
public ExternalSystemJdkComboBox(@Nullable Project project) {
  myProject = project;
  setRenderer(new ColoredListCellRendererWrapper() {

    @Override
    protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      JdkComboBoxItem item = (JdkComboBoxItem)value;
      CompositeAppearance appearance = new CompositeAppearance();
      SdkType sdkType = JavaSdk.getInstance();
      appearance.setIcon(sdkType.getIcon());
      SimpleTextAttributes attributes = getTextAttributes(item.valid, selected);
      CompositeAppearance.DequeEnd ending = appearance.getEnding();

      ending.addText(item.label, attributes);
      if (item.comment != null && !item.comment.equals(item.jdkName)) {
        final SimpleTextAttributes textAttributes;
        if (!item.valid) {
          textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
        }
        else {
          textAttributes = SystemInfo.isMac && selected
                           ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.WHITE)
                           : SimpleTextAttributes.GRAY_ATTRIBUTES;
        }

        ending.addComment(item.comment, textAttributes);
      }

      final CompositeAppearance compositeAppearance = ending.getAppearance();
      compositeAppearance.customize(this);
    }
  });
}
项目:MissingInActions    文件:ComboBoxAction.java   
@Override
public Dimension getPreferredSize() {
    final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
    int width = isEmpty ? JBUI.scale(10) + getArrowIcon().getIconWidth() : super.getPreferredSize().width;
    if (isSmallVariant() && !((SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()))) {
        width += JBUI.scale(4);
        if (UIUtil.isUnderWin10LookAndFeel()) {
            width += JBUI.scale(8);
        }
    }
    return new Dimension(width, isSmallVariant() ? JBUI.scale(19) : super.getPreferredSize().height);
}
项目:intellij-ce-playground    文件:PythonDebuggerTest.java   
public void testPyQtMoveToThread() throws Exception {
  if (UsefulTestCase.IS_UNDER_TEAMCITY && SystemInfo.isWindows) {
    return; //Don't run under Windows
  }

  runPythonTest(new PyDebuggerTask("/debug", "test_pyqt2.py") {
    @Override
    protected void init() {
      setMultiprocessDebug(true);
    }

    @Override
    public void before() throws Exception {
      toggleBreakpoint(getScriptPath(), 10);
    }

    @Override
    public void testing() throws Exception {

      waitForPause();

      eval("i").hasValue("0");

      resume();

      waitForPause();

      eval("i").hasValue("1");

      resume();
    }

    @NotNull
    @Override
    public Set<String> getTags() {
      return Sets.newHashSet("pyqt5");
    }
  });
}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
private boolean checkLookAndFeel(final UIManager.LookAndFeelInfo lafInfo, final boolean confirm) {
  String message = null;

  if (lafInfo.getName().contains("GTK") && SystemInfo.isXWindow && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
    message = IdeBundle.message("warning.problem.laf.1");
  }

  if (message != null) {
    if (confirm) {
      final String[] options = {IdeBundle.message("confirm.set.look.and.feel"), CommonBundle.getCancelButtonText()};
      final int result = Messages.showOkCancelDialog(message, CommonBundle.getWarningTitle(), options[0], options[1], Messages.getWarningIcon());
      if (result == Messages.OK) {
        myLastWarning = message;
        return true;
      }
      return false;
    }

    if (!message.equals(myLastWarning)) {
      Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "L&F Manager", message, NotificationType.WARNING,
                                                NotificationListener.URL_OPENING_LISTENER));
      myLastWarning = message;
    }
  }

  return true;
}
项目:fastdex    文件:NotificationUtils.java   
/**
 * 提示
 */
public static void gradleWrapperNotFound() {
    String tip = null;
    if (SystemInfo.isWindows) {
        tip = "'gradlew.bat' not found. ";
    }
    else {
        tip = "'gradlew' not found. ";
    }
    errorNotification(tip);
}
项目:intellij-ce-playground    文件:EclipseClasspathTest.java   
static Module setUpModule(final String path, @NotNull final Project project) throws Exception {
  final File classpathFile = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
  String fileText = FileUtil.loadFile(classpathFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
  if (!SystemInfo.isWindows) {
    fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
  }
  final Element classpathElement = JDOMUtil.loadDocument(fileText).getRootElement();

  final Module module = WriteCommandAction.runWriteCommandAction(null, new Computable<Module>() {
    @Override
    public Module compute() {
      String imlPath = path + "/" + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT;
      return ModuleManager.getInstance(project).newModule(imlPath, StdModuleTypes.JAVA.getId());
    }
  });

  ModuleRootModificationUtil.updateModel(module, new Consumer<ModifiableRootModel>() {
    @Override
    public void consume(ModifiableRootModel model) {
      try {
        EclipseClasspathReader classpathReader = new EclipseClasspathReader(path, project, null);
        classpathReader.init(model);
        classpathReader.readClasspath(model, classpathElement);
        new EclipseClasspathStorageProvider().assertCompatible(model);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  });
  return module;
}
项目:intellij-ce-playground    文件:SelectionTracker.java   
@Override
protected void handleButtonUp(int button) {
  if (myState == STATE_DRAG) {
    // Control clicking on a Mac is used to simulate right clicks: do not treat this as
    // a selection reset (since it makes it impossible to pull up the context menu with
    // a multi-selection: the right click action causes the selection to be replaced
    // with the single item under the mouse)
    if (SystemInfo.isMac && myInputEvent != null && myInputEvent.isControlDown()) {
      return;
    }

    performSelection();
    myState = STATE_NONE;
  }
}
项目:intellij-ce-playground    文件:PyCondaPackageService.java   
@Nullable
public static String getCondaExecutable() {
  final String condaName = SystemInfo.isWindows ? "conda.exe" : "conda";
  final File condaInPath = PathEnvironmentVariableUtil.findInPath(condaName);
  if (condaInPath != null) return condaInPath.getPath();
  return getCondaExecutable(condaName);
}