Changeset 10134 in josm for trunk/src/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2016-04-10T16:57:50+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 3 edited
-
display/LanguagePreference.java (modified) (4 diffs)
-
imagery/ImageryPreference.java (modified) (1 diff)
-
shortcut/PrefJPanel.java (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java
r8836 r10134 31 31 /** 32 32 * Language preferences. 33 * @since 1065 33 34 */ 34 35 public class LanguagePreference implements SubPreferenceSetting { 36 37 private static final String LANGUAGE = "language"; 35 38 36 39 /** … … 52 55 // Selecting the language BEFORE the JComboBox listens to model changes speed up initialization by ~35ms (see #7386) 53 56 // See https://stackoverflow.com/questions/3194958/fast-replacement-for-jcombobox-basiccomboboxui 54 model.selectLanguage(Main.pref.get( "language"));57 model.selectLanguage(Main.pref.get(LANGUAGE)); 55 58 langCombo = new JosmComboBox<>(model); 56 59 langCombo.setRenderer(new LanguageCellRenderer()); … … 70 73 public boolean ok() { 71 74 if (langCombo.getSelectedItem() == null) 72 return Main.pref.put( "language", null);75 return Main.pref.put(LANGUAGE, null); 73 76 else 74 return Main.pref.put( "language",77 return Main.pref.put(LANGUAGE, 75 78 LanguageInfo.getJOSMLocaleCode((Locale) langCombo.getSelectedItem())); 76 79 } … … 84 87 } 85 88 86 p ublicvoid selectLanguage(String language) {89 private void selectLanguage(String language) { 87 90 setSelectedItem(null); 88 91 if (language != null) { 89 language= LanguageInfo.getJavaLocaleCode(language);92 String lang = LanguageInfo.getJavaLocaleCode(language); 90 93 for (Locale locale: data) { 91 94 if (locale == null) { 92 95 continue; 93 96 } 94 if (locale.toString().equals(lang uage)) {97 if (locale.toString().equals(lang)) { 95 98 setSelectedItem(locale); 96 99 return; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r10099 r10134 878 878 } 879 879 880 p ublicOffsetBookmark getRow(int row) {880 private OffsetBookmark getRow(int row) { 881 881 return bookmarks.get(row); 882 882 } 883 883 884 p ublicvoid addRow(OffsetBookmark i) {884 private void addRow(OffsetBookmark i) { 885 885 bookmarks.add(i); 886 886 int p = getRowCount() - 1; -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r9543 r10134 77 77 private static Map<Integer, String> keyList = setKeyList(); 78 78 79 private final JCheckBox cbAlt = new JCheckBox(); 80 private final JCheckBox cbCtrl = new JCheckBox(); 81 private final JCheckBox cbMeta = new JCheckBox(); 82 private final JCheckBox cbShift = new JCheckBox(); 83 private final JCheckBox cbDefault = new JCheckBox(); 84 private final JCheckBox cbDisable = new JCheckBox(); 85 private final JosmComboBox<String> tfKey = new JosmComboBox<>(); 86 87 private final JTable shortcutTable = new JTable(); 88 89 private final JosmTextField filterField = new JosmTextField(); 90 91 /** Creates new form prefJPanel */ 92 public PrefJPanel() { 93 this.model = new ScListModel(); 94 initComponents(); 95 } 96 79 97 private static Map<Integer, String> setKeyList() { 80 98 Map<Integer, String> list = new LinkedHashMap<>(); … … 89 107 list.put(Integer.valueOf(i), s); 90 108 } 91 } catch (Exception e) { 109 } catch (IllegalArgumentException | IllegalAccessException e) { 92 110 Main.error(e); 93 111 } … … 96 114 list.put(Integer.valueOf(-1), ""); 97 115 return list; 98 }99 100 private final JCheckBox cbAlt = new JCheckBox();101 private final JCheckBox cbCtrl = new JCheckBox();102 private final JCheckBox cbMeta = new JCheckBox();103 private final JCheckBox cbShift = new JCheckBox();104 private final JCheckBox cbDefault = new JCheckBox();105 private final JCheckBox cbDisable = new JCheckBox();106 private final JosmComboBox<String> tfKey = new JosmComboBox<>();107 108 private final JTable shortcutTable = new JTable();109 110 private final JosmTextField filterField = new JosmTextField();111 112 /** Creates new form prefJPanel */113 public PrefJPanel() {114 this.model = new ScListModel();115 initComponents();116 116 } 117 117 … … 169 169 int row1 = shortcutTable.convertRowIndexToModel(row); 170 170 Shortcut sc = (Shortcut) model.getValueAt(row1, -1); 171 if (sc == null) return null; 171 if (sc == null) 172 return null; 172 173 JLabel label = (JLabel) super.getTableCellRendererComponent( 173 174 table, name ? sc.getLongText() : sc.getKeyText(), isSelected, hasFocus, row, column); … … 187 188 188 189 private void initComponents() { 189 JPanel listPane = new JPanel(new GridLayout());190 JScrollPane listScrollPane = new JScrollPane();191 JPanel shortcutEditPane = new JPanel(new GridLayout(5, 2));192 193 190 CbAction action = new CbAction(this); 194 191 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); … … 197 194 // This is the list of shortcuts: 198 195 shortcutTable.setModel(model); 199 shortcutTable.getSelectionModel().addListSelectionListener( new CbAction(this));196 shortcutTable.getSelectionModel().addListSelectionListener(action); 200 197 shortcutTable.setFillsViewportHeight(true); 201 198 shortcutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); … … 204 201 mod.getColumn(0).setCellRenderer(new ShortcutTableCellRenderer(true)); 205 202 mod.getColumn(1).setCellRenderer(new ShortcutTableCellRenderer(false)); 203 JScrollPane listScrollPane = new JScrollPane(); 206 204 listScrollPane.setViewportView(shortcutTable); 207 205 206 JPanel listPane = new JPanel(new GridLayout()); 208 207 listPane.add(listScrollPane); 209 210 208 add(listPane); 211 209 … … 227 225 cbMeta.setText(META); // see above for why no tr() 228 226 227 JPanel shortcutEditPane = new JPanel(new GridLayout(5, 2)); 228 229 229 shortcutEditPane.add(cbDefault); 230 230 shortcutEditPane.add(new JLabel()); … … 266 266 } 267 267 268 private void disableAllModifierCheckboxes() {269 cbDefault.setEnabled(false);270 cbDisable.setEnabled(false);271 cbShift.setEnabled(false);272 cbCtrl.setEnabled(false);273 cbAlt.setEnabled(false);274 cbMeta.setEnabled(false);275 }276 277 268 // this allows to edit shortcuts. it: 278 269 // * sets the edit controls to the selected shortcut … … 282 273 // are playing ping-pong (politically correct: table tennis, I know) and 283 274 // even have some duplicated code. Feel free to refactor, If you have 284 // more exp irience with GUI coding than I have.285 private class CbAction extends AbstractAction implements ListSelectionListener { 275 // more experience with GUI coding than I have. 276 private static class CbAction extends AbstractAction implements ListSelectionListener { 286 277 private final PrefJPanel panel; 287 278 288 279 CbAction(PrefJPanel panel) { 289 280 this.panel = panel; 281 } 282 283 private void disableAllModifierCheckboxes() { 284 panel.cbDefault.setEnabled(false); 285 panel.cbDisable.setEnabled(false); 286 panel.cbShift.setEnabled(false); 287 panel.cbCtrl.setEnabled(false); 288 panel.cbAlt.setEnabled(false); 289 panel.cbMeta.setEnabled(false); 290 290 } 291 291 … … 303 303 panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.META_DOWN_MASK) != 0); 304 304 if (sc.getKeyStroke() != null) { 305 tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode())); 305 panel.tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode())); 306 306 } else { 307 tfKey.setSelectedItem(keyList.get(-1)); 307 panel.tfKey.setSelectedItem(keyList.get(-1)); 308 308 } 309 309 if (!sc.isChangeable()) { … … 314 314 actionPerformed(null); 315 315 } 316 model.fireTableRowsUpdated(row, row); 316 panel.model.fireTableRowsUpdated(row, row); 317 317 } else { 318 panel.disableAllModifierCheckboxes();318 disableAllModifierCheckboxes(); 319 319 panel.tfKey.setEnabled(false); 320 320 } … … 357 357 panel.tfKey.setEnabled(state); 358 358 } else { 359 panel.disableAllModifierCheckboxes();359 disableAllModifierCheckboxes(); 360 360 panel.tfKey.setEnabled(false); 361 361 } … … 364 364 365 365 class FilterFieldAdapter implements DocumentListener { 366 p ublicvoid filter() {366 private void filter() { 367 367 String expr = filterField.getText().trim(); 368 368 if (expr.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.
