Ignore:
Timestamp:
2016-04-10T16:57:50+02:00 (10 years ago)
Author:
Don-vip
Message:

sonar, javadoc

Location:
trunk/src/org/openstreetmap/josm/gui/preferences
Files:
3 edited

Legend:

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

    r8836 r10134  
    3131/**
    3232 * Language preferences.
     33 * @since 1065
    3334 */
    3435public class LanguagePreference implements SubPreferenceSetting {
     36
     37    private static final String LANGUAGE = "language";
    3538
    3639    /**
     
    5255        // Selecting the language BEFORE the JComboBox listens to model changes speed up initialization by ~35ms (see #7386)
    5356        // 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));
    5558        langCombo = new JosmComboBox<>(model);
    5659        langCombo.setRenderer(new LanguageCellRenderer());
     
    7073    public boolean ok() {
    7174        if (langCombo.getSelectedItem() == null)
    72             return Main.pref.put("language", null);
     75            return Main.pref.put(LANGUAGE, null);
    7376        else
    74             return Main.pref.put("language",
     77            return Main.pref.put(LANGUAGE,
    7578                    LanguageInfo.getJOSMLocaleCode((Locale) langCombo.getSelectedItem()));
    7679    }
     
    8487        }
    8588
    86         public void selectLanguage(String language) {
     89        private void selectLanguage(String language) {
    8790            setSelectedItem(null);
    8891            if (language != null) {
    89                 language = LanguageInfo.getJavaLocaleCode(language);
     92                String lang = LanguageInfo.getJavaLocaleCode(language);
    9093                for (Locale locale: data) {
    9194                    if (locale == null) {
    9295                        continue;
    9396                    }
    94                     if (locale.toString().equals(language)) {
     97                    if (locale.toString().equals(lang)) {
    9598                        setSelectedItem(locale);
    9699                        return;
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r10099 r10134  
    878878            }
    879879
    880             public OffsetBookmark getRow(int row) {
     880            private OffsetBookmark getRow(int row) {
    881881                return bookmarks.get(row);
    882882            }
    883883
    884             public void addRow(OffsetBookmark i) {
     884            private void addRow(OffsetBookmark i) {
    885885                bookmarks.add(i);
    886886                int p = getRowCount() - 1;
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java

    r9543 r10134  
    7777    private static Map<Integer, String> keyList = setKeyList();
    7878
     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
    7997    private static Map<Integer, String> setKeyList() {
    8098        Map<Integer, String> list = new LinkedHashMap<>();
     
    89107                        list.put(Integer.valueOf(i), s);
    90108                    }
    91                 } catch (Exception e) {
     109                } catch (IllegalArgumentException | IllegalAccessException e) {
    92110                    Main.error(e);
    93111                }
     
    96114        list.put(Integer.valueOf(-1), "");
    97115        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();
    116116    }
    117117
     
    169169            int row1 = shortcutTable.convertRowIndexToModel(row);
    170170            Shortcut sc = (Shortcut) model.getValueAt(row1, -1);
    171             if (sc == null) return null;
     171            if (sc == null)
     172                return null;
    172173            JLabel label = (JLabel) super.getTableCellRendererComponent(
    173174                table, name ? sc.getLongText() : sc.getKeyText(), isSelected, hasFocus, row, column);
     
    187188
    188189    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 
    193190        CbAction action = new CbAction(this);
    194191        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
     
    197194        // This is the list of shortcuts:
    198195        shortcutTable.setModel(model);
    199         shortcutTable.getSelectionModel().addListSelectionListener(new CbAction(this));
     196        shortcutTable.getSelectionModel().addListSelectionListener(action);
    200197        shortcutTable.setFillsViewportHeight(true);
    201198        shortcutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     
    204201        mod.getColumn(0).setCellRenderer(new ShortcutTableCellRenderer(true));
    205202        mod.getColumn(1).setCellRenderer(new ShortcutTableCellRenderer(false));
     203        JScrollPane listScrollPane = new JScrollPane();
    206204        listScrollPane.setViewportView(shortcutTable);
    207205
     206        JPanel listPane = new JPanel(new GridLayout());
    208207        listPane.add(listScrollPane);
    209 
    210208        add(listPane);
    211209
     
    227225        cbMeta.setText(META); // see above for why no tr()
    228226
     227        JPanel shortcutEditPane = new JPanel(new GridLayout(5, 2));
     228
    229229        shortcutEditPane.add(cbDefault);
    230230        shortcutEditPane.add(new JLabel());
     
    266266    }
    267267
    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 
    277268    // this allows to edit shortcuts. it:
    278269    //  * sets the edit controls to the selected shortcut
     
    282273    // are playing ping-pong (politically correct: table tennis, I know) and
    283274    // even have some duplicated code. Feel free to refactor, If you have
    284     // more expirience 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 {
    286277        private final PrefJPanel panel;
    287278
    288279        CbAction(PrefJPanel panel) {
    289280            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);
    290290        }
    291291
     
    303303                panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.META_DOWN_MASK) != 0);
    304304                if (sc.getKeyStroke() != null) {
    305                     tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode()));
     305                    panel.tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode()));
    306306                } else {
    307                     tfKey.setSelectedItem(keyList.get(-1));
     307                    panel.tfKey.setSelectedItem(keyList.get(-1));
    308308                }
    309309                if (!sc.isChangeable()) {
     
    314314                    actionPerformed(null);
    315315                }
    316                 model.fireTableRowsUpdated(row, row);
     316                panel.model.fireTableRowsUpdated(row, row);
    317317            } else {
    318                 panel.disableAllModifierCheckboxes();
     318                disableAllModifierCheckboxes();
    319319                panel.tfKey.setEnabled(false);
    320320            }
     
    357357                panel.tfKey.setEnabled(state);
    358358            } else {
    359                 panel.disableAllModifierCheckboxes();
     359                disableAllModifierCheckboxes();
    360360                panel.tfKey.setEnabled(false);
    361361            }
     
    364364
    365365    class FilterFieldAdapter implements DocumentListener {
    366         public void filter() {
     366        private void filter() {
    367367            String expr = filterField.getText().trim();
    368368            if (expr.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.