Package org.openstreetmap.josm.gui
Class MainApplication
- java.lang.Object
-
- org.openstreetmap.josm.gui.MainApplication
-
public class MainApplication extends java.lang.Object
Main window class application.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MainApplication.DefaultNativeOsCallback
private static class
MainApplication.GuiFinalizationWorker
-
Field Summary
Fields Modifier and Type Field 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 ofMainFrame
, 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 forMapFrameListener
handling.(package private) static MapFrame
map
The MapFrame.(package private) static MainMenu
menu
The main menu bar at top of screen.private static java.lang.String
PREF_STARTUP_FAILURE_COUNTER
The preference key for the startup failure counter(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 Summary
Constructors Constructor Description MainApplication()
Constructs a newMainApplication
without a window.MainApplication(MainFrame mainFrame)
Constructs a main frame, ready sized and operating.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
addAndFireMapFrameListener(MapFrameListener listener)
Registers a newMapFrameListener
that will be notified of MapFrame changes.static boolean
addMapFrameListener(MapFrameListener listener)
Registers a newMapFrameListener
that will be notified of MapFrame changesprivate static java.lang.String
align(java.lang.String str)
(package private) static void
applyLaFWorkarounds()
Apply workarounds for LaF and platform specific issues.private static void
askUpdate(java.lang.String title, java.lang.String update, java.lang.String property, java.lang.String icon, java.lang.StringBuilder content, java.lang.String url)
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 shortcutstatic 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 Startupstatic 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 fromsource
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 aJosmAction
and its shortcut.static void
registerCLIModule(CLIModule module)
Register a command line interface module.static boolean
removeMapFrameListener(MapFrameListener listener)
Unregisters the givenMapFrameListener
from MapFrame changesstatic void
sanityCheckFailed(java.lang.String title, boolean canContinue, java.lang.String... message)
Tells the user that a sanity check failedprivate static void
scaleFonts(double factor, java.lang.String... fonts)
(package private) static void
setupCallbacks()
static void
setupNadGridSources()
Setup the sources for NTV2 grid shift files for projection support.private static void
setupTextAntiAliasing()
(package private) static void
setupUIManager()
Set up the UI managerstatic void
showHelp()
Displays help on the consolestatic void
unregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)
Unregisters an action and its shortcut.static void
unregisterActionShortcut(JosmAction action)
Unregisters aJosmAction
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.
-
-
-
Field Detail
-
commandLineArgs
private static volatile java.util.List<java.lang.String> commandLineArgs
Command-line arguments used to run the application.
-
PREF_STARTUP_FAILURE_COUNTER
private static final java.lang.String PREF_STARTUP_FAILURE_COUNTER
The preference key for the startup failure counter- See Also:
- Constant Field Values
-
mainPanel
static MainPanel mainPanel
The main panel, required to be static forMapFrameListener
handling.
-
contentPanePrivate
static javax.swing.JComponent contentPanePrivate
The private content pane ofMainFrame
, required to be static for shortcut handling.
-
toolbar
static volatile ToolbarPreferences toolbar
The toolbar preference control to register new actions.
-
worker
public static final java.util.concurrent.ExecutorService worker
The worker thread slave. This is for executing all long and intensive calculations. The executed runnables are guaranteed to be executed separately and sequential.- Since:
- 12634 (as a replacement to
Main.worker
)
-
layerManager
private static final MainLayerManager layerManager
Provides access to the layers displayed in the main view.
-
undoRedoCleaner
private static final LayerManager.LayerChangeListener undoRedoCleaner
-
mainBoundsProvider
private static final ProjectionBoundsProvider mainBoundsProvider
-
cliModules
private static final java.util.List<CLIModule> cliModules
-
JOSM_CLI_MODULE
public static final CLIModule JOSM_CLI_MODULE
Default JOSM command line interface.Runs JOSM and performs some action, depending on the options and positional arguments.
-
redoUndoListener
final UndoRedoHandler.CommandQueueListener redoUndoListener
Listener that sets the enabled state of undo/redo menu entries.
-
JOSM_WEBSITE_NTV2_SOURCE
public static final NTV2GridShiftFileSource JOSM_WEBSITE_NTV2_SOURCE
Source of NTV2 shift files: Download from JOSM website.- Since:
- 12777
-
-
Constructor Detail
-
MainApplication
public MainApplication()
Constructs a newMainApplication
without a window.
-
MainApplication
public MainApplication(MainFrame mainFrame)
Constructs a main frame, ready sized and operating. Does not display the frame.- Parameters:
mainFrame
- The main JFrame of the application- Since:
- 10340
-
-
Method Detail
-
registerCLIModule
public static void registerCLIModule(CLIModule module)
Register a command line interface module.- Parameters:
module
- the module- Since:
- 12886
-
askUpdate
private static void askUpdate(java.lang.String title, java.lang.String update, java.lang.String property, java.lang.String icon, java.lang.StringBuilder content, java.lang.String url)
-
askUpdateJava
public 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.- Parameters:
updVersion
- target update versionurl
- download URLmajor
- true for a migration towards a major version of Java (8:11), false otherwiseeolDate
- the EOL/expiration date- Since:
- 12270
-
sanityCheckFailed
public static void sanityCheckFailed(java.lang.String title, boolean canContinue, java.lang.String... message)
Tells the user that a sanity check failed- Parameters:
title
- The title of the message to showcanContinue
-true
if the failed sanity check(s) will not instantly kill JOSM when the user editsmessage
- The message parts to show the user (as a list)
-
initializeMainWindow
protected void initializeMainWindow()
-
getMainFrame
public static MainFrame getMainFrame()
Returns the JOSM main frame.- Returns:
- the JOSM main frame
- Since:
- 14140
-
getCommandLineArgs
public static java.util.List<java.lang.String> getCommandLineArgs()
Returns the command-line arguments used to run the application.- Returns:
- the command-line arguments used to run the application
- Since:
- 11650
-
getLayerManager
public static MainLayerManager getLayerManager()
Returns the main layer manager that is used by the map view.- Returns:
- The layer manager. The value returned will never change.
- Since:
- 12636 (as a replacement to
Main.getLayerManager()
)
-
getMap
public static MapFrame getMap()
Returns the MapFrame.There should be no need to access this to access any map data. Use
layerManager
instead.- Returns:
- the MapFrame
- Since:
- 12630
- See Also:
MainPanel
-
getMainPanel
public static MainPanel getMainPanel()
Returns the main panel.- Returns:
- the main panel
- Since:
- 12642
-
getMenu
public static MainMenu getMenu()
Returns the main menu, at top of screen.- Returns:
- the main menu
- Since:
- 12643 (as a replacement to
MainApplication.getMenu()
)
-
getToolbar
public static ToolbarPreferences getToolbar()
Returns the toolbar preference control to register new actions.- Returns:
- the toolbar preference control
- Since:
- 12637
-
isDisplayingMapView
public static boolean isDisplayingMapView()
Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if it only shows the MOTD panel.You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
- Returns:
true
if JOSM currently displays a map view- Since:
- 12630 (as a replacement to
Main.isDisplayingMapView()
)
-
exitJosm
public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason)
Closes JOSM and optionally terminates the Java Virtual Machine (JVM). If there are some unsaved data layers, asks first for user confirmation.- Parameters:
exit
- Iftrue
, the JVM is terminated by runningSystem.exit(int)
with a given return code.exitCode
- The return codereason
- the reason for exiting- Returns:
true
if JOSM has been closed,false
if the user has cancelled the operation.- Since:
- 12636 (specialized version of
Lifecycle.exitJosm(boolean, int)
)
-
redirectToMainContentPane
public static void redirectToMainContentPane(javax.swing.JComponent source)
Redirects the key inputs fromsource
to main content pane.- Parameters:
source
- source component from which key inputs are redirected
-
addAndFireMapFrameListener
public static boolean addAndFireMapFrameListener(MapFrameListener listener)
Registers a newMapFrameListener
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.
- Parameters:
listener
- The MapFrameListener- Returns:
true
if the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.addAndFireMapFrameListener
) - See Also:
addMapFrameListener(org.openstreetmap.josm.gui.MapFrameListener)
-
addMapFrameListener
public static boolean addMapFrameListener(MapFrameListener listener)
Registers a newMapFrameListener
that will be notified of MapFrame changes- Parameters:
listener
- The MapFrameListener- Returns:
true
if the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.addMapFrameListener
) - See Also:
addAndFireMapFrameListener(org.openstreetmap.josm.gui.MapFrameListener)
-
removeMapFrameListener
public static boolean removeMapFrameListener(MapFrameListener listener)
Unregisters the givenMapFrameListener
from MapFrame changes- Parameters:
listener
- The MapFrameListener- Returns:
true
if the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.removeMapFrameListener
)
-
registerActionShortcut
public static void registerActionShortcut(JosmAction action)
Registers aJosmAction
and its shortcut.- Parameters:
action
- action defining its own shortcut- Since:
- 12639 (as a replacement to
Main.registerActionShortcut
)
-
registerActionShortcut
public static void registerActionShortcut(javax.swing.Action action, Shortcut shortcut)
Registers an action and its shortcut.- Parameters:
action
- action to registershortcut
- shortcut to associate toaction
- Since:
- 12639 (as a replacement to
Main.registerActionShortcut
)
-
unregisterShortcut
public static void unregisterShortcut(Shortcut shortcut)
Unregisters a shortcut.- Parameters:
shortcut
- shortcut to unregister- Since:
- 12639 (as a replacement to
Main.unregisterShortcut
)
-
unregisterActionShortcut
public static void unregisterActionShortcut(JosmAction action)
Unregisters aJosmAction
and its shortcut.- Parameters:
action
- action to unregister- Since:
- 12639 (as a replacement to
Main.unregisterActionShortcut
)
-
unregisterActionShortcut
public static void unregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)
Unregisters an action and its shortcut.- Parameters:
action
- action to unregistershortcut
- shortcut to unregister- Since:
- 12639 (as a replacement to
Main.unregisterActionShortcut
)
-
getRegisteredActionShortcut
public static javax.swing.Action getRegisteredActionShortcut(Shortcut shortcut)
Replies the registered action for the given shortcut- Parameters:
shortcut
- The shortcut to look for- Returns:
- the registered action for the given shortcut
- Since:
- 12639 (as a replacement to
Main.getRegisteredActionShortcut
)
-
showHelp
public static void showHelp()
Displays help on the console- Since:
- 2748
-
getHelp
static java.lang.String getHelp()
-
align
private static java.lang.String align(java.lang.String str)
-
main
public static void main(java.lang.String[] argArray)
Main application Startup- Parameters:
argArray
- Command-line arguments
-
mainJOSM
public static void mainJOSM(ProgramArguments args)
Main method to run the JOSM GUI.- Parameters:
args
- program arguments
-
createMainFrame
private static MainFrame createMainFrame(WindowGeometry geometry)
-
updateSystemProperties
private static void updateSystemProperties()
Updates system properties with the current values in the preferences.
-
setupNadGridSources
public static void setupNadGridSources()
Setup the sources for NTV2 grid shift files for projection support.- Since:
- 12795
-
applyLaFWorkarounds
static void applyLaFWorkarounds()
Apply workarounds for LaF and platform specific issues. This must be called after the LaF is set.
-
setupCallbacks
static void setupCallbacks()
-
setupUIManager
static void setupUIManager()
Set up the UI manager
-
scaleFonts
private static void scaleFonts(double factor, java.lang.String... fonts)
-
setupTextAntiAliasing
private static void setupTextAntiAliasing()
-
updateAndLoadEarlyPlugins
static java.util.Collection<PluginInformation> updateAndLoadEarlyPlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor)
-
loadLatePlugins
static void loadLatePlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor, java.util.Collection<PluginInformation> pluginsToLoad)
-
processOffline
private static void processOffline(ProgramArguments args)
-
checkIPv6
private static void checkIPv6()
Check if IPv6 can be safely enabled and do so. Because this cannot be done after network activation, disabling or enabling IPV6 may only be done with next start.
-
downloadFromParamBounds
static java.util.List<java.util.concurrent.Future<?>> downloadFromParamBounds(boolean rawGps, Bounds b)
Download area specified as Bounds value.- Parameters:
rawGps
- Flag to download raw GPS tracksb
- The bounds value- Returns:
- the complete download task (including post-download handler)
-
postConstructorProcessCmdLine
static java.util.List<java.util.concurrent.Future<?>> postConstructorProcessCmdLine(ProgramArguments args)
Handle command line instructions after GUI has been initialized.- Parameters:
args
- program arguments- Returns:
- the list of submitted tasks
-
notifyNewMessages
static void notifyNewMessages(UserInfo userInfo)
-
-