Changeset 12636 in josm for trunk/src/org/openstreetmap/josm/Main.java
- Timestamp:
- 2017-08-24T22:53:50+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r12634 r12636 37 37 38 38 import org.openstreetmap.josm.actions.JosmAction; 39 import org.openstreetmap.josm.actions.mapmode.DrawAction;40 39 import org.openstreetmap.josm.data.Bounds; 41 40 import org.openstreetmap.josm.data.Preferences; … … 52 51 import org.openstreetmap.josm.gui.MapFrame; 53 52 import org.openstreetmap.josm.gui.MapFrameListener; 54 import org.openstreetmap.josm.gui.io.SaveLayersDialog;55 53 import org.openstreetmap.josm.gui.layer.MainLayerManager; 56 54 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; … … 59 57 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 60 58 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 61 import org.openstreetmap.josm.gui.util.GuiHelper;62 import org.openstreetmap.josm.gui.util.RedirectInputMap;63 59 import org.openstreetmap.josm.io.FileWatcher; 64 60 import org.openstreetmap.josm.io.OnlineResource; … … 145 141 146 142 /** 147 * Provides access to the layers displayed in the main view.148 * @since 10271149 */150 private static final MainLayerManager layerManager = new MainLayerManager();151 152 /**153 143 * The toolbar preference control to register new actions. 154 144 */ … … 650 640 * @return The layer manager. The value returned will never change. 651 641 * @since 10279 652 */ 642 * @deprecated use {@link MainApplication#getLayerManager} instead 643 */ 644 @Deprecated 653 645 public static MainLayerManager getLayerManager() { 654 return layerManager;646 return MainApplication.getLayerManager(); 655 647 } 656 648 … … 658 650 * Replies the current selected primitives, from a end-user point of view. 659 651 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}. 660 * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,661 * see {@link DrawAction#getInProgressSelection()}.662 *663 652 * @return The current selected primitives, from a end-user point of view. Can be {@code null}. 664 653 * @since 6546 665 654 */ 666 655 public Collection<OsmPrimitive> getInProgressSelection() { 667 DataSet ds = getLayerManager().getEditDataSet(); 668 if (ds == null) return null; 669 return ds.getSelected(); 670 } 671 672 public static void redirectToMainContentPane(JComponent source) { 673 RedirectInputMap.redirect(source, contentPanePrivate); 656 return Collections.emptyList(); 674 657 } 675 658 … … 826 809 /** 827 810 * Closes JOSM and optionally terminates the Java Virtual Machine (JVM). 828 * If there are some unsaved data layers, asks first for user confirmation.829 811 * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code. 830 812 * @param exitCode The return code 831 * @param reason the reason for exiting 832 * @return {@code true} if JOSM has been closed, {@code false} if the user has cancelled the operation. 833 * @since 11093 (3378 with a different function signature) 834 */ 835 public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) { 836 final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> 837 SaveLayersDialog.saveUnsavedModifications(getLayerManager().getLayers(), 838 reason != null ? reason : SaveLayersDialog.Reason.EXIT))); 839 if (proceed) { 840 if (Main.main != null) { 841 Main.main.shutdown(); 842 } 843 844 if (exit) { 845 System.exit(exitCode); 846 } 847 return true; 848 } 849 return false; 813 * @return {@code true} 814 * @since 12636 815 */ 816 public static boolean exitJosm(boolean exit, int exitCode) { 817 if (Main.main != null) { 818 Main.main.shutdown(); 819 } 820 821 if (exit) { 822 System.exit(exitCode); 823 } 824 return true; 850 825 } 851 826 … … 858 833 JCSCacheManager.shutdown(); 859 834 } 860 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)861 getLayerManager().resetState();862 835 try { 863 836 pref.saveDefaults();
Note:
See TracChangeset
for help on using the changeset viewer.