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 5f395ef97abf..46a65aa5d69d 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,7 +84,6 @@ 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; @@ -555,7 +554,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi updateCaretCursor(); - if (MacGestureSupportUtils.isSupported()) { + if (SystemInfo.isJavaVersionAtLeast("1.8") && SystemInfo.isMacIntel64 && SystemInfo.isJetBrainsJvm && Registry.is("ide.mac.forceTouch")) { 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 359db68d5e45..111cb17ccfb8 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,12 +15,11 @@ */ 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.actionSystem.PressureShortcut; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.JBColor; -import com.intellij.ui.mac.MacGestureSupportUtils; +import com.intellij.ui.mac.MacGestureSupportForMouseShortcutPanel; import java.awt.BorderLayout; import java.awt.event.MouseAdapter; @@ -71,13 +70,8 @@ public final class MouseShortcutPanel extends ShortcutPanel { myClickCount = allowDoubleClick ? 2 : 1; addMouseListener(myMouseListener); addMouseWheelListener(myMouseListener); - if (MacGestureSupportUtils.isSupported()) { - GestureUtilities.addGestureListenerTo(this, (PressureListener)e -> { - if (e.getStage() == 2) { - setShortcut(new PressureShortcut(e.getStage())); - myMouseShortcut = null; - } - }); + if (SystemInfo.isJavaVersionAtLeast("1.8") && SystemInfo.isMacIntel64 && SystemInfo.isJetBrainsJvm && Registry.is("ide.mac.forceTouch")) { + new MacGestureSupportForMouseShortcutPanel(this, () -> 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 new file mode 100644 index 000000000000..472210a3243f --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportForMouseShortcutPanel.java @@ -0,0 +1,42 @@ +/* + * 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; + +/* + * @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 deleted file mode 100644 index aa3e2c13311c..000000000000 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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"); - } -}