- Timestamp:
- 2012-02-10T05:04:22+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PrefJPanel.java
r4909 r4914 9 9 10 10 import java.awt.event.KeyEvent; 11 import java.util.ArrayList; 11 12 import java.util.LinkedHashMap; 12 13 import java.util.HashMap; … … 14 15 15 16 import 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; 17 import javax.swing.*; 25 18 import javax.swing.event.DocumentEvent; 26 19 import javax.swing.event.DocumentListener; … … 38 31 * If someone wants to merge it with ShortcutPreference.java, feel free. 39 32 */ 40 public class PrefJPanel extends javax.swing.JPanel {33 public class PrefJPanel extends JPanel { 41 34 42 35 // table of shortcuts … … 63 56 tr("disabled"), 64 57 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()) 77 70 }; 78 71 // this are the display(!) texts for the checkboxes. Let the JVM do the i18n for us <g>. … … 82 75 // usually matches the keyboard. This even works with my English Windows and my German 83 76 // 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()); 88 81 89 82 // A list of keys to present the user. Sadly this really is a list of keys Java knows about, 90 83 // not a list of real physical keys. If someone knows how to get that list? 91 84 private static Map<Integer, String> keyList = setKeyList(); 92 85 93 86 private static Map<Integer, String> setKeyList() { 94 87 Map<Integer, String> list = new LinkedHashMap<Integer, String>(); … … 104 97 return list; 105 98 } 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(); 106 123 107 124 /** Creates new form prefJPanel */ … … 116 133 // Did I mention auto-generated? That's the reason we 117 134 // 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)); 168 155 169 156 // 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)); 171 158 JEditorPane editor = new JEditorPane(); 172 159 editor.setEditable(false); … … 196 183 prefTabPane.addTab(tr("Read First"), new JScrollPane(editor)); 197 184 198 shortcutTab.setLayout(new javax.swing.BoxLayout(shortcutTab, javax.swing.BoxLayout.Y_AXIS));185 shortcutTab.setLayout(new BoxLayout(shortcutTab, BoxLayout.Y_AXIS)); 199 186 200 187 shortcutTab.add(buildFilterPanel()); … … 203 190 // This is the list of shortcuts: 204 191 shortcutTable.setModel(model); 205 shortcutTable.getSelectionModel().addListSelectionListener(new cbAction(this));192 shortcutTable.getSelectionModel().addListSelectionListener(new CbAction(this)); 206 193 //shortcutTable.setFillsViewportHeight(true); Java 1.6 207 shortcutTable.setSelectionMode( javax.swing.ListSelectionModel.SINGLE_SELECTION);194 shortcutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 208 195 shortcutTable.setAutoCreateRowSorter(true); 209 196 listScrollPane.setViewportView(shortcutTable); … … 218 205 cbDefault.setAction(action); 219 206 cbDefault.setText(tr("Use default")); 220 shortcutEditPane.add(cbDefault);221 222 shortcutEditPane.add(jLabel4);223 224 207 cbShift.setAction(action); 225 208 cbShift.setText(SHIFT); // see above for why no tr() 226 shortcutEditPane.add(cbShift);227 228 209 cbDisable.setAction(action); 229 210 cbDisable.setText(tr("Disable")); 230 shortcutEditPane.add(cbDisable);231 232 211 cbCtrl.setAction(action); 233 212 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 240 213 cbAlt.setAction(action); 241 214 cbAlt.setText(ALT); // see above for why no tr() 242 shortcutEditPane.add(cbAlt);243 244 215 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())); 248 217 cbMeta.setAction(action); 249 218 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); 250 229 shortcutEditPane.add(cbMeta); 251 230 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!"))); 254 232 255 233 action.actionPerformed(null); // init checkboxes … … 264 242 JScrollPane modifierScroller = new JScrollPane(modifierTab); 265 243 266 editGroupPane.setBorder( javax.swing.BorderFactory.createTitledBorder(tr("Edit Shortcuts")));244 editGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Edit Shortcuts"))); 267 245 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:"))); 273 253 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:"))); 279 255 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:"))); 285 257 editGroupPane.add(bxTer1); 286 287 258 modifierTab.add(editGroupPane); 288 259 289 menuGroupPane.setBorder( javax.swing.BorderFactory.createTitledBorder(tr("Menu Shortcuts")));260 menuGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Menu Shortcuts"))); 290 261 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:"))); 296 263 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:"))); 302 265 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:"))); 308 267 menuGroupPane.add(bxTer2); 309 310 268 modifierTab.add(menuGroupPane); 311 269 312 hotkeyGroupPane.setBorder( javax.swing.BorderFactory.createTitledBorder(tr("Hotkey Shortcuts")));270 hotkeyGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Hotkey Shortcuts"))); 313 271 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:"))); 319 273 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:")))); 325 275 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:"))); 331 277 hotkeyGroupPane.add(bxTer3); 332 333 278 modifierTab.add(hotkeyGroupPane); 334 279 335 subwindowGroupPane.setBorder( javax.swing.BorderFactory.createTitledBorder(tr("Subwindow Shortcuts")));280 subwindowGroupPane.setBorder(BorderFactory.createTitledBorder(tr("Subwindow Shortcuts"))); 336 281 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:"))); 342 283 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:"))); 348 285 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:"))); 354 287 subwindowGroupPane.add(bxTer4); 355 288 356 289 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); 369 291 370 292 modifierTab.add(subwindowGroupPane); … … 389 311 gc.gridx = 1; 390 312 gc.weightx = 1.0; 391 pnl.add(filterField = new JTextField(), gc);313 pnl.add(filterField, gc); 392 314 filterField.setToolTipText(tr("Enter a search expression")); 393 315 SelectAllOnFocusGainedDecorator.decorate(filterField); … … 395 317 pnl.setMaximumSize(new Dimension(300,10)); 396 318 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); 397 328 } 398 329 … … 405 336 // even have some duplicated code. Feel free to refactor, If you have 406 337 // more expirience with GUI coding than I have. 407 private class cbAction extends AbstractAction implements ListSelectionListener {338 private class CbAction extends AbstractAction implements ListSelectionListener { 408 339 private PrefJPanel panel; 409 public cbAction (PrefJPanel panel) {340 public CbAction (PrefJPanel panel) { 410 341 this.panel = panel; 411 342 } … … 427 358 } 428 359 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(); 435 361 panel.tfKey.setEnabled(false); 436 362 } else { … … 439 365 } 440 366 } 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(); 447 368 panel.tfKey.setEnabled(false); 448 369 } … … 483 404 panel.tfKey.setEnabled(state); 484 405 } 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(); 491 407 panel.tfKey.setEnabled(false); 492 408 } … … 495 411 496 412 // this handles the modifier groups 497 private class bxAction extends javax.swing.AbstractAction {413 private class BxAction extends AbstractAction { 498 414 public void actionPerformed(java.awt.event.ActionEvent e) { 499 415 Main.pref.putInteger("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_EDIT), modifInts[bxPrim1.getSelectedIndex()]); … … 533 449 setBx(bxTer4, groups, Shortcut.GROUPS_ALT2 +Shortcut.GROUP_LAYER); 534 450 } 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) { 536 452 int target = Main.pref.getInteger("shortcut.groups."+key, groups.get(key)); 537 453 for (int i = 0; i < modifInts.length; i++) { … … 542 458 } 543 459 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;591 460 592 461 class FilterFieldAdapter implements DocumentListener { … … 597 466 final TableRowSorter<TableModel> sorter = 598 467 ((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 } 601 478 } 602 479 catch (PatternSyntaxException ex) { }
Note:
See TracChangeset
for help on using the changeset viewer.