public abstract class Main extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Main.InitializationTask |
static interface |
Main.InitStatusListener
Initialization task listener.
|
Modifier and Type | Field and Description |
---|---|
static FileWatcher |
fileWatcher
The file watcher service.
|
private static Main.InitStatusListener |
initListener |
private static java.lang.String |
JOSM_WEBSITE
The JOSM website URL.
|
private static java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>> |
listeners |
static Main |
main
Global application.
|
private static java.util.Map<java.lang.String,java.lang.Throwable> |
NETWORK_ERRORS |
private static java.util.Set<OnlineResource> |
OFFLINE_RESOURCES |
private static java.lang.String |
OSM_WEBSITE
The OSM website URL.
|
static java.awt.Component |
parent
Global parent component for all dialogs and message boxes
|
static PlatformHook |
platform
Platform specific code goes in here.
|
static Preferences |
pref
Global application preferences
|
private static Projection |
proj
The projection method used.
|
UndoRedoHandler |
undoRedo
The commands undo/redo handler.
|
Modifier | Constructor and Description |
---|---|
protected |
Main()
Constructs new
Main object. |
Modifier and Type | Method and Description |
---|---|
static java.lang.Throwable |
addNetworkError(java.lang.String url,
java.lang.Throwable t)
Adds a new network error that occur to give a hint about broken Internet connection.
|
static java.lang.Throwable |
addNetworkError(java.net.URL url,
java.lang.Throwable t)
Adds a new network error that occur to give a hint about broken Internet connection.
|
static void |
addProjectionChangeListener(ProjectionChangeListener listener)
Register a projection change listener.
|
protected java.util.List<Main.InitializationTask> |
afterInitializationTasks()
Returns tasks that must be run after parallel tasks.
|
protected java.util.List<java.util.concurrent.Callable<?>> |
asynchronousCallableTasks()
Returns asynchronous callable initializations to be completed eventually
|
protected java.util.List<java.lang.Runnable> |
asynchronousRunnableTasks()
Returns asynchronous runnable initializations to be completed eventually
|
protected java.util.List<Main.InitializationTask> |
beforeInitializationTasks()
Returns tasks that must be run before parallel tasks.
|
static void |
clearNetworkErrors()
Clears the network errors cache.
|
static void |
clearProjectionChangeListeners()
Remove all projection change listeners.
|
abstract boolean |
containsDataSet(DataSet ds)
Determines if the list of data sets managed by JOSM contains
ds . |
static void |
determinePlatformHook()
Identifies the current operating system family and initializes the platform hook accordingly.
|
static boolean |
exitJosm(boolean exit,
int exitCode)
Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
|
private static void |
fireProjectionChanged(Projection oldValue,
Projection newValue,
Bounds oldBounds) |
abstract DataSet |
getActiveDataSet()
Gets the active data set (can be read-only).
|
static java.lang.String |
getBaseBrowseUrl()
Replies the base URL for browsing information about a primitive.
|
static java.lang.String |
getBaseUserUrl()
Replies the base URL for browsing information about a user.
|
abstract DataSet |
getEditDataSet()
Gets the active edit data set (not read-only).
|
java.util.Collection<OsmPrimitive> |
getInProgressSelection()
Replies the current selected primitives, from a end-user point of view.
|
static java.lang.String |
getJOSMWebsite()
Returns the JOSM website URL.
|
static java.util.Map<java.lang.String,java.lang.Throwable> |
getNetworkErrors()
Returns the network errors that occured until now.
|
static java.util.Set<OnlineResource> |
getOfflineResources()
Replies the set of online resources currently offline.
|
static java.lang.String |
getOSMWebsite()
Returns the OSM website URL.
|
private static java.lang.String |
getOSMWebsiteDependingOnSelectedApi()
Returns the OSM website URL depending on the selected
OsmApi . |
static Projection |
getProjection()
Replies the current projection.
|
protected Bounds |
getRealBounds()
Returns the bounds for the current projection.
|
static java.lang.String |
getXMLBase()
Returns the JOSM XML URL.
|
void |
initialize()
Initializes the main object.
|
static boolean |
isOffline(OnlineResource r)
Determines if the given online resource is currently offline.
|
static boolean |
isPlatformOsx()
Determines if we are currently running on OSX.
|
static boolean |
isPlatformWindows()
Determines if we are currently running on Windows.
|
protected java.util.Collection<Main.InitializationTask> |
parallelInitializationTasks()
Returns tasks to be executed (in parallel) by a ExecutorService.
|
static void |
preConstructorInit()
Should be called before the main constructor to setup some parameter stuff
|
static void |
removeProjectionChangeListener(ProjectionChangeListener listener)
Removes a projection change listener.
|
protected void |
restoreOldBounds(Bounds oldBounds)
Restore clean state corresponding to old bounds after a projection change event.
|
private static void |
runInitializationTasks(java.util.List<Main.InitializationTask> tasks) |
abstract void |
setActiveDataSet(DataSet ds)
Sets the active data set (and also edit data set if not read-only).
|
static void |
setInitStatusListener(Main.InitStatusListener listener)
Sets initialization task listener.
|
private static void |
setInstance(Main instance) |
static boolean |
setOffline(OnlineResource r)
Sets the given online resource to offline state.
|
static boolean |
setOnline(OnlineResource r)
Sets the given online resource to online state.
|
static void |
setProjection(Projection p)
Sets the current projection
|
protected void |
shutdown()
Shutdown JOSM.
|
private static final java.lang.String JOSM_WEBSITE
private static final java.lang.String OSM_WEBSITE
public static java.awt.Component parent
public static final Preferences pref
public final UndoRedoHandler undoRedo
public static final FileWatcher fileWatcher
private static final java.util.Map<java.lang.String,java.lang.Throwable> NETWORK_ERRORS
private static final java.util.Set<OnlineResource> OFFLINE_RESOURCES
public static volatile PlatformHook platform
private static volatile Main.InitStatusListener initListener
private static volatile Projection proj
getProjection()
and setProjection(Projection)
for access.
Use setProjection(Projection)
in order to trigger a projection change event.private static final java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>> listeners
protected Main()
Main
object.initialize()
public static void setInitStatusListener(Main.InitStatusListener listener)
listener
- initialization task listenerprivate static void setInstance(Main instance)
public void initialize()
private static void runInitializationTasks(java.util.List<Main.InitializationTask> tasks)
protected java.util.List<Main.InitializationTask> beforeInitializationTasks()
afterInitializationTasks()
,
parallelInitializationTasks()
protected java.util.Collection<Main.InitializationTask> parallelInitializationTasks()
protected java.util.List<java.util.concurrent.Callable<?>> asynchronousCallableTasks()
protected java.util.List<java.lang.Runnable> asynchronousRunnableTasks()
protected java.util.List<Main.InitializationTask> afterInitializationTasks()
beforeInitializationTasks()
,
parallelInitializationTasks()
public java.util.Collection<OsmPrimitive> getInProgressSelection()
DataSet.getSelected()
.null
.public abstract DataSet getEditDataSet()
null
.getActiveDataSet()
public abstract DataSet getActiveDataSet()
null
.getEditDataSet()
public abstract void setActiveDataSet(DataSet ds)
ds
- New data set, or null
public abstract boolean containsDataSet(DataSet ds)
ds
.ds
- the data set to look fortrue
if the list of data sets managed by JOSM contains ds
public static void preConstructorInit()
public static boolean exitJosm(boolean exit, int exitCode)
exit
- If true
, the JVM is terminated by running System.exit(int)
with a given return code.exitCode
- The return codetrue
protected void shutdown()
public static void determinePlatformHook()
public static Projection getProjection()
public static void setProjection(Projection p)
p
- the projectionprotected Bounds getRealBounds()
restoreOldBounds(org.openstreetmap.josm.data.Bounds)
protected void restoreOldBounds(Bounds oldBounds)
oldBounds
- bounds previously returned by getRealBounds()
, before the change of projectiongetRealBounds()
private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds)
public static void addProjectionChangeListener(ProjectionChangeListener listener)
listener
- the listener. Ignored if null
.public static void removeProjectionChangeListener(ProjectionChangeListener listener)
listener
- the listener. Ignored if null
.public static void clearProjectionChangeListeners()
public static java.lang.Throwable addNetworkError(java.net.URL url, java.lang.Throwable t)
url
- The accessed URL that caused the errort
- The network errornull
public static java.lang.Throwable addNetworkError(java.lang.String url, java.lang.Throwable t)
url
- The accessed URL that caused the errort
- The network errornull
public static java.util.Map<java.lang.String,java.lang.Throwable> getNetworkErrors()
public static void clearNetworkErrors()
public static java.lang.String getJOSMWebsite()
public static java.lang.String getXMLBase()
public static java.lang.String getOSMWebsite()
private static java.lang.String getOSMWebsiteDependingOnSelectedApi()
OsmApi
.OsmApi
public static java.lang.String getBaseBrowseUrl()
public static java.lang.String getBaseUserUrl()
public static boolean isPlatformOsx()
true
if we are currently running on OSXpublic static boolean isPlatformWindows()
true
if we are currently running on Windowspublic static boolean isOffline(OnlineResource r)
r
- the online resourcetrue
if r
is offline and should not be accessedpublic static boolean setOffline(OnlineResource r)
r
- the online resourcetrue
if r
was not already offlinepublic static boolean setOnline(OnlineResource r)
r
- the online resourcetrue
if r
was offlinepublic static java.util.Set<OnlineResource> getOfflineResources()