org.jdesktop.jdnc.app
Class Application

java.lang.Object
  extended by org.jdesktop.jdnc.app.Application

public class Application
extends java.lang.Object

Class which represents central state and properties for a single client application which can be either a standalone Java application (typically initiated using Java WebStart) or a set of one or more Java applets which share the same code base. There should only be a single Application instance per client application.

This class also encapsulates any functionality which has variable API between applets and Java WebStart applications so that UI components can reliably talk to a single interface for such services.

Version:
1.0
Author:
Amy Fowler

Constructor Summary
Application()
           
 
Method Summary
 void addSelectionListener(SelectionListener l)
           
 ActionManager getActionManager()
          Return the action manager for this application.
 javax.swing.ActionMap getActionMap()
          Return the action map associated with this application.
static Application getApp(java.awt.Component c)
          Convenience method for getting the JDNCapp instance given a component instance.
 java.util.Iterator getApplets()
           
 java.net.URL getBaseURL()
           
static java.net.URL getBaseURL(java.lang.Object obj)
          Will retrieve the applet base url if this application is running in an applet.
static javax.swing.Icon getIcon(java.lang.String name, java.lang.Object obj)
           
static java.awt.Image getImage(java.lang.String name, java.lang.Object obj)
           
static Application getInstance()
          Private constructor so that an Application can't be directly instantated.
static Application getInstance(java.lang.Object key)
          Factory method for obtaining the Application instance associated with the application designated by the specified key.
 SelectionListener[] getSelectionListeners()
           
 java.awt.Image getSplashImage()
           
 java.lang.String getTitle()
           
 java.awt.Image getTitleBarImage()
           
static java.net.URL getURL(java.lang.String value, java.lang.Object obj)
          Fetches a url of a resource value using the clasloader and relative path of obj.
static java.net.URL getURLResource(java.lang.String value, java.lang.Object obj)
           
 java.lang.String getVersionString()
           
 java.util.Iterator getWindows()
           
 boolean isRunningApplet()
          Returns a boolean value indicating if the application is in an applet.
 boolean isRunningInSandbox()
          Returns a boolean value indicating whether or not this application is running in the security sandbox
 boolean isRunningWebStart()
          Returns a boolean value indicating if the application has been launched with Java WebStart.
 boolean isStandAlone()
          Returns true if running as a standalone application and returns false if running one or more applets.
 void registerApplet(java.applet.Applet applet)
           
 void registerWindow(java.awt.Window window)
          Registers a window with the application instance.
 void removeSelectionListener(SelectionListener l)
           
 void setBaseURL(java.net.URL baseURL)
          Sets the "baseURL" property of this application.
 void setSplashImage(java.awt.Image splashImage)
          Sets the "splashImage" property of this application.
 void setTitle(java.lang.String title)
          Sets the "title" property of this application.
 void setTitleBarImage(java.awt.Image titleBarImage)
          Sets the "titleBarImage" property of this application.
 void setVersionString(java.lang.String versionString)
          Sets the "versionString" property of this application.
 void showDocument(java.net.URL url, java.lang.String target)
          Display the document referenced by the url in a browser.
 void unregisterApplet(java.applet.Applet applet)
           
 void unregisterWindow(java.awt.Window window)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Application

public Application()
Method Detail

getInstance

public static Application getInstance()
Private constructor so that an Application can't be directly instantated. private Application() { } /** Factory method for obtaining the Application instance associated with this application. The Application object will be instantiated if it does not already exist. This method is intended for use by standalone applications where there may be one and only one JDNCapp instance.

Returns:
Application instance for application

getInstance

public static Application getInstance(java.lang.Object key)
Factory method for obtaining the Application instance associated with the application designated by the specified key. The Application object will be instantiated if it does not already exist. This method is intended for use by applets, where there may be multiple Application instances in a running VM.

Parameters:
key - object designating the application
Returns:
Application instance for application

getApp

public static Application getApp(java.awt.Component c)
Convenience method for getting the JDNCapp instance given a component instance. The component instance must be contained in a containent hierarchy which has either a Window or an Applet instance as the root.

Parameters:
c - the ui component
Returns:
Application instance for the specified component's application

getActionManager

public ActionManager getActionManager()
Return the action manager for this application.

Returns:
the action manager instance

setBaseURL

public void setBaseURL(java.net.URL baseURL)
Sets the "baseURL" property of this application.

Parameters:
baseURL - URL of codebase for this application

getBaseURL

public java.net.URL getBaseURL()
Returns:
URL of codebase for this application

getBaseURL

public static java.net.URL getBaseURL(java.lang.Object obj)
Will retrieve the applet base url if this application is running in an applet. Otherwise, it will try to retrieve the base URL of the xml configuration file.


getURL

public static java.net.URL getURL(java.lang.String value,
                                  java.lang.Object obj)
Fetches a url of a resource value using the clasloader and relative path of obj. Will first try to load from the classpath, then the direct url and then look for a base url.


getURLResource

public static java.net.URL getURLResource(java.lang.String value,
                                          java.lang.Object obj)

getImage

public static java.awt.Image getImage(java.lang.String name,
                                      java.lang.Object obj)

getIcon

public static javax.swing.Icon getIcon(java.lang.String name,
                                       java.lang.Object obj)

showDocument

public void showDocument(java.net.URL url,
                         java.lang.String target)
Display the document referenced by the url in a browser.

If the application is an Applet then the document will be shown from the browser from which it has been launched. If the application has been launched from Java WebStart then it will use the javax.jnlp.BasicService to show the document. If this is a standalone application then it will use the platform browser to show the document.

Parameters:
url - an absolute URL giving locationto display
target - indicates where to display the page
See Also:
AppletContext.showDocument(java.net.URL, java.lang.String), javax.jnlp.BasicService#showDocument

setSplashImage

public void setSplashImage(java.awt.Image splashImage)
Sets the "splashImage" property of this application. If set, this image will be rendered in the splash screen which is displayed momentarily at application startup while the application initializes.

Parameters:
splashImage - image displayed in the application's splash screen

getSplashImage

public java.awt.Image getSplashImage()
Returns:
Image displayed in the application's splash screen

setTitle

public void setTitle(java.lang.String title)
Sets the "title" property of this application.

Parameters:
title - string containing the title of this application

getTitle

public java.lang.String getTitle()
Returns:
String containing the title of this application

setTitleBarImage

public void setTitleBarImage(java.awt.Image titleBarImage)
Sets the "titleBarImage" property of this application. If set, this image will be displayed in the titlebar of all UI windows shown by this application. The placement of this image within the titlebar is Look and Feel dependent.

Parameters:
titleBarImage - image displayed in titlebar of application's toplevel windows

getTitleBarImage

public java.awt.Image getTitleBarImage()
Returns:
image displayed in titlebar of application's toplevel windows

setVersionString

public void setVersionString(java.lang.String versionString)
Sets the "versionString" property of this application.

Parameters:
versionString - string containing the version of this application

getVersionString

public java.lang.String getVersionString()
Returns:
String containing the version of this application

isStandAlone

public boolean isStandAlone()
Returns true if running as a standalone application and returns false if running one or more applets.

Returns:
true if this client is running as an application; false if running as an applet

isRunningInSandbox

public boolean isRunningInSandbox()
Returns a boolean value indicating whether or not this application is running in the security sandbox

Returns:
true if the application is in a sandbox; otherwise false

isRunningApplet

public boolean isRunningApplet()
Returns a boolean value indicating if the application is in an applet.

Returns:
true if the app is in an applet; otherwise falsee

isRunningWebStart

public boolean isRunningWebStart()
Returns a boolean value indicating if the application has been launched with Java WebStart.

Returns:
true if running in web start; otherwise false

registerWindow

public void registerWindow(java.awt.Window window)
Registers a window with the application instance.


unregisterWindow

public void unregisterWindow(java.awt.Window window)

registerApplet

public void registerApplet(java.applet.Applet applet)

unregisterApplet

public void unregisterApplet(java.applet.Applet applet)

getActionMap

public javax.swing.ActionMap getActionMap()
Return the action map associated with this application. The action map holds all the global application actions.


getApplets

public java.util.Iterator getApplets()
Returns:
iterator containing all applets registered with this app instance or null if the app was instantiated from a standalone application

getWindows

public java.util.Iterator getWindows()
Returns:
iterator containing all windows registered with this app instance or null if there were no toplevel windows registered

addSelectionListener

public void addSelectionListener(SelectionListener l)

removeSelectionListener

public void removeSelectionListener(SelectionListener l)

getSelectionListeners

public SelectionListener[] getSelectionListeners()


Copyright © 2005 Sun Microsystems All Rights Reserved.