/hg/icedtea-web: PolicyEditor mnemonics and accelerators overhaul
aazores at icedtea.classpath.org
aazores at icedtea.classpath.org
Mon Jul 14 14:06:40 UTC 2014
changeset a2d1b4b606bf in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=a2d1b4b606bf
author: Andrew Azores <aazores at redhat.com>
date: Mon Jul 14 10:06:27 2014 -0400
PolicyEditor mnemonics and accelerators overhaul
2014-07-14 Andrew Azores <aazores at redhat.com>
PolicyEditor mnemonics and accelerators overhaul
* netx/net/sourceforge/jnlp/resources/Messages.properties (PECodebaseMenu,
PERenameCodebaseItem, PECopyCodebaseItem, PEPasteCodebaseItem,
PECopyCodebaseToClipboardItem, PEFileMenuMnemonic, PECodebaseMenuMnemonic
PEViewMenuMnemonic, PEAddCodebaseItem, PERemoveCodebaseItem): removed "codebase"
from item labels, "Edit" menu renamed "codebase"
(PEAddCodebaseMnemonic, PEAddCodebaseItemMnemonic, PERemoveCodebaseMnemonic,
PERemoveCodebaseItemMnemonic, PEOpenMenuItemMnemonic, PESaveMenuItemMnemonic,
PEExitMenuItemMnemonic, PECustomPermissionsItemMnemonic,
PECopyCodebaseItemMnemonic, PEPasteCodebaseItemMnemonic,
PECopyCodebaseToClipboardItemMnemonic, PESaveAsMenuItemMnemonic,
PERenameCodebaseItemMnemonic): updated mnemonics
(PEAddCodebaseItemAccelerator, PERemoveCodebaseItemAccelerator,
PEOpenMenuItemAccelerator, PESaveMenuItemAccelerator,
PESaveAsMenuItemAccelerator, PEExitMenuItemAccelerator,
PECustomPermissionsItemAccelerator, PECopyCodebaseItemAccelerator,
PEPasteCodebaseItemAccelerator, PERenameCodebaseItemAccelerator,
PECopyCodebaseToClipboardItemAccelerator): added accelerators
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
(closeButtonAction): set in PolicyEditor constructor rather than
setupPolicyEditorWindow
(setupPolicyEditorWindow): do not set save/quit/esc actions
(setAccelerators, setAccelerator, setAddCodebaseAccelerator,
setRemoveCodebaseAccelerator): removed
(setButtonMnemonic): simplified, takes a String expected to be a single
character representing the mnemonic key directly, rather than a String
parseable to an integer which represented the value of the mnemonic key
(setMenuItemAccelerator): new method
(createMenuBar): use new mnemonics and accelerators, add new Add/Remove
items to Codebase menu, override JList default Control-C/Control-V
copy/paste actions
(setupLayout): groupCh MouseListener#mouseClicked logic extracted to
toggleExpandedCheckboxGroupPanel, KeyListener added to allow expanding
checkbox groups via keyboard with Enter or "Context Menu"
(toggleExpandedCheckboxGroupPanel): new method
diffstat:
ChangeLog | 38 +
netx/net/sourceforge/jnlp/resources/Messages.properties | 66 +-
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java | 273 ++++-----
3 files changed, 195 insertions(+), 182 deletions(-)
diffs (truncated from 554 to 500 lines):
diff -r 88fd3fdab3f4 -r a2d1b4b606bf ChangeLog
--- a/ChangeLog Fri Jul 11 16:30:57 2014 -0400
+++ b/ChangeLog Mon Jul 14 10:06:27 2014 -0400
@@ -1,3 +1,41 @@
+2014-07-14 Andrew Azores <aazores at redhat.com>
+
+ PolicyEditor mnemonics and accelerators overhaul
+ * netx/net/sourceforge/jnlp/resources/Messages.properties (PECodebaseMenu,
+ PERenameCodebaseItem, PECopyCodebaseItem, PEPasteCodebaseItem,
+ PECopyCodebaseToClipboardItem, PEFileMenuMnemonic, PECodebaseMenuMnemonic
+ PEViewMenuMnemonic, PEAddCodebaseItem, PERemoveCodebaseItem): removed "codebase"
+ from item labels, "Edit" menu renamed "codebase"
+ (PEAddCodebaseMnemonic, PEAddCodebaseItemMnemonic, PERemoveCodebaseMnemonic,
+ PERemoveCodebaseItemMnemonic, PEOpenMenuItemMnemonic, PESaveMenuItemMnemonic,
+ PEExitMenuItemMnemonic, PECustomPermissionsItemMnemonic,
+ PECopyCodebaseItemMnemonic, PEPasteCodebaseItemMnemonic,
+ PECopyCodebaseToClipboardItemMnemonic, PESaveAsMenuItemMnemonic,
+ PERenameCodebaseItemMnemonic): updated mnemonics
+ (PEAddCodebaseItemAccelerator, PERemoveCodebaseItemAccelerator,
+ PEOpenMenuItemAccelerator, PESaveMenuItemAccelerator,
+ PESaveAsMenuItemAccelerator, PEExitMenuItemAccelerator,
+ PECustomPermissionsItemAccelerator, PECopyCodebaseItemAccelerator,
+ PEPasteCodebaseItemAccelerator, PERenameCodebaseItemAccelerator,
+ PECopyCodebaseToClipboardItemAccelerator): added accelerators
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
+ (closeButtonAction): set in PolicyEditor constructor rather than
+ setupPolicyEditorWindow
+ (setupPolicyEditorWindow): do not set save/quit/esc actions
+ (setAccelerators, setAccelerator, setAddCodebaseAccelerator,
+ setRemoveCodebaseAccelerator): removed
+ (setButtonMnemonic): simplified, takes a String expected to be a single
+ character representing the mnemonic key directly, rather than a String
+ parseable to an integer which represented the value of the mnemonic key
+ (setMenuItemAccelerator): new method
+ (createMenuBar): use new mnemonics and accelerators, add new Add/Remove
+ items to Codebase menu, override JList default Control-C/Control-V
+ copy/paste actions
+ (setupLayout): groupCh MouseListener#mouseClicked logic extracted to
+ toggleExpandedCheckboxGroupPanel, KeyListener added to allow expanding
+ checkbox groups via keyboard with Enter or "Context Menu"
+ (toggleExpandedCheckboxGroupPanel): new method
+
2014-07-11 Andrew Azores <aazores at redhat.com>
Fixed bug where the "Cancel" option on the "save changes before exiting"
diff -r 88fd3fdab3f4 -r a2d1b4b606bf netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties Fri Jul 11 16:30:57 2014 -0400
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties Mon Jul 14 10:06:27 2014 -0400
@@ -562,11 +562,13 @@
PESaveMenuItem=Save
PESaveAsMenuItem=Save As...
PEExitMenuItem=Exit
-PEEditMenu=Edit
-PERenameCodebaseItem=Rename codebase
-PECopyCodebaseItem=Copy codebase
-PEPasteCodebaseItem=Paste codebase
-PECopyCodebaseToClipboardItem=Copy codebase URL to clipboard
+PECodebaseMenu=Codebase
+PEAddCodebaseItem=Add new
+PERemoveCodebaseItem=Remove
+PERenameCodebaseItem=Rename
+PECopyCodebaseItem=Copy
+PEPasteCodebaseItem=Paste
+PECopyCodebaseToClipboardItem=Copy URL to clipboard
PERenameCodebase=Rename codebase to:
PEPasteCodebase=Paste copied codebase as:
PEViewMenu=View
@@ -593,30 +595,36 @@
PECPPrompt=Enter a custom permission. Do not include \"permission\" or punctuation marks.
# PolicyEditor key mnemonics. See KeyEvent.VK_*
-# N
-PEAddCodebaseMnemonic=78
-# R
-PERemoveCodebaseMnemonic=82
-# A
-PEOkButtonMnemonic=65
-# C
-PECancelButtonMnemonic=67
-# F
-PEFileMenuMnemonic=70
-# E
-PEEditMenuMnemonic=69
-# I
-PEViewMenuMnemonic=73
-# O
-PEOpenMenuItemMnemonic=79
-# S
-PESaveMenuItemMnemonic=83
-# A
-PESaveAsMenuItemMnemonic=65
-# X
-PEExitMenuItemMnemonic=88
-# U
-PECustomPermissionsItemMnemonic=85
+PEFileMenuMnemonic=F
+PECodebaseMenuMnemonic=C
+PEViewMenuMnemonic=V
+
+PEAddCodebaseMnemonic=N
+PEAddCodebaseItemMnemonic=N
+PERemoveCodebaseMnemonic=R
+PERemoveCodebaseItemMnemonic=R
+PEOpenMenuItemMnemonic=O
+PESaveMenuItemMnemonic=S
+PEExitMenuItemMnemonic=X
+PECustomPermissionsItemMnemonic=U
+PECopyCodebaseItemMnemonic=C
+PEPasteCodebaseItemMnemonic=P
+PECopyCodebaseToClipboardItemMnemonic=U
+PESaveAsMenuItemMnemonic=A
+PERenameCodebaseItemMnemonic=E
+
+# See javax.swing.KeyStroke.getKeyStroke(String)
+PEAddCodebaseItemAccelerator=control N
+PERemoveCodebaseItemAccelerator=DELETE
+PEOpenMenuItemAccelerator=control O
+PESaveMenuItemAccelerator=control S
+PESaveAsMenuItemAccelerator=control shift S
+PEExitMenuItemAccelerator=control Q
+PECustomPermissionsItemAccelerator=control U
+PECopyCodebaseItemAccelerator=control C
+PEPasteCodebaseItemAccelerator=control V
+PERenameCodebaseItemAccelerator=F2
+PECopyCodebaseToClipboardItemAccelerator=control shift C
#conole itself labels
CONSOLErungc = Run GC
diff -r 88fd3fdab3f4 -r a2d1b4b606bf netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Fri Jul 11 16:30:57 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Mon Jul 14 10:06:27 2014 -0400
@@ -50,6 +50,8 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
@@ -76,10 +78,11 @@
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.DefaultListModel;
+import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JCheckBox;
-import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
@@ -363,7 +366,7 @@
copyCodebaseToClipboardButtonAction = new ActionListener() {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
final String selectedCodebase = getSelectedCodebase();
if (selectedCodebase.isEmpty()) {
return;
@@ -396,7 +399,17 @@
}
};
- setAccelerators();
+ closeButtonAction = new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ final Window parentWindow = SwingUtilities.getWindowAncestor(PolicyEditor.this);
+ if (parentWindow instanceof PolicyEditorWindow) {
+ ((PolicyEditorWindow) parentWindow).quit();
+ }
+ }
+ };
+ closeButton.setText(R("ButClose"));
+ closeButton.addActionListener(closeButtonAction);
setupLayout();
}
@@ -417,7 +430,7 @@
w.setPolicyEditor(e);
w.setTitle(R("PETitle"));
w.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- w.setJMenuBar(createMenuBar(w.asWindow(), w.getPolicyEditor()));
+ w.setJMenuBar(createMenuBar(w.getPolicyEditor()));
setupPolicyEditorWindow(w.asWindow(), w.getPolicyEditor());
}
@@ -432,39 +445,6 @@
((PolicyEditorWindow) window).quit();
}
});
-
- editor.closeButtonAction = new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent event) {
- ((PolicyEditorWindow) window).quit();
- }
- };
- editor.closeButton.setText(R("ButClose"));
- editor.closeButton.addActionListener(editor.closeButtonAction);
-
- final Action saveAct = new AbstractAction() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- editor.savePolicyFile();
- }
- };
- editor.setAccelerator(R("PEOkButtonMnemonic"), ActionEvent.ALT_MASK, saveAct, "OkButtonAccelerator");
-
- final Action quitAct = new AbstractAction() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- ((PolicyEditorWindow) window).quit();
- }
- };
- editor.setAccelerator(R("PECancelButtonMnemonic"), ActionEvent.ALT_MASK, quitAct, "CancelButtonAccelerator");
-
- final Action escAct = new AbstractAction() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- ((PolicyEditorWindow) window).quit();
- }
- };
- editor.setAccelerator(KeyEvent.VK_ESCAPE, ActionEvent.ALT_MASK, escAct, "ExitOnEscape");
}
public static interface PolicyEditorWindow {
@@ -648,73 +628,6 @@
}
/**
- * Set keyboard accelerators for each major function in the editor
- */
- private void setAccelerators() {
- setAddCodebaseAccelerator();
- setRemoveCodebaseAccelerator();
- }
-
- /**
- * Set a key accelerator
- * @param trigger the accelerator key
- * @param modifiers Alt, Ctrl, or other modifiers to be held with the trigger
- * @param action to be performed
- * @param identifier an identifier for the action
- */
- private void setAccelerator(final String trigger, final int modifiers, final Action action, final String identifier) {
- final int trig;
- try {
- trig = Integer.parseInt(trigger);
- } catch (final NumberFormatException nfe) {
- OutputController.getLogger().log("Unable to set accelerator action \""
- + identifier + "\" for trigger \"" + trigger + "\"");
- OutputController.getLogger().log(nfe);
- return;
- }
- setAccelerator(trig, modifiers, action, identifier);
- }
-
- /**
- * Set a key accelerator
- * @param trigger the accelerator key
- * @param modifiers Alt, Ctrl, or other modifiers to be held with the trigger
- * @param action to be performed
- * @param identifier an identifier for the action
- */
- private void setAccelerator(final int trigger, final int modifiers, final Action action, final String identifier) {
- final KeyStroke key = KeyStroke.getKeyStroke(trigger, modifiers);
- this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, identifier);
- this.getActionMap().put(identifier, action);
- }
-
- /**
- * Add an accelerator for adding new codebases
- */
- private void setAddCodebaseAccelerator() {
- final Action act = new AbstractAction() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- addNewCodebaseInteractive();
- }
- };
- setAccelerator(R("PEAddCodebaseMnemonic"), ActionEvent.ALT_MASK, act, "AddCodebaseAccelerator");
- }
-
- /**
- * Add an accelerator for removing the selected codebase
- */
- private void setRemoveCodebaseAccelerator() {
- final Action act = new AbstractAction() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- removeCodebase(getSelectedCodebase());
- }
- };
- setAccelerator(R("PERemoveCodebaseMnemonic"), ActionEvent.ALT_MASK, act, "RemoveCodebaseAccelerator");
- }
-
- /**
* Add a new codebase to the editor's model. If the codebase is not a valid URL,
* the codebase is not added.
* @param codebase to be added
@@ -937,88 +850,132 @@
/**
* Set a mnemonic key for a menu item or button
- * @param component the component for which to set a mnemonic
+ * @param button the component for which to set a mnemonic
* @param mnemonic the mnemonic to set
*/
- private static void setComponentMnemonic(final AbstractButton component, final String mnemonic) {
- final int trig;
- try {
- trig = Integer.parseInt(mnemonic);
- } catch (final NumberFormatException nfe) {
- OutputController.getLogger().log(nfe);
+ private static void setButtonMnemonic(final AbstractButton button, final String mnemonic) {
+ if (mnemonic.length() != 1) {
+ OutputController.getLogger().log(OutputController.Level.WARNING_DEBUG, "Could not set mnemonic \"" + mnemonic + "\" for " + button);
return;
}
- component.setMnemonic(trig);
+ final char ch = mnemonic.charAt(0);
+ button.setMnemonic(ch);
}
- private static JMenuBar createMenuBar(final Window window, final PolicyEditor editor) {
+ private static void setMenuItemAccelerator(final JMenuItem menuItem, final String accelerator) {
+ final KeyStroke ks = KeyStroke.getKeyStroke(accelerator);
+ menuItem.setAccelerator(ks);
+ }
+
+ private static JMenuBar createMenuBar(final PolicyEditor editor) {
final JMenuBar menuBar = new JMenuBar();
final JMenu fileMenu = new JMenu(R("PEFileMenu"));
- setComponentMnemonic(fileMenu, R("PEFileMenuMnemonic"));
+ setButtonMnemonic(fileMenu, R("PEFileMenuMnemonic"));
final JMenuItem openItem = new JMenuItem(R("PEOpenMenuItem"));
- setComponentMnemonic(openItem, R("PEOpenMenuItemMnemonic"));
- openItem.setAccelerator(KeyStroke.getKeyStroke(openItem.getMnemonic(), ActionEvent.CTRL_MASK));
+ setButtonMnemonic(openItem, R("PEOpenMenuItemMnemonic"));
+ setMenuItemAccelerator(openItem, R("PEOpenMenuItemAccelerator"));
openItem.addActionListener(editor.openButtonAction);
fileMenu.add(openItem);
final JMenuItem saveItem = new JMenuItem(R("PESaveMenuItem"));
- setComponentMnemonic(saveItem, R("PESaveMenuItemMnemonic"));
- saveItem.setAccelerator(KeyStroke.getKeyStroke(saveItem.getMnemonic(), ActionEvent.CTRL_MASK));
+ setButtonMnemonic(saveItem, R("PESaveMenuItemMnemonic"));
+ setMenuItemAccelerator(saveItem, R("PESaveMenuItemAccelerator"));
saveItem.addActionListener(editor.okButtonAction);
fileMenu.add(saveItem);
final JMenuItem saveAsItem = new JMenuItem(R("PESaveAsMenuItem"));
- setComponentMnemonic(saveAsItem, R("PESaveAsMenuItemMnemonic"));
- saveAsItem.setAccelerator(KeyStroke.getKeyStroke(saveAsItem.getMnemonic(), ActionEvent.CTRL_MASK));
+ setButtonMnemonic(saveAsItem, R("PESaveAsMenuItemMnemonic"));
+ setMenuItemAccelerator(saveAsItem, R("PESaveAsMenuItemAccelerator"));
saveAsItem.addActionListener(editor.saveAsButtonAction);
fileMenu.add(saveAsItem);
final JMenuItem exitItem = new JMenuItem(R("PEExitMenuItem"));
- setComponentMnemonic(exitItem, R("PEExitMenuItemMnemonic"));
- exitItem.setAccelerator(KeyStroke.getKeyStroke(exitItem.getMnemonic(), ActionEvent.CTRL_MASK));
+ setButtonMnemonic(exitItem, R("PEExitMenuItemMnemonic"));
+ setMenuItemAccelerator(exitItem, R("PEExitMenuItemAccelerator"));
exitItem.addActionListener(editor.closeButtonAction);
- exitItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- window.dispose();
- }
- });
fileMenu.add(exitItem);
menuBar.add(fileMenu);
- final JMenu editMenu = new JMenu(R("PEEditMenu"));
- setComponentMnemonic(editMenu, R("PEEditMenuMnemonic"));
+ final JMenu codebaseMenu = new JMenu(R("PECodebaseMenu"));
+ setButtonMnemonic(codebaseMenu, R("PECodebaseMenuMnemonic"));
+
+ final JMenuItem addNewCodebaseItem = new JMenuItem(R("PEAddCodebaseItem"));
+ setButtonMnemonic(addNewCodebaseItem, R("PEAddCodebaseItemMnemonic"));
+ setMenuItemAccelerator(addNewCodebaseItem, R("PEAddCodebaseItemAccelerator"));
+ addNewCodebaseItem.addActionListener(editor.addCodebaseButtonAction);
+ codebaseMenu.add(addNewCodebaseItem);
+
+ final JMenuItem removeCodebaseItem = new JMenuItem(R("PERemoveCodebaseItem"));
+ setButtonMnemonic(removeCodebaseItem, R("PERemoveCodebaseItemMnemonic"));
+ setMenuItemAccelerator(removeCodebaseItem, R("PERemoveCodebaseItemAccelerator"));
+ removeCodebaseItem.addActionListener(editor.removeCodebaseButtonAction);
+ codebaseMenu.add(removeCodebaseItem);
+
+ codebaseMenu.addSeparator();
final JMenuItem renameCodebaseItem = new JMenuItem(R("PERenameCodebaseItem"));
+ setButtonMnemonic(renameCodebaseItem, R("PERenameCodebaseItemMnemonic"));
+ setMenuItemAccelerator(renameCodebaseItem, R("PERenameCodebaseItemAccelerator"));
renameCodebaseItem.addActionListener(editor.renameCodebaseButtonAction);
- editMenu.add(renameCodebaseItem);
+ codebaseMenu.add(renameCodebaseItem);
final JMenuItem copyCodebaseItem = new JMenuItem(R("PECopyCodebaseItem"));
+ setButtonMnemonic(copyCodebaseItem, R("PECopyCodebaseItemMnemonic"));
+ setMenuItemAccelerator(copyCodebaseItem, R("PECopyCodebaseItemAccelerator"));
copyCodebaseItem.addActionListener(editor.copyCodebaseButtonAction);
- editMenu.add(copyCodebaseItem);
+ codebaseMenu.add(copyCodebaseItem);
+
+ final JMenuItem copyCodebaseToClipboardItem = new JMenuItem(R("PECopyCodebaseToClipboardItem"));
+ setButtonMnemonic(copyCodebaseToClipboardItem, R("PECopyCodebaseToClipboardItemMnemonic"));
+ setMenuItemAccelerator(copyCodebaseToClipboardItem, R("PECopyCodebaseToClipboardItemAccelerator"));
+ copyCodebaseToClipboardItem.addActionListener(editor.copyCodebaseToClipboardButtonAction);
+ codebaseMenu.add(copyCodebaseToClipboardItem);
+ menuBar.add(codebaseMenu);
final JMenuItem pasteCodebaseItem = new JMenuItem(R("PEPasteCodebaseItem"));
+ setButtonMnemonic(pasteCodebaseItem, R("PEPasteCodebaseItemMnemonic"));
+ setMenuItemAccelerator(pasteCodebaseItem, R("PEPasteCodebaseItemAccelerator"));
pasteCodebaseItem.addActionListener(editor.pasteCodebaseButtonAction);
- editMenu.add(pasteCodebaseItem);
-
- final JMenuItem copyCodebaseToClipboardItem = new JMenuItem(R("PECopyCodebaseToClipboardItem"));
- copyCodebaseToClipboardItem.addActionListener(editor.copyCodebaseToClipboardButtonAction);
- editMenu.add(copyCodebaseToClipboardItem);
- menuBar.add(editMenu);
+ codebaseMenu.add(pasteCodebaseItem);
final JMenu viewMenu = new JMenu(R("PEViewMenu"));
- setComponentMnemonic(viewMenu, R("PEViewMenuMnemonic"));
+ setButtonMnemonic(viewMenu, R("PEViewMenuMnemonic"));
final JMenuItem customPermissionsItem = new JMenuItem(R("PECustomPermissionsItem"));
- setComponentMnemonic(customPermissionsItem, R("PECustomPermissionsItemMnemonic"));
- customPermissionsItem.setAccelerator(KeyStroke.getKeyStroke(customPermissionsItem.getMnemonic(), ActionEvent.ALT_MASK));
+ setButtonMnemonic(customPermissionsItem, R("PECustomPermissionsItemMnemonic"));
+ setMenuItemAccelerator(customPermissionsItem, R("PECustomPermissionsItemAccelerator"));
customPermissionsItem.addActionListener(editor.viewCustomButtonAction);
viewMenu.add(customPermissionsItem);
menuBar.add(viewMenu);
+ /*
+ * JList has default Ctrl-C and Ctrl-V bindings, which we want to override with custom actions
+ */
+ final InputMap listInputMap = editor.list.getInputMap();
+ final ActionMap listActionMap = editor.list.getActionMap();
+
+ final Action listCopyOverrideAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ editor.copyCodebaseButtonAction.actionPerformed(e);
+ }
+ };
+
+ final Action listPasteOverrideAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ editor.pasteCodebaseButtonAction.actionPerformed(e);
+ }
+ };
+
+ listInputMap.put(copyCodebaseItem.getAccelerator(), "CopyCodebaseOverride");
+ listActionMap.put("CopyCodebaseOverride", listCopyOverrideAction);
+ listInputMap.put(pasteCodebaseItem.getAccelerator(), "PasteCodebaseOverride");
+ listActionMap.put("PasteCodebaseOverride", listPasteOverrideAction);
+
return menuBar;
}
@@ -1069,20 +1026,23 @@
groupCh.setToolTipText(R("PEGrightClick"));
groupCh.addMouseListener(new MouseAdapter() {
@Override
- public void mouseClicked(MouseEvent e) {
+ public void mouseClicked(final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
- groupPanel.setVisible(!groupPanel.isVisible());
- PolicyEditor.this.validate();
- final Window w = SwingUtilities.getWindowAncestor(PolicyEditor.this);
- if (w != null) {
- w.pack();
- }
+ toggleExpandedCheckboxGroupPanel(groupPanel);
+ }
+ }
+ });
+ groupCh.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
+ toggleExpandedCheckboxGroupPanel(groupPanel);
}
}
});
groupCh.addActionListener(new ActionListener() {
More information about the distro-pkg-dev
mailing list