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 classMainApplication.DefaultNativeOsCallbackprivate static classMainApplication.GuiFinalizationWorker
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<CLIModule>cliModulesprivate static java.util.List<java.lang.String>commandLineArgsCommand-line arguments used to run the application.(package private) static javax.swing.JComponentcontentPanePrivateThe private content pane ofMainFrame, required to be static for shortcut handling.static CLIModuleJOSM_CLI_MODULEDefault JOSM command line interface.static NTV2GridShiftFileSourceJOSM_WEBSITE_NTV2_SOURCESource of NTV2 shift files: Download from JOSM website.private static MainLayerManagerlayerManagerProvides access to the layers displayed in the main view.private static ProjectionBoundsProvidermainBoundsProviderprivate static MainFramemainFrame(package private) static MainPanelmainPanelThe main panel, required to be static forMapFrameListenerhandling.(package private) static MapFramemapThe MapFrame.(package private) static MainMenumenuThe main menu bar at top of screen.private static java.lang.StringPREF_STARTUP_FAILURE_COUNTERThe preference key for the startup failure counter(package private) UndoRedoHandler.CommandQueueListenerredoUndoListenerListener that sets the enabled state of undo/redo menu entries.(package private) static ToolbarPreferencestoolbarThe toolbar preference control to register new actions.private static LayerManager.LayerChangeListenerundoRedoCleanerstatic java.util.concurrent.ExecutorServiceworkerThe worker thread slave.
-
Constructor Summary
Constructors Constructor Description MainApplication()Constructs a newMainApplicationwithout 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 booleanaddAndFireMapFrameListener(MapFrameListener listener)Registers a newMapFrameListenerthat will be notified of MapFrame changes.static booleanaddMapFrameListener(MapFrameListener listener)Registers a newMapFrameListenerthat will be notified of MapFrame changesprivate static java.lang.Stringalign(java.lang.String str)(package private) static voidapplyLaFWorkarounds()Apply workarounds for LaF and platform specific issues.private static voidaskUpdate(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 voidaskUpdateJava(java.lang.String updVersion, java.lang.String url, java.lang.String eolDate, boolean major)Asks user to update its version of Java.private static voidcheckIPv6()Check if IPv6 can be safely enabled and do so.private static MainFramecreateMainFrame(WindowGeometry geometry)(package private) static java.util.List<java.util.concurrent.Future<?>>downloadFromParamBounds(boolean rawGps, Bounds b)Download area specified as Bounds value.static booleanexitJosm(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.StringgetHelp()static MainLayerManagergetLayerManager()Returns the main layer manager that is used by the map view.static MainFramegetMainFrame()Returns the JOSM main frame.static MainPanelgetMainPanel()Returns the main panel.static MapFramegetMap()Returns the MapFrame.static MainMenugetMenu()Returns the main menu, at top of screen.static javax.swing.ActiongetRegisteredActionShortcut(Shortcut shortcut)Replies the registered action for the given shortcutstatic ToolbarPreferencesgetToolbar()Returns the toolbar preference control to register new actions.protected voidinitializeMainWindow()Called once at startup to initialize the main window content.static booleanisDisplayingMapView()Replies true if JOSM currently displays a map view.(package private) static voidloadLatePlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor, java.util.Collection<PluginInformation> pluginsToLoad)static voidmain(java.lang.String[] argArray)Main application Startupstatic voidmainJOSM(ProgramArguments args)Main method to run the JOSM GUI.(package private) static voidnotifyNewMessages(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 voidprocessOffline(ProgramArguments args)static voidredirectToMainContentPane(javax.swing.JComponent source)Redirects the key inputs fromsourceto main content pane.static voidregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)Registers an action and its shortcut.static voidregisterActionShortcut(JosmAction action)Registers aJosmActionand its shortcut.static voidregisterCLIModule(CLIModule module)Register a command line interface module.static booleanremoveMapFrameListener(MapFrameListener listener)Unregisters the givenMapFrameListenerfrom MapFrame changesstatic voidsanityCheckFailed(java.lang.String title, boolean canContinue, java.lang.String... message)Tells the user that a sanity check failedprivate static voidscaleFonts(double factor, java.lang.String... fonts)(package private) static voidsetupCallbacks()static voidsetupNadGridSources()Setup the sources for NTV2 grid shift files for projection support.private static voidsetupTextAntiAliasing()(package private) static voidsetupUIManager()Set up the UI managerstatic voidshowHelp()Displays help on the consolestatic voidunregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)Unregisters an action and its shortcut.static voidunregisterActionShortcut(JosmAction action)Unregisters aJosmActionand its shortcut.static voidunregisterShortcut(Shortcut shortcut)Unregisters a shortcut.(package private) static java.util.Collection<PluginInformation>updateAndLoadEarlyPlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor)private static voidupdateSystemProperties()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 forMapFrameListenerhandling.
-
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 newMainApplicationwithout 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-trueif 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
layerManagerinstead.- 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:
trueif 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:
trueif JOSM has been closed,falseif 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 fromsourceto main content pane.- Parameters:
source- source component from which key inputs are redirected
-
addAndFireMapFrameListener
public static boolean addAndFireMapFrameListener(MapFrameListener listener)
Registers a newMapFrameListenerthat 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:
trueif 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 newMapFrameListenerthat will be notified of MapFrame changes- Parameters:
listener- The MapFrameListener- Returns:
trueif 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 givenMapFrameListenerfrom MapFrame changes- Parameters:
listener- The MapFrameListener- Returns:
trueif 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 aJosmActionand 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 aJosmActionand 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)
-
-