Ignore:
Timestamp:
2014-01-01T23:07:33+01:00 (11 years ago)
Author:
stoecker
Message:

cleanup validator prefs to better support prefs format (resets some settings to default)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r6591 r6593  
    9494    public static final String PREF_CHECK_FIXMES = PREFIX + ".checkFixmes";
    9595
    96     public static final String PREF_SOURCES = PREFIX + ".sources";
    97     public static final String PREF_USE_DATA_FILE = PREFIX + ".usedatafile";
    98     public static final String PREF_USE_IGNORE_FILE = PREFIX + ".useignorefile";
    99     public static final String PREF_USE_SPELL_FILE = PREFIX + ".usespellfile";
     96    public static final String PREF_SOURCES = PREFIX + ".source";
    10097
    10198    public static final String PREF_CHECK_KEYS_BEFORE_UPLOAD = PREF_CHECK_KEYS + "BeforeUpload";
     
    120117    protected JCheckBox prefCheckFixmesBeforeUpload;
    121118    protected JCheckBox prefCheckPaintBeforeUpload;
    122 
    123     protected JCheckBox prefUseDataFile;
    124     protected JCheckBox prefUseIgnoreFile;
    125     protected JCheckBox prefUseSpellFile;
    126119
    127120    protected static final int EMPTY_VALUES      = 1200;
     
    172165
    173166        spellCheckKeyData = new HashMap<String, String>();
    174         String sources = Main.pref.get( PREF_SOURCES, "");
    175         if (Main.pref.getBoolean(PREF_USE_DATA_FILE, true)) {
    176             if (sources == null || sources.length() == 0) {
    177                 sources = DATA_FILE;
    178             } else {
    179                 sources = DATA_FILE + ";" + sources;
    180             }
    181         }
    182         if (Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true)) {
    183             if (sources == null || sources.length() == 0) {
    184                 sources = IGNORE_FILE;
    185             } else {
    186                 sources = IGNORE_FILE + ";" + sources;
    187             }
    188         }
    189         if (Main.pref.getBoolean(PREF_USE_SPELL_FILE, true)) {
    190             if( sources == null || sources.length() == 0) {
    191                 sources = SPELL_FILE;
    192             } else {
    193                 sources = SPELL_FILE + ";" + sources;
    194             }
    195         }
    196 
     167       
    197168        String errorSources = "";
    198         if (sources.length() == 0)
    199             return;
    200         for (String source : sources.split(";")) {
     169        for (String source : Main.pref.getCollection(PREF_SOURCES, Arrays.asList(DATA_FILE, IGNORE_FILE, SPELL_FILE))) {
    201170            BufferedReader reader = null;
    202171            try {
     
    511480        testPanel.add(prefCheckComplexBeforeUpload, a);
    512481
    513         final String sources = Main.pref.get(PREF_SOURCES);
     482        final Collection<String> sources = Main.pref.getCollection(PREF_SOURCES, Arrays.asList(DATA_FILE, IGNORE_FILE, SPELL_FILE));
    514483        sourcesList = new EditableList(tr("TagChecker source"));
    515         sourcesList.setItems(sources != null ? Arrays.asList(sources.split(";")) : Collections.<String>emptyList());
     484        sourcesList.setItems(sources);
    516485        testPanel.add(new JLabel(tr("Data sources ({0})", "*.cfg")), GBC.eol().insets(23, 0, 0, 0));
    517486        testPanel.add(sourcesList, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(23, 0, 0, 0));
     
    545514        prefCheckFixmesBeforeUpload.setSelected(Main.pref.getBoolean(PREF_CHECK_FIXMES_BEFORE_UPLOAD, true));
    546515        testPanel.add(prefCheckFixmesBeforeUpload, a);
    547 
    548         prefUseDataFile = new JCheckBox(tr("Use default data file."), Main.pref.getBoolean(PREF_USE_DATA_FILE, true));
    549         prefUseDataFile.setToolTipText(tr("Use the default data file (recommended)."));
    550         testPanel.add(prefUseDataFile, GBC.eol().insets(20,0,0,0));
    551 
    552         prefUseIgnoreFile = new JCheckBox(tr("Use default tag ignore file."), Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true));
    553         prefUseIgnoreFile.setToolTipText(tr("Use the default tag ignore file (recommended)."));
    554         testPanel.add(prefUseIgnoreFile, GBC.eol().insets(20,0,0,0));
    555 
    556         prefUseSpellFile = new JCheckBox(tr("Use default spellcheck file."), Main.pref.getBoolean(PREF_USE_SPELL_FILE, true));
    557         prefUseSpellFile.setToolTipText(tr("Use the default spellcheck file (recommended)."));
    558         testPanel.add(prefUseSpellFile, GBC.eol().insets(20,0,0,0));
    559516    }
    560517
     
    579536        Main.pref.put(PREF_CHECK_KEYS_BEFORE_UPLOAD, prefCheckKeysBeforeUpload.isSelected());
    580537        Main.pref.put(PREF_CHECK_FIXMES_BEFORE_UPLOAD, prefCheckFixmesBeforeUpload.isSelected());
    581         Main.pref.put(PREF_USE_DATA_FILE, prefUseDataFile.isSelected());
    582         Main.pref.put(PREF_USE_IGNORE_FILE, prefUseIgnoreFile.isSelected());
    583         Main.pref.put(PREF_USE_SPELL_FILE, prefUseSpellFile.isSelected());
    584         final List<String> sources = sourcesList.getItems();
    585         return Main.pref.put(PREF_SOURCES, sources.isEmpty() ? null : Utils.join(";", sources));
     538        return Main.pref.putCollection(PREF_SOURCES, sourcesList.getItems());
    586539    }
    587540
    588541    @Override
    589542    public Command fixError(TestError testError) {
    590 
    591543        List<Command> commands = new ArrayList<Command>(50);
    592544
     
    631583    @Override
    632584    public boolean isFixable(TestError testError) {
    633 
    634585        if (testError.getTester() instanceof TagChecker) {
    635586            int code = testError.getCode();
Note: See TracChangeset for help on using the changeset viewer.