Changeset 5829 in josm for trunk/src


Ignore:
Timestamp:
2013-04-06T14:56:43+02:00 (11 years ago)
Author:
Don-vip
Message:

fix javadoc + minor refactorization/code cleanup

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/JOSM.java

    r3083 r5829  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 //Licence: GPL
    3 
    4 // Note: The name of the main class will be the name of the application menu on OS X.
    5 //       so instead of exposing "org.openstreetmap.josm.gui.MainApplication" to the
    6 //       user, we subclass it with a nicer name "JOSM".
    7 //       An alternative would be to set the name in the plist file---but JOSM usually
    8 //       is not delivered as an OS X Application Bundle, so we have no plist file.
    9 
    102import org.openstreetmap.josm.gui.MainApplication;
    113
     4/**
     5 * JOSM main class (entry point of the application).<br/>
     6 *
     7 * The name of the main class will be the name of the application menu on OS X.
     8 * so instead of exposing "org.openstreetmap.josm.gui.MainApplication" to the
     9 * user, we subclass it with a nicer name "JOSM".
     10 * An alternative would be to set the name in the plist file---but JOSM usually
     11 * is not delivered as an OS X Application Bundle, so we have no plist file.
     12 *
     13 * @since 1023
     14 */
    1215public class JOSM extends MainApplication {}
  • trunk/src/org/openstreetmap/josm/Main.java

    r5696 r5829  
    9595import org.openstreetmap.josm.tools.WindowGeometry;
    9696
     97/**
     98 * Abstract class holding various static global variables and methods used in large parts of JOSM application.
     99 * @since 98
     100 */
    97101abstract public class Main {
    98102
     
    108112        return true;
    109113    }
     114   
    110115    /**
    111116     * Global parent component for all dialogs and message boxes
    112117     */
    113118    public static Component parent;
     119   
    114120    /**
    115121     * Global application.
    116122     */
    117123    public static Main main;
     124   
    118125    /**
    119126     * The worker thread slave. This is for executing all long and intensive
     
    122129     */
    123130    public final static ExecutorService worker = new ProgressMonitorExecutor();
     131   
    124132    /**
    125133     * Global application preferences
     
    131139     */
    132140    public static final PrimitiveDeepCopy pasteBuffer = new PrimitiveDeepCopy();
     141   
     142    /**
     143     * The layer source from which {@link Main#pasteBuffer} data comes from.
     144     */
    133145    public static Layer pasteSource;
    134146
    135147    /**
    136      * The MapFrame. Use setMapFrame to set or clear it.
     148     * The MapFrame. Use {@link Main#setMapFrame} to set or clear it.
    137149     */
    138150    public static MapFrame map;
     151   
    139152    /**
    140153     * Set to <code>true</code>, when in applet mode
     
    147160    public static ToolbarPreferences toolbar;
    148161
     162    /**
     163     * The commands undo/redo handler.
     164     */
    149165    public UndoRedoHandler undoRedo = new UndoRedoHandler();
    150166
     
    240256    /**
    241257     * Set or clear (if passed <code>null</code>) the map.
     258     * @param map The map to set {@link Main#map} to. Can be null.
    242259     */
    243260    public final void setMapFrame(final MapFrame map) {
     
    532549    ///////////////////////////////////////////////////////////////////////////
    533550
     551    /**
     552     * Global panel.
     553     */
    534554    public static final JPanel panel = new JPanel(new BorderLayout());
    535555
     
    592612    }
    593613
    594     public void postConstructorProcessCmdLine(Map<Option, Collection<String>> args) {
     614    protected static void postConstructorProcessCmdLine(Map<Option, Collection<String>> args) {
    595615        if (args.containsKey(Option.DOWNLOAD)) {
    596616            List<File> fileList = new ArrayList<File>();
     
    705725    }
    706726
     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     */
    707733    public static boolean exitJosm(boolean exit) {
    708734        if (Main.saveUnsavedModifications()) {
    709735            geometry.remember("gui.geometry");
    710             if (map  != null) {
     736            if (map != null) {
    711737                map.rememberToggleDialogWidth();
    712738            }
     
    721747            if (exit) {
    722748                System.exit(0);
    723                 return true;
    724             } else
    725                 return true;
    726         } else
    727             return false;
     749            }
     750            return true;
     751        }
     752        return false;
    728753    }
    729754
     
    739764     * @return The guessed parameter type
    740765     */
    741     private DownloadParamType paramType(String s) {
     766    private static DownloadParamType paramType(String s) {
    742767        if(s.startsWith("http:")) return DownloadParamType.httpUrl;
    743768        if(s.startsWith("file:")) return DownloadParamType.fileUrl;
     
    798823    }
    799824
     825    /**
     826     * Identifies the current operating system family and initializes the platform hook accordingly.
     827     * @since 1849
     828     */
    800829    public static void determinePlatformHook() {
    801830        String os = System.getProperty("os.name");
     
    853882        }
    854883    }
    855     public static void addListener() {
     884   
     885    protected static void addListener() {
    856886        parent.addComponentListener(new WindowPositionSizeListener());
    857887        ((JFrame)parent).addWindowStateListener(new WindowPositionSizeListener());
    858888    }
    859889
     890    /**
     891     * Checks that JOSM is at least running with Java 6.
     892     * @since 3815
     893     */
    860894    public static void checkJava6() {
    861895        String version = System.getProperty("java.version");
    862896        if (version != null) {
    863897            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"))
    865900                return;
    866901            if (version.startsWith("1.5") || version.startsWith("5")) {
  • trunk/src/org/openstreetmap/josm/gui/MainApplet.java

    r5752 r5829  
    4949
    5050    private final class MainCaller extends Main {
    51         private MainCaller() {
     51        private MainCaller(Map<Option, Collection<String>> mapargs) {
     52            addListener();
    5253            setContentPane(contentPanePrivate);
    5354            setJMenuBar(menu);
     55            postConstructorProcessCmdLine(mapargs);
    5456        }
    5557    }
     
    131133        Main.preConstructorInit(Option.fromStringMap(args));
    132134        Main.parent = frame;
    133         Main.addListener();
    134135
    135         new MainCaller().postConstructorProcessCmdLine(Option.fromStringMap(args));
     136        new MainCaller(Option.fromStringMap(args));
    136137
    137138        MainMenu m = Main.main.menu; // shortcut
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r5796 r5829  
    6464
    6565    /**
    66      * Construct an main frame, ready sized and operating. Does not
    67      * 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
    6868     */
    6969    public MainApplication(JFrame mainFrame) {
    70         super();
     70        addListener();
    7171        mainFrame.setContentPane(contentPanePrivate);
    7272        mainFrame.setJMenuBar(menu);
     
    223223    /**
    224224     * Main application Startup
     225     * @param argArray Command-line arguments
    225226     */
    226227    public static void main(final String[] argArray) {
     
    343344
    344345        monitor.indeterminateSubTask(tr("Creating main GUI"));
    345         Main.addListener();
    346346        final Main main = new MainApplication(mainFrame);
    347347
     
    404404                }
    405405
    406                 main.postConstructorProcessCmdLine(args_final);
     406                postConstructorProcessCmdLine(args_final);
    407407
    408408                DownloadDialog.autostartIfNeeded();
Note: See TracChangeset for help on using the changeset viewer.