Changeset 16846 in josm for trunk/src


Ignore:
Timestamp:
2020-08-03T23:09:13+02:00 (4 years ago)
Author:
simon04
Message:

PreferencesTable: remove code duplication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r16844 r16846  
    104104            }
    105105        } else if (stg instanceof ListSetting) {
    106             ok = doEditList(gui, e, (ListSetting) stg);
     106            ok = doAddEditList(gui, e, (ListSetting) stg);
    107107        } else if (stg instanceof ListListSetting) {
    108             ok = doEditListList(gui, e, (ListListSetting) stg);
     108            ok = doAddEditListList(gui, e, (ListListSetting) stg);
    109109        } else if (stg instanceof MapListSetting) {
    110             ok = doEditMapList(gui, e, (MapListSetting) stg);
     110            ok = doAddEditMapList(gui, e, (MapListSetting) stg);
    111111        }
    112112        return ok;
    113     }
    114 
    115     private static boolean doEditList(final JComponent gui, final PrefEntry e, ListSetting lSetting) {
    116         ListEditor lEditor = new ListEditor(gui, e, lSetting);
    117         lEditor.showDialog();
    118         if (lEditor.getValue() == 1) {
    119             List<String> data = lEditor.getData();
    120             if (!lSetting.equalVal(data)) {
    121                 e.setValue(new ListSetting(data));
    122                 return true;
    123             }
    124         }
    125         return false;
    126     }
    127 
    128     private static boolean doEditListList(final JComponent gui, final PrefEntry e, ListListSetting llSetting) {
    129         ListListEditor llEditor = new ListListEditor(gui, e, llSetting);
    130         llEditor.showDialog();
    131         if (llEditor.getValue() == 1) {
    132             List<List<String>> data = llEditor.getData();
    133             if (!llSetting.equalVal(data)) {
    134                 e.setValue(new ListListSetting(data));
    135                 return true;
    136             }
    137         }
    138         return false;
    139     }
    140 
    141     private static boolean doEditMapList(final JComponent gui, final PrefEntry e, MapListSetting mlSetting) {
    142         MapListEditor mlEditor = new MapListEditor(gui, e, mlSetting);
    143         mlEditor.showDialog();
    144         if (mlEditor.getValue() == 1) {
    145             List<Map<String, String>> data = mlEditor.getData();
    146             if (!mlSetting.equalVal(data)) {
    147                 e.setValue(new MapListSetting(data));
    148                 return true;
    149             }
    150         }
    151         return false;
    152113    }
    153114
     
    193154                ListSetting lSetting = new ListSetting(null);
    194155                pe = new PrefEntry(tkey.getText(), lSetting, lSetting, false);
    195                 ok = doAddList(gui, pe, lSetting);
     156                ok = doAddEditList(gui, pe, lSetting);
    196157            } else if (rbListList.isSelected()) {
    197158                ListListSetting llSetting = new ListListSetting(null);
    198159                pe = new PrefEntry(tkey.getText(), llSetting, llSetting, false);
    199                 ok = doAddListList(gui, pe, llSetting);
     160                ok = doAddEditListList(gui, pe, llSetting);
    200161            } else if (rbMapList.isSelected()) {
    201162                MapListSetting mlSetting = new MapListSetting(null);
    202163                pe = new PrefEntry(tkey.getText(), mlSetting, mlSetting, false);
    203                 ok = doAddMapList(gui, pe, mlSetting);
     164                ok = doAddEditMapList(gui, pe, mlSetting);
    204165            }
    205166        }
     
    225186    }
    226187
    227     private static boolean doAddList(final JComponent gui, PrefEntry pe, ListSetting lSetting) {
     188    private static boolean doAddEditList(final JComponent gui, PrefEntry pe, ListSetting lSetting) {
    228189        ListEditor lEditor = new ListEditor(gui, pe, lSetting);
    229190        lEditor.showDialog();
     
    238199    }
    239200
    240     private static boolean doAddListList(final JComponent gui, PrefEntry pe, ListListSetting llSetting) {
     201    private static boolean doAddEditListList(final JComponent gui, PrefEntry pe, ListListSetting llSetting) {
    241202        ListListEditor llEditor = new ListListEditor(gui, pe, llSetting);
    242203        llEditor.showDialog();
     
    251212    }
    252213
    253     private static boolean doAddMapList(final JComponent gui, PrefEntry pe, MapListSetting mlSetting) {
     214    private static boolean doAddEditMapList(final JComponent gui, PrefEntry pe, MapListSetting mlSetting) {
    254215        MapListEditor mlEditor = new MapListEditor(gui, pe, mlSetting);
    255216        mlEditor.showDialog();
Note: See TracChangeset for help on using the changeset viewer.