Generalize isLinux check when appropriate

This commit is contained in:
Roman Shevchenko
2012-11-12 15:50:14 +01:00
parent aa4e8df46e
commit 16c1145afa
13 changed files with 36 additions and 43 deletions
@@ -284,7 +284,7 @@ public class InitialConfigurationDialog extends DialogWrapper {
private static boolean matchesPlatform(Keymap keymap) {
final String name = keymap.getName();
if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(name)) {
return !SystemInfo.isMac && !SystemInfo.isLinux;
return SystemInfo.isWindows;
}
else if (KeymapManager.MAC_OS_X_KEYMAP.equals(name) || "Mac OS X 10.5+".equals(name)) {
return SystemInfo.isMac;
@@ -116,7 +116,7 @@ public class ScreenUtil {
private static Insets calcInsets(GraphicsConfiguration gc) {
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
if (SystemInfo.isLinux && GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1) {
if (SystemInfo.isXWindow && GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1) {
return fixGlobalInsets(gc.getBounds(), insets);
}
return insets;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ public class RunnerMediator {
*
*/
public ProcessHandler createProcess(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
if (isWindows()) {
if (SystemInfo.isWindows) {
injectRunnerCommand(commandLine);
}
@@ -87,8 +87,8 @@ public class RunnerMediator {
}
@Nullable
private String getRunnerPath() {
if (isWindows()) {
private static String getRunnerPath() {
if (SystemInfo.isWindows) {
final String path = System.getenv("IDEA_RUNNERW");
if (path != null && new File(path).exists()) {
return path;
@@ -103,7 +103,7 @@ public class RunnerMediator {
}
}
private void injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
private static void injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
final String path = getRunnerPath();
if (path != null) {
commandLine.getParametersList().addAt(0, commandLine.getExePath());
@@ -111,28 +111,27 @@ public class RunnerMediator {
}
}
/** @deprecated use {@link SystemInfo#isUnix} (to remove in IDEA 13) */
public static boolean isUnix() {
return SystemInfo.isLinux || SystemInfo.isMac;
return SystemInfo.isUnix;
}
/** @deprecated use {@link SystemInfo#isWindows} (to remove in IDEA 13) */
public static boolean isWindows() {
if (File.separatorChar == '\\') {
return true;
}
return false;
return SystemInfo.isWindows;
}
/**
* Destroys process tree: in case of windows via imitating ctrl+break, in case of unix via sending sig_kill to every process in tree.
* @param process to kill with all subprocesses
* @param process to kill with all sub-processes.
*/
public static boolean destroyProcess(Process process) {
try {
if (isWindows()) {
if (SystemInfo.isWindows) {
sendCtrlBreakThroughStream(process);
return true;
}
else if (isUnix()) {
else if (SystemInfo.isUnix) {
return UnixProcessManager.sendSigKillToProcessTree(process);
}
else {
@@ -145,14 +144,8 @@ public class RunnerMediator {
}
}
/**
*
*/
public static class CustomDestroyProcessHandler extends ColoredProcessHandler {
public CustomDestroyProcessHandler(@NotNull Process process,
@NotNull GeneralCommandLine commandLine) {
public CustomDestroyProcessHandler(@NotNull Process process, @NotNull GeneralCommandLine commandLine) {
super(process, commandLine.getCommandLineString());
}
@@ -47,7 +47,7 @@ import java.util.Set;
* <ul>
* <li>for Macs we perform synchronization with system clipboard on a separate thread and schedule it when IDEA frame is activated
* or Copy/Cut action in Swing component is invoked, and use native method calls to access system clipboard lock-free (?);</li>
* <li>for Linux we temporary set short timeout and check for available formats (which should be fast if a clipboard owner is alive).</li>
* <li>for X Window we temporary set short timeout and check for available formats (which should be fast if a clipboard owner is alive).</li>
* </ul>
* </p>
*
@@ -73,8 +73,8 @@ public class ClipboardSynchronizer implements ApplicationComponent {
else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isMac) {
myClipboardHandler = new MacClipboardHandler();
}
else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isLinux) {
myClipboardHandler = new LinuxClipboardHandler();
else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isXWindow) {
myClipboardHandler = new XWinClipboardHandler();
}
else {
myClipboardHandler = new ClipboardHandler();
@@ -304,7 +304,7 @@ public class ClipboardSynchronizer implements ApplicationComponent {
return result;
}
private static class LinuxClipboardHandler extends ClipboardHandler {
private static class XWinClipboardHandler extends ClipboardHandler {
private static final FlavorTable FLAVOR_MAP = (FlavorTable)SystemFlavorMap.getDefaultFlavorMap();
private volatile Transferable myCurrentContent = null;
@@ -422,7 +422,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
private boolean checkLookAndFeel(final UIManager.LookAndFeelInfo lafInfo, final boolean confirm) {
String message = null;
if (lafInfo.getName().contains("GTK") && SystemInfo.isLinux && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
if (lafInfo.getName().contains("GTK") && SystemInfo.isXWindow && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
message = IdeBundle.message("warning.problem.laf.1");
}
@@ -547,7 +547,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
private static String getDefaultFontName() {
if (SystemInfo.isMacOSSnowLeopard) return "Menlo";
if (SystemInfo.isLinux) {
if (SystemInfo.isXWindow) {
for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
if ("DejaVu Sans Mono".equals(font.getName())) {
return font.getFontName();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ public class DefaultKeymap {
if (SystemInfo.isMac) {
return KeymapManager.MAC_OS_X_KEYMAP;
}
else if (SystemInfo.isLinux) {
else if (SystemInfo.isXWindow) {
return KeymapManager.X_WINDOW_KEYMAP;
}
else {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -139,7 +139,7 @@ public final class IdeMouseEventDispatcher {
}
}
if (SystemInfo.isLinux && e.isPopupTrigger() && e.getButton() != 3) {
if (SystemInfo.isXWindow && e.isPopupTrigger() && e.getButton() != 3) {
// we can do better than silly triggering popup on everything but left click
resetPopupTrigger(e);
}
@@ -1126,7 +1126,7 @@ public class AbstractPopup implements JBPopup {
private PopupComponent.Factory getFactory(boolean forceHeavyweight, boolean forceDialog) {
boolean noFocus = !myFocusable || !myRequestFocus;
boolean cannotBeDialog = noFocus && SystemInfo.isLinux;
boolean cannotBeDialog = noFocus && SystemInfo.isXWindow;
if (!cannotBeDialog && (isPersistent() || forceDialog)) {
return new PopupComponent.Factory.Dialog();
@@ -65,7 +65,7 @@ public class SystemInfo extends SystemInfoRt {
public static final boolean isMacIntel64 = isMac && "x86_64".equals(OS_ARCH);
/** @deprecated use {@linkplain #hasXdgOpen()} (to remove in IDEA 13) */
public static final boolean hasXdgOpen = isLinux;
public static final boolean hasXdgOpen = isXWindow;
private static final NotNullLazyValue<Boolean> ourHasXdgOpen = new AtomicNotNullLazyValue<Boolean>() {
@NotNull
@Override
@@ -74,7 +74,7 @@ public class UIUtil {
@NotNull
@Override
protected Boolean compute() {
if (!SystemInfo.isLinux) {
if (!SystemInfo.isXWindow) {
return false;
}
try {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@ public class PluginRunConfiguration extends RunConfigurationBase implements Modu
vm.defineProperty("apple.laf.useScreenMenuBar", "true");
}
if (SystemInfo.isLinux) {
if (SystemInfo.isXWindow) {
if (VM_PARAMETERS == null || !VM_PARAMETERS.contains("-Dsun.awt.disablegrab")) {
vm.defineProperty("sun.awt.disablegrab", "true"); // See http://devnet.jetbrains.net/docs/DOC-1142
}
@@ -66,18 +66,18 @@ public class BrowsersConfiguration implements PersistentStateComponent<Element>
private final String myName;
private final String myWindowsPath;
private final String myLinuxPath;
private final String myUnixPath;
private final String myMacPath;
private final Icon myIcon;
BrowserFamily(final String name,
@NonNls final String windowsPath,
@NonNls final String linuxPath,
@NonNls final String unixPath,
@NonNls final String macPath,
final Icon icon) {
myName = name;
myWindowsPath = windowsPath;
myLinuxPath = linuxPath;
myUnixPath = unixPath;
myMacPath = macPath;
myIcon = icon;
}
@@ -92,12 +92,12 @@ public class BrowsersConfiguration implements PersistentStateComponent<Element>
if (SystemInfo.isWindows) {
return myWindowsPath;
}
else if (SystemInfo.isLinux) {
return myLinuxPath;
}
else if (SystemInfo.isMac) {
return myMacPath;
}
else if (SystemInfo.isUnix) {
return myUnixPath;
}
return null;
}