Changeset 12637 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-08-24T23:29:01+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r12636 r12637 11 11 import java.text.MessageFormat; 12 12 import java.util.ArrayList; 13 import java.util.Arrays;14 13 import java.util.Collection; 15 14 import java.util.Collections; … … 32 31 import javax.swing.JComponent; 33 32 import javax.swing.KeyStroke; 34 import javax.swing.LookAndFeel;35 import javax.swing.UIManager;36 import javax.swing.UnsupportedLookAndFeelException;37 33 38 34 import org.openstreetmap.josm.actions.JosmAction; … … 54 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 55 51 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 56 import org.openstreetmap.josm.gui.preferences.display.LafPreference;57 52 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 58 53 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 60 55 import org.openstreetmap.josm.io.OnlineResource; 61 56 import org.openstreetmap.josm.io.OsmApi; 62 import org.openstreetmap.josm.plugins.PluginHandler;63 57 import org.openstreetmap.josm.tools.CheckParameterUtil; 64 58 import org.openstreetmap.josm.tools.I18n; … … 132 126 * The MapFrame. 133 127 * <p> 134 * There should be no need to access this to access any map data. Use {@link #layerManager} instead.128 * There should be no need to access this to access any map data. Use {@link MainApplication#getLayerManager} instead. 135 129 * 136 * @deprecated Use {@link org.openstreetmap.josm.gui.MainApplication#getMap()} instead130 * @deprecated Use {@link MainApplication#getMap()} instead 137 131 * @see MainPanel 138 132 */ … … 142 136 /** 143 137 * The toolbar preference control to register new actions. 144 */ 138 * @deprecated Use {@link MainApplication#getToolbar} instead 139 */ 140 @Deprecated 145 141 public static volatile ToolbarPreferences toolbar; 146 142 … … 744 740 public static void preConstructorInit() { 745 741 ProjectionPreference.setProjection(); 746 747 String defaultlaf = platform.getDefaultStyle();748 String laf = LafPreference.LAF.get();749 try {750 UIManager.setLookAndFeel(laf);751 } catch (final NoClassDefFoundError | ClassNotFoundException e) {752 // Try to find look and feel in plugin classloaders753 Logging.trace(e);754 Class<?> klass = null;755 for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {756 try {757 klass = cl.loadClass(laf);758 break;759 } catch (ClassNotFoundException ex) {760 Logging.trace(ex);761 }762 }763 if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {764 try {765 UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());766 } catch (ReflectiveOperationException ex) {767 Logging.log(Logging.LEVEL_WARN, "Cannot set Look and Feel: " + laf + ": "+ex.getMessage(), ex);768 } catch (UnsupportedLookAndFeelException ex) {769 Logging.info("Look and Feel not supported: " + laf);770 LafPreference.LAF.put(defaultlaf);771 Logging.trace(ex);772 }773 } else {774 Logging.info("Look and Feel not found: " + laf);775 LafPreference.LAF.put(defaultlaf);776 }777 } catch (UnsupportedLookAndFeelException e) {778 Logging.info("Look and Feel not supported: " + laf);779 LafPreference.LAF.put(defaultlaf);780 Logging.trace(e);781 } catch (InstantiationException | IllegalAccessException e) {782 Logging.error(e);783 }784 toolbar = new ToolbarPreferences();785 786 UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));787 UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));788 UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel"));789 UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));790 // Ensures caret color is the same than text foreground color, see #12257791 // See http://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html792 for (String p : Arrays.asList(793 "EditorPane", "FormattedTextField", "PasswordField", "TextArea", "TextField", "TextPane")) {794 UIManager.put(p+".caretForeground", UIManager.getColor(p+".foreground"));795 }796 797 742 I18n.translateJavaInternalMessages(); 798 743 799 744 // init default coordinate format 800 //801 745 try { 802 746 CoordinateFormat.setCoordinateFormat(CoordinateFormat.valueOf(Main.pref.get("coordinates"))); -
trunk/src/org/openstreetmap/josm/actions/ExpertToggleAction.java
r12542 r12637 7 7 import java.awt.event.ActionEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.preferences.BooleanProperty; 10 import org.openstreetmap.josm.gui.MainApplication; 11 11 import org.openstreetmap.josm.tools.ListenerList; 12 12 … … 100 100 ); 101 101 putValue("toolbar", "expertmode"); 102 if (Main .toolbar!= null) {103 Main .toolbar.register(this);102 if (MainApplication.getToolbar() != null) { 103 MainApplication.getToolbar().register(this); 104 104 } 105 105 setSelected(PREF_EXPERT.get()); -
trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java
r11278 r12637 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.gui.MainApplication; 22 23 import org.openstreetmap.josm.gui.util.GuiHelper; 23 24 import org.openstreetmap.josm.tools.Shortcut; … … 43 44 putValue("help", ht("/Action/FullscreenView")); 44 45 putValue("toolbar", "fullscreen"); 45 Main .toolbar.register(this);46 MainApplication.getToolbar().register(this); 46 47 gd = GraphicsEnvironment.isHeadless() ? null : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); 47 48 setSelected(Main.pref.getBoolean("draw.fullscreen", false)); -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r12279 r12637 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog; 13 14 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; … … 31 32 putValue("help", ht("/Action/ObjectHistory")); 32 33 putValue("toolbar", "action/historyinfo"); 33 Main .toolbar.register(this);34 MainApplication.getToolbar().register(this); 34 35 setEnabled(true); 35 36 } -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r12636 r12637 85 85 putValue("toolbar", toolbarId); 86 86 } 87 if (registerInToolbar && Main .toolbar!= null) {88 Main .toolbar.register(this);87 if (registerInToolbar && MainApplication.getToolbar() != null) { 88 MainApplication.getToolbar().register(this); 89 89 } 90 90 if (installAdapters) { -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r12630 r12637 97 97 putValue("toolbar", "action/move/right"); 98 98 } 99 Main .toolbar.register(this);99 MainApplication.getToolbar().register(this); 100 100 } 101 101 -
trunk/src/org/openstreetmap/josm/actions/RestartAction.java
r12636 r12637 49 49 putValue("help", ht("/Action/Restart")); 50 50 putValue("toolbar", "action/restart"); 51 if (Main .toolbar!= null) {52 Main .toolbar.register(this);51 if (MainApplication.getToolbar() != null) { 52 MainApplication.getToolbar().register(this); 53 53 } 54 54 setEnabled(isRestartSupported()); -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r12636 r12637 65 65 putValue("help", ht("/Action/ShowStatusReport")); 66 66 putValue("toolbar", "help/showstatusreport"); 67 Main .toolbar.register(this);67 MainApplication.getToolbar().register(this); 68 68 } 69 69 -
trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java
r12636 r12637 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory; 11 10 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 12 11 import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer; 12 import org.openstreetmap.josm.gui.MainApplication; 13 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 14 import org.openstreetmap.josm.tools.Shortcut; … … 31 31 ); 32 32 putValue("toolbar", "wireframe"); 33 Main .toolbar.register(this);33 MainApplication.getToolbar().register(this); 34 34 setSelected(MapRendererFactory.getInstance().isWireframeMapRendererActive()); 35 35 notifySelectedState(); -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r12636 r12637 465 465 466 466 // add custom search button to toolbar preferences 467 Main .toolbar.addCustomButton(res, -1, false);467 MainApplication.getToolbar().addCustomButton(res, -1, false); 468 468 } 469 469 -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r12636 r12637 53 53 super(tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false); 54 54 putValue("toolbar", "imagery-offset"); 55 Main .toolbar.register(this);55 MainApplication.getToolbar().register(this); 56 56 } 57 57 … … 271 271 for (Object item : dynamicItems) { 272 272 if (item instanceof JMenuItem) { 273 Optional.ofNullable(((JMenuItem) item).getAction()).ifPresent(Main .toolbar::unregister);273 Optional.ofNullable(((JMenuItem) item).getAction()).ifPresent(MainApplication.getToolbar()::unregister); 274 274 remove((JMenuItem) item); 275 275 } else if (item instanceof MenuComponent) { -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12636 r12637 46 46 import javax.swing.JComponent; 47 47 import javax.swing.JOptionPane; 48 import javax.swing.LookAndFeel; 48 49 import javax.swing.RepaintManager; 49 50 import javax.swing.SwingUtilities; 51 import javax.swing.UIManager; 52 import javax.swing.UnsupportedLookAndFeelException; 50 53 51 54 import org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager; … … 74 77 import org.openstreetmap.josm.gui.layer.MainLayerManager; 75 78 import org.openstreetmap.josm.gui.layer.TMSLayer; 79 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 80 import org.openstreetmap.josm.gui.preferences.display.LafPreference; 76 81 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 77 82 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; … … 98 103 import org.openstreetmap.josm.tools.HttpClient; 99 104 import org.openstreetmap.josm.tools.I18n; 105 import org.openstreetmap.josm.tools.ImageProvider; 100 106 import org.openstreetmap.josm.tools.Logging; 101 107 import org.openstreetmap.josm.tools.OpenBrowser; … … 127 133 */ 128 134 static MapFrame map; 135 136 /** 137 * The toolbar preference control to register new actions. 138 */ 139 static volatile ToolbarPreferences toolbar; 129 140 130 141 private final MainFrame mainFrame; … … 237 248 } else { 238 249 // required for running some tests. 239 panel = new MainPanel( MainApplication.getLayerManager());250 panel = new MainPanel(layerManager); 240 251 menu = new MainMenu(); 241 252 } … … 256 267 } 257 268 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask) 258 getLayerManager().resetState();269 layerManager.resetState(); 259 270 super.shutdown(); 260 271 if (!GraphicsEnvironment.isHeadless()) { … … 289 300 return ((DrawAction) map.mapMode).getInProgressSelection(); 290 301 } else { 291 DataSet ds = getLayerManager().getEditDataSet();302 DataSet ds = layerManager.getEditDataSet(); 292 303 if (ds == null) return null; 293 304 return ds.getSelected(); … … 307 318 * Returns the main layer manager that is used by the map view. 308 319 * @return The layer manager. The value returned will never change. 309 * @since 12636 (as a replacement to {@code Main Application.getLayerManager()})320 * @since 12636 (as a replacement to {@code Main.getLayerManager()}) 310 321 */ 311 322 @SuppressWarnings("deprecation") … … 324 335 public static MapFrame getMap() { 325 336 return map; 337 } 338 339 /** 340 * Returns the toolbar preference control to register new actions. 341 * @return the toolbar preference control 342 * @since 12637 (as a replacement to {@code Main.toolbar}) 343 */ 344 public static ToolbarPreferences getToolbar() { 345 return toolbar; 326 346 } 327 347 … … 351 371 public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) { 352 372 final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> 353 SaveLayersDialog.saveUnsavedModifications( MainApplication.getLayerManager().getLayers(),373 SaveLayersDialog.saveUnsavedModifications(layerManager.getLayers(), 354 374 reason != null ? reason : SaveLayersDialog.Reason.EXIT))); 355 375 if (proceed) { … … 430 450 * @param argArray Command-line arguments 431 451 */ 452 @SuppressWarnings("deprecation") 432 453 public static void main(final String[] argArray) { 433 454 I18n.init(); … … 576 597 577 598 monitor.indeterminateSubTask(tr("Setting defaults")); 599 setupUIManager(); 600 toolbar = new ToolbarPreferences(); 601 Main.toolbar = toolbar; 578 602 preConstructorInit(); 579 603 … … 627 651 Logging.info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console"); 628 652 RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager()); 653 } 654 } 655 656 static void setupUIManager() { 657 String defaultlaf = platform.getDefaultStyle(); 658 String laf = LafPreference.LAF.get(); 659 try { 660 UIManager.setLookAndFeel(laf); 661 } catch (final NoClassDefFoundError | ClassNotFoundException e) { 662 // Try to find look and feel in plugin classloaders 663 Logging.trace(e); 664 Class<?> klass = null; 665 for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) { 666 try { 667 klass = cl.loadClass(laf); 668 break; 669 } catch (ClassNotFoundException ex) { 670 Logging.trace(ex); 671 } 672 } 673 if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) { 674 try { 675 UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance()); 676 } catch (ReflectiveOperationException ex) { 677 Logging.log(Logging.LEVEL_WARN, "Cannot set Look and Feel: " + laf + ": "+ex.getMessage(), ex); 678 } catch (UnsupportedLookAndFeelException ex) { 679 Logging.info("Look and Feel not supported: " + laf); 680 LafPreference.LAF.put(defaultlaf); 681 Logging.trace(ex); 682 } 683 } else { 684 Logging.info("Look and Feel not found: " + laf); 685 LafPreference.LAF.put(defaultlaf); 686 } 687 } catch (UnsupportedLookAndFeelException e) { 688 Logging.info("Look and Feel not supported: " + laf); 689 LafPreference.LAF.put(defaultlaf); 690 Logging.trace(e); 691 } catch (InstantiationException | IllegalAccessException e) { 692 Logging.error(e); 693 } 694 695 UIManager.put("OptionPane.okIcon", ImageProvider.get("ok")); 696 UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon")); 697 UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel")); 698 UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon")); 699 // Ensures caret color is the same than text foreground color, see #12257 700 // See http://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html 701 for (String p : Arrays.asList( 702 "EditorPane", "FormattedTextField", "PasswordField", "TextArea", "TextField", "TextPane")) { 703 UIManager.put(p+".caretForeground", UIManager.getColor(p+".foreground")); 629 704 } 630 705 } -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r12630 r12637 122 122 } else { 123 123 x = margin; 124 y = parentWindow.getHeight() - Main .toolbar.control.getSize().height - size.height - margin;124 y = parentWindow.getHeight() - MainApplication.getToolbar().control.getSize().height - size.height - margin; 125 125 } 126 126 parentWindow.getLayeredPane().add(currentNotificationPanel, JLayeredPane.POPUP_LAYER, 0); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r12634 r12637 548 548 SETTINGS_FACTORIES.add(new BackupPreference.Factory()); 549 549 SETTINGS_FACTORIES.add(new PluginPreference.Factory()); 550 SETTINGS_FACTORIES.add(Main .toolbar);550 SETTINGS_FACTORIES.add(MainApplication.getToolbar()); 551 551 SETTINGS_FACTORIES.add(new AudioPreference.Factory()); 552 552 SETTINGS_FACTORIES.add(new ShortcutPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r12620 r12637 68 68 import org.openstreetmap.josm.data.imagery.ImageryInfo; 69 69 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 70 import org.openstreetmap.josm.gui.MainApplication; 70 71 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 71 72 import org.openstreetmap.josm.gui.util.GuiHelper; … … 502 503 t.remove(res); 503 504 Main.pref.putCollection("toolbar", t); 504 Main .toolbar.refreshToolbarControl();505 MainApplication.getToolbar().refreshToolbarControl(); 505 506 } 506 507 }); … … 523 524 p.setVisible(true); 524 525 // refresh toolbar to try using changed shortcuts without restart 525 Main .toolbar.refreshToolbarControl();526 MainApplication.getToolbar().refreshToolbarControl(); 526 527 } 527 528 }); … … 987 988 } 988 989 Main.pref.putCollection("toolbar", t); 989 Main .toolbar.refreshToolbarControl();990 MainApplication.getToolbar().refreshToolbarControl(); 990 991 return false; 991 992 } … … 1214 1215 } 1215 1216 Main.pref.putCollection("toolbar", t); 1216 Main .toolbar.refreshToolbarControl();1217 MainApplication.getToolbar().refreshToolbarControl(); 1217 1218 } 1218 1219 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r12636 r12637 625 625 public void actionPerformed(ActionEvent ae) { 626 626 String res = getToolbarString(); 627 Main .toolbar.addCustomButton(res, toolbarIndex, true);627 MainApplication.getToolbar().addCustomButton(res, toolbarIndex, true); 628 628 } 629 629 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchAction.java
r12636 r12637 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.JosmAction; 11 10 import org.openstreetmap.josm.gui.MainApplication; … … 25 24 Shortcut.registerShortcut("preset:search", tr("Search presets"), KeyEvent.VK_F3, Shortcut.DIRECT), false); 26 25 putValue("toolbar", "presets/search"); 27 Main .toolbar.register(this);26 MainApplication.getToolbar().register(this); 28 27 } 29 28 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java
r12636 r12637 39 39 false); 40 40 putValue("toolbar", "presets/search-objects"); 41 Main .toolbar.register(this);41 MainApplication.getToolbar().register(this); 42 42 } 43 43 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
r12636 r12637 219 219 final TaggingPreset preset = getSelectedPreset(); 220 220 if (preset != null) { 221 Main .toolbar.addCustomButton(preset.getToolbarString(), -1, false);221 MainApplication.getToolbar().addCustomButton(preset.getToolbarString(), -1, false); 222 222 } 223 223 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
r12620 r12637 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 import org.openstreetmap.josm.gui.MainApplication; 18 19 import org.openstreetmap.josm.gui.MenuScroller; 19 20 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; … … 62 63 for (TaggingPreset tp: taggingPresets) { 63 64 if (!(tp instanceof TaggingPresetSeparator)) { 64 Main .toolbar.register(tp);65 MainApplication.getToolbar().register(tp); 65 66 } 66 67 }
Note:
See TracChangeset
for help on using the changeset viewer.