IDEA-110576 Add ability to search keymaps by mouse shortcut

refresh filter when shortcut removed
This commit is contained in:
Sergey Malenkov
2015-11-03 14:42:50 +03:00
parent 908c3effee
commit 261f79a647
5 changed files with 26 additions and 17 deletions
@@ -201,13 +201,11 @@ public class ChooseActionsDialog extends DialogWrapper {
}
private void filterTreeByShortcut(Shortcut shortcut) {
if (shortcut != null) {
if (!myTreeExpansionMonitor.isFreeze()) myTreeExpansionMonitor.freeze();
myActionsTree.reset(myKeymap, myQuicklists);
myActionsTree.filterTree(shortcut, myQuicklists);
final JTree tree = myActionsTree.getTree();
TreeUtil.expandAll(tree);
}
if (!myTreeExpansionMonitor.isFreeze()) myTreeExpansionMonitor.freeze();
myActionsTree.reset(myKeymap, myQuicklists);
myActionsTree.filterTree(shortcut, myQuicklists);
final JTree tree = myActionsTree.getTree();
TreeUtil.expandAll(tree);
}
public void dispose() {
@@ -73,7 +73,7 @@ final class KeyboardShortcutPanel extends JPanel {
void setShortcut(KeyboardShortcut shortcut) {
Shortcut old = myShortcut;
if (old != null || shortcut != null) {
if (old == null || !old.equals(shortcut)) {
myShortcut = shortcut;
myFirstStroke.setKeyStroke(shortcut == null ? null : shortcut.getFirstKeyStroke());
mySecondStroke.setKeyStroke(shortcut == null ? null : shortcut.getSecondKeyStroke());
@@ -453,13 +453,11 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
}
private void filterTreeByShortcut(Shortcut shortcut) {
if (shortcut != null) {
myTreeExpansionMonitor.freeze();
myActionsTree.filterTree(shortcut, myQuickLists);
final JTree tree = myActionsTree.getTree();
TreeUtil.expandAll(tree);
myTreeExpansionMonitor.restore();
}
myTreeExpansionMonitor.freeze();
myActionsTree.filterTree(shortcut, myQuickLists);
final JTree tree = myActionsTree.getTree();
TreeUtil.expandAll(tree);
myTreeExpansionMonitor.restore();
}
public void showOption(String option) {
@@ -57,8 +57,12 @@ final class ShortcutFilteringPanel extends JPanel {
}
};
private final PropertyChangeListener myPropertyListener = new PropertyChangeListener() {
private volatile boolean myInternal;
@Override
public void propertyChange(PropertyChangeEvent event) {
boolean internal = myInternal;
myInternal = true;
Object value = event.getNewValue();
if (ShortcutFilteringPanel.this == event.getSource()) {
if (value instanceof KeyboardShortcut) {
@@ -85,6 +89,10 @@ final class ShortcutFilteringPanel extends JPanel {
else if (value instanceof Shortcut) {
setShortcut((Shortcut)value);
}
else if (!internal) {
setShortcut(null);
}
myInternal = internal;
}
};
@@ -137,7 +145,6 @@ final class ShortcutFilteringPanel extends JPanel {
.setMovable(true)
.createPopup();
}
myKeyboardPanel.mySecondStrokeEnable.setSelected(false);
myPopup.showUnderneathOf(component);
}
@@ -22,6 +22,7 @@
*/
package com.intellij.openapi.keymap.impl.ui;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.KeyStrokeAdapter;
@@ -65,7 +66,8 @@ public class ShortcutTextField extends JTextField {
KeyStroke old = myKeyStroke;
if (old != null || keyStroke != null) {
myKeyStroke = keyStroke;
setText(KeyboardShortcutDialog.getTextByKeyStroke(keyStroke));
super.setText(KeymapUtil.getKeystrokeText(keyStroke));
setCaretPosition(0);
updateCurrentKeyStrokeInfo();
firePropertyChange("keyStroke", old, keyStroke);
}
@@ -87,5 +89,9 @@ public class ShortcutTextField extends JTextField {
public void setText(String text) {
super.setText(text);
setCaretPosition(0);
if (text == null || text.isEmpty()) {
myKeyStroke = null;
firePropertyChange("keyStroke", null, null);
}
}
}