Changeset 4914 in josm for trunk/src


Ignore:
Timestamp:
2012-02-10T05:04:22+01:00 (13 years ago)
Author:
akks
Message:

fix #6239 - Patch by Joshdoe [Case insensitive word-based search in shortcut prefs] + refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/PrefJPanel.java

    r4909 r4914  
    99
    1010import java.awt.event.KeyEvent;
     11import java.util.ArrayList;
    1112import java.util.LinkedHashMap;
    1213import java.util.HashMap;
     
    1415
    1516import java.util.regex.PatternSyntaxException;
    16 import javax.swing.AbstractAction;
    17 import javax.swing.BorderFactory;
    18 import javax.swing.JEditorPane;
    19 import javax.swing.JLabel;
    20 import javax.swing.JPanel;
    21 import javax.swing.JScrollPane;
    22 import javax.swing.JTextField;
    23 import javax.swing.ListSelectionModel;
    24 import javax.swing.RowFilter;
     17import javax.swing.*;
    2518import javax.swing.event.DocumentEvent;
    2619import javax.swing.event.DocumentListener;
     
    3831 * If someone wants to merge it with ShortcutPreference.java, feel free.
    3932 */
    40 public class PrefJPanel extends javax.swing.JPanel {
     33public class PrefJPanel extends JPanel {
    4134
    4235    // table of shortcuts
     
    6356        tr("disabled"),
    6457        tr("no modifier"),
    65         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[2]).getModifiers()),
    66         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[3]).getModifiers()),
    67         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[4]).getModifiers()),
    68         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[5]).getModifiers()),
    69         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[6]).getModifiers()),
    70         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[7]).getModifiers()),
    71         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[8]).getModifiers()),
    72         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[9]).getModifiers()),
    73         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[10]).getModifiers()),
    74         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[11]).getModifiers()),
    75         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[12]).getModifiers()),
    76         KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[13]).getModifiers())
     58        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[2]).getModifiers()),
     59        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[3]).getModifiers()),
     60        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[4]).getModifiers()),
     61        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[5]).getModifiers()),
     62        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[6]).getModifiers()),
     63        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[7]).getModifiers()),
     64        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[8]).getModifiers()),
     65        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[9]).getModifiers()),
     66        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[10]).getModifiers()),
     67        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[11]).getModifiers()),
     68        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[12]).getModifiers()),
     69        KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[13]).getModifiers())
    7770    };
    7871    // this are the display(!) texts for the checkboxes. Let the JVM do the i18n for us <g>.
     
    8275    // usually matches the keyboard. This even works with my English Windows and my German
    8376    // keyboard.
    84     private static String SHIFT = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
    85     private static String CTRL  = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
    86     private static String ALT   = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
    87     private static String META  = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
     77    private static String SHIFT = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
     78    private static String CTRL  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
     79    private static String ALT   = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
     80    private static String META  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
    8881
    8982    // A list of keys to present the user. Sadly this really is a list of keys Java knows about,
    9083    // not a list of real physical keys. If someone knows how to get that list?
    9184    private static Map<Integer, String> keyList = setKeyList();
    92 
     85   
    9386    private static Map<Integer, String> setKeyList() {
    9487        Map<Integer, String> list = new LinkedHashMap<Integer, String>();
     
    10497        return list;
    10598    }
     99   
     100    private JComboBox bxPrim1 = new JComboBox();
     101    private JComboBox bxPrim2 = new JComboBox();
     102    private JComboBox bxPrim3 = new JComboBox();
     103    private JComboBox bxPrim4 = new JComboBox();
     104    private JComboBox bxSec1 = new JComboBox();
     105    private JComboBox bxSec2 = new JComboBox();
     106    private JComboBox bxSec3 = new JComboBox();
     107    private JComboBox bxSec4 = new JComboBox();
     108    private JComboBox bxTer1 = new JComboBox();
     109    private JComboBox bxTer2 = new JComboBox();
     110    private JComboBox bxTer3 = new JComboBox();
     111    private JComboBox bxTer4 = new JComboBox();
     112    private JCheckBox cbAlt = new JCheckBox();
     113    private JCheckBox cbCtrl = new JCheckBox();
     114    private JCheckBox cbMeta = new JCheckBox();
     115    private JCheckBox cbShift = new JCheckBox();
     116    private JCheckBox cbDefault = new JCheckBox();
     117    private JCheckBox cbDisable = new JCheckBox();
     118    private JComboBox tfKey = new JComboBox();
     119   
     120    JTable shortcutTable = new JTable();
     121   
     122    private JTextField filterField = new JTextField();
    106123
    107124    /** Creates new form prefJPanel */
     
    116133        // Did I mention auto-generated? That's the reason we
    117134        // have lots of properties here and not some arrays...
    118         prefTabPane = new javax.swing.JTabbedPane();
    119         shortcutTab = new javax.swing.JPanel();
    120         listPane = new javax.swing.JPanel();
    121         listScrollPane = new javax.swing.JScrollPane();
    122         shortcutTable = new javax.swing.JTable();
    123         shortcutEditPane = new javax.swing.JPanel();
    124         cbDefault = new javax.swing.JCheckBox();
    125         jLabel4 = new javax.swing.JLabel();
    126         cbShift = new javax.swing.JCheckBox();
    127         cbDisable = new javax.swing.JCheckBox();
    128         cbCtrl = new javax.swing.JCheckBox();
    129         tfKeyLabel = new javax.swing.JLabel();
    130         cbAlt = new javax.swing.JCheckBox();
    131         tfKey = new javax.swing.JComboBox();
    132         cbMeta = new javax.swing.JCheckBox();
    133         jLabel6 = new javax.swing.JLabel();
    134         modifierTab = new javax.swing.JPanel();
    135         editGroupPane = new javax.swing.JPanel();
    136         jLabel1 = new javax.swing.JLabel();
    137         bxPrim1 = new javax.swing.JComboBox();
    138         jLabel2 = new javax.swing.JLabel();
    139         bxSec1 = new javax.swing.JComboBox();
    140         jLabel3 = new javax.swing.JLabel();
    141         bxTer1 = new javax.swing.JComboBox();
    142         menuGroupPane = new javax.swing.JPanel();
    143         jLabel7 = new javax.swing.JLabel();
    144         bxPrim2 = new javax.swing.JComboBox();
    145         jLabel8 = new javax.swing.JLabel();
    146         bxSec2 = new javax.swing.JComboBox();
    147         jLabel9 = new javax.swing.JLabel();
    148         bxTer2 = new javax.swing.JComboBox();
    149         hotkeyGroupPane = new javax.swing.JPanel();
    150         jLabel10 = new javax.swing.JLabel();
    151         bxPrim3 = new javax.swing.JComboBox();
    152         jLabel11 = new javax.swing.JLabel();
    153         bxSec3 = new javax.swing.JComboBox();
    154         jLabel12 = new javax.swing.JLabel();
    155         bxTer3 = new javax.swing.JComboBox();
    156         subwindowGroupPane = new javax.swing.JPanel();
    157         jLabel13 = new javax.swing.JLabel();
    158         bxPrim4 = new javax.swing.JComboBox();
    159         jLabel14 = new javax.swing.JLabel();
    160         bxSec4 = new javax.swing.JComboBox();
    161         jLabel15 = new javax.swing.JLabel();
    162         bxTer4 = new javax.swing.JComboBox();
    163         infoTab = new javax.swing.JPanel();
    164         cbAction action = new cbAction(this);
    165         bxAction action2 = new bxAction();
    166 
    167         setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
     135       
     136        // r4914 - autogenerated code rearranged manually
     137       
     138        JPanel editGroupPane = new JPanel();
     139        JPanel hotkeyGroupPane = new JPanel();
     140
     141        JPanel listPane = new JPanel();
     142        JScrollPane listScrollPane = new JScrollPane();
     143        JPanel menuGroupPane = new JPanel();
     144        JPanel modifierTab = new JPanel();
     145        JTabbedPane prefTabPane = new JTabbedPane();
     146        JPanel shortcutEditPane = new JPanel();
     147        JPanel shortcutTab = new JPanel();
     148        JPanel subwindowGroupPane = new JPanel();
     149        JPanel infoTab = new JPanel();
     150
     151        CbAction action = new CbAction(this);
     152        BxAction action2 = new BxAction();
     153
     154        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    168155
    169156        // If someone wants to move this text into some resource, feel free.
    170         infoTab.setLayout(new javax.swing.BoxLayout(shortcutTab, javax.swing.BoxLayout.Y_AXIS));
     157        infoTab.setLayout(new BoxLayout(shortcutTab, BoxLayout.Y_AXIS));
    171158        JEditorPane editor = new JEditorPane();
    172159        editor.setEditable(false);
     
    196183        prefTabPane.addTab(tr("Read First"), new JScrollPane(editor));
    197184
    198         shortcutTab.setLayout(new javax.swing.BoxLayout(shortcutTab, javax.swing.BoxLayout.Y_AXIS));
     185        shortcutTab.setLayout(new BoxLayout(shortcutTab, BoxLayout.Y_AXIS));
    199186
    200187        shortcutTab.add(buildFilterPanel());
     
    203190        // This is the list of shortcuts:
    204191        shortcutTable.setModel(model);
    205         shortcutTable.getSelectionModel().addListSelectionListener(new cbAction(this));
     192        shortcutTable.getSelectionModel().addListSelectionListener(new CbAction(this));
    206193        //shortcutTable.setFillsViewportHeight(true); Java 1.6
    207         shortcutTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
     194        shortcutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    208195        shortcutTable.setAutoCreateRowSorter(true);
    209196        listScrollPane.setViewportView(shortcutTable);
     
    218205        cbDefault.setAction(action);
    219206        cbDefault.setText(tr("Use default"));
    220         shortcutEditPane.add(cbDefault);
    221 
    222         shortcutEditPane.add(jLabel4);
    223 
    224207        cbShift.setAction(action);
    225208        cbShift.setText(SHIFT); // see above for why no tr()
    226         shortcutEditPane.add(cbShift);
    227 
    228209        cbDisable.setAction(action);
    229210        cbDisable.setText(tr("Disable"));
    230         shortcutEditPane.add(cbDisable);
    231 
    232211        cbCtrl.setAction(action);
    233212        cbCtrl.setText(CTRL); // see above for why no tr()
    234         shortcutEditPane.add(cbCtrl);
    235 
    236         tfKeyLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    237         tfKeyLabel.setText(tr("Key:"));
    238         shortcutEditPane.add(tfKeyLabel);
    239 
    240213        cbAlt.setAction(action);
    241214        cbAlt.setText(ALT); // see above for why no tr()
    242         shortcutEditPane.add(cbAlt);
    243 
    244215        tfKey.setAction(action);
    245         tfKey.setModel(new javax.swing.DefaultComboBoxModel(keyList.values().toArray()));
    246         shortcutEditPane.add(tfKey);
    247 
     216        tfKey.setModel(new DefaultComboBoxModel(keyList.values().toArray()));
    248217        cbMeta.setAction(action);
    249218        cbMeta.setText(META); // see above for why no tr()
     219       
     220       
     221        shortcutEditPane.add(cbDefault);
     222        shortcutEditPane.add(new JLabel());
     223        shortcutEditPane.add(cbShift);
     224        shortcutEditPane.add(cbDisable);
     225        shortcutEditPane.add(cbCtrl);
     226        shortcutEditPane.add(new JLabel(tr("Key:"), SwingConstants.LEFT));
     227        shortcutEditPane.add(cbAlt);
     228        shortcutEditPane.add(tfKey);
    250229        shortcutEditPane.add(cbMeta);
    251230
    252         jLabel6.setText(tr("Attention: Use real keyboard keys only!"));
    253         shortcutEditPane.add(jLabel6);
     231        shortcutEditPane.add(new JLabel(tr("Attention: Use real keyboard keys only!")));
    254232
    255233        action.actionPerformed(null); // init checkboxes
     
    264242        JScrollPane modifierScroller = new JScrollPane(modifierTab);
    265243
    266         editGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Edit Shortcuts")));
     244        editGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Edit Shortcuts")));
    267245        editGroupPane.setLayout(new java.awt.GridLayout(3, 5));
    268 
    269         jLabel1.setText(tr("Primary modifier:"));
    270         editGroupPane.add(jLabel1);
    271 
    272         bxPrim1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     246       
     247        JComboBox[] bxArray = new JComboBox[] {
     248                    bxPrim1,bxSec1,bxTer1,bxPrim2,bxSec2,bxTer2,
     249                    bxPrim3,bxSec3,bxTer3,bxPrim4,bxSec4,bxTer4};
     250        for (JComboBox bxi: bxArray) bxi.setModel(new DefaultComboBoxModel(modifList));
     251       
     252        editGroupPane.add(new JLabel(tr("Primary modifier:")));
    273253        editGroupPane.add(bxPrim1);
    274 
    275         jLabel2.setText(tr("Secondary modifier:"));
    276         editGroupPane.add(jLabel2);
    277 
    278         bxSec1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     254        editGroupPane.add(new JLabel(tr("Secondary modifier:")));
    279255        editGroupPane.add(bxSec1);
    280 
    281         jLabel3.setText(tr("Tertiary modifier:"));
    282         editGroupPane.add(jLabel3);
    283 
    284         bxTer1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     256        editGroupPane.add(new JLabel(tr("Tertiary modifier:")));
    285257        editGroupPane.add(bxTer1);
    286 
    287258        modifierTab.add(editGroupPane);
    288259
    289         menuGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Menu Shortcuts")));
     260        menuGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Menu Shortcuts")));
    290261        menuGroupPane.setLayout(new java.awt.GridLayout(3, 5));
    291 
    292         jLabel7.setText(tr("Primary modifier:"));
    293         menuGroupPane.add(jLabel7);
    294 
    295         bxPrim2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     262        menuGroupPane.add(new JLabel(tr("Primary modifier:")));
    296263        menuGroupPane.add(bxPrim2);
    297 
    298         jLabel8.setText(tr("Secondary modifier:"));
    299         menuGroupPane.add(jLabel8);
    300 
    301         bxSec2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     264        menuGroupPane.add(new JLabel(tr("Secondary modifier:")));
    302265        menuGroupPane.add(bxSec2);
    303 
    304         jLabel9.setText(tr("Tertiary modifier:"));
    305         menuGroupPane.add(jLabel9);
    306 
    307         bxTer2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     266        menuGroupPane.add(new JLabel(tr("Tertiary modifier:")));
    308267        menuGroupPane.add(bxTer2);
    309 
    310268        modifierTab.add(menuGroupPane);
    311269
    312         hotkeyGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Hotkey Shortcuts")));
     270        hotkeyGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Hotkey Shortcuts")));
    313271        hotkeyGroupPane.setLayout(new java.awt.GridLayout(3, 5));
    314 
    315         jLabel10.setText(tr("Primary modifier:"));
    316         hotkeyGroupPane.add(jLabel10);
    317 
    318         bxPrim3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     272        hotkeyGroupPane.add(new JLabel(tr("Primary modifier:")));
    319273        hotkeyGroupPane.add(bxPrim3);
    320 
    321         jLabel11.setText(tr("Secondary modifier:"));
    322         hotkeyGroupPane.add(jLabel11);
    323 
    324         bxSec3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     274        hotkeyGroupPane.add(new JLabel((tr("Secondary modifier:"))));
    325275        hotkeyGroupPane.add(bxSec3);
    326 
    327         jLabel12.setText(tr("Tertiary modifier:"));
    328         hotkeyGroupPane.add(jLabel12);
    329 
    330         bxTer3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     276        hotkeyGroupPane.add(new JLabel(tr("Tertiary modifier:")));
    331277        hotkeyGroupPane.add(bxTer3);
    332 
    333278        modifierTab.add(hotkeyGroupPane);
    334279
    335         subwindowGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Subwindow Shortcuts")));
     280        subwindowGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Subwindow Shortcuts")));
    336281        subwindowGroupPane.setLayout(new java.awt.GridLayout(3, 5));
    337 
    338         jLabel13.setText(tr("Primary modifier:"));
    339         subwindowGroupPane.add(jLabel13);
    340 
    341         bxPrim4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     282        subwindowGroupPane.add(new JLabel(tr("Primary modifier:")));
    342283        subwindowGroupPane.add(bxPrim4);
    343 
    344         jLabel14.setText(tr("Secondary modifier:"));
    345         subwindowGroupPane.add(jLabel14);
    346 
    347         bxSec4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     284        subwindowGroupPane.add(new JLabel(tr("Secondary modifier:")));
    348285        subwindowGroupPane.add(bxSec4);
    349 
    350         jLabel15.setText(tr("Tertiary modifier:"));
    351         subwindowGroupPane.add(jLabel15);
    352 
    353         bxTer4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
     286        subwindowGroupPane.add(new JLabel(tr("Tertiary modifier:")));
    354287        subwindowGroupPane.add(bxTer4);
    355288
    356289        initbx();
    357         bxPrim1.setAction(action2);
    358         bxSec1.setAction(action2);
    359         bxTer1.setAction(action2);
    360         bxPrim2.setAction(action2);
    361         bxSec2.setAction(action2);
    362         bxTer2.setAction(action2);
    363         bxPrim3.setAction(action2);
    364         bxSec3.setAction(action2);
    365         bxTer3.setAction(action2);
    366         bxPrim4.setAction(action2);
    367         bxSec4.setAction(action2);
    368         bxTer4.setAction(action2);
     290        for (JComboBox bxi: bxArray) bxi.setAction(action2);
    369291
    370292        modifierTab.add(subwindowGroupPane);
     
    389311        gc.gridx = 1;
    390312        gc.weightx = 1.0;
    391         pnl.add(filterField = new JTextField(), gc);
     313        pnl.add(filterField, gc);
    392314        filterField.setToolTipText(tr("Enter a search expression"));
    393315        SelectAllOnFocusGainedDecorator.decorate(filterField);
     
    395317        pnl.setMaximumSize(new Dimension(300,10));
    396318        return pnl;
     319    }
     320   
     321    private void disableAllModifierCheckboxes() {
     322        cbDefault.setEnabled(false);
     323        cbDisable.setEnabled(false);
     324        cbShift.setEnabled(false);
     325        cbCtrl.setEnabled(false);
     326        cbAlt.setEnabled(false);
     327        cbMeta.setEnabled(false);
    397328    }
    398329
     
    405336    // even have some duplicated code. Feel free to refactor, If you have
    406337    // more expirience with GUI coding than I have.
    407     private class cbAction extends AbstractAction implements ListSelectionListener {
     338    private class CbAction extends AbstractAction implements ListSelectionListener {
    408339        private PrefJPanel panel;
    409         public cbAction (PrefJPanel panel) {
     340        public CbAction (PrefJPanel panel) {
    410341            this.panel = panel;
    411342        }
     
    427358                }
    428359                if (!sc.isChangeable()) {
    429                     panel.cbDefault.setEnabled(false);
    430                     panel.cbDisable.setEnabled(false);
    431                     panel.cbShift.setEnabled(false);
    432                     panel.cbCtrl.setEnabled(false);
    433                     panel.cbAlt.setEnabled(false);
    434                     panel.cbMeta.setEnabled(false);
     360                    disableAllModifierCheckboxes();
    435361                    panel.tfKey.setEnabled(false);
    436362                } else {
     
    439365                }
    440366            } else {
    441                 panel.cbDefault.setEnabled(false);
    442                 panel.cbDisable.setEnabled(false);
    443                 panel.cbShift.setEnabled(false);
    444                 panel.cbCtrl.setEnabled(false);
    445                 panel.cbAlt.setEnabled(false);
    446                 panel.cbMeta.setEnabled(false);
     367                panel.disableAllModifierCheckboxes();
    447368                panel.tfKey.setEnabled(false);
    448369            }
     
    483404                panel.tfKey.setEnabled(state);
    484405            } else {
    485                 panel.cbDefault.setEnabled(false);
    486                 panel.cbDisable.setEnabled(false);
    487                 panel.cbShift.setEnabled(false);
    488                 panel.cbCtrl.setEnabled(false);
    489                 panel.cbAlt.setEnabled(false);
    490                 panel.cbMeta.setEnabled(false);
     406                panel.disableAllModifierCheckboxes();
    491407                panel.tfKey.setEnabled(false);
    492408            }
     
    495411
    496412    // this handles the modifier groups
    497     private class bxAction extends javax.swing.AbstractAction {
     413    private class BxAction extends AbstractAction {
    498414        public void actionPerformed(java.awt.event.ActionEvent e) {
    499415            Main.pref.putInteger("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_EDIT),    modifInts[bxPrim1.getSelectedIndex()]);
     
    533449        setBx(bxTer4,  groups, Shortcut.GROUPS_ALT2   +Shortcut.GROUP_LAYER);
    534450    }
    535     private void setBx(javax.swing.JComboBox bx, HashMap<Integer, Integer> groups, int key) {
     451    private void setBx(JComboBox bx, HashMap<Integer, Integer> groups, int key) {
    536452        int target = Main.pref.getInteger("shortcut.groups."+key, groups.get(key));
    537453        for (int i = 0; i < modifInts.length; i++) {
     
    542458    }
    543459
    544     private javax.swing.JComboBox bxPrim1;
    545     private javax.swing.JComboBox bxPrim2;
    546     private javax.swing.JComboBox bxPrim3;
    547     private javax.swing.JComboBox bxPrim4;
    548     private javax.swing.JComboBox bxSec1;
    549     private javax.swing.JComboBox bxSec2;
    550     private javax.swing.JComboBox bxSec3;
    551     private javax.swing.JComboBox bxSec4;
    552     private javax.swing.JComboBox bxTer1;
    553     private javax.swing.JComboBox bxTer2;
    554     private javax.swing.JComboBox bxTer3;
    555     private javax.swing.JComboBox bxTer4;
    556     private javax.swing.JCheckBox cbAlt;
    557     private javax.swing.JCheckBox cbCtrl;
    558     private javax.swing.JCheckBox cbDefault;
    559     private javax.swing.JCheckBox cbDisable;
    560     private javax.swing.JCheckBox cbMeta;
    561     private javax.swing.JCheckBox cbShift;
    562     private javax.swing.JPanel editGroupPane;
    563     private javax.swing.JPanel hotkeyGroupPane;
    564     private javax.swing.JLabel jLabel1;
    565     private javax.swing.JLabel jLabel10;
    566     private javax.swing.JLabel jLabel11;
    567     private javax.swing.JLabel jLabel12;
    568     private javax.swing.JLabel jLabel13;
    569     private javax.swing.JLabel jLabel14;
    570     private javax.swing.JLabel jLabel15;
    571     private javax.swing.JLabel jLabel2;
    572     private javax.swing.JLabel jLabel3;
    573     private javax.swing.JLabel jLabel4;
    574     private javax.swing.JLabel jLabel6;
    575     private javax.swing.JLabel jLabel7;
    576     private javax.swing.JLabel jLabel8;
    577     private javax.swing.JLabel jLabel9;
    578     private javax.swing.JPanel listPane;
    579     private javax.swing.JScrollPane listScrollPane;
    580     private javax.swing.JPanel menuGroupPane;
    581     private javax.swing.JPanel modifierTab;
    582     private javax.swing.JTabbedPane prefTabPane;
    583     private javax.swing.JPanel shortcutEditPane;
    584     private javax.swing.JPanel shortcutTab;
    585     private javax.swing.JTable shortcutTable;
    586     private javax.swing.JPanel subwindowGroupPane;
    587     private javax.swing.JComboBox tfKey;
    588     private javax.swing.JLabel tfKeyLabel;
    589     private javax.swing.JPanel infoTab;
    590     private JTextField filterField;
    591460   
    592461     class FilterFieldAdapter implements DocumentListener {
     
    597466                final TableRowSorter<TableModel> sorter =
    598467                    ((TableRowSorter<TableModel> )shortcutTable.getRowSorter());
    599                 if (expr==null) sorter.setRowFilter(null);
    600                     else  sorter.setRowFilter(  RowFilter.regexFilter(expr) );
     468                if (expr == null) {
     469                    sorter.setRowFilter(null);
     470                } else {
     471                    // split search string on whitespace, do case-insensitive AND search
     472                    ArrayList<RowFilter<Object, Object>> andFilters = new ArrayList<RowFilter<Object, Object>>();
     473                    for (String word : expr.split("\\s+")) {
     474                        andFilters.add(RowFilter.regexFilter("(?i)" + word));
     475                    }
     476                    sorter.setRowFilter(RowFilter.andFilter(andFilters));
     477                }
    601478            }
    602479            catch (PatternSyntaxException ex) { }
Note: See TracChangeset for help on using the changeset viewer.