source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/prefJPanel.java@ 1169

Last change on this file since 1169 was 1169, checked in by stoecker, 15 years ago

removed usage of tab stops

File size: 27.3 KB
Line 
1/*
2 * prefJPanel.java
3 *
4 * Created on 28. September 2008, 17:47
5 */
6
7package org.openstreetmap.josm.gui.preferences;
8
9import static org.openstreetmap.josm.tools.I18n.tr;
10
11import java.awt.event.KeyEvent;
12import java.util.LinkedHashMap;
13import java.util.Map;
14
15import javax.swing.JEditorPane;
16import javax.swing.JScrollPane;
17import javax.swing.ListSelectionModel;
18import javax.swing.event.ListSelectionEvent;
19import javax.swing.event.ListSelectionListener;
20import javax.swing.table.TableModel;
21
22import org.openstreetmap.josm.Main;
23import org.openstreetmap.josm.tools.Shortcut;
24
25/**
26 * This is the keyboard preferences content.
27 * If someone wants to merge it with ShortcutPreference.java, feel free.
28 */
29public class prefJPanel extends javax.swing.JPanel {
30
31 // table of shortcuts
32 private TableModel model;
33 // comboboxes of modifier groups, mapping selectedIndex to real data
34 private static int[] modifInts = new int[]{
35 -1,
36 0,
37 KeyEvent.SHIFT_DOWN_MASK,
38 KeyEvent.CTRL_DOWN_MASK,
39 KeyEvent.ALT_DOWN_MASK,
40 KeyEvent.META_DOWN_MASK,
41 KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
42 KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
43 KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
44 KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
45 KeyEvent.CTRL_DOWN_MASK | KeyEvent.META_DOWN_MASK,
46 KeyEvent.ALT_DOWN_MASK | KeyEvent.META_DOWN_MASK,
47 KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
48 KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK
49 };
50 // and here are the texts fro the comboboxes
51 private static String[] modifList = new String[] {
52 tr("disabled"),
53 tr("no modifier"),
54 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[2]).getModifiers()),
55 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[3]).getModifiers()),
56 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[4]).getModifiers()),
57 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[5]).getModifiers()),
58 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[6]).getModifiers()),
59 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[7]).getModifiers()),
60 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[8]).getModifiers()),
61 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[9]).getModifiers()),
62 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[10]).getModifiers()),
63 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[11]).getModifiers()),
64 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[12]).getModifiers()),
65 KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[13]).getModifiers())
66 };
67 // this are the display(!) texts for the checkboxes. Let the JVM do the i18n for us <g>.
68 // Ok, there's a real reason for this: The JVM should know best how the keys are labelled
69 // on the physical keyboard. What language pack is installed in JOSM is completely
70 // independent from the keyboard's labelling. But the operation system's locale
71 // usually matches the keyboard. This even works with my English Windows and my German
72 // keyboard.
73 private static String SHIFT = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
74 private static String CTRL = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
75 private static String ALT = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
76 private static String META = KeyEvent.getKeyModifiersText(javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
77
78 // A list of keys to present the user. Sadly this really is a list of keys Java knows about,
79 // not a list of real physical keys. If someone knows how to get that list?
80 private static Map<Integer, String> keyList = setKeyList();
81
82 private static Map<Integer, String> setKeyList() {
83 Map<Integer, String> list = new LinkedHashMap<Integer, String>();
84 // I hate this, but I found no alternative...
85 for (int i = 0; i < 65534; i++) {
86 String s = KeyEvent.getKeyText(i);
87 if (s != null && s.length() > 0 && !s.contains("Unknown")) {
88 list.put(new Integer(i), s);
89 //System.out.println(i+": "+s);
90 }
91 }
92 list.put(new Integer(-1), "");
93 return list;
94 }
95
96 /** Creates new form prefJPanel */
97 // Ain't those auto-generated comments helpful or what? <g>
98 public prefJPanel(TableModel model) {
99 this.model = model;
100 initComponents();
101 }
102
103 private void initComponents() {
104
105 // Did I mention auto-generated? That's the reason we
106 // have lots of properties here and not some arrays...
107 prefTabPane = new javax.swing.JTabbedPane();
108 shortcutTab = new javax.swing.JPanel();
109 listPane = new javax.swing.JPanel();
110 listScrollPane = new javax.swing.JScrollPane();
111 shortcutTable = new javax.swing.JTable();
112 shortcutEditPane = new javax.swing.JPanel();
113 cbDefault = new javax.swing.JCheckBox();
114 jLabel4 = new javax.swing.JLabel();
115 cbShift = new javax.swing.JCheckBox();
116 cbDisable = new javax.swing.JCheckBox();
117 cbCtrl = new javax.swing.JCheckBox();
118 tfKeyLabel = new javax.swing.JLabel();
119 cbAlt = new javax.swing.JCheckBox();
120 tfKey = new javax.swing.JComboBox();
121 cbMeta = new javax.swing.JCheckBox();
122 jLabel6 = new javax.swing.JLabel();
123 modifierTab = new javax.swing.JPanel();
124 editGroupPane = new javax.swing.JPanel();
125 jLabel1 = new javax.swing.JLabel();
126 bxPrim1 = new javax.swing.JComboBox();
127 jLabel2 = new javax.swing.JLabel();
128 bxSec1 = new javax.swing.JComboBox();
129 jLabel3 = new javax.swing.JLabel();
130 bxTer1 = new javax.swing.JComboBox();
131 menuGroupPane = new javax.swing.JPanel();
132 jLabel7 = new javax.swing.JLabel();
133 bxPrim2 = new javax.swing.JComboBox();
134 jLabel8 = new javax.swing.JLabel();
135 bxSec2 = new javax.swing.JComboBox();
136 jLabel9 = new javax.swing.JLabel();
137 bxTer2 = new javax.swing.JComboBox();
138 hotkeyGroupPane = new javax.swing.JPanel();
139 jLabel10 = new javax.swing.JLabel();
140 bxPrim3 = new javax.swing.JComboBox();
141 jLabel11 = new javax.swing.JLabel();
142 bxSec3 = new javax.swing.JComboBox();
143 jLabel12 = new javax.swing.JLabel();
144 bxTer3 = new javax.swing.JComboBox();
145 subwindowGroupPane = new javax.swing.JPanel();
146 jLabel13 = new javax.swing.JLabel();
147 bxPrim4 = new javax.swing.JComboBox();
148 jLabel14 = new javax.swing.JLabel();
149 bxSec4 = new javax.swing.JComboBox();
150 jLabel15 = new javax.swing.JLabel();
151 bxTer4 = new javax.swing.JComboBox();
152 infoTab = new javax.swing.JPanel();
153 cbAction action = new cbAction(this);
154 bxAction action2 = new bxAction();
155
156 setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
157
158 // If someone wants to move this text into some resource, feel free.
159 infoTab.setLayout(new javax.swing.BoxLayout(shortcutTab, javax.swing.BoxLayout.Y_AXIS));
160 JEditorPane editor = new JEditorPane();
161 editor.setEditable(false);
162 editor.setContentType("text/html");
163 editor.setText(
164 tr("<h1><a name=\"top\">Keyboard Shortcuts</a></h1>")+
165 tr("<p>Please note that shortcuts keys are assigned to the actions when JOSM is started. So you need to <b>restart</b> "
166 +"JOSM to see your changes.</p>")+
167 tr("<p>Furthermore, the shortcuts are activated when the actions are assigned to a menu entry of button for the first "
168 +"time. So some of your changes may become active even without restart --- but also without collistion handling. "
169 +"This is another reason to <b>restart</b> JOSM after making any changes here.</p>")+
170 tr("<p>You may notice that the key selection list on the next page lists all keys that exist on all kinds of keyboards "
171 +"Java knows about, not just those keys that exist on your keyboard. Please use only those values that correspond to "
172 +"a real key on your keyboard. So if your keyboard has no 'Copy' key (PC keyboard don't have them, Sun keyboards do), "
173 +"the do not use it. Also there will be 'keys' listed that correspond to a shortcut on your keyboard (e.g. ':'/Colon). "
174 +"Please also do not use them, use the base key (';'/Semicolon on US keyboards, '.'/Period on German keyboards, ...) "
175 +"instead. Not doing so may result in conflicts, as there is no way for JOSM to know that Ctrl+Shift+; and Ctrl+: "
176 +"actually is the same thing on an US keyboard...</p>")+
177 tr("<p>Thank you for your understanding</p>")+
178 tr("<h1>Modifier Groups</h1>")+
179 tr("<p>The last page lists the modifier keys JOSM will automatically assign to shortcuts. For every of the four kinds "
180 +"of shortcuts there are three alternatives. JOSM will try those alternative in the listed order when managing a "
181 +"conflict. If all alternatives would result in shortcuts that are already taken, it will assign a random shortcut "
182 +"instead.</p>")+
183 tr("<p>The pseudo-modifier 'disabled' will disable the shortcut when encountered.</p>")
184 );
185 editor.setCaretPosition(0); // scroll up
186 prefTabPane.addTab(tr("Read First"), new JScrollPane(editor));
187
188 shortcutTab.setLayout(new javax.swing.BoxLayout(shortcutTab, javax.swing.BoxLayout.Y_AXIS));
189
190 listPane.setLayout(new java.awt.GridLayout());
191
192 // This is the list of shortcuts:
193 shortcutTable.setModel(model);
194 shortcutTable.getSelectionModel().addListSelectionListener(new cbAction(this));
195 //shortcutTable.setFillsViewportHeight(true); Java 1.6
196 shortcutTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
197 listScrollPane.setViewportView(shortcutTable);
198
199 listPane.add(listScrollPane);
200
201 shortcutTab.add(listPane);
202
203 // and here follows the edit area. I won't object to someone re-designing it, it looks, um, "minimalistic" ;)
204 shortcutEditPane.setLayout(new java.awt.GridLayout(5, 2));
205
206 cbDefault.setAction(action);
207 cbDefault.setText(tr("Use default"));
208 shortcutEditPane.add(cbDefault);
209
210 shortcutEditPane.add(jLabel4);
211
212 cbShift.setAction(action);
213 cbShift.setText(SHIFT); // see above for why no tr()
214 shortcutEditPane.add(cbShift);
215
216 cbDisable.setAction(action);
217 cbDisable.setText(tr("Disable"));
218 shortcutEditPane.add(cbDisable);
219
220 cbCtrl.setAction(action);
221 cbCtrl.setText(CTRL); // see above for why no tr()
222 shortcutEditPane.add(cbCtrl);
223
224 tfKeyLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
225 tfKeyLabel.setText(tr("Key:"));
226 shortcutEditPane.add(tfKeyLabel);
227
228 cbAlt.setAction(action);
229 cbAlt.setText(ALT); // see above for why no tr()
230 shortcutEditPane.add(cbAlt);
231
232 tfKey.setAction(action);
233 tfKey.setModel(new javax.swing.DefaultComboBoxModel(keyList.values().toArray()));
234 shortcutEditPane.add(tfKey);
235
236 cbMeta.setAction(action);
237 cbMeta.setText(META); // see above for why no tr()
238 shortcutEditPane.add(cbMeta);
239
240 jLabel6.setText(tr("Attention: Use real keyboard keys only!"));
241 shortcutEditPane.add(jLabel6);
242
243 action.actionPerformed(null); // init checkboxes
244
245 shortcutTab.add(shortcutEditPane);
246
247 prefTabPane.addTab(tr("Keyboard Shortcuts"), shortcutTab);
248
249 // next is the modfier group tab.
250 // Would be a nice array if I had done it by hand. But then, it would be finished next year or so...
251 modifierTab.setLayout(new java.awt.GridLayout(0, 1));
252 JScrollPane modifierScroller = new JScrollPane(modifierTab);
253
254 editGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Edit Shortcuts")));
255 editGroupPane.setLayout(new java.awt.GridLayout(3, 5));
256
257 jLabel1.setText(tr("Primary modifier:"));
258 editGroupPane.add(jLabel1);
259
260 bxPrim1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
261 editGroupPane.add(bxPrim1);
262
263 jLabel2.setText(tr("Secondary modifier:"));
264 editGroupPane.add(jLabel2);
265
266 bxSec1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
267 editGroupPane.add(bxSec1);
268
269 jLabel3.setText(tr("Tertiary modifier:"));
270 editGroupPane.add(jLabel3);
271
272 bxTer1.setModel(new javax.swing.DefaultComboBoxModel(modifList));
273 editGroupPane.add(bxTer1);
274
275 modifierTab.add(editGroupPane);
276
277 menuGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Menu Shortcuts")));
278 menuGroupPane.setLayout(new java.awt.GridLayout(3, 5));
279
280 jLabel7.setText(tr("Primary modifier:"));
281 menuGroupPane.add(jLabel7);
282
283 bxPrim2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
284 menuGroupPane.add(bxPrim2);
285
286 jLabel8.setText(tr("Secondary modifier:"));
287 menuGroupPane.add(jLabel8);
288
289 bxSec2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
290 menuGroupPane.add(bxSec2);
291
292 jLabel9.setText(tr("Tertiary modifier:"));
293 menuGroupPane.add(jLabel9);
294
295 bxTer2.setModel(new javax.swing.DefaultComboBoxModel(modifList));
296 menuGroupPane.add(bxTer2);
297
298 modifierTab.add(menuGroupPane);
299
300 hotkeyGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Hotkey Shortcuts")));
301 hotkeyGroupPane.setLayout(new java.awt.GridLayout(3, 5));
302
303 jLabel10.setText(tr("Primary modifier:"));
304 hotkeyGroupPane.add(jLabel10);
305
306 bxPrim3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
307 hotkeyGroupPane.add(bxPrim3);
308
309 jLabel11.setText(tr("Secondary modifier:"));
310 hotkeyGroupPane.add(jLabel11);
311
312 bxSec3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
313 hotkeyGroupPane.add(bxSec3);
314
315 jLabel12.setText(tr("Tertiary modifier:"));
316 hotkeyGroupPane.add(jLabel12);
317
318 bxTer3.setModel(new javax.swing.DefaultComboBoxModel(modifList));
319 hotkeyGroupPane.add(bxTer3);
320
321 modifierTab.add(hotkeyGroupPane);
322
323 subwindowGroupPane.setBorder(javax.swing.BorderFactory.createTitledBorder(tr("Subwindow Shortcuts")));
324 subwindowGroupPane.setLayout(new java.awt.GridLayout(3, 5));
325
326 jLabel13.setText(tr("Primary modifier:"));
327 subwindowGroupPane.add(jLabel13);
328
329 bxPrim4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
330 subwindowGroupPane.add(bxPrim4);
331
332 jLabel14.setText(tr("Secondary modifier:"));
333 subwindowGroupPane.add(jLabel14);
334
335 bxSec4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
336 subwindowGroupPane.add(bxSec4);
337
338 jLabel15.setText(tr("Tertiary modifier:"));
339 subwindowGroupPane.add(jLabel15);
340
341 bxTer4.setModel(new javax.swing.DefaultComboBoxModel(modifList));
342 subwindowGroupPane.add(bxTer4);
343
344 initbx();
345 bxPrim1.setAction(action2);
346 bxSec1.setAction(action2);
347 bxTer1.setAction(action2);
348 bxPrim2.setAction(action2);
349 bxSec2.setAction(action2);
350 bxTer2.setAction(action2);
351 bxPrim3.setAction(action2);
352 bxSec3.setAction(action2);
353 bxTer3.setAction(action2);
354 bxPrim4.setAction(action2);
355 bxSec4.setAction(action2);
356 bxTer4.setAction(action2);
357
358 modifierTab.add(subwindowGroupPane);
359
360 prefTabPane.addTab(tr("Modifier Groups"), modifierScroller);
361
362 add(prefTabPane);
363 }
364
365 // this allows to edit shortcuts. it:
366 // * sets the edit controls to the selected shortcut
367 // * enabled/disables the controls as needed
368 // * writes the user's changes to the shortcut
369 // And after I finally had it working, I realized that those two methods
370 // are playing ping-pong (politically correct: table tennis, I know) and
371 // even have some duplicated code. Feel free to refactor, If you have
372 // more expirience with GUI coding than I have.
373 private class cbAction extends javax.swing.AbstractAction implements ListSelectionListener {
374 private prefJPanel panel;
375 public cbAction (prefJPanel panel) {
376 this.panel = panel;
377 }
378 public void valueChanged(ListSelectionEvent e) {
379 ListSelectionModel lsm = panel.shortcutTable.getSelectionModel(); // can't use e here
380 if (!lsm.isSelectionEmpty()) {
381 int row = lsm.getMinSelectionIndex();
382 Shortcut sc = (Shortcut)panel.model.getValueAt(row, -1);
383 panel.cbDefault.setSelected(!sc.getAssignedUser());
384 panel.cbDisable.setSelected(sc.getKeyStroke() == null);
385 panel.cbShift.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.SHIFT_DOWN_MASK) != 0);
386 panel.cbCtrl.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.CTRL_DOWN_MASK) != 0);
387 panel.cbAlt.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.ALT_DOWN_MASK) != 0);
388 panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.META_DOWN_MASK) != 0);
389 if (sc.getKeyStroke() != null) {
390 tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode()));
391 } else {
392 tfKey.setSelectedItem(keyList.get(-1));
393 }
394 if (sc.getAutomatic()) {
395 panel.cbDefault.setEnabled(false);
396 panel.cbDisable.setEnabled(false);
397 panel.cbShift.setEnabled(false);
398 panel.cbCtrl.setEnabled(false);
399 panel.cbAlt.setEnabled(false);
400 panel.cbMeta.setEnabled(false);
401 panel.tfKey.setEnabled(false);
402 } else {
403 panel.cbDefault.setEnabled(true);
404 actionPerformed(null);
405 }
406 } else {
407 panel.cbDefault.setEnabled(false);
408 panel.cbDisable.setEnabled(false);
409 panel.cbShift.setEnabled(false);
410 panel.cbCtrl.setEnabled(false);
411 panel.cbAlt.setEnabled(false);
412 panel.cbMeta.setEnabled(false);
413 panel.tfKey.setEnabled(false);
414 }
415 }
416 public void actionPerformed(java.awt.event.ActionEvent e) {
417 ListSelectionModel lsm = panel.shortcutTable.getSelectionModel();
418 if (lsm != null && !lsm.isSelectionEmpty()) {
419 if (e != null) { // only if we've been called by a user action
420 int row = lsm.getMinSelectionIndex();
421 Shortcut sc = (Shortcut)panel.model.getValueAt(row, -1);
422 sc.setAssignedUser(!panel.cbDefault.isSelected());
423 if (panel.cbDisable.isSelected()) {
424 sc.setAssignedModifier(-1);
425 } else if (panel.tfKey.getSelectedItem().equals("")) {
426 sc.setAssignedModifier(KeyEvent.VK_CANCEL);
427 } else {
428 sc.setAssignedModifier(
429 (panel.cbShift.isSelected() ? KeyEvent.SHIFT_DOWN_MASK : 0) |
430 (panel.cbCtrl.isSelected() ? KeyEvent.CTRL_DOWN_MASK : 0) |
431 (panel.cbAlt.isSelected() ? KeyEvent.ALT_DOWN_MASK : 0) |
432 (panel.cbMeta.isSelected() ? KeyEvent.META_DOWN_MASK : 0)
433 );
434 for (Map.Entry<Integer, String> entry : keyList.entrySet()) {
435 if (entry.getValue().equals(panel.tfKey.getSelectedItem())) {
436 sc.setAssignedKey(entry.getKey());
437 }
438 }
439 }
440 valueChanged(null);
441 }
442 boolean state = !panel.cbDefault.isSelected();
443 panel.cbDisable.setEnabled(state);
444 state = state && !panel.cbDisable.isSelected();
445 panel.cbShift.setEnabled(state);
446 panel.cbCtrl.setEnabled(state);
447 panel.cbAlt.setEnabled(state);
448 panel.cbMeta.setEnabled(state);
449 panel.tfKey.setEnabled(state);
450 } else {
451 panel.cbDefault.setEnabled(false);
452 panel.cbDisable.setEnabled(false);
453 panel.cbShift.setEnabled(false);
454 panel.cbCtrl.setEnabled(false);
455 panel.cbAlt.setEnabled(false);
456 panel.cbMeta.setEnabled(false);
457 panel.tfKey.setEnabled(false);
458 }
459 }
460 }
461
462 // this handles the modifier groups
463 private class bxAction extends javax.swing.AbstractAction {
464 public void actionPerformed(java.awt.event.ActionEvent e) {
465 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_EDIT), Integer.toString( modifInts[bxPrim1.getSelectedIndex()] ));
466 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_EDIT), Integer.toString( modifInts[ bxSec1.getSelectedIndex()] ));
467 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_EDIT), Integer.toString( modifInts[ bxTer1.getSelectedIndex()] ));
468
469 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_MENU), Integer.toString( modifInts[bxPrim2.getSelectedIndex()] ));
470 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_MENU), Integer.toString( modifInts[ bxSec2.getSelectedIndex()] ));
471 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_MENU), Integer.toString( modifInts[ bxTer2.getSelectedIndex()] ));
472
473 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_HOTKEY), Integer.toString( modifInts[bxPrim3.getSelectedIndex()] ));
474 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_HOTKEY), Integer.toString( modifInts[ bxSec3.getSelectedIndex()] ));
475 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_HOTKEY), Integer.toString( modifInts[ bxTer3.getSelectedIndex()] ));
476
477 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_LAYER), Integer.toString( modifInts[bxPrim4.getSelectedIndex()] ));
478 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_LAYER), Integer.toString( modifInts[ bxSec4.getSelectedIndex()] ));
479 Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_LAYER), Integer.toString( modifInts[ bxTer4.getSelectedIndex()] ));
480 }
481 }
482
483 private void initbx() {
484 setBx(bxPrim1, "shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_EDIT));
485 setBx(bxSec1, "shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_EDIT));
486 setBx(bxTer1, "shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_EDIT));
487
488 setBx(bxPrim2, "shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_MENU));
489 setBx(bxSec2, "shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_MENU));
490 setBx(bxTer2, "shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_MENU));
491
492 setBx(bxPrim3, "shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_HOTKEY));
493 setBx(bxSec3, "shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_HOTKEY));
494 setBx(bxTer3, "shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_HOTKEY));
495
496 setBx(bxPrim4, "shortcut.groups."+(Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_LAYER));
497 setBx(bxSec4, "shortcut.groups."+(Shortcut.GROUPS_ALT1 +Shortcut.GROUP_LAYER));
498 setBx(bxTer4, "shortcut.groups."+(Shortcut.GROUPS_ALT2 +Shortcut.GROUP_LAYER));
499 }
500 private void setBx(javax.swing.JComboBox bx, String key) {
501 int target = Main.pref.getInteger(key, -1);
502 for (int i = 0; i < modifInts.length; i++) {
503 if (modifInts[i] == target) {
504 bx.setSelectedIndex(i);
505 }
506 }
507 }
508
509 private javax.swing.JComboBox bxPrim1;
510 private javax.swing.JComboBox bxPrim2;
511 private javax.swing.JComboBox bxPrim3;
512 private javax.swing.JComboBox bxPrim4;
513 private javax.swing.JComboBox bxSec1;
514 private javax.swing.JComboBox bxSec2;
515 private javax.swing.JComboBox bxSec3;
516 private javax.swing.JComboBox bxSec4;
517 private javax.swing.JComboBox bxTer1;
518 private javax.swing.JComboBox bxTer2;
519 private javax.swing.JComboBox bxTer3;
520 private javax.swing.JComboBox bxTer4;
521 private javax.swing.JCheckBox cbAlt;
522 private javax.swing.JCheckBox cbCtrl;
523 private javax.swing.JCheckBox cbDefault;
524 private javax.swing.JCheckBox cbDisable;
525 private javax.swing.JCheckBox cbMeta;
526 private javax.swing.JCheckBox cbShift;
527 private javax.swing.JPanel editGroupPane;
528 private javax.swing.JPanel hotkeyGroupPane;
529 private javax.swing.JLabel jLabel1;
530 private javax.swing.JLabel jLabel10;
531 private javax.swing.JLabel jLabel11;
532 private javax.swing.JLabel jLabel12;
533 private javax.swing.JLabel jLabel13;
534 private javax.swing.JLabel jLabel14;
535 private javax.swing.JLabel jLabel15;
536 private javax.swing.JLabel jLabel2;
537 private javax.swing.JLabel jLabel3;
538 private javax.swing.JLabel jLabel4;
539 private javax.swing.JLabel jLabel6;
540 private javax.swing.JLabel jLabel7;
541 private javax.swing.JLabel jLabel8;
542 private javax.swing.JLabel jLabel9;
543 private javax.swing.JPanel listPane;
544 private javax.swing.JScrollPane listScrollPane;
545 private javax.swing.JPanel menuGroupPane;
546 private javax.swing.JPanel modifierTab;
547 private javax.swing.JTabbedPane prefTabPane;
548 private javax.swing.JPanel shortcutEditPane;
549 private javax.swing.JPanel shortcutTab;
550 private javax.swing.JTable shortcutTable;
551 private javax.swing.JPanel subwindowGroupPane;
552 private javax.swing.JComboBox tfKey;
553 private javax.swing.JLabel tfKeyLabel;
554 private javax.swing.JPanel infoTab;
555}
Note: See TracBrowser for help on using the repository browser.