mnemonics for add/remove buttons in Project Structure dialog are replaced by insert/delete shortcuts (IDEA-43339)

This commit is contained in:
nik
2011-04-20 14:36:58 +04:00
parent 1e196ceb60
commit 9657ef7784
7 changed files with 42 additions and 23 deletions
@@ -20,6 +20,7 @@ import com.intellij.facet.impl.autodetecting.DisabledAutodetectionByTypeElement;
import com.intellij.facet.impl.autodetecting.DisabledAutodetectionInModuleElement;
import com.intellij.facet.impl.autodetecting.FacetAutodetectingManager;
import com.intellij.facet.impl.autodetecting.FacetAutodetectingManagerImpl;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
@@ -45,6 +46,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.*;
/**
@@ -105,9 +107,11 @@ public class FacetAutodetectionConfigurable implements Configurable {
}
}
});
UIUtil.addKeyboardShortcut(myModulesList, myAddModuleButton, CommonShortcuts.getInsertKeystroke());
myRemoveModuleButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
//noinspection unchecked
List<String> removed = ListUtil.removeSelectedItems(myModulesList);
for (String moduleName : removed) {
if (!myAddedModules.remove(moduleName)) {
@@ -117,14 +121,18 @@ public class FacetAutodetectionConfigurable implements Configurable {
updateButtons();
}
});
KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
UIUtil.addKeyboardShortcut(myModulesList, myRemoveModuleButton, delete);
myRemoveFileButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
//noinspection unchecked
List<String> removed = ListUtil.removeSelectedItems(myFilesList);
myRemovedFiles.addAll(removed);
updateButtons();
}
});
UIUtil.addKeyboardShortcut(myFilesList, myRemoveFileButton, delete);
myEnableAutoDetectionCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
@@ -50,6 +50,7 @@ import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ui.Table;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -306,10 +307,10 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
});
}
addKeyboardShortcut(myEntryTable, removeButton, KeyEvent.VK_DELETE, 0);
addKeyboardShortcut(myEntryTable, addButton, KeyEvent.VK_INSERT, 0);
addKeyboardShortcut(myEntryTable, upButton, KeyEvent.VK_UP, KeyEvent.CTRL_DOWN_MASK);
addKeyboardShortcut(myEntryTable, downButton, KeyEvent.VK_DOWN, KeyEvent.CTRL_DOWN_MASK);
UIUtil.addKeyboardShortcut(myEntryTable, removeButton, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
UIUtil.addKeyboardShortcut(myEntryTable, addButton, CommonShortcuts.getInsertKeystroke());
UIUtil.addKeyboardShortcut(myEntryTable, upButton, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_DOWN_MASK));
UIUtil.addKeyboardShortcut(myEntryTable, downButton, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_DOWN_MASK));
addButton.addActionListener(new ActionListener() {
@Override
@@ -407,20 +408,6 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
return panel;
}
private static void addKeyboardShortcut(final JComponent target, final JButton button, final int keyEvent, final int modifiers) {
target.registerKeyboardAction(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (button.isEnabled()) {
button.doClick();
}
}
},
KeyStroke.getKeyStroke(keyEvent, modifiers),
WHEN_FOCUSED
);
}
@Override
public void runClasspathPanelAction(Runnable action) {
try {
@@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots.ui;
import com.google.common.collect.Lists;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -52,6 +53,7 @@ import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -188,12 +190,14 @@ public class PathEditor {
setSelectedRoots(added);
}
});
UIUtil.addKeyboardShortcut(myList, myAddButton, CommonShortcuts.getInsertKeystroke());
myRemoveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int[] idxs = myList.getSelectedIndices();
doRemoveItems(idxs, myList);
}
});
UIUtil.addKeyboardShortcut(myList, myRemoveButton, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
mySpecifyUrlButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onSpecifyUrlButtonClicked();
@@ -32,13 +32,17 @@ public class CommonShortcuts {
SystemInfo.isMac
? KeyEvent.META_DOWN_MASK
: KeyEvent.CTRL_DOWN_MASK));
public static final ShortcutSet INSERT = new CustomShortcutSet(SystemInfo.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK)
: KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0));
public static final ShortcutSet INSERT = new CustomShortcutSet(getInsertKeystroke());
public static final ShortcutSet DELETE = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
public static final ShortcutSet ESCAPE = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
public static final ShortcutSet DOUBLE_CLICK_1 = new CustomShortcutSet(new Shortcut[]{new MouseShortcut(MouseEvent.BUTTON1, 0, 2)});
public static KeyStroke getInsertKeystroke() {
return SystemInfo.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK)
: KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0);
}
public static ShortcutSet getCopy() {
return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_COPY));
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@@ -180,7 +181,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
/**
* Sets a new component icon
*/
public final void setIcon(final Icon icon) {
public final void setIcon(final @Nullable Icon icon) {
myIcon = icon;
revalidateAndRepaint();
}
@@ -79,8 +79,8 @@ sdk.table.settings=SDK Table
sdk.unknown.name=Unknown SDK
sdk.list.name.required.error=Please specify SDK name
sdk.list.unique.name.required.error=Please specify a different SDK name
button.add=&Add...
button.remove=&Remove
button.add=Add...
button.remove=Remove
sdk.paths.specify.url.button=&Specify URL...
sdk.configure.title=Configure SDK
sdk.configure.save.settings.error=Cannot Save Settings
@@ -1463,6 +1463,21 @@ public class UIUtil {
}
}
public static void addKeyboardShortcut(final JComponent target,
final AbstractButton button, final KeyStroke keyStroke) {
target.registerKeyboardAction(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (button.isEnabled()) {
button.doClick();
}
}
},
keyStroke,
JComponent.WHEN_FOCUSED
);
}
public static class MacTreeUI extends BasicTreeUI {
public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list";