public class MainApplication extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
MainApplication.DefaultNativeOsCallback |
private static class |
MainApplication.GuiFinalizationWorker |
Modifier and Type | Field and Description |
---|---|
private static java.util.List<CLIModule> |
cliModules |
private static java.util.List<java.lang.String> |
commandLineArgs
Command-line arguments used to run the application.
|
(package private) static javax.swing.JComponent |
contentPanePrivate
The private content pane of
MainFrame , required to be static for shortcut handling. |
static CLIModule |
JOSM_CLI_MODULE
Default JOSM command line interface.
|
static NTV2GridShiftFileSource |
JOSM_WEBSITE_NTV2_SOURCE
Source of NTV2 shift files: Download from JOSM website.
|
private static MainLayerManager |
layerManager
Provides access to the layers displayed in the main view.
|
private static ProjectionBoundsProvider |
mainBoundsProvider |
private static MainFrame |
mainFrame |
(package private) static MainPanel |
mainPanel
The main panel, required to be static for
MapFrameListener handling. |
(package private) static MapFrame |
map
The MapFrame.
|
(package private) static MainMenu |
menu
The main menu bar at top of screen.
|
(package private) UndoRedoHandler.CommandQueueListener |
redoUndoListener
Listener that sets the enabled state of undo/redo menu entries.
|
(package private) static ToolbarPreferences |
toolbar
The toolbar preference control to register new actions.
|
private static LayerManager.LayerChangeListener |
undoRedoCleaner |
static java.util.concurrent.ExecutorService |
worker
The worker thread slave.
|
Constructor and Description |
---|
MainApplication()
Constructs a new
MainApplication without a window. |
MainApplication(MainFrame mainFrame)
Constructs a main frame, ready sized and operating.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
addAndFireMapFrameListener(MapFrameListener listener)
Registers a new
MapFrameListener that will be notified of MapFrame changes. |
static boolean |
addMapFrameListener(MapFrameListener listener)
Registers a new
MapFrameListener that will be notified of MapFrame changes |
private static java.lang.String |
align(java.lang.String str) |
(package private) static void |
applyWorkarounds() |
static void |
askUpdateJava(java.lang.String updVersion,
java.lang.String url,
java.lang.String eolDate,
boolean major)
Asks user to update its version of Java.
|
private static void |
checkIPv6()
Check if IPv6 can be safely enabled and do so.
|
private static MainFrame |
createMainFrame(WindowGeometry geometry) |
(package private) static java.util.List<java.util.concurrent.Future<?>> |
downloadFromParamBounds(boolean rawGps,
Bounds b)
Download area specified as Bounds value.
|
static boolean |
exitJosm(boolean exit,
int exitCode,
SaveLayersDialog.Reason reason)
Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
|
static java.util.List<java.lang.String> |
getCommandLineArgs()
Returns the command-line arguments used to run the application.
|
(package private) static java.lang.String |
getHelp() |
static MainLayerManager |
getLayerManager()
Returns the main layer manager that is used by the map view.
|
static MainFrame |
getMainFrame()
Returns the JOSM main frame.
|
static MainPanel |
getMainPanel()
Returns the main panel.
|
static MapFrame |
getMap()
Returns the MapFrame.
|
static MainMenu |
getMenu()
Returns the main menu, at top of screen.
|
static javax.swing.Action |
getRegisteredActionShortcut(Shortcut shortcut)
Replies the registered action for the given shortcut
|
static ToolbarPreferences |
getToolbar()
Returns the toolbar preference control to register new actions.
|
protected void |
initializeMainWindow()
Called once at startup to initialize the main window content.
|
static boolean |
isDisplayingMapView()
Replies true if JOSM currently displays a map view.
|
(package private) static void |
loadLatePlugins(SplashScreen splash,
SplashScreen.SplashProgressMonitor monitor,
java.util.Collection<PluginInformation> pluginsToLoad) |
static void |
main(java.lang.String[] argArray)
Main application Startup
|
static void |
mainJOSM(ProgramArguments args)
Main method to run the JOSM GUI.
|
(package private) static void |
notifyNewMessages(UserInfo userInfo) |
(package private) static java.util.List<java.util.concurrent.Future<?>> |
postConstructorProcessCmdLine(ProgramArguments args)
Handle command line instructions after GUI has been initialized.
|
private static void |
processOffline(ProgramArguments args) |
static void |
redirectToMainContentPane(javax.swing.JComponent source)
Redirects the key inputs from
source to main content pane. |
static void |
registerActionShortcut(javax.swing.Action action,
Shortcut shortcut)
Registers an action and its shortcut.
|
static void |
registerActionShortcut(JosmAction action)
Registers a
JosmAction and its shortcut. |
static void |
registerCLIModule(CLIModule module)
Register a command line interface module.
|
static boolean |
removeMapFrameListener(MapFrameListener listener)
Unregisters the given
MapFrameListener from MapFrame changes |
(package private) static void |
setupCallbacks() |
static void |
setupNadGridSources()
Setup the sources for NTV2 grid shift files for projection support.
|
(package private) static void |
setupUIManager() |
static void |
showHelp()
Displays help on the console
|
static void |
unregisterActionShortcut(javax.swing.Action action,
Shortcut shortcut)
Unregisters an action and its shortcut.
|
static void |
unregisterActionShortcut(JosmAction action)
Unregisters a
JosmAction and its shortcut. |
static void |
unregisterShortcut(Shortcut shortcut)
Unregisters a shortcut.
|
(package private) static java.util.Collection<PluginInformation> |
updateAndLoadEarlyPlugins(SplashScreen splash,
SplashScreen.SplashProgressMonitor monitor) |
private static void |
updateSystemProperties()
Updates system properties with the current values in the preferences.
|
private static volatile java.util.List<java.lang.String> commandLineArgs
static MainPanel mainPanel
MapFrameListener
handling.static javax.swing.JComponent contentPanePrivate
MainFrame
, required to be static for shortcut handling.static volatile ToolbarPreferences toolbar
public static final java.util.concurrent.ExecutorService worker
Main.worker
)private static final MainLayerManager layerManager
private static final LayerManager.LayerChangeListener undoRedoCleaner
private static final ProjectionBoundsProvider mainBoundsProvider
private static final java.util.List<CLIModule> cliModules
public static final CLIModule JOSM_CLI_MODULE
Runs JOSM and performs some action, depending on the options and positional arguments.
final UndoRedoHandler.CommandQueueListener redoUndoListener
public static final NTV2GridShiftFileSource JOSM_WEBSITE_NTV2_SOURCE
public MainApplication()
MainApplication
without a window.public MainApplication(MainFrame mainFrame)
mainFrame
- The main JFrame of the applicationpublic static void registerCLIModule(CLIModule module)
module
- the modulepublic static void askUpdateJava(java.lang.String updVersion, java.lang.String url, java.lang.String eolDate, boolean major)
updVersion
- target update versionurl
- download URLmajor
- true for a migration towards a major version of Java (8:9), false otherwiseeolDate
- the EOL/expiration dateprotected void initializeMainWindow()
public static MainFrame getMainFrame()
public static java.util.List<java.lang.String> getCommandLineArgs()
public static MainLayerManager getLayerManager()
Main.getLayerManager()
)public static MapFrame getMap()
There should be no need to access this to access any map data. Use layerManager
instead.
MainPanel
public static MainPanel getMainPanel()
public static MainMenu getMenu()
MainApplication.getMenu()
)public static ToolbarPreferences getToolbar()
public static boolean isDisplayingMapView()
You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
true
if JOSM currently displays a map viewMain.isDisplayingMapView()
)public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason)
exit
- If true
, the JVM is terminated by running System.exit(int)
with a given return code.exitCode
- The return codereason
- the reason for exitingtrue
if JOSM has been closed, false
if the user has cancelled the operation.Lifecycle.exitJosm(boolean, int)
)public static void redirectToMainContentPane(javax.swing.JComponent source)
source
to main content pane.source
- source component from which key inputs are redirectedpublic static boolean addAndFireMapFrameListener(MapFrameListener listener)
MapFrameListener
that will be notified of MapFrame changes.
It will fire an initial mapFrameInitialized event when the MapFrame is present. Otherwise will only fire when the MapFrame is created or destroyed.
listener
- The MapFrameListenertrue
if the listeners collection changed as a result of the callMain.addAndFireMapFrameListener
)addMapFrameListener(org.openstreetmap.josm.gui.MapFrameListener)
public static boolean addMapFrameListener(MapFrameListener listener)
MapFrameListener
that will be notified of MapFrame changeslistener
- The MapFrameListenertrue
if the listeners collection changed as a result of the callMain.addMapFrameListener
)addAndFireMapFrameListener(org.openstreetmap.josm.gui.MapFrameListener)
public static boolean removeMapFrameListener(MapFrameListener listener)
MapFrameListener
from MapFrame changeslistener
- The MapFrameListenertrue
if the listeners collection changed as a result of the callMain.removeMapFrameListener
)public static void registerActionShortcut(JosmAction action)
JosmAction
and its shortcut.action
- action defining its own shortcutMain.registerActionShortcut
)public static void registerActionShortcut(javax.swing.Action action, Shortcut shortcut)
action
- action to registershortcut
- shortcut to associate to action
Main.registerActionShortcut
)public static void unregisterShortcut(Shortcut shortcut)
shortcut
- shortcut to unregisterMain.unregisterShortcut
)public static void unregisterActionShortcut(JosmAction action)
JosmAction
and its shortcut.action
- action to unregisterMain.unregisterActionShortcut
)public static void unregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)
action
- action to unregistershortcut
- shortcut to unregisterMain.unregisterActionShortcut
)public static javax.swing.Action getRegisteredActionShortcut(Shortcut shortcut)
shortcut
- The shortcut to look forMain.getRegisteredActionShortcut
)public static void showHelp()
static java.lang.String getHelp()
private static java.lang.String align(java.lang.String str)
public static void main(java.lang.String[] argArray)
argArray
- Command-line argumentspublic static void mainJOSM(ProgramArguments args)
args
- program argumentsprivate static MainFrame createMainFrame(WindowGeometry geometry)
private static void updateSystemProperties()
public static void setupNadGridSources()
static void applyWorkarounds()
static void setupCallbacks()
static void setupUIManager()
static java.util.Collection<PluginInformation> updateAndLoadEarlyPlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor)
static void loadLatePlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor, java.util.Collection<PluginInformation> pluginsToLoad)
private static void processOffline(ProgramArguments args)
private static void checkIPv6()
static java.util.List<java.util.concurrent.Future<?>> downloadFromParamBounds(boolean rawGps, Bounds b)
rawGps
- Flag to download raw GPS tracksb
- The bounds valuestatic java.util.List<java.util.concurrent.Future<?>> postConstructorProcessCmdLine(ProgramArguments args)
args
- program argumentsstatic void notifyNewMessages(UserInfo userInfo)