org.apache.pivot.wtk
Class ApplicationContext

java.lang.Object
  extended by org.apache.pivot.wtk.ApplicationContext
Direct Known Subclasses:
BrowserApplicationContext, DesktopApplicationContext

public abstract class ApplicationContext
extends Object

Base class for application contexts.

TODO Fire events when entries are added to/removed from the cache?

TODO Provide a means of mapping common "actions" to keystrokes (e.g. "copy" to Control-C or Command-C)


Nested Class Summary
 class ApplicationContext.DisplayHost
          Native display host.
static class ApplicationContext.ResourceCacheDictionary
          Resource cache dictionary implementation.
static class ApplicationContext.ScheduledCallback
          Class representing a scheduled callback.
 
Field Summary
protected static URL origin
           
 
Constructor Summary
protected ApplicationContext()
           
 
Method Summary
static void beep()
          Issues a system alert sound.
protected static void createTimer()
           
protected static void destroyTimer()
           
protected  Application getApplication()
           
protected  Display getDisplay()
           
protected  ApplicationContext.DisplayHost getDisplayHost()
           
static Version getJVMVersion()
          Returns the current JVM version.
static URL getOrigin()
          Returns this application's origin (the URL of it's originating server).
static ApplicationContext.ResourceCacheDictionary getResourceCache()
          Resource properties accessor.
static void open(String location)
          Opens the resource at the given location.
static void open(URL location)
          Opens the resource at the given location.
static void queueCallback(Runnable callback)
          Queues a task to execute after all pending events have been processed and returns without waiting for the task to complete.
static void queueCallback(Runnable callback, boolean wait)
          Queues a task to execute after all pending events have been processed and optionally waits for the task to complete.
static ApplicationContext.ScheduledCallback scheduleCallback(Runnable callback, long delay)
          Schedules a task for one-time execution.
static ApplicationContext.ScheduledCallback scheduleRecurringCallback(Runnable callback, long period)
          Schedules a task for repeated execution.
static ApplicationContext.ScheduledCallback scheduleRecurringCallback(Runnable callback, long delay, long period)
          Schedules a task for repeated execution.
protected  void setApplication(Application application)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origin

protected static URL origin
Constructor Detail

ApplicationContext

protected ApplicationContext()
Method Detail

getApplication

protected Application getApplication()

setApplication

protected void setApplication(Application application)

getDisplayHost

protected ApplicationContext.DisplayHost getDisplayHost()

getDisplay

protected Display getDisplay()

getOrigin

public static URL getOrigin()
Returns this application's origin (the URL of it's originating server).

Returns:
The application's origin, or null if the origin cannot be determined.

getResourceCache

public static ApplicationContext.ResourceCacheDictionary getResourceCache()
Resource properties accessor.


open

public static void open(String location)
                 throws MalformedURLException
Opens the resource at the given location.

Parameters:
location -
Throws:
MalformedURLException

open

public static void open(URL location)
Opens the resource at the given location.

Parameters:
location -

beep

public static void beep()
Issues a system alert sound.


getJVMVersion

public static Version getJVMVersion()
Returns the current JVM version.

Returns:
The current JVM version, or null if the version can't be determined.

scheduleCallback

public static ApplicationContext.ScheduledCallback scheduleCallback(Runnable callback,
                                                                    long delay)
Schedules a task for one-time execution. The task will be executed on the UI thread.

Parameters:
callback - The task to execute.
delay - The length of time to wait before executing the task.

scheduleRecurringCallback

public static ApplicationContext.ScheduledCallback scheduleRecurringCallback(Runnable callback,
                                                                             long period)
Schedules a task for repeated execution. The task will be executed on the UI thread and will begin executing immediately.

Parameters:
callback - The task to execute.
period - The interval at which the task will be repeated.

scheduleRecurringCallback

public static ApplicationContext.ScheduledCallback scheduleRecurringCallback(Runnable callback,
                                                                             long delay,
                                                                             long period)
Schedules a task for repeated execution. The task will be executed on the UI thread.

Parameters:
callback - The task to execute.
delay - The length of time to wait before the first execution of the task
period - The interval at which the task will be repeated.

queueCallback

public static void queueCallback(Runnable callback)
Queues a task to execute after all pending events have been processed and returns without waiting for the task to complete.

Parameters:
callback - The task to execute.

queueCallback

public static void queueCallback(Runnable callback,
                                 boolean wait)
Queues a task to execute after all pending events have been processed and optionally waits for the task to complete.

Parameters:
callback - The task to execute.
wait - If true, does not return until the task has executed. Otherwise, returns immediately.

createTimer

protected static void createTimer()

destroyTimer

protected static void destroyTimer()