Changeset 14149 in josm
- Timestamp:
- 2018-08-12T17:24:32+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.groovy
r14020 r14149 25 25 import javax.json.JsonValue 26 26 27 import org.openstreetmap.josm.Main28 27 import org.openstreetmap.josm.data.Preferences 29 28 import org.openstreetmap.josm.data.imagery.ImageryInfo … … 61 60 Locale.setDefault(Locale.ROOT) 62 61 parse_command_line_arguments(args) 63 Main.determinePlatformHook()64 62 def pref = new Preferences(JosmBaseDirectories.getInstance()) 65 63 Config.setPreferencesInstance(pref) -
trunk/scripts/TagInfoExtract.groovy
r14120 r14149 21 21 import javax.json.stream.JsonGenerator 22 22 23 import org.openstreetmap.josm.Main24 23 import org.openstreetmap.josm.actions.DeleteAction 25 24 import org.openstreetmap.josm.command.DeleteCommand 25 import org.openstreetmap.josm.data.Preferences 26 26 import org.openstreetmap.josm.data.Version 27 27 import org.openstreetmap.josm.data.coor.LatLon … … 413 413 */ 414 414 def init() { 415 Main.determinePlatformHook()416 415 Logging.setLogLevel(Logging.LEVEL_INFO) 417 Main.pref.enableSaveOnPut(false)418 Config.setPreferencesInstance( Main.pref)416 Preferences.main().enableSaveOnPut(false) 417 Config.setPreferencesInstance(Preferences.main()) 419 418 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()) 420 419 Config.setUrlsProvider(JosmUrls.getInstance()) -
trunk/src/org/openstreetmap/josm/Main.java
r14143 r14149 43 43 /** 44 44 * Global application preferences 45 */ 45 * @deprecated Use {@link Config#getPref()} or {@link Preferences#main()} 46 */ 47 @Deprecated 46 48 public static final Preferences pref = new Preferences(JosmBaseDirectories.getInstance()); 47 49 -
trunk/src/org/openstreetmap/josm/actions/PreferenceToggleAction.java
r14134 r14149 6 6 import javax.swing.JCheckBoxMenuItem; 7 7 8 import org.openstreetmap.josm. Main;8 import org.openstreetmap.josm.data.Preferences; 9 9 import org.openstreetmap.josm.data.preferences.BooleanProperty; 10 10 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; … … 35 35 checkbox = new JCheckBoxMenuItem(this); 36 36 checkbox.setSelected(pref.get()); 37 Main.pref.addWeakKeyPreferenceChangeListener(prefKey, this);37 Preferences.main().addWeakKeyPreferenceChangeListener(prefKey, this); 38 38 } 39 39 -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r14143 r14149 26 26 27 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.data.Preferences; 28 29 import org.openstreetmap.josm.data.Version; 29 30 import org.openstreetmap.josm.data.osm.DataSet; … … 277 278 String reportHeader = getReportHeader(); 278 279 text.append(reportHeader); 279 Map<String, Setting<?>> settings = Main.pref.getAllSettings();280 Map<String, Setting<?>> settings = Preferences.main().getAllSettings(); 280 281 Set<String> keys = new HashSet<>(settings.keySet()); 281 282 for (String key : keys) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java
r13434 r14149 18 18 import javax.swing.JPopupMenu; 19 19 20 import org.openstreetmap.josm. Main;20 import org.openstreetmap.josm.data.Preferences; 21 21 import org.openstreetmap.josm.data.coor.EastNorth; 22 22 import org.openstreetmap.josm.data.coor.LatLon; … … 234 234 235 235 computeSnapAngles(); 236 Main.pref.addWeakKeyPreferenceChangeListener(DRAW_ANGLESNAP_ANGLES, e -> this.computeSnapAngles());236 Preferences.main().addWeakKeyPreferenceChangeListener(DRAW_ANGLESNAP_ANGLES, e -> this.computeSnapAngles()); 237 237 } 238 238 -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r14148 r14149 36 36 import org.openstreetmap.josm.Main; 37 37 import org.openstreetmap.josm.data.preferences.ColorInfo; 38 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 38 39 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 39 40 import org.openstreetmap.josm.data.preferences.PreferencesReader; … … 116 117 private final HashMap<String, ListenerList<org.openstreetmap.josm.spi.preferences.PreferenceChangedListener>> keyListeners = new HashMap<>(); 117 118 119 private static final Preferences defaultInstance = new Preferences(JosmBaseDirectories.getInstance()); 120 118 121 /** 119 122 * Constructs a new {@code Preferences}. … … 141 144 settingsMap.putAll(pref.settingsMap); 142 145 defaultsMap.putAll(pref.defaultsMap); 146 } 147 148 /** 149 * Returns the main (default) preferences instance. 150 * @return the main (default) preferences instance 151 * @since 14149 152 */ 153 public static Preferences main() { 154 return defaultInstance; 143 155 } 144 156 … … 274 286 public static Collection<String> getAllPossiblePreferenceDirs() { 275 287 Set<String> locations = new HashSet<>(); 276 addPossibleResourceDir(locations, Config.getDirs().getPreferencesDirectory(false).getPath());277 addPossibleResourceDir(locations, Config.getDirs().getUserDataDirectory(false).getPath());288 addPossibleResourceDir(locations, defaultInstance.dirs.getPreferencesDirectory(false).getPath()); 289 addPossibleResourceDir(locations, defaultInstance.dirs.getUserDataDirectory(false).getPath()); 278 290 addPossibleResourceDir(locations, getSystemEnv("JOSM_RESOURCES")); 279 291 addPossibleResourceDir(locations, getSystemProperty("josm.resources")); -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14146 r14149 83 83 import org.openstreetmap.josm.command.SplitWayCommand; 84 84 import org.openstreetmap.josm.data.Bounds; 85 import org.openstreetmap.josm.data.Preferences; 85 86 import org.openstreetmap.josm.data.UndoRedoHandler; 86 87 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; … … 819 820 PlatformManager.getPlatform().preStartupHook(); 820 821 821 Config.setPreferencesInstance(Main.pref); 822 Preferences prefs = Preferences.main(); 823 Config.setPreferencesInstance(prefs); 822 824 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); 823 825 Config.setUrlsProvider(JosmUrls.getInstance()); … … 843 845 844 846 try { 845 Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));847 Preferences.main().init(args.hasOption(Option.RESET_PREFERENCES)); 846 848 } catch (SecurityException e) { 847 849 Logging.log(Logging.LEVEL_ERROR, "Unable to initialize preferences", e); 848 850 } 849 851 850 args.getPreferencesToSet().forEach( Main.pref::put);852 args.getPreferencesToSet().forEach(prefs::put); 851 853 852 854 if (!language.isPresent()) { … … 854 856 } 855 857 updateSystemProperties(); 856 Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() {858 Preferences.main().addPreferenceChangeListener(new PreferenceChangedListener() { 857 859 @Override 858 860 public void preferenceChanged(PreferenceChangeEvent e) { … … 887 889 888 890 if (args.hasOption(Option.LOAD_PREFERENCES)) { 889 XMLCommandProcessor config = new XMLCommandProcessor( Main.pref);891 XMLCommandProcessor config = new XMLCommandProcessor(prefs); 890 892 for (String i : args.get(Option.LOAD_PREFERENCES)) { 891 893 try { -
trunk/src/org/openstreetmap/josm/gui/MainTermination.java
r14140 r14149 8 8 import java.util.Objects; 9 9 10 import org.openstreetmap.josm. Main;10 import org.openstreetmap.josm.data.Preferences; 11 11 import org.openstreetmap.josm.data.cache.JCSCacheManager; 12 12 import org.openstreetmap.josm.tools.ImageProvider; … … 48 48 ImageProvider.shutdown(false); 49 49 try { 50 Main.pref.saveDefaults();50 Preferences.main().saveDefaults(); 51 51 } catch (IOException | InvalidPathException ex) { 52 52 Logging.log(Logging.LEVEL_WARN, tr("Failed to save default preferences."), ex); -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r13901 r14149 100 100 */ 101 101 public static void readXML(File file) { 102 readXML(file, Main.pref);102 readXML(file, Preferences.main()); 103 103 } 104 104 … … 206 206 public static void exportPreferencesKeysByPatternToFile(String fileName, boolean append, String pattern) { 207 207 List<String> keySet = new ArrayList<>(); 208 Map<String, Setting<?>> allSettings = Main.pref.getAllSettings();208 Map<String, Setting<?>> allSettings = Preferences.main().getAllSettings(); 209 209 for (String key: allSettings.keySet()) { 210 210 if (key.matches(pattern)) … … 227 227 228 228 try { 229 String toXML = Main.pref.toXML(true);229 String toXML = Preferences.main().toXML(true); 230 230 DocumentBuilder builder = XmlUtils.newSafeDOMBuilder(); 231 231 document = builder.parse(new ByteArrayInputStream(toXML.getBytes(StandardCharsets.UTF_8))); … … 358 358 for (PluginInformation pi4: toDeletePlugins) { 359 359 pls.remove(pi4.name); 360 new File( Main.pref.getPluginsDirectory(), pi4.name+".jar").deleteOnExit();360 new File(Preferences.main().getPluginsDirectory(), pi4.name+".jar").deleteOnExit(); 361 361 } 362 362 Config.getPref().putList("plugins", pls); … … 375 375 dir = Config.getDirs().getCacheDirectory(false).getAbsolutePath(); 376 376 } else if ("plugins".equals(base)) { 377 dir = Main.pref.getPluginsDirectory().getAbsolutePath();377 dir = Preferences.main().getPluginsDirectory().getAbsolutePath(); 378 378 } else { 379 379 dir = null; -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r13838 r14149 130 130 } 131 131 }); 132 readPreferences( Main.pref);132 readPreferences(Preferences.main()); 133 133 134 134 applyFilter(); … … 181 181 private void readPreferences(Preferences tmpPrefs) { 182 182 Map<String, Setting<?>> loaded; 183 Map<String, Setting<?>> orig = Main.pref.getAllSettings();183 Map<String, Setting<?>> orig = Preferences.main().getAllSettings(); 184 184 Map<String, Setting<?>> defaults = tmpPrefs.getAllDefaults(); 185 185 orig.remove("osm-server.password"); 186 186 defaults.remove("osm-server.password"); 187 if (tmpPrefs != Main.pref) {187 if (tmpPrefs != Preferences.main()) { 188 188 loaded = tmpPrefs.getAllSettings(); 189 189 // plugins preference keys may be changed directly later, after plugins are downloaded … … 262 262 return; 263 263 264 Preferences tmpPrefs = new Preferences( Main.pref);264 Preferences tmpPrefs = new Preferences(Preferences.main()); 265 265 266 266 StringBuilder log = new StringBuilder(); … … 324 324 325 325 for (Entry<String, String> e: profileTypes.entrySet()) { 326 menu.add(new ExportProfileAction( Main.pref, e.getKey(), e.getValue()));326 menu.add(new ExportProfileAction(Preferences.main(), e.getKey(), e.getValue())); 327 327 } 328 328 … … 339 339 "Are you sure you want to continue?") 340 340 +"</html>", null, "")) { 341 Main.pref.resetToDefault();341 Preferences.main().resetToDefault(); 342 342 try { 343 Main.pref.save();343 Preferences.main().save(); 344 344 } catch (IOException | InvalidPathException e) { 345 345 Logging.log(Logging.LEVEL_WARN, "Exception while saving preferences:", e); 346 346 } 347 readPreferences( Main.pref);347 readPreferences(Preferences.main()); 348 348 applyFilter(); 349 349 } … … 412 412 @Override 413 413 public void actionPerformed(ActionEvent ae) { 414 Preferences tmpPrefs = new Preferences( Main.pref);414 Preferences tmpPrefs = new Preferences(Preferences.main()); 415 415 CustomConfigurator.readXML(file, tmpPrefs); 416 416 readPreferences(tmpPrefs); … … 460 460 for (PrefEntry e : allData) { 461 461 if (e.isChanged()) { 462 Main.pref.putSetting(e.getKey(), e.getValue().getValue() == null ? null : e.getValue());462 Preferences.main().putSetting(e.getKey(), e.getValue().getValue() == null ? null : e.getValue()); 463 463 } 464 464 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r13986 r14149 36 36 import javax.swing.table.DefaultTableCellRenderer; 37 37 38 import org.openstreetmap.josm. Main;38 import org.openstreetmap.josm.data.Preferences; 39 39 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 40 40 import org.openstreetmap.josm.data.preferences.ColorInfo; … … 269 269 public void addGui(final PreferenceTabbedPane gui) { 270 270 fixColorPrefixes(); 271 setColors( Main.pref.getAllNamedColors());271 setColors(Preferences.main().getAllNamedColors()); 272 272 273 273 colorEdit = new JButton(tr("Choose")); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r14052 r14149 45 45 import org.openstreetmap.josm.Main; 46 46 import org.openstreetmap.josm.actions.ExpertToggleAction; 47 import org.openstreetmap.josm.data.Preferences; 47 48 import org.openstreetmap.josm.data.Version; 48 49 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 300 301 if (answer != 0 /* OK */) 301 302 return; 302 Main.pref.setPluginSites(pnl.getUpdateSites());303 Preferences.main().setPluginSites(pnl.getUpdateSites()); 303 304 } 304 305 … … 376 377 @Override 377 378 public void actionPerformed(ActionEvent e) { 378 Collection<String> pluginSites = Main.pref.getOnlinePluginSites();379 Collection<String> pluginSites = Preferences.main().getOnlinePluginSites(); 379 380 if (pluginSites.isEmpty()) { 380 381 return; … … 430 431 // the async task for downloading plugin information 431 432 final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask( 432 Main.pref.getOnlinePluginSites());433 Preferences.main().getOnlinePluginSites()); 433 434 434 435 // to be run asynchronously after the plugin download … … 601 602 super(new GridBagLayout()); 602 603 add(new JLabel(tr("Add JOSM Plugin description URL.")), GBC.eol()); 603 for (String s : Main.pref.getPluginSites()) {604 for (String s : Preferences.main().getPluginSites()) { 604 605 model.addElement(s); 605 606 } -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r14138 r14149 29 29 import java.util.zip.ZipFile; 30 30 31 import org.openstreetmap.josm. Main;31 import org.openstreetmap.josm.data.Preferences; 32 32 import org.openstreetmap.josm.spi.preferences.Config; 33 33 import org.openstreetmap.josm.tools.HttpClient; … … 298 298 cacheFile = new File(Config.getDirs().getUserDataDirectory(false), name.substring("josmdir://".length())); 299 299 } else if (name.startsWith("josmplugindir://")) { 300 cacheFile = new File( Main.pref.getPluginsDirectory(), name.substring("josmplugindir://".length()));300 cacheFile = new File(Preferences.main().getPluginsDirectory(), name.substring("josmplugindir://".length())); 301 301 } else { 302 302 cacheFile = new File(name); -
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r14005 r14149 11 11 import java.util.List; 12 12 13 import org.openstreetmap.josm. Main;13 import org.openstreetmap.josm.data.Preferences; 14 14 import org.openstreetmap.josm.gui.MapFrame; 15 15 import org.openstreetmap.josm.gui.MapFrameListener; … … 167 167 */ 168 168 public ClassLoader getPluginResourceClassLoader() { 169 File pluginDir = Main.pref.getPluginsDirectory();169 File pluginDir = Preferences.main().getPluginsDirectory(); 170 170 File pluginJar = new File(pluginDir, info.name + ".jar"); 171 171 final URL pluginJarUrl = Utils.fileToURL(pluginJar); -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r13761 r14149 15 15 import java.util.LinkedList; 16 16 17 import org.openstreetmap.josm. Main;17 import org.openstreetmap.josm.data.Preferences; 18 18 import org.openstreetmap.josm.data.Version; 19 19 import org.openstreetmap.josm.gui.ExtendedDialog; … … 155 155 @Override 156 156 protected void realRun() throws SAXException, IOException { 157 File pluginDir = Main.pref.getPluginsDirectory();157 File pluginDir = Preferences.main().getPluginsDirectory(); 158 158 if (!pluginDir.exists() && !pluginDir.mkdirs()) { 159 159 String message = tr("Failed to create plugin directory ''{0}''", pluginDir.toString()); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r14121 r14149 55 55 import org.openstreetmap.josm.Main; 56 56 import org.openstreetmap.josm.actions.RestartAction; 57 import org.openstreetmap.josm.data.Preferences; 57 58 import org.openstreetmap.josm.data.PreferencesUtils; 58 59 import org.openstreetmap.josm.data.Version; … … 535 536 } 536 537 if (NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)) { 537 for (String updateSite : Main.pref.getPluginSites()) {538 for (String updateSite : Preferences.main().getPluginSites()) { 538 539 try { 539 540 OnlineResource.JOSM_WEBSITE.checkOfflineAccess(updateSite, Config.getUrls().getJOSMWebsite()); … … 598 599 // Update plugin list 599 600 final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask( 600 Main.pref.getOnlinePluginSites());601 Preferences.main().getOnlinePluginSites()); 601 602 MainApplication.worker.submit(pluginInfoDownloadTask); 602 603 … … 743 744 private static void extendJoinedPluginResourceCL(Collection<PluginInformation> plugins) { 744 745 // iterate all plugins and collect all libraries of all plugins: 745 File pluginDir = Main.pref.getPluginsDirectory();746 File pluginDir = Preferences.main().getPluginsDirectory(); 746 747 DynamicURLClassLoader cl = getJoinedPluginResourceCL(); 747 748 … … 1076 1077 ReadRemotePluginInformationTask task1 = new ReadRemotePluginInformationTask( 1077 1078 monitor.createSubTaskMonitor(1, false), 1078 Main.pref.getOnlinePluginSites(), displayErrMsg1079 Preferences.main().getOnlinePluginSites(), displayErrMsg 1079 1080 ); 1080 1081 task1.run(); … … 1248 1249 */ 1249 1250 public static void installDownloadedPlugins(Collection<PluginInformation> pluginsToLoad, boolean dowarn) { 1250 File pluginDir = Main.pref.getPluginsDirectory();1251 File pluginDir = Preferences.main().getPluginsDirectory(); 1251 1252 if (!pluginDir.exists() || !pluginDir.isDirectory() || !pluginDir.canWrite()) 1252 1253 return; … … 1326 1327 */ 1327 1328 public static File findUpdatedJar(String name) { 1328 File pluginDir = Main.pref.getPluginsDirectory();1329 File pluginDir = Preferences.main().getPluginsDirectory(); 1329 1330 // Find the downloaded file. We have tried to install the downloaded plugins 1330 1331 // (PluginHandler.installDownloadedPlugins). This succeeds depending on the platform. -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r12846 r14149 31 31 import javax.swing.JScrollPane; 32 32 33 import org.openstreetmap.josm. Main;33 import org.openstreetmap.josm.data.Preferences; 34 34 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 35 35 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 245 245 */ 246 246 protected void cachePluginList(String site, String list) { 247 File pluginDir = Main.pref.getPluginsDirectory();247 File pluginDir = Preferences.main().getPluginsDirectory(); 248 248 if (!pluginDir.exists() && !pluginDir.mkdirs()) { 249 249 Logging.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", … … 318 318 } 319 319 320 File pluginDir = Main.pref.getPluginsDirectory();320 File pluginDir = Preferences.main().getPluginsDirectory(); 321 321 for (String site: sites) { 322 322 String printsite = site.replaceAll("%<(.*)>", ""); -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r14138 r14149 22 22 import javax.swing.text.JTextComponent; 23 23 24 import org.openstreetmap.josm. Main;24 import org.openstreetmap.josm.data.Preferences; 25 25 import org.openstreetmap.josm.spi.preferences.Config; 26 26 … … 386 386 PlatformManager.getPlatform().initSystemShortcuts(); 387 387 // (2) User defined shortcuts 388 Main.pref.getAllPrefixCollectionKeys("shortcut.entry.").stream()388 Preferences.main().getAllPrefixCollectionKeys("shortcut.entry.").stream() 389 389 .map(Shortcut::new) 390 390 .filter(sc -> !findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()).isPresent()) -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r14143 r14149 16 16 import org.openstreetmap.josm.actions.DeleteAction; 17 17 import org.openstreetmap.josm.command.DeleteCommand; 18 import org.openstreetmap.josm.data.Preferences; 18 19 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 19 20 import org.openstreetmap.josm.data.preferences.JosmUrls; … … 104 105 System.setProperty("josm.home", josmHome); 105 106 TimeZone.setDefault(DateUtils.UTC); 106 Config.setPreferencesInstance(Main.pref); 107 Preferences pref = Preferences.main(); 108 Config.setPreferencesInstance(pref); 107 109 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); 108 110 Config.setUrlsProvider(JosmUrls.getInstance()); 109 Main.pref.resetToInitialState();110 Main.pref.enableSaveOnPut(false);111 pref.resetToInitialState(); 112 pref.enableSaveOnPut(false); 111 113 I18n.init(); 112 114 // initialize the plaform hook, and … … 115 117 116 118 Logging.setLogLevel(Logging.LEVEL_INFO); 117 Main.pref.init(false);119 pref.init(false); 118 120 String url = Config.getPref().get("osm-server.url"); 119 121 if (url == null || url.isEmpty() || isProductionApiUrl(url)) { -
trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java
r14052 r14149 13 13 import org.junit.Rule; 14 14 import org.junit.Test; 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.TestUtils; 16 import org.openstreetmap.josm.data.Preferences; 17 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 18 import org.openstreetmap.josm.plugins.PluginDownloadTask; … … 62 62 new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath 63 63 ); 64 final File pluginDir = Main.pref.getPluginsDirectory();64 final File pluginDir = Preferences.main().getPluginsDirectory(); 65 65 final File pluginFile = new File(pluginDir, "dummy_plugin.jar"); 66 66 final File pluginFileNew = new File(pluginDir, "dummy_plugin.jar.new"); … … 104 104 new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath 105 105 ); 106 final File pluginDir = Main.pref.getPluginsDirectory();106 final File pluginDir = Preferences.main().getPluginsDirectory(); 107 107 final File pluginFile = new File(pluginDir, "corrupted_plugin.jar"); 108 108 final File pluginFileNew = new File(pluginDir, "corrupted_plugin.jar.new"); -
trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.java
r14138 r14149 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 9 … … 33 32 " <tag key='osm-server.url' value='http://fake.xxx/api'/>%n" + 34 33 "</preferences>%n", Version.getInstance().getVersion()), 35 Main.pref.toXML(true));34 Preferences.main().toXML(true)); 36 35 } 37 36 } -
trunk/test/unit/org/openstreetmap/josm/data/preferences/NamedColorPropertyTest.java
r12989 r14149 11 11 import org.junit.Rule; 12 12 import org.junit.Test; 13 import org.openstreetmap.josm. Main;13 import org.openstreetmap.josm.data.Preferences; 14 14 import org.openstreetmap.josm.spi.preferences.Config; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 18 18 19 19 /** 20 * Test {@link ColorProperty}20 * Test {@link NamedColorProperty} 21 21 * @author Michael Zangl 22 22 */ … … 39 39 40 40 /** 41 * Test {@link ColorProperty#get()}41 * Test {@link NamedColorProperty#get()} 42 42 */ 43 43 @Test … … 47 47 48 48 /** 49 * Test {@link ColorProperty#put}49 * Test {@link NamedColorProperty#put} 50 50 */ 51 51 @Test … … 67 67 public void testColorAlpha() { 68 68 assertEquals(0x12, new NamedColorProperty("foo", new Color(0x12345678, true)).get().getAlpha()); 69 assertTrue( Main.pref.putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));69 assertTrue(Preferences.main().putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar"))); 70 70 assertEquals(0x12, new NamedColorProperty("bar", Color.RED).get().getAlpha()); 71 71 } … … 80 80 81 81 /** 82 * Test {@link ColorProperty#getChildColor(String)}82 * Test {@link NamedColorProperty#getChildColor(String)} 83 83 */ 84 84 @Test -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r14138 r14149 26 26 import org.junit.Rule; 27 27 import org.junit.Test; 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.TestUtils; 30 29 import org.openstreetmap.josm.data.Bounds; … … 217 216 assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0)); 218 217 219 assertEquals("Green Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));218 assertEquals("Green Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail")); 220 219 } 221 220 … … 244 243 this.assertSingleSelectedSourceLabel("Magenta Tiles"); 245 244 246 assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));245 assertEquals("Magenta Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail")); 247 246 } 248 247 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
r14081 r14149 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.TestUtils; 9 import org.openstreetmap.josm.data.Preferences; 10 10 import org.openstreetmap.josm.testutils.JOSMTestRules; 11 11 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; … … 35 35 "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION 36 36 )); 37 new ExportProfileAction( Main.pref, "foo", "bar").actionPerformed(null);38 new ExportProfileAction( Main.pref, "expert", "expert").actionPerformed(null);37 new ExportProfileAction(Preferences.main(), "foo", "bar").actionPerformed(null); 38 new ExportProfileAction(Preferences.main(), "expert", "expert").actionPerformed(null); 39 39 } 40 40 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r14138 r14149 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.TestUtils; 25 import org.openstreetmap.josm.data.Preferences; 25 26 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 26 27 import org.openstreetmap.josm.gui.util.GuiHelper; … … 97 98 this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar"); 98 99 this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar"); 99 this.pluginDir = Main.pref.getPluginsDirectory();100 this.pluginDir = Preferences.main().getPluginsDirectory(); 100 101 this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar"); 101 102 this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new"); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r14081 r14149 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.TestUtils; 19 import org.openstreetmap.josm.data.Preferences; 19 20 import org.openstreetmap.josm.spi.preferences.Config; 20 21 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 66 67 this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar"); 67 68 this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar"); 68 this.pluginDir = Main.pref.getPluginsDirectory();69 this.pluginDir = Preferences.main().getPluginsDirectory(); 69 70 this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar"); 70 71 this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new"); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
r14138 r14149 19 19 import org.junit.Rule; 20 20 import org.junit.Test; 21 import org.openstreetmap.josm. Main;21 import org.openstreetmap.josm.data.Preferences; 22 22 import org.openstreetmap.josm.data.gpx.GpxData; 23 23 import org.openstreetmap.josm.data.osm.DataSet; … … 93 93 // Download complete list of plugins 94 94 ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask( 95 Main.pref.getOnlinePluginSites());95 Preferences.main().getOnlinePluginSites()); 96 96 pluginInfoDownloadTask.run(); 97 97 List<PluginInformation> plugins = pluginInfoDownloadTask.getAvailablePlugins(); -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r14138 r14149 26 26 import org.openstreetmap.josm.actions.DeleteAction; 27 27 import org.openstreetmap.josm.command.DeleteCommand; 28 import org.openstreetmap.josm.data.Preferences; 28 29 import org.openstreetmap.josm.data.UserIdentityManager; 29 30 import org.openstreetmap.josm.data.Version; … … 418 419 } 419 420 420 Config.setPreferencesInstance(Main.pref); 421 Preferences pref = Preferences.main(); 422 Config.setPreferencesInstance(pref); 421 423 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); 422 424 Config.setUrlsProvider(JosmUrls.getInstance()); … … 449 451 if (usePreferences) { 450 452 @SuppressWarnings("unchecked") 451 final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField( Main.pref, "defaultsMap");453 final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(pref, "defaultsMap"); 452 454 defaultsMap.clear(); 453 Main.pref.resetToInitialState();454 Main.pref.enableSaveOnPut(false);455 pref.resetToInitialState(); 456 pref.enableSaveOnPut(false); 455 457 // No pref init -> that would only create the preferences file. 456 458 // We force the use of a wrong API server, just in case anyone attempts an upload … … 543 545 MemoryManagerTest.resetState(true); 544 546 cleanLayerEnvironment(); 545 Main.pref.resetToInitialState();547 Preferences.main().resetToInitialState(); 546 548 System.gc(); 547 549 } … … 584 586 // TODO: Remove global listeners and other global state. 585 587 ProjectionRegistry.clearProjectionChangeListeners(); 586 Main.pref.resetToInitialState();588 Preferences.main().resetToInitialState(); 587 589 588 590 if (this.assumeRevisionString != null && this.originalVersion != null) {
Note:
See TracChangeset
for help on using the changeset viewer.