Changeset 5829 in josm for trunk/src/org
- Timestamp:
- 2013-04-06T14:56:43+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r5696 r5829 95 95 import org.openstreetmap.josm.tools.WindowGeometry; 96 96 97 /** 98 * Abstract class holding various static global variables and methods used in large parts of JOSM application. 99 * @since 98 100 */ 97 101 abstract public class Main { 98 102 … … 108 112 return true; 109 113 } 114 110 115 /** 111 116 * Global parent component for all dialogs and message boxes 112 117 */ 113 118 public static Component parent; 119 114 120 /** 115 121 * Global application. 116 122 */ 117 123 public static Main main; 124 118 125 /** 119 126 * The worker thread slave. This is for executing all long and intensive … … 122 129 */ 123 130 public final static ExecutorService worker = new ProgressMonitorExecutor(); 131 124 132 /** 125 133 * Global application preferences … … 131 139 */ 132 140 public static final PrimitiveDeepCopy pasteBuffer = new PrimitiveDeepCopy(); 141 142 /** 143 * The layer source from which {@link Main#pasteBuffer} data comes from. 144 */ 133 145 public static Layer pasteSource; 134 146 135 147 /** 136 * The MapFrame. Use setMapFrameto set or clear it.148 * The MapFrame. Use {@link Main#setMapFrame} to set or clear it. 137 149 */ 138 150 public static MapFrame map; 151 139 152 /** 140 153 * Set to <code>true</code>, when in applet mode … … 147 160 public static ToolbarPreferences toolbar; 148 161 162 /** 163 * The commands undo/redo handler. 164 */ 149 165 public UndoRedoHandler undoRedo = new UndoRedoHandler(); 150 166 … … 240 256 /** 241 257 * Set or clear (if passed <code>null</code>) the map. 258 * @param map The map to set {@link Main#map} to. Can be null. 242 259 */ 243 260 public final void setMapFrame(final MapFrame map) { … … 532 549 /////////////////////////////////////////////////////////////////////////// 533 550 551 /** 552 * Global panel. 553 */ 534 554 public static final JPanel panel = new JPanel(new BorderLayout()); 535 555 … … 592 612 } 593 613 594 p ublic void postConstructorProcessCmdLine(Map<Option, Collection<String>> args) {614 protected static void postConstructorProcessCmdLine(Map<Option, Collection<String>> args) { 595 615 if (args.containsKey(Option.DOWNLOAD)) { 596 616 List<File> fileList = new ArrayList<File>(); … … 705 725 } 706 726 727 /** 728 * Closes JOSM and optionally terminates the Java Virtual Machine (JVM). If there are some unsaved data layers, asks first for user confirmation. 729 * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a return code of 0. 730 * @return {@code true} if JOSM has been closed, {@code false} if the user has cancelled the operation. 731 * @since 3378 732 */ 707 733 public static boolean exitJosm(boolean exit) { 708 734 if (Main.saveUnsavedModifications()) { 709 735 geometry.remember("gui.geometry"); 710 if (map 736 if (map != null) { 711 737 map.rememberToggleDialogWidth(); 712 738 } … … 721 747 if (exit) { 722 748 System.exit(0); 723 return true; 724 } else 725 return true; 726 } else 727 return false; 749 } 750 return true; 751 } 752 return false; 728 753 } 729 754 … … 739 764 * @return The guessed parameter type 740 765 */ 741 private DownloadParamType paramType(String s) {766 private static DownloadParamType paramType(String s) { 742 767 if(s.startsWith("http:")) return DownloadParamType.httpUrl; 743 768 if(s.startsWith("file:")) return DownloadParamType.fileUrl; … … 798 823 } 799 824 825 /** 826 * Identifies the current operating system family and initializes the platform hook accordingly. 827 * @since 1849 828 */ 800 829 public static void determinePlatformHook() { 801 830 String os = System.getProperty("os.name"); … … 853 882 } 854 883 } 855 public static void addListener() { 884 885 protected static void addListener() { 856 886 parent.addComponentListener(new WindowPositionSizeListener()); 857 887 ((JFrame)parent).addWindowStateListener(new WindowPositionSizeListener()); 858 888 } 859 889 890 /** 891 * Checks that JOSM is at least running with Java 6. 892 * @since 3815 893 */ 860 894 public static void checkJava6() { 861 895 String version = System.getProperty("java.version"); 862 896 if (version != null) { 863 897 if (version.startsWith("1.6") || version.startsWith("6") || 864 version.startsWith("1.7") || version.startsWith("7")) 898 version.startsWith("1.7") || version.startsWith("7") || 899 version.startsWith("1.8") || version.startsWith("8")) 865 900 return; 866 901 if (version.startsWith("1.5") || version.startsWith("5")) { -
trunk/src/org/openstreetmap/josm/gui/MainApplet.java
r5752 r5829 49 49 50 50 private final class MainCaller extends Main { 51 private MainCaller() { 51 private MainCaller(Map<Option, Collection<String>> mapargs) { 52 addListener(); 52 53 setContentPane(contentPanePrivate); 53 54 setJMenuBar(menu); 55 postConstructorProcessCmdLine(mapargs); 54 56 } 55 57 } … … 131 133 Main.preConstructorInit(Option.fromStringMap(args)); 132 134 Main.parent = frame; 133 Main.addListener();134 135 135 new MainCaller( ).postConstructorProcessCmdLine(Option.fromStringMap(args));136 new MainCaller(Option.fromStringMap(args)); 136 137 137 138 MainMenu m = Main.main.menu; // shortcut -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r5796 r5829 64 64 65 65 /** 66 * Construct an main frame, ready sized and operating. Does not67 * display the frame.66 * Constructs a main frame, ready sized and operating. Does not display the frame. 67 * @param mainFrame The main JFrame of the application 68 68 */ 69 69 public MainApplication(JFrame mainFrame) { 70 super();70 addListener(); 71 71 mainFrame.setContentPane(contentPanePrivate); 72 72 mainFrame.setJMenuBar(menu); … … 223 223 /** 224 224 * Main application Startup 225 * @param argArray Command-line arguments 225 226 */ 226 227 public static void main(final String[] argArray) { … … 343 344 344 345 monitor.indeterminateSubTask(tr("Creating main GUI")); 345 Main.addListener();346 346 final Main main = new MainApplication(mainFrame); 347 347 … … 404 404 } 405 405 406 main.postConstructorProcessCmdLine(args_final);406 postConstructorProcessCmdLine(args_final); 407 407 408 408 DownloadDialog.autostartIfNeeded();
Note:
See TracChangeset
for help on using the changeset viewer.