Ignore:
Timestamp:
2009-01-23T22:22:10+01:00 (15 years ago)
Author:
stoecker
Message:

reworked plugin handling a lot, more to come

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r1245 r1326  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.data;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.Color;
     
    2224import java.util.regex.Pattern;
    2325
     26import javax.swing.JOptionPane;
     27
    2428import org.openstreetmap.josm.Main;
    2529import org.openstreetmap.josm.actions.AboutAction;
     
    298302            properties.put(line.substring(0,i), line.substring(i+1));
    299303        }
    300         if (!errLines.isEmpty()) {
    301             throw new IOException("Malformed config file at lines " + errLines);
    302         }
     304        if (!errLines.isEmpty())
     305            throw new IOException(tr("Malformed config file at lines {0}", errLines));
    303306        setSystemProperties();
     307    }
     308
     309    public void init(Boolean reset)
     310    {
     311        // get the preferences.
     312        File prefDir = getPreferencesDirFile();
     313        if (prefDir.exists()) {
     314            if(!prefDir.isDirectory()) {
     315                JOptionPane.showMessageDialog(null, tr("Cannot open preferences directory: {0}",Main.pref.getPreferencesDir()));
     316                return;
     317            }
     318        }
     319        else
     320            prefDir.mkdirs();
     321
     322        if (!new File(getPreferencesDir()+"preferences").exists())
     323            resetToDefault();
     324
     325        try {
     326            if (reset)
     327                resetToDefault();
     328            else
     329                load();
     330        } catch (final IOException e1) {
     331            e1.printStackTrace();
     332            String backup = getPreferencesDir() + "preferences.bak";
     333            JOptionPane.showMessageDialog(null, tr("Preferences file had errors. Making backup of old one to {0}.", backup));
     334            new File(getPreferencesDir() + "preferences").renameTo(new File(backup));
     335            save();
     336        }
    304337    }
    305338
     
    448481            /* handle space separated stuff - remove in future */
    449482            else if(s.indexOf(' ') >= 0)
    450                 return Arrays.asList(s.split(","));
     483                return Arrays.asList(s.split(" "));
    451484            else
    452485                return Arrays.asList(s.split(";"));
Note: See TracChangeset for help on using the changeset viewer.