Changeset 10109 in josm for trunk/src/org


Ignore:
Timestamp:
2016-04-04T23:13:08+02:00 (9 years ago)
Author:
Don-vip
Message:

add unit test, javadoc, remove unused and untestable code

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r9942 r10109  
    242242
    243243    /**
    244      * replies the tag table model for the respective point in time
     244     * Replies the tag table model for the respective point in time.
    245245     *
    246246     * @param pointInTimeType the type of the point in time (must not be null)
     
    252252        if (pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME))
    253253            return currentTagTableModel;
    254         else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME))
     254        else // REFERENCE_POINT_IN_TIME
    255255            return referenceTagTableModel;
    256 
    257         // should not happen
    258         return null;
    259     }
    260 
     256    }
     257
     258    /**
     259     * Replies the node list table model for the respective point in time.
     260     *
     261     * @param pointInTimeType the type of the point in time (must not be null)
     262     * @return the node list table model
     263     * @throws IllegalArgumentException if pointInTimeType is null
     264     */
    261265    public DiffTableModel getNodeListTableModel(PointInTimeType pointInTimeType) {
    262266        CheckParameterUtil.ensureParameterNotNull(pointInTimeType, "pointInTimeType");
    263267        if (pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME))
    264268            return currentNodeListTableModel;
    265         else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME))
     269        else // REFERENCE_POINT_IN_TIME
    266270            return referenceNodeListTableModel;
    267 
    268         // should not happen
    269         return null;
    270     }
    271 
     271    }
     272
     273    /**
     274     * Replies the relation member table model for the respective point in time.
     275     *
     276     * @param pointInTimeType the type of the point in time (must not be null)
     277     * @return the relation member table model
     278     * @throws IllegalArgumentException if pointInTimeType is null
     279     */
    272280    public DiffTableModel getRelationMemberTableModel(PointInTimeType pointInTimeType) {
    273281        CheckParameterUtil.ensureParameterNotNull(pointInTimeType, "pointInTimeType");
    274282        if (pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME))
    275283            return currentRelationMemberTableModel;
    276         else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME))
     284        else // REFERENCE_POINT_IN_TIME
    277285            return referenceRelationMemberTableModel;
    278 
    279         // should not happen
    280         return null;
    281286    }
    282287
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r10035 r10109  
    88import java.awt.Component;
    99import java.awt.Font;
     10import java.awt.GraphicsEnvironment;
    1011import java.awt.GridBagLayout;
    1112import java.awt.event.MouseAdapter;
     
    9596    public boolean editPreference(final JComponent gui) {
    9697        if (getSelectedRowCount() != 1) {
    97             JOptionPane.showMessageDialog(
    98                     gui,
    99                     tr("Please select the row to edit."),
    100                     tr("Warning"),
    101                     JOptionPane.WARNING_MESSAGE
    102                     );
     98            if (!GraphicsEnvironment.isHeadless()) {
     99                JOptionPane.showMessageDialog(
     100                        gui,
     101                        tr("Please select the row to edit."),
     102                        tr("Warning"),
     103                        JOptionPane.WARNING_MESSAGE
     104                        );
     105            }
    103106            return false;
    104107        }
     
    122125    }
    123126
    124     static boolean doEditList(final JComponent gui, final PrefEntry e, ListSetting lSetting) {
     127    private static boolean doEditList(final JComponent gui, final PrefEntry e, ListSetting lSetting) {
    125128        ListEditor lEditor = new ListEditor(gui, e, lSetting);
    126129        lEditor.showDialog();
     
    135138    }
    136139
    137     static boolean doEditListList(final JComponent gui, final PrefEntry e, ListListSetting llSetting) {
     140    private static boolean doEditListList(final JComponent gui, final PrefEntry e, ListListSetting llSetting) {
    138141        ListListEditor llEditor = new ListListEditor(gui, e, llSetting);
    139142        llEditor.showDialog();
     
    148151    }
    149152
    150     static boolean doEditMapList(final JComponent gui, final PrefEntry e, MapListSetting mlSetting) {
     153    private static boolean doEditMapList(final JComponent gui, final PrefEntry e, MapListSetting mlSetting) {
    151154        MapListEditor mlEditor = new MapListEditor(gui, e, mlSetting);
    152155        mlEditor.showDialog();
     
    192195        rbString.setSelected(true);
    193196
    194         ExtendedDialog dlg = new ExtendedDialog(gui, tr("Add setting"), new String[] {tr("OK"), tr("Cancel")});
    195         dlg.setButtonIcons(new String[] {"ok.png", "cancel.png"});
    196         dlg.setContent(p);
    197         dlg.showDialog();
    198 
    199197        PrefEntry pe = null;
    200198        boolean ok = false;
    201         if (dlg.getValue() == 1) {
     199        if (!GraphicsEnvironment.isHeadless() && askAddSetting(gui, p)) {
    202200            if (rbString.isSelected()) {
    203201                StringSetting sSetting = new StringSetting(null);
     
    221219    }
    222220
    223     static boolean doAddSimple(final JComponent gui, PrefEntry pe, StringSetting sSetting) {
     221    private static boolean askAddSetting(JComponent gui, JPanel p) {
     222        return new ExtendedDialog(gui, tr("Add setting"), new String[] {tr("OK"), tr("Cancel")})
     223                .setContent(p).setButtonIcons(new String[] {"ok.png", "cancel.png"}).showDialog().getValue() == 1;
     224    }
     225
     226    private static boolean doAddSimple(final JComponent gui, PrefEntry pe, StringSetting sSetting) {
    224227        StringEditor sEditor = new StringEditor(gui, pe, sSetting);
    225228        sEditor.showDialog();
     
    234237    }
    235238
    236     static boolean doAddList(final JComponent gui, PrefEntry pe, ListSetting lSetting) {
     239    private static boolean doAddList(final JComponent gui, PrefEntry pe, ListSetting lSetting) {
    237240        ListEditor lEditor = new ListEditor(gui, pe, lSetting);
    238241        lEditor.showDialog();
     
    247250    }
    248251
    249     static boolean doAddListList(final JComponent gui, PrefEntry pe, ListListSetting llSetting) {
     252    private static boolean doAddListList(final JComponent gui, PrefEntry pe, ListListSetting llSetting) {
    250253        ListListEditor llEditor = new ListListEditor(gui, pe, llSetting);
    251254        llEditor.showDialog();
     
    260263    }
    261264
    262     static boolean doAddMapList(final JComponent gui, PrefEntry pe, MapListSetting mlSetting) {
     265    private static boolean doAddMapList(final JComponent gui, PrefEntry pe, MapListSetting mlSetting) {
    263266        MapListEditor mlEditor = new MapListEditor(gui, pe, mlSetting);
    264267        mlEditor.showDialog();
     
    279282    public void resetPreferences(final JComponent gui) {
    280283        if (getSelectedRowCount() == 0) {
    281             JOptionPane.showMessageDialog(
    282                     gui,
    283                     tr("Please select the row to delete."),
    284                     tr("Warning"),
    285                     JOptionPane.WARNING_MESSAGE
    286                     );
     284            if (!GraphicsEnvironment.isHeadless()) {
     285                JOptionPane.showMessageDialog(
     286                        gui,
     287                        tr("Please select the row to delete."),
     288                        tr("Warning"),
     289                        JOptionPane.WARNING_MESSAGE
     290                        );
     291            }
    287292            return;
    288293        }
     
    294299    }
    295300
    296     private class AllSettingsTableModel extends DefaultTableModel {
     301    final class AllSettingsTableModel extends DefaultTableModel {
    297302
    298303        AllSettingsTableModel() {
     
    329334    }
    330335
    331     private static class SettingCellRenderer extends DefaultTableCellRenderer {
     336    static final class SettingCellRenderer extends DefaultTableCellRenderer {
    332337        private final Color backgroundColor = UIManager.getColor("Table.background");
    333338        private final Color changedColor = Main.pref.getColor(
     
    374379    }
    375380
    376     private static class SettingCellEditor extends DefaultCellEditor {
     381    static final class SettingCellEditor extends DefaultCellEditor {
    377382        SettingCellEditor() {
    378383            super(new JosmTextField());
Note: See TracChangeset for help on using the changeset viewer.