com.intellij.util.SystemProperties Java Examples
The following examples show how to use
com.intellij.util.SystemProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StateMap.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static byte[] getNewByteIfDiffers(@Nonnull String key, @Nonnull Object newState, @Nonnull byte[] oldState) { byte[] newBytes = newState instanceof Element ? archiveState((Element)newState) : (byte[])newState; if (Arrays.equals(newBytes, oldState)) { return null; } else if (LOG.isDebugEnabled() && SystemProperties.getBooleanProperty("idea.log.changed.components", false)) { String before = stateToString(oldState); String after = stateToString(newState); if (before.equals(after)) { LOG.debug("Serialization error: serialized are different, but unserialized are equal"); } else { LOG.debug(key + " " + StringUtil.repeat("=", 80 - key.length()) + "\nBefore:\n" + before + "\nAfter:\n" + after); } } return newBytes; }
Example #2
Source File: ErrorViewTextExporter.java From consulo with Apache License 2.0 | 6 votes |
private void getReportText(StringBuffer buffer, final ErrorTreeElement element, boolean withUsages, final int indent) { final String newline = SystemProperties.getLineSeparator(); Object[] children = myStructure.getChildElements(element); for (final Object child : children) { if (!(child instanceof ErrorTreeElement)) { continue; } if (!withUsages && child instanceof NavigatableMessageElement) { continue; } final ErrorTreeElement childElement = (ErrorTreeElement)child; if (buffer.length() > 0) { buffer.append(newline); } shift(buffer, indent); exportElement(childElement, buffer, indent, newline); getReportText(buffer, childElement, withUsages, indent + 4); } }
Example #3
Source File: FirefoxUtil.java From consulo with Apache License 2.0 | 6 votes |
private static File[] getProfilesDirs() { final String userHome = SystemProperties.getUserHome(); if (SystemInfo.isMac) { return new File[] { new File(userHome, "Library" + File.separator + "Mozilla" + File.separator + "Firefox"), new File(userHome, "Library" + File.separator + "Application Support" + File.separator + "Firefox"), }; } if (SystemInfo.isUnix) { return new File[] {new File(userHome, ".mozilla" + File.separator + "firefox")}; } String localPath = "Mozilla" + File.separator + "Firefox"; return new File[] { new File(System.getenv("APPDATA"), localPath), new File(userHome, "AppData" + File.separator + "Roaming" + File.separator + localPath), new File(userHome, "Application Data" + File.separator + localPath) }; }
Example #4
Source File: PathManager.java From dynkt with GNU Affero General Public License v3.0 | 6 votes |
@NotNull public static String getPluginsPath() { if (ourPluginsPath != null) { String tmp9_6 = ourPluginsPath; if (tmp9_6 == null) { throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/intellij/openapi/application/PathManager", "getPluginsPath" })); } return tmp9_6; } if (System.getProperty("idea.plugins.path") != null) { ourPluginsPath = getAbsolutePath(trimPathQuotes(System.getProperty("idea.plugins.path"))); } else if ((SystemInfo.isMac) && (PATHS_SELECTOR != null)) { ourPluginsPath = SystemProperties.getUserHome() + File.separator + "Library/Application Support" + File.separator + PATHS_SELECTOR; } else { ourPluginsPath = getConfigPath() + File.separatorChar + "plugins"; } String tmp159_156 = ourPluginsPath; if (tmp159_156 == null) { throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/intellij/openapi/application/PathManager", "getPluginsPath" })); } return tmp159_156; }
Example #5
Source File: XDebugSessionTab.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static XDebugSessionTab create(@Nonnull XDebugSessionImpl session, @Nullable Image icon, @Nullable ExecutionEnvironment environment, @Nullable RunContentDescriptor contentToReuse) { if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) { JComponent component = contentToReuse.getComponent(); if (component != null) { XDebugSessionTab oldTab = DataManager.getInstance().getDataContext(component).getData(TAB_KEY); if (oldTab != null) { oldTab.setSession(session, environment, icon); oldTab.attachToSession(session); return oldTab; } } } XDebugSessionTab tab = new XDebugSessionTab(session, icon, environment); tab.myRunContentDescriptor.setActivateToolWindowWhenAdded(contentToReuse == null || contentToReuse.isActivateToolWindowWhenAdded()); return tab; }
Example #6
Source File: Jdks.java From intellij with Apache License 2.0 | 6 votes |
@Nullable private static String getJdkHomePath(LanguageLevel langLevel) { Collection<String> jdkHomePaths = new ArrayList<>(JavaSdk.getInstance().suggestHomePaths()); if (jdkHomePaths.isEmpty()) { return null; } // prefer jdk path of getJavaHome(), since we have to allow access to it in tests // see AndroidProjectDataServiceTest#testImportData() final List<String> list = new ArrayList<>(); String javaHome = SystemProperties.getJavaHome(); if (javaHome != null && !javaHome.isEmpty()) { for (Iterator<String> it = jdkHomePaths.iterator(); it.hasNext(); ) { final String path = it.next(); if (path != null && javaHome.startsWith(path)) { it.remove(); list.add(path); } } } list.addAll(jdkHomePaths); return getBestJdkHomePath(list, langLevel); }
Example #7
Source File: JBUIScale.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public Float initialize() { if (!SystemProperties.getBooleanProperty("hidpi", true)) { return 1f; } if (JreHiDpiUtil.isJreHiDPIEnabled()) { GraphicsDevice gd = null; try { gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); } catch (HeadlessException ignore) { } if (gd != null && gd.getDefaultConfiguration() != null) { return sysScale(gd.getDefaultConfiguration()); } return 1f; } Pair<String, Integer> fdata = JBUIScale.getSystemFontData(); int size = fdata.getSecond(); return getFontScale(size); }
Example #8
Source File: JBUIScale.java From consulo with Apache License 2.0 | 6 votes |
private static float computeUserScaleFactor(float scale) { if (!SystemProperties.getBooleanProperty("hidpi", true)) { return 1f; } scale = discreteScale(scale); // Downgrading user scale below 1.0 may be uncomfortable (tiny icons), // whereas some users prefer font size slightly below normal which is ok. if (scale < 1 && sysScale() >= 1) { scale = 1; } // Ignore the correction when UIUtil.DEF_SYSTEM_FONT_SIZE is overridden, see UIUtil.initSystemFontData. if (SystemInfo.isLinux && scale == 1.25f && UIUtil.DEF_SYSTEM_FONT_SIZE == 12) { // Default UI font size for Unity and Gnome is 15. Scaling factor 1.25f works badly on Linux scale = 1f; } return scale; }
Example #9
Source File: SimpleContent.java From consulo with Apache License 2.0 | 5 votes |
public String correctText(String text) { LineTokenizer lineTokenizer = new LineTokenizer(text); String[] lines = lineTokenizer.execute(); mySeparator = lineTokenizer.getLineSeparator(); LOG.assertTrue(mySeparator == null || mySeparator.length() > 0); if (mySeparator == null) mySeparator = SystemProperties.getLineSeparator(); return LineTokenizer.concatLines(lines); }
Example #10
Source File: ExporterToTextFile.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public String getReportText() { StringBuilder buf = new StringBuilder(); appendNode(buf, myUsageView.getModelRoot(), SystemProperties.getLineSeparator(), ""); return buf.toString(); }
Example #11
Source File: LaterInvocator.java From consulo with Apache License 2.0 | 5 votes |
public static void invokeAndWait(@Nonnull final Runnable runnable, @Nonnull ModalityState modalityState) { LOG.assertTrue(!isDispatchThread()); final Semaphore semaphore = new Semaphore(); semaphore.down(); final Ref<Throwable> exception = Ref.create(); Runnable runnable1 = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Throwable e) { exception.set(e); } finally { semaphore.up(); } } @Override @NonNls public String toString() { return "InvokeAndWait[" + runnable + "]"; } }; invokeLaterWithCallback(runnable1, modalityState, Conditions.FALSE, null); semaphore.waitFor(); if (!exception.isNull()) { Throwable cause = exception.get(); if (SystemProperties.getBooleanProperty("invoke.later.wrap.error", true)) { // wrap everything to keep the current thread stacktrace // also TC ComparisonFailure feature depends on this throw new RuntimeException(cause); } else { ExceptionUtil.rethrow(cause); } } }
Example #12
Source File: OutOfMemoryDialog.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("SSBasedInspection") private void snapshot() { enableControls(false); myDumpMessageLabel.setVisible(true); myDumpMessageLabel.setText("Dumping memory..."); Runnable task = () -> { TimeoutUtil.sleep(250); // to give UI chance to update String message = ""; try { String name = ApplicationNamesInfo.getInstance().getFullProductName().replace(' ', '-').toLowerCase(Locale.US); String path = SystemProperties.getUserHome() + File.separator + "heapDump-" + name + '-' + System.currentTimeMillis() + ".hprof.zip"; MemoryDumpHelper.captureMemoryDumpZipped(path); message = "Dumped to " + path; } catch (Throwable t) { message = "Error: " + t.getMessage(); } finally { final String _message = message; SwingUtilities.invokeLater(() -> { myDumpMessageLabel.setText(_message); enableControls(true); }); } }; new Thread(task, "OOME Heap Dump").start(); }
Example #13
Source File: Unity3dPackageWatcher.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Nonnull private static List<String> getUnityUserPaths() { List<String> paths = new SmartList<>(); if(SystemInfo.isWinVistaOrNewer) { paths.add(Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA) + "\\Unity"); PointerByReference pointerByReference = new PointerByReference(); // LocalLow WinNT.HRESULT hresult = Shell32.INSTANCE.SHGetKnownFolderPath(Guid.GUID.fromString("{A520A1A4-1780-4FF6-BD18-167343C5AF16}"), 0, null, pointerByReference); if(hresult.longValue() == 0) { paths.add(pointerByReference.getValue().getWideString(0) + "\\Unity"); } } else if(SystemInfo.isMac) { paths.add(SystemProperties.getUserHome() + "/Library/Unity"); } else if(SystemInfo.isLinux) { paths.add(SystemProperties.getUserHome() + "/.config/unity3d"); } return paths; }
Example #14
Source File: VfsRootAccess.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static String findInUserHome(@Nonnull String path) { try { // in case if we have a symlink like ~/.m2 -> /opt/.m2 return FileUtil.toSystemIndependentName(new File(SystemProperties.getUserHome(), path).getCanonicalPath()); } catch (IOException e) { return null; } }
Example #15
Source File: ScrollingModelImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public Rectangle getVisibleAreaOnScrollingFinished() { assertIsDispatchThread(); if (SystemProperties.isTrueSmoothScrollingEnabled()) { Rectangle viewRect = myEditor.getScrollPane().getViewport().getViewRect(); return new Rectangle(getOffset(getHorizontalScrollBar()), getOffset(getVerticalScrollBar()), viewRect.width, viewRect.height); } if (myCurrentAnimationRequest != null) { return myCurrentAnimationRequest.getTargetVisibleArea(); } return getVisibleArea(); }
Example #16
Source File: WSLDistribution.java From consulo with Apache License 2.0 | 5 votes |
/** * @return UNC root for the distribution, e.g. {@code \\wsl$\Ubuntu} * @implNote there is a hack in {@link LocalFileSystemBase#getAttributes(com.intellij.openapi.vfs.VirtualFile)} which causes all network * virtual files to exists all the time. So we need to check explicitly that root exists. After implementing proper non-blocking check * for the network resource availability, this method may be simplified to findFileByIoFile * @see VfsUtil#findFileByIoFile(java.io.File, boolean) */ //@ApiStatus.Experimental @Nullable public VirtualFile getUNCRootVirtualFile(boolean refreshIfNeed) { if (!SystemProperties.getBooleanProperty("wsl.p9.support", true)) { return null; } File uncRoot = getUNCRoot(); return uncRoot.exists() ? VfsUtil.findFileByIoFile(uncRoot, refreshIfNeed) : null; }
Example #17
Source File: WSLUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * @return list of existing UNC roots for known WSL distributions */ //@ApiStatus.Experimental @Nonnull public static List<File> getExistingUNCRoots() { if (!isSystemCompatible() || !SystemProperties.getBooleanProperty("wsl.p9.support", true)) { return Collections.emptyList(); } return getAvailableDistributions().stream().map(WSLDistribution::getUNCRoot).filter(File::exists).collect(Collectors.toList()); }
Example #18
Source File: ProjectUtil.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Nullable public static VirtualFile findProjectBaseDir(@NotNull Project project) { String projectDir = project.getBasePath(); if (projectDir == null) { projectDir = SystemProperties.getUserHome(); if (projectDir == null) { projectDir = "/"; } } return VfsUtil.findFileByIoFile(new File(projectDir), false); }
Example #19
Source File: SystemNotificationsImpl.java From consulo with Apache License 2.0 | 5 votes |
private static Notifier getPlatformNotifier() { try { if (SystemInfo.isMac) { if (SystemInfo.isMacOSMountainLion && SystemProperties.getBooleanProperty("ide.mac.mountain.lion.notifications.enabled", true)) { return MountainLionNotifications.getInstance(); } else { return GrowlNotifications.getInstance(); } } else if (SystemInfo.isXWindow) { return LibNotifyWrapper.getInstance(); } else if (SystemInfo.isWin10OrNewer) { return SystemTrayNotifications.getWin10Instance(); } } catch (Throwable t) { Logger logger = Logger.getInstance(SystemNotifications.class); if (logger.isDebugEnabled()) { logger.debug(t); } else { logger.info(t.getMessage()); } } return null; }
Example #20
Source File: RepositoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String buildUrlForDownload(@Nonnull UpdateChannel channel, @Nonnull String pluginId, @Nullable String platformVersion, boolean noTracking, boolean viaUpdate) { if (platformVersion == null) { platformVersion = ApplicationInfoImpl.getShadowInstance().getBuild().asString(); } StringBuilder builder = new StringBuilder(); builder.append(WebServiceApi.REPOSITORY_API.buildUrl("download")); builder.append("?platformVersion="); builder.append(platformVersion); builder.append("&channel="); builder.append(channel); builder.append("&id="); builder.append(pluginId); if (!noTracking) { noTracking = SystemProperties.getBooleanProperty("consulo.repository.no.tracking", false); } if (noTracking) { builder.append("&noTracking=true"); } if (viaUpdate) { builder.append("&viaUpdate=true"); } return builder.toString(); }
Example #21
Source File: VMOptions.java From consulo with Apache License 2.0 | 5 votes |
private static void writeGeneralOption(@Nonnull Pattern pattern, @Nonnull String value) { File file = getWriteFile(); if (file == null) { LOG.warn("VM options file not configured"); return; } try { String content = file.exists() ? FileUtil.loadFile(file) : read(); if (!StringUtil.isEmptyOrSpaces(content)) { Matcher m = pattern.matcher(content); if (m.find()) { StringBuffer b = new StringBuffer(); m.appendReplacement(b, Matcher.quoteReplacement(value)); m.appendTail(b); content = b.toString(); } else { content = StringUtil.trimTrailing(content) + SystemProperties.getLineSeparator() + value; } } else { content = value; } if (file.exists()) { FileUtil.setReadOnlyAttribute(file.getPath(), false); } else { FileUtil.ensureExists(file.getParentFile()); } FileUtil.writeToFile(file, content); } catch (IOException e) { LOG.warn(e); } }
Example #22
Source File: DefaultPaths.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public String getDocumentsDir() { String userHome = SystemProperties.getUserHome(); // some OS-es can have documents dir inside user home, for example Ubuntu File file = new File(userHome, "Documents"); if (file.exists()) { return userHome + File.separatorChar + "Documents" + File.separatorChar + ourDefaultPrefix; } return userHome + File.separatorChar + ourDefaultPrefix + " Project"; }
Example #23
Source File: LowMemoryWatcherManager.java From consulo with Apache License 2.0 | 5 votes |
public LowMemoryWatcherManager(@Nonnull ExecutorService backendExecutorService) { // whether LowMemoryWatcher runnables should be executed on the same thread that the low memory events come myExecutorService = SystemProperties.getBooleanProperty("low.memory.watcher.sync", false) ? ConcurrencyUtil.newSameThreadExecutorService() : SequentialTaskExecutor.createSequentialApplicationPoolExecutor("LowMemoryWatcherManager", backendExecutorService); myMemoryPoolMXBeansFuture = initializeMXBeanListenersLater(backendExecutorService); }
Example #24
Source File: PerformanceWatcher.java From consulo with Apache License 2.0 | 5 votes |
@Inject public PerformanceWatcher(ContainerPathManager containerPathManager) { myContainerPathManager = containerPathManager; myCurHangLogDir = mySessionLogDir = new File(ContainerPathManager.get().getLogPath() + "/threadDumps-" + myDateFormat.format(new Date()) + "-" + ApplicationInfo.getInstance().getBuild().asString()); myPublisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(IdePerformanceListener.TOPIC); myThread = JobScheduler.getScheduler().scheduleWithFixedDelay((Runnable)() -> samplePerformance(), SAMPLING_INTERVAL_MS, SAMPLING_INTERVAL_MS, TimeUnit.MILLISECONDS); UNRESPONSIVE_THRESHOLD_SECONDS = SystemProperties.getIntProperty("performance.watcher.threshold", 5); UNRESPONSIVE_INTERVAL_SECONDS = SystemProperties.getIntProperty("performance.watcher.interval", 5); if (shouldWatch()) { final AppScheduledExecutorService service = (AppScheduledExecutorService)AppExecutorUtil.getAppScheduledExecutorService(); service.setNewThreadListener(new Consumer<Thread>() { private final int ourReasonableThreadPoolSize = Registry.intValue("core.pooled.threads"); @Override public void consume(Thread thread) { if (service.getBackendPoolExecutorSize() > ourReasonableThreadPoolSize && ApplicationProperties.isInSandbox()) { File file = dumpThreads("newPooledThread/", true); LOG.info("Not enough pooled threads" + (file != null ? "; dumped threads into file '" + file.getPath() + "'" : "")); } } }); ApplicationManager.getApplication().executeOnPooledThread((Runnable)() -> deleteOldThreadDumps()); for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) { if ("Code Cache".equals(bean.getName())) { watchCodeCache(bean); break; } } } }
Example #25
Source File: PredefinedBundlesLoader.java From consulo with Apache License 2.0 | 5 votes |
@Override public void preload(@Nonnull ProgressIndicator indicator) { if (SystemProperties.is("consulo.disable.predefined.bundles")) { return; } SdkTable sdkTable = mySdkTable.get(); ContextImpl context = new ContextImpl(sdkTable); for (PredefinedBundlesProvider provider : PredefinedBundlesProvider.EP_NAME.getExtensionList()) { try { provider.createBundles(context); } catch (Error e) { LOG.error(e); } } List<Sdk> bundles = context.myBundles; if (!bundles.isEmpty()) { for (Sdk bundle : bundles) { ((SdkImpl)bundle).setPredefined(true); } ((SdkTableImpl)sdkTable).addSdksUnsafe(bundles); } }
Example #26
Source File: DependenciesPanel.java From consulo with Apache License 2.0 | 5 votes |
@Override public String getReportText() { final Element rootElement = new Element("root"); rootElement.setAttribute("isBackward", String.valueOf(!myForward)); final List<PsiFile> files = new ArrayList<PsiFile>(myDependencies.keySet()); Collections.sort(files, new Comparator<PsiFile>() { @Override public int compare(PsiFile f1, PsiFile f2) { final VirtualFile virtualFile1 = f1.getVirtualFile(); final VirtualFile virtualFile2 = f2.getVirtualFile(); if (virtualFile1 != null && virtualFile2 != null) { return virtualFile1.getPath().compareToIgnoreCase(virtualFile2.getPath()); } return 0; } }); for (PsiFile file : files) { final Element fileElement = new Element("file"); fileElement.setAttribute("path", file.getVirtualFile().getPath()); for (PsiFile dep : myDependencies.get(file)) { Element depElement = new Element("dependency"); depElement.setAttribute("path", dep.getVirtualFile().getPath()); fileElement.addContent(depElement); } rootElement.addContent(fileElement); } PathMacroManager.getInstance(myProject).collapsePaths(rootElement); return JDOMUtil.writeDocument(new Document(rootElement), SystemProperties.getLineSeparator()); }
Example #27
Source File: FileTemplateManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void fillDefaultVariables(@Nonnull Map<String, Object> map) { Calendar calendar = Calendar.getInstance(); Date date = myTestDate == null ? calendar.getTime() : myTestDate; SimpleDateFormat sdfMonthNameShort = new SimpleDateFormat("MMM"); SimpleDateFormat sdfMonthNameFull = new SimpleDateFormat("MMMM"); SimpleDateFormat sdfDayNameShort = new SimpleDateFormat("EEE"); SimpleDateFormat sdfDayNameFull = new SimpleDateFormat("EEEE"); SimpleDateFormat sdfYearFull = new SimpleDateFormat("yyyy"); map.put("DATE", DateFormatUtil.formatDate(date)); map.put("TIME", DateFormatUtil.formatTime(date)); map.put("YEAR", sdfYearFull.format(date)); map.put("MONTH", getCalendarValue(calendar, Calendar.MONTH)); map.put("MONTH_NAME_SHORT", sdfMonthNameShort.format(date)); map.put("MONTH_NAME_FULL", sdfMonthNameFull.format(date)); map.put("DAY", getCalendarValue(calendar, Calendar.DAY_OF_MONTH)); map.put("DAY_NAME_SHORT", sdfDayNameShort.format(date)); map.put("DAY_NAME_FULL", sdfDayNameFull.format(date)); map.put("HOUR", getCalendarValue(calendar, Calendar.HOUR_OF_DAY)); map.put("MINUTE", getCalendarValue(calendar, Calendar.MINUTE)); map.put("SECOND", getCalendarValue(calendar, Calendar.SECOND)); map.put("USER", SystemProperties.getUserName()); map.put("PRODUCT_NAME", ApplicationNamesInfo.getInstance().getFullProductName()); map.put("DS", "$"); // Dollar sign, strongly needed for PHP, JS, etc. See WI-8979 map.put(PROJECT_NAME_VARIABLE, myProject.getName()); }
Example #28
Source File: DesktopStartUIUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void blockATKWrapper() { /* * The method should be called before java.awt.Toolkit.initAssistiveTechnologies() * which is called from Toolkit.getDefaultToolkit(). */ if (!SystemInfo.isLinux || !SystemProperties.getBooleanProperty("linux.jdk.accessibility.atkwrapper.block", true)) return; if (ScreenReader.isEnabled(ScreenReader.ATK_WRAPPER)) { // Replace AtkWrapper with a dummy Object. It'll be instantiated & GC'ed right away, a NOP. System.setProperty("javax.accessibility.assistive_technologies", "java.lang.Object"); getLogger().info(ScreenReader.ATK_WRAPPER + " is blocked, see IDEA-149219"); } }
Example #29
Source File: JreHiDpiUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Returns whether the JRE-managed HiDPI mode is enabled. * (True for macOS JDK >= 7.10 versions) * * @see ScaleType */ public static boolean isJreHiDPIEnabled() { Boolean value = jreHiDPI.get(); if (value == null) { synchronized (jreHiDPI) { value = jreHiDPI.get(); if (value == null) { value = false; if (SystemProperties.getBooleanProperty("hidpi", true)) { jreHiDPI_earlierVersion = true; // fixme [vistall] always allow hidpi on other jdks if (Boolean.TRUE) { try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Boolean uiScaleEnabled = GraphicsEnvironmentHacking.isUIScaleEnabled(ge); if (uiScaleEnabled != null) { value = uiScaleEnabled; jreHiDPI_earlierVersion = false; } } catch (Throwable ignore) { } } if (SystemInfo.isMac) { value = true; } } jreHiDPI.set(value); } } } return value; }
Example #30
Source File: JBUIScale.java From consulo with Apache License 2.0 | 5 votes |
/** * Sets the user scale factor. * The method is used by the IDE, it's not recommended to call the method directly from the client code. * For debugging purposes, the following JVM system property can be used: * ide.ui.scale=[float] * or the IDE registry keys (for backward compatibility): * ide.ui.scale.override=[boolean] * ide.ui.scale=[float] * * @return the result */ public static float setUserScaleFactor(float scale) { if (DEBUG_USER_SCALE_FACTOR.isNotNull()) { float debugScale = ObjectUtil.notNull(DEBUG_USER_SCALE_FACTOR.get()); if (scale == debugScale) { setUserScaleFactorProperty(debugScale); // set the debug value as is, or otherwise ignore } return debugScale; } if (!SystemProperties.getBooleanProperty("hidpi", true)) { setUserScaleFactorProperty(1f); return 1f; } scale = discreteScale(scale); // Downgrading user scale below 1.0 may be uncomfortable (tiny icons), // whereas some users prefer font size slightly below normal which is ok. if (scale < 1 && sysScale() >= 1) scale = 1; // Ignore the correction when UIUtil.DEF_SYSTEM_FONT_SIZE is overridden, see UIUtil.initSystemFontData. if (SystemInfo.isLinux && scale == 1.25f && UIUtil.DEF_SYSTEM_FONT_SIZE == 12) { //Default UI font size for Unity and Gnome is 15. Scaling factor 1.25f works badly on Linux scale = 1f; } setUserScaleFactorProperty(scale); return scale; }