IDEA-90194 Ability to disable drag & drop in Project View

This commit is contained in:
Vassiliy
2014-04-23 21:47:08 +04:00
parent 817908d1b1
commit 2bd67bce3e
7 changed files with 38 additions and 14 deletions
@@ -110,6 +110,7 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
public int MAX_LOOKUP_WIDTH2 = 500;
public int MAX_LOOKUP_LIST_HEIGHT = 11;
public boolean HIDE_NAVIGATION_ON_FOCUS_LOSS = true;
public boolean DND_WITH_PRESSED_ALT_ONLY = false;
public boolean FILE_COLORS_IN_PROJECT_VIEW = false;
public boolean DEFAULT_AUTOSCROLL_TO_SOURCE = false;
@Transient
@@ -15,6 +15,7 @@
*/
package com.intellij.ui;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.ui.NullableComponent;
import com.intellij.openapi.util.Disposer;
@@ -27,10 +28,7 @@ import com.intellij.util.ui.update.UiNotifyConnector;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.*;
public abstract class MouseDragHelper implements MouseListener, MouseMotionListener, KeyEventDispatcher, Weighted {
@@ -58,6 +56,16 @@ public abstract class MouseDragHelper implements MouseListener, MouseMotionListe
}
/**
*
* @param event
* @return false if Settings -> Appearance -> Drag-n-Drop with ALT pressed only is selected but event doesn't have ALT modifier
*/
public static boolean checkModifiers(InputEvent event) {
if (event == null || !UISettings.getInstance().DND_WITH_PRESSED_ALT_ONLY) return true;
return (event.getModifiers() & InputEvent.ALT_MASK) != 0;
}
public void start() {
if (myGlassPane != null) return;
@@ -94,7 +94,7 @@ class DragHelper extends MouseDragHelper {
}
protected void processDrag(MouseEvent event, Point targetScreenPoint, Point startPointScreen) {
if (!myTabs.isTabDraggingEnabled() || !isDragSource(event)) return;
if (!myTabs.isTabDraggingEnabled() || !isDragSource(event) || !MouseDragHelper.checkModifiers(event)) return;
SwingUtilities.convertPointFromScreen(startPointScreen, myTabs);
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.reference.SoftReference;
import com.intellij.ui.MouseDragHelper;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.ui.GeometryUtil;
import com.intellij.util.ui.UIUtil;
@@ -538,7 +539,7 @@ public class DnDManagerImpl extends DnDManager implements Disposable {
public void dragGestureRecognized(DragGestureEvent dge) {
try {
final DnDSource source = getSource(dge.getComponent());
if (source == null) return;
if (source == null || !MouseDragHelper.checkModifiers(dge.getTriggerEvent())) return;
DnDAction action = getDnDActionForPlatformAction(dge.getDragAction());
if (source.canStartDragging(action, dge.getDragOrigin())) {
@@ -154,6 +154,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
settings.OVERRIDE_NONIDEA_LAF_FONTS = myComponent.myOverrideLAFFonts.isSelected();
settings.MOVE_MOUSE_ON_DEFAULT_BUTTON = myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected();
settings.HIDE_NAVIGATION_ON_FOCUS_LOSS = myComponent.myHideNavigationPopupsCheckBox.isSelected();
settings.DND_WITH_PRESSED_ALT_ONLY = myComponent.myAltDNDCheckBox.isSelected();
update |= settings.DISABLE_MNEMONICS != myComponent.myDisableMnemonics.isSelected();
settings.DISABLE_MNEMONICS = myComponent.myDisableMnemonics.isSelected();
@@ -270,6 +271,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
myComponent.myHideIconsInQuickNavigation.setSelected(settings.SHOW_ICONS_IN_QUICK_NAVIGATION);
myComponent.myMoveMouseOnDefaultButtonCheckBox.setSelected(settings.MOVE_MOUSE_ON_DEFAULT_BUTTON);
myComponent.myHideNavigationPopupsCheckBox.setSelected(settings.HIDE_NAVIGATION_ON_FOCUS_LOSS);
myComponent.myAltDNDCheckBox.setSelected(settings.DND_WITH_PRESSED_ALT_ONLY);
myComponent.myLafComboBox.setSelectedItem(LafManager.getInstance().getCurrentLookAndFeel());
myComponent.myOverrideLAFFonts.setSelected(settings.OVERRIDE_NONIDEA_LAF_FONTS);
myComponent.myDisableMnemonics.setSelected(settings.DISABLE_MNEMONICS);
@@ -330,6 +332,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
isModified |= myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected() != settings.MOVE_MOUSE_ON_DEFAULT_BUTTON;
isModified |= myComponent.myHideNavigationPopupsCheckBox.isSelected() != settings.HIDE_NAVIGATION_ON_FOCUS_LOSS;
isModified |= myComponent.myAltDNDCheckBox.isSelected() != settings.DND_WITH_PRESSED_ALT_ONLY;
isModified |= !Comparing.equal(myComponent.myLafComboBox.getSelectedItem(), LafManager.getInstance().getCurrentLookAndFeel());
if (WindowManagerEx.getInstanceEx().isAlphaModeSupported()) {
isModified |= myComponent.myEnableAlphaModeCheckBox.isSelected() != settings.ENABLE_ALPHA_MODE;
@@ -385,6 +388,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
private JCheckBox myDisableMnemonics;
private JCheckBox myDisableMnemonicInControlsCheckBox;
private JCheckBox myHideNavigationPopupsCheckBox;
private JCheckBox myAltDNDCheckBox;
private JCheckBox myAllowMergeButtons;
private JBCheckBox myUseSmallLabelsOnTabs;
private JBCheckBox myWidescreenLayoutCheckBox;
@@ -3,7 +3,7 @@
<grid id="41bd3" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="81" y="44" width="507" height="731"/>
<xy x="81" y="44" width="510" height="822"/>
</constraints>
<properties/>
<border type="none"/>
@@ -16,7 +16,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="d992b" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="d992b" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="3" indent="0" use-parent-layout="false"/>
@@ -49,7 +49,7 @@
<grid id="4c401" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -77,7 +77,7 @@
<grid id="d9fb" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -137,7 +137,7 @@
<grid id="ce348" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -164,7 +164,9 @@
</component>
<component id="9327f" class="javax.swing.JCheckBox" binding="myHideNavigationPopupsCheckBox">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="271" height="29"/>
</grid>
</constraints>
<properties>
<margin top="2" left="0" bottom="2" right="2"/>
@@ -174,7 +176,7 @@
<grid id="372a6" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -198,6 +200,14 @@
</component>
</children>
</grid>
<component id="2124a" class="javax.swing.JCheckBox" binding="myAltDNDCheckBox">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Drag-n-Drop with ALT pressed only"/>
</properties>
</component>
</children>
</grid>
<grid id="26e1c" binding="myTransparencyPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -174,7 +174,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
}
private void processDrag(final MouseEvent e) {
if (myDragCancelled) return;
if (myDragCancelled || !MouseDragHelper.checkModifiers(e)) return;
if (!isDraggingNow()) {
if (myPressedPoint == null) return;
if (isWithinDeadZone(e)) return;