Changeset 12855 in josm
- Timestamp:
- 2017-09-14T14:39:53+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.groovy
r12852 r12855 384 384 Main.pref.enableSaveOnPut(false) 385 385 Config.setPreferencesInstance(Main.pref) 386 Config.setBaseDirectoriesProvider(Main.pref); 386 387 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")) 387 388 Path tmpdir = Files.createTempDirectory(FileSystems.getDefault().getPath(base_dir), "pref") -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r12846 r12855 38 38 import org.openstreetmap.josm.io.OsmApi; 39 39 import org.openstreetmap.josm.plugins.PluginHandler; 40 import org.openstreetmap.josm.spi.preferences.Config; 40 41 import org.openstreetmap.josm.tools.Logging; 41 42 import org.openstreetmap.josm.tools.PlatformHookUnixoid; … … 230 231 final String propJavaHome = System.getProperty("java.home"); 231 232 final String propJavaHomeAlt = "<java.home>"; 232 final String prefDir = Main.pref.getPreferencesDirectory().toString();233 final String prefDir = Config.getDirs().getPreferencesDirectory().toString(); 233 234 final String prefDirAlt = "<josm.pref>"; 234 final String userDataDir = Main.pref.getUserDataDirectory().toString();235 final String userDataDir = Config.getDirs().getUserDataDirectory().toString(); 235 236 final String userDataDirAlt = "<josm.userdata>"; 236 final String userCacheDir = Main.pref.getCacheDirectory().toString();237 final String userCacheDir = Config.getDirs().getCacheDirectory().toString(); 237 238 final String userCacheDirAlt = "<josm.cache>"; 238 239 final String userHomeDir = System.getProperty("user.home"); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r12853 r12855 44 44 45 45 import org.openstreetmap.josm.Main; 46 import org.openstreetmap.josm.spi.preferences.AbstractPreferences;47 46 import org.openstreetmap.josm.data.preferences.BooleanProperty; 48 47 import org.openstreetmap.josm.data.preferences.ColorProperty; … … 62 61 import org.openstreetmap.josm.io.OfflineAccessException; 63 62 import org.openstreetmap.josm.io.OnlineResource; 63 import org.openstreetmap.josm.spi.preferences.AbstractPreferences; 64 import org.openstreetmap.josm.spi.preferences.IBaseDirectories; 64 65 import org.openstreetmap.josm.tools.CheckParameterUtil; 65 66 import org.openstreetmap.josm.tools.ColorHelper; … … 92 93 * @since 74 93 94 */ 94 public class Preferences extends AbstractPreferences {95 public class Preferences extends AbstractPreferences implements IBaseDirectories { 95 96 96 97 private static final String COLOR_PREFIX = "color."; … … 331 332 * @since 7834 332 333 */ 334 @Override 333 335 public File getPreferencesDirectory() { 334 336 if (preferencesDir != null) … … 355 357 * @since 7834 356 358 */ 359 @Override 357 360 public File getUserDataDirectory() { 358 361 if (userdataDir != null) … … 404 407 * @return the cache directory 405 408 */ 409 @Override 406 410 public File getCacheDirectory() { 407 411 if (cacheDir != null) -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r12813 r12855 27 27 import org.apache.commons.jcs.engine.control.CompositeCacheManager; 28 28 import org.apache.commons.jcs.utils.serialization.StandardSerializer; 29 import org.openstreetmap.josm.Main;30 29 import org.openstreetmap.josm.data.preferences.BooleanProperty; 31 30 import org.openstreetmap.josm.data.preferences.IntegerProperty; 31 import org.openstreetmap.josm.spi.preferences.Config; 32 32 import org.openstreetmap.josm.tools.Logging; 33 33 import org.openstreetmap.josm.tools.Utils; … … 101 101 @SuppressWarnings("resource") 102 102 private static void initialize() throws IOException { 103 File cacheDir = new File( Main.pref.getCacheDirectory(), "jcs");103 File cacheDir = new File(Config.getDirs().getCacheDirectory(), "jcs"); 104 104 105 105 if (!cacheDir.exists() && !cacheDir.mkdirs()) -
trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
r12846 r12855 11 11 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 12 12 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener; 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.Version; 15 14 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; … … 57 56 String defPath = null; 58 57 try { 59 defPath = new File( Main.pref.getCacheDirectory(), "tiles").getAbsolutePath();58 defPath = new File(Config.getDirs().getCacheDirectory(), "tiles").getAbsolutePath(); 60 59 } catch (SecurityException e) { 61 60 Logging.warn(e); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r12846 r12855 176 176 */ 177 177 public static String getValidatorDir() { 178 return new File( Main.pref.getUserDataDirectory(), "validator").getAbsolutePath();178 return new File(Config.getDirs().getUserDataDirectory(), "validator").getAbsolutePath(); 179 179 } 180 180 -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12845 r12855 916 916 Main.pref.init(args.hasOption(Option.RESET_PREFERENCES)); 917 917 Config.setPreferencesInstance(Main.pref); 918 Config.setBaseDirectoriesProvider(Main.pref); 918 919 919 920 args.getPreferencesToSet().forEach(Main.pref::put); -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r12846 r12855 425 425 String dir; 426 426 if ("prefs".equals(base) || base.isEmpty()) { 427 dir = Main.pref.getPreferencesDirectory().getAbsolutePath();427 dir = Config.getDirs().getPreferencesDirectory().getAbsolutePath(); 428 428 } else if ("cache".equals(base)) { 429 dir = Main.pref.getCacheDirectory().getAbsolutePath();429 dir = Config.getDirs().getCacheDirectory().getAbsolutePath(); 430 430 } else if ("plugins".equals(base)) { 431 431 dir = Main.pref.getPluginsDirectory().getAbsolutePath(); … … 477 477 engine.eval("API={}; API.pref={}; API.fragments={};"); 478 478 479 engine.eval("homeDir='"+normalizeDirName( Main.pref.getPreferencesDirectory().getAbsolutePath()) +"';");479 engine.eval("homeDir='"+normalizeDirName(Config.getDirs().getPreferencesDirectory().getAbsolutePath()) +"';"); 480 480 engine.eval("josmVersion="+Version.getInstance().getVersion()+';'); 481 481 String className = CustomConfigurator.class.getName(); -
trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
r12846 r12855 29 29 import java.util.regex.Pattern; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask; 33 32 import org.openstreetmap.josm.data.osm.DataSet; … … 117 116 private final Deque<File> deletedLayers = new LinkedList<>(); 118 117 119 private final File autosaveDir = new File( Main.pref.getUserDataDirectory(), AUTOSAVE_DIR);120 private final File deletedLayersDir = new File( Main.pref.getUserDataDirectory(), DELETED_LAYERS_DIR);118 private final File autosaveDir = new File(Config.getDirs().getUserDataDirectory(), AUTOSAVE_DIR); 119 private final File deletedLayersDir = new File(Config.getDirs().getUserDataDirectory(), DELETED_LAYERS_DIR); 121 120 122 121 /** -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
r12846 r12855 18 18 19 19 import org.apache.commons.jcs.access.behavior.ICacheAccess; 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 22 21 import org.openstreetmap.josm.data.cache.JCSCacheManager; … … 70 69 try { 71 70 cache = JCSCacheManager.getCache("geoimage-thumbnails", 0, 120, 72 Main.pref.getCacheDirectory().getPath() + File.separator + "geoimage-thumbnails");71 Config.getDirs().getCacheDirectory().getPath() + File.separator + "geoimage-thumbnails"); 73 72 } catch (IOException e) { 74 73 Logging.warn("Failed to initialize cache for geoimage-thumbnails"); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r12826 r12855 51 51 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 52 52 import org.openstreetmap.josm.gui.widgets.JosmTextField; 53 import org.openstreetmap.josm.spi.preferences.Config; 53 54 import org.openstreetmap.josm.tools.GBC; 54 55 import org.openstreetmap.josm.tools.Logging; … … 369 370 } 370 371 } 371 files = Main.pref.getPreferencesDirectory().listFiles();372 files = Config.getDirs().getPreferencesDirectory().listFiles(); 372 373 if (files != null) { 373 374 for (File f: files) { -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r12846 r12855 11 11 import java.util.concurrent.TimeUnit; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.spi.preferences.Config; 15 14 import org.openstreetmap.josm.tools.Logging; … … 77 76 this.ident = ident; 78 77 this.updateInterval = updateInterval; 79 this.path = new File( Main.pref.getCacheDirectory(), ident);78 this.path = new File(Config.getDirs().getCacheDirectory(), ident); 80 79 } 81 80 -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r12853 r12855 277 277 return null; 278 278 } else if (name.startsWith("josmdir://")) { 279 cacheFile = new File( Main.pref.getUserDataDirectory(), name.substring("josmdir://".length()));279 cacheFile = new File(Config.getDirs().getUserDataDirectory(), name.substring("josmdir://".length())); 280 280 } else if (name.startsWith("josmplugindir://")) { 281 281 cacheFile = new File(Main.pref.getPluginsDirectory(), name.substring("josmplugindir://".length())); … … 448 448 } 449 449 if (destDir == null) { 450 destDir = Main.pref.getCacheDirectory().getPath();450 destDir = Config.getDirs().getCacheDirectory().getPath(); 451 451 } 452 452 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java
r12846 r12855 8 8 import java.net.UnknownHostException; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.preferences.BooleanProperty; 12 11 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler; … … 96 95 */ 97 96 public static String getRemoteControlDir() { 98 return new File( Main.pref.getUserDataDirectory(), "remotecontrol").getAbsolutePath();97 return new File(Config.getDirs().getUserDataDirectory(), "remotecontrol").getAbsolutePath(); 99 98 } 100 99 -
trunk/src/org/openstreetmap/josm/spi/preferences/Config.java
r12854 r12855 5 5 6 6 /** 7 * Class to hold the global preferences object .7 * Class to hold the global preferences object and the provider of base directories. 8 8 * @since 12847 9 9 */ … … 11 11 12 12 private static IPreferences preferences; 13 private static IBaseDirectories baseDirectories; 13 14 14 15 private Config() { … … 26 27 27 28 /** 29 * Get class that provides the location of certain base directories 30 * @return the global {@link IBaseDirectories} instance 31 * @since 12855 32 */ 33 public static IBaseDirectories getDirs() { 34 return baseDirectories; 35 } 36 37 /** 28 38 * Install the global preference instance. 29 39 * @param preferences the global preference instance to set (must not be null) 40 * @since 12847 30 41 */ 31 42 public static void setPreferencesInstance(IPreferences preferences) { 32 43 Config.preferences = Objects.requireNonNull(preferences, "preferences"); 33 44 } 45 46 /** 47 * Install the global base directories provider. 48 * @param baseDirectories the global base directories provider instance to set 49 * (must not be null) 50 * @since 12855 51 */ 52 public static void setBaseDirectoriesProvider(IBaseDirectories baseDirectories) { 53 Config.baseDirectories = Objects.requireNonNull(baseDirectories, "baseDirectories"); 54 } 34 55 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r12846 r12855 927 927 */ 928 928 private static ImageResource getIfAvailableHttp(String url, ImageType type) { 929 try (CachedFile cf = new CachedFile(url).setDestDir(new File(Main.pref.getCacheDirectory(), "images").getPath()); 929 try (CachedFile cf = new CachedFile(url).setDestDir( 930 new File(Config.getDirs().getCacheDirectory(), "images").getPath()); 930 931 InputStream is = cf.getInputStream()) { 931 932 switch (type) { … … 1172 1173 } 1173 1174 // Try user-data directory 1174 if ( Main.pref!= null) {1175 String dir = new File( Main.pref.getUserDataDirectory(), "images").getAbsolutePath();1175 if (Config.getDirs() != null) { 1176 String dir = new File(Config.getDirs().getUserDataDirectory(), "images").getAbsolutePath(); 1176 1177 try { 1177 1178 u = getImageUrl(dir, imageName, additionalClassLoaders); … … 1246 1247 parser.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(new byte[0]))); 1247 1248 1248 try (CachedFile cf = new CachedFile(base + fn).setDestDir(new File(Main.pref.getUserDataDirectory(), "images").getPath()); 1249 try (CachedFile cf = new CachedFile(base + fn).setDestDir( 1250 new File(Config.getDirs().getUserDataDirectory(), "images").getPath()); 1249 1251 InputStream is = cf.getInputStream()) { 1250 1252 parser.parse(new InputSource(is)); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r12851 r12855 477 477 public File getDefaultUserDataDirectory() { 478 478 // Use preferences directory by default 479 return Main.pref.getPreferencesDirectory();479 return Config.getDirs().getPreferencesDirectory(); 480 480 } 481 481 … … 522 522 props.load(fis); 523 523 byte[] content = Files.readAllBytes(templateFile); 524 File cachePath = Main.pref.getCacheDirectory();524 File cachePath = Config.getDirs().getCacheDirectory(); 525 525 Path fontconfigFile = cachePath.toPath().resolve("fontconfig.properties"); 526 526 OutputStream os = Files.newOutputStream(fontconfigFile); -
trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
r12718 r12855 17 17 import java.util.Set; 18 18 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.actions.JoinAreasAction; 21 20 import org.openstreetmap.josm.actions.JoinAreasAction.JoinAreasResult; … … 32 31 import org.openstreetmap.josm.io.OsmWriter; 33 32 import org.openstreetmap.josm.io.OsmWriterFactory; 33 import org.openstreetmap.josm.spi.preferences.Config; 34 34 35 35 /** … … 153 153 private static void saveOptimizedBoundaries(Collection<Way> optimizedWays) { 154 154 DataSet ds = optimizedWays.iterator().next().getDataSet(); 155 File file = new File( Main.pref.getCacheDirectory(), "left-right-hand-traffic.osm");155 File file = new File(Config.getDirs().getCacheDirectory(), "left-right-hand-traffic.osm"); 156 156 try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8); 157 157 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, ds.getVersion()) … … 166 166 167 167 private static Collection<Way> loadOptimizedBoundaries() { 168 try (InputStream is = new FileInputStream(new File( Main.pref.getCacheDirectory(), "left-right-hand-traffic.osm"))) {168 try (InputStream is = new FileInputStream(new File(Config.getDirs().getCacheDirectory(), "left-right-hand-traffic.osm"))) { 169 169 return OsmReader.parseDataSet(is, null).getWays(); 170 170 } catch (IllegalDataException | IOException ex) { -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r12849 r12855 98 98 TimeZone.setDefault(TimeZone.getTimeZone("UTC")); 99 99 Config.setPreferencesInstance(Main.pref); 100 Config.setBaseDirectoriesProvider(Main.pref); 100 101 Main.pref.resetToInitialState(); 101 102 Main.pref.enableSaveOnPut(false); -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r12849 r12855 278 278 279 279 Config.setPreferencesInstance(Main.pref); 280 Config.setBaseDirectoriesProvider(Main.pref); 280 281 // All tests use the same timezone. 281 282 TimeZone.setDefault(DateUtils.UTC);
Note:
See TracChangeset
for help on using the changeset viewer.