X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fconfig%2FConfig.java;h=412f408b803c79055ffbe7eb100ab9d707d606c2;hb=649c5da6ee1bbc590699e11a92316ece2ea8512d;hp=a822b6e34ebef38da13b798f6afa7460c288f0eb;hpb=1ee49ae3c8ef3aa2e63eadd458531e5f8bd4f92c;p=GpsPrune.git diff --git a/tim/prune/config/Config.java b/tim/prune/config/Config.java index a822b6e..412f408 100644 --- a/tim/prune/config/Config.java +++ b/tim/prune/config/Config.java @@ -4,6 +4,8 @@ import java.io.File; import java.io.FileInputStream; import java.util.Properties; +import tim.prune.data.RecentFileList; + /** * Abstract class to hold application-wide configuration @@ -17,9 +19,12 @@ public abstract class Config private static Properties _configValues = new Properties(); /** Colour scheme object is also part of config */ private static ColourScheme _colourScheme = new ColourScheme(); + /** Recently-used file list */ + private static RecentFileList _recentFiles = new RecentFileList(); /** Default config file */ - private static final File DEFAULT_CONFIG_FILE = new File(".pruneconfig"); + public static final File DEFAULT_CONFIG_FILE = new File(".pruneconfig"); + public static final File HOME_CONFIG_FILE = new File(System.getProperty("user.home"), ".pruneconfig"); /** Key for track directory */ public static final String KEY_TRACK_DIR = "prune.trackdirectory"; @@ -37,12 +42,16 @@ public abstract class Config public static final String KEY_POVRAY_FONT = "prune.povrayfont"; /** Key for metric/imperial */ public static final String KEY_METRIC_UNITS = "prune.metricunits"; - /** Key for map server index */ - public static final String KEY_MAPSERVERINDEX = "prune.mapserverindex"; - /** Key for map server url */ - public static final String KEY_MAPSERVERURL = "prune.mapserverurl"; + /** Key for index of map source */ + public static final String KEY_MAPSOURCE_INDEX = "prune.mapsource"; + /** Key for String containing custom map sources */ + public static final String KEY_MAPSOURCE_LIST = "prune.mapsourcelist"; /** Key for show map flag */ public static final String KEY_SHOW_MAP = "prune.showmap"; + /** Key for path to disk cache */ + public static final String KEY_DISK_CACHE = "prune.diskcache"; + /** Key for working online flag */ + public static final String KEY_ONLINE_MODE = "prune.onlinemode"; /** Key for width of thumbnails in kmz */ public static final String KEY_KMZ_IMAGE_WIDTH = "prune.kmzimagewidth"; /** Key for height of thumbnails in kmz */ @@ -55,8 +64,14 @@ public abstract class Config public static final String KEY_EXIFTOOL_PATH = "prune.exiftoolpath"; /** Key for colour scheme */ public static final String KEY_COLOUR_SCHEME = "prune.colourscheme"; + /** Key for line width used for drawing */ + public static final String KEY_LINE_WIDTH = "prune.linewidth"; /** Key for kml track colour */ public static final String KEY_KML_TRACK_COLOUR = "prune.kmltrackcolour"; + /** Key for autosaving settings */ + public static final String KEY_AUTOSAVE_SETTINGS = "prune.autosavesettings"; + /** Key for recently used files */ + public static final String KEY_RECENT_FILES = "prune.recentfiles"; /** @@ -64,11 +79,21 @@ public abstract class Config */ public static void loadDefaultFile() { - try + if (DEFAULT_CONFIG_FILE.exists()) + { + try { + loadFile(DEFAULT_CONFIG_FILE); + return; + } + catch (ConfigException ce) {} // ignore + } + if (HOME_CONFIG_FILE.exists()) { - loadFile(DEFAULT_CONFIG_FILE); + try { + loadFile(HOME_CONFIG_FILE); + } + catch (ConfigException ce) {} // ignore } - catch (ConfigException ce) {} // ignore } @@ -101,6 +126,7 @@ public abstract class Config // Save all properties from file _configValues.putAll(props); _colourScheme.loadFromHex(_configValues.getProperty(KEY_COLOUR_SCHEME)); + _recentFiles = new RecentFileList(_configValues.getProperty(KEY_RECENT_FILES)); if (loadFailed) { throw new ConfigException(); } @@ -124,6 +150,7 @@ public abstract class Config props.put(KEY_GPSBABEL_PATH, "gpsbabel"); props.put(KEY_KMZ_IMAGE_WIDTH, "240"); props.put(KEY_KMZ_IMAGE_HEIGHT, "240"); + props.put(KEY_AUTOSAVE_SETTINGS, "0"); // autosave false by default return props; } @@ -152,6 +179,8 @@ public abstract class Config */ public static Properties getAllConfig() { + // Update recently-used files + _configValues.setProperty(KEY_RECENT_FILES, _recentFiles.getConfigString()); return _configValues; } @@ -163,6 +192,14 @@ public abstract class Config return _colourScheme; } + /** + * @return list of recently used files + */ + public static RecentFileList getRecentFileList() + { + return _recentFiles; + } + /** * Store the given configuration setting * @param inKey key (from constants) @@ -217,7 +254,7 @@ public abstract class Config /** * Get the given configuration setting as a boolean * @param inKey key - * @return configuration setting as a boolean + * @return configuration setting as a boolean (default to true) */ public static boolean getConfigBoolean(String inKey) {