Changeset 14149 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2018-08-12T17:24:32+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.