diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 46a65aa5d69d..5f395ef97abf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -84,6 +84,7 @@ import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.JBScrollBar; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.mac.MacGestureSupportForEditor; +import com.intellij.ui.mac.MacGestureSupportUtils; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import com.intellij.util.IJSwingUtilities; @@ -554,7 +555,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi updateCaretCursor(); - if (SystemInfo.isJavaVersionAtLeast("1.8") && SystemInfo.isMacIntel64 && SystemInfo.isJetBrainsJvm && Registry.is("ide.mac.forceTouch")) { + if (MacGestureSupportUtils.isSupported()) { new MacGestureSupportForEditor(getComponent()); } backwardCompatibilityWithSoftWrapAppliancePlaces(mySettings, kind); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutPanel.java index 111cb17ccfb8..359db68d5e45 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutPanel.java @@ -15,11 +15,12 @@ */ package com.intellij.openapi.keymap.impl.ui; +import com.apple.eawt.event.GestureUtilities; +import com.apple.eawt.event.PressureListener; import com.intellij.openapi.actionSystem.MouseShortcut; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.actionSystem.PressureShortcut; import com.intellij.ui.JBColor; -import com.intellij.ui.mac.MacGestureSupportForMouseShortcutPanel; +import com.intellij.ui.mac.MacGestureSupportUtils; import java.awt.BorderLayout; import java.awt.event.MouseAdapter; @@ -70,8 +71,13 @@ public final class MouseShortcutPanel extends ShortcutPanel { myClickCount = allowDoubleClick ? 2 : 1; addMouseListener(myMouseListener); addMouseWheelListener(myMouseListener); - if (SystemInfo.isJavaVersionAtLeast("1.8") && SystemInfo.isMacIntel64 && SystemInfo.isJetBrainsJvm && Registry.is("ide.mac.forceTouch")) { - new MacGestureSupportForMouseShortcutPanel(this, () -> myMouseShortcut = null); + if (MacGestureSupportUtils.isSupported()) { + GestureUtilities.addGestureListenerTo(this, (PressureListener)e -> { + if (e.getStage() == 2) { + setShortcut(new PressureShortcut(e.getStage())); + myMouseShortcut = null; + } + }); } setBackground(BACKGROUND); setOpaque(true); diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportForMouseShortcutPanel.java b/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportForMouseShortcutPanel.java deleted file mode 100644 index 8c3528dec480..000000000000 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportForMouseShortcutPanel.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.ui.mac; - -/* - * @author denis - */ - -import com.apple.eawt.event.GestureListener; -import com.apple.eawt.event.GestureUtilities; -import com.apple.eawt.event.PressureEvent; -import com.apple.eawt.event.PressureListener; -import com.intellij.openapi.actionSystem.PressureShortcut; -import com.intellij.openapi.keymap.impl.ui.MouseShortcutPanel; - -public class MacGestureSupportForMouseShortcutPanel { - public MacGestureSupportForMouseShortcutPanel(MouseShortcutPanel panel, Runnable runnable) { - GestureListener pressureListener = new PressureListener() { - @Override - public void pressure(PressureEvent e) { - if (e.getStage() == 2) { - panel.setShortcut(new PressureShortcut(e.getStage())); - runnable.run(); - } - } - }; - GestureUtilities.addGestureListenerTo(panel, pressureListener); - } -} diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportUtils.java b/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportUtils.java new file mode 100644 index 000000000000..aa3e2c13311c --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportUtils.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui.mac; + +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; + +/** + * @author Konstantin Bulenkov + */ +public class MacGestureSupportUtils { + public static boolean isSupported() { + return SystemInfo.isJavaVersionAtLeast("1.8") + && SystemInfo.isMacIntel64 + && SystemInfo.isJetBrainsJvm + && Registry.is("ide.mac.forceTouch"); + } +}