From 5e5208fbfa1e1aa63378bb6665230bc5d14c59b1 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 2 Nov 2012 14:00:57 +0100 Subject: [PATCH] Handy isXWindow property --- .../options/InitialConfigurationDialog.java | 2 +- .../platform-api/src/com/intellij/ui/ScreenUtil.java | 5 ++--- .../openapi/editor/actions/PasteFromX11Action.java | 6 +++--- .../openapi/keymap/impl/DefaultKeymapImpl.java | 11 ++++------- platform/util/src/com/intellij/Patches.java | 2 +- .../src/com/intellij/openapi/util/SystemInfo.java | 9 +++------ 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index d9ab146ee5bc..2c7ef8801929 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -290,7 +290,7 @@ public class InitialConfigurationDialog extends DialogWrapper { return SystemInfo.isMac; } else if (KeymapManager.X_WINDOW_KEYMAP.equals(name) || "Default for GNOME".equals(name) || "Default for KDE".equals(name)) { - return SystemInfo.isUnix && !SystemInfo.isMac; + return SystemInfo.isXWindow; } return true; } diff --git a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java index 08a505b7878a..1f0d2f68ed18 100644 --- a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java @@ -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. @@ -30,8 +30,7 @@ import java.util.Map; public class ScreenUtil { @Nullable private static final Map> ourInsetsCache; static { - final boolean useCache = (SystemInfo.isLinux || SystemInfo.isSolaris) - && !GraphicsEnvironment.isHeadless(); + final boolean useCache = SystemInfo.isXWindow && !GraphicsEnvironment.isHeadless(); ourInsetsCache = useCache ? new WeakHashMap>() : null; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java index b71efd325c9f..07edc2767b4c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java @@ -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. @@ -38,7 +38,7 @@ import java.awt.event.InputEvent; import java.awt.event.MouseEvent; /** - * Author: msk + * @author msk */ public class PasteFromX11Action extends EditorAction { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.actions.PasteFromX11Action"); @@ -52,7 +52,7 @@ public class PasteFromX11Action extends EditorAction { Presentation presentation = e.getPresentation(); DataContext dataContext = e.getDataContext(); Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); - if (editor == null || !SystemInfo.X11PasteEnabledSystem) { + if (editor == null || !SystemInfo.isXWindow) { presentation.setEnabled(false); } else { diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymapImpl.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymapImpl.java index b050b11880a9..adbf7e9481d9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymapImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymapImpl.java @@ -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. @@ -26,11 +26,8 @@ import org.jdom.Element; import java.awt.event.MouseEvent; /** - * Created by IntelliJ IDEA. - * User: max - * Date: Nov 21, 2003 - * Time: 9:00:35 PM - * To change this template use Options | File Templates. + * @author max + * @since Nov 21, 2003 */ class DefaultKeymapImpl extends KeymapImpl { public boolean canModify() { @@ -44,7 +41,7 @@ class DefaultKeymapImpl extends KeymapImpl { public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException { super.readExternal(keymapElement, existingKeymaps); - if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.X11PasteEnabledSystem) { + if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) { addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1)); } } diff --git a/platform/util/src/com/intellij/Patches.java b/platform/util/src/com/intellij/Patches.java index 6e19ea18878a..5d696b0a3607 100644 --- a/platform/util/src/com/intellij/Patches.java +++ b/platform/util/src/com/intellij/Patches.java @@ -35,7 +35,7 @@ public class Patches { * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322854. * java.lang.NullPointerException: Failed to retrieve atom name. */ - public static final boolean SUN_BUG_ID_6322854 = SystemInfo.isUnix && !SystemInfo.isMac; + public static final boolean SUN_BUG_ID_6322854 = SystemInfo.isXWindow; /** * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4218084. diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 2f86c51de7d8..d6a50cf0b273 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -46,6 +46,7 @@ public class SystemInfo extends SystemInfoRt { public static final boolean isFreeBSD = _OS_NAME.startsWith("freebsd"); public static final boolean isSolaris = _OS_NAME.startsWith("sunos"); public static final boolean isUnix = SystemInfoRt.isUnix; + public static final boolean isXWindow = isUnix && !isMac; /** @deprecated inaccurate (to remove in IDEA 13) */ public static final boolean isKDE = SUN_DESKTOP.toLowerCase().contains("kde"); @@ -146,12 +147,8 @@ public class SystemInfo extends SystemInfoRt { */ public static final boolean isMacOSMountainLion = isMountainLion(); - /** - * Operating system is supposed to have middle mouse button click occupied by paste action. - * - * @since 6.0 - */ - public static boolean X11PasteEnabledSystem = isUnix && !isMac; + /** @deprecated use {@linkplain #isXWindow} (to remove in IDEA 13) */ + public static boolean X11PasteEnabledSystem = isXWindow; private static boolean isIntelMac() { return isMac && "i386".equals(OS_ARCH);