thinwire.ui
Class Application

java.lang.Object
  extended by thinwire.ui.Application

public abstract class Application
extends java.lang.Object

The Application class represents an instance of a ThinWire application. Methods in this class are those that directly affect the system and it's environment.


Nested Class Summary
static class Application.Local<T>
           
 
Constructor Summary
protected Application()
           
 
Method Summary
 void addExceptionListener(ExceptionListener listener)
           
 void addGlobalActionListener(java.lang.String[] actions, ActionListener listener)
          Adds a ActionListener that will be notified when any of the specified actions occur on any new component.
 void addGlobalActionListener(java.lang.String action, ActionListener listener)
          Adds a ActionListener that will be notified when the specified action occurs on any new component.
 void addGlobalDropListener(Component[] dragSources, DropListener listener)
           
 void addGlobalDropListener(Component dragSource, DropListener listener)
           
 void addGlobalItemChangeListener(ItemChangeListener listener)
           
 void addGlobalKeyPressListener(java.lang.String[] keyPressCombos, KeyPressListener listener)
           
 void addGlobalKeyPressListener(java.lang.String keyPressCombo, KeyPressListener listener)
           
 void addGlobalPropertyChangeListener(java.lang.String[] propertyNames, PropertyChangeListener listener)
          Adds a PropertyChangeListener that will be notified when any of the specified properties of any new component changes.
 void addGlobalPropertyChangeListener(java.lang.String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener that will be notified when the specified property of any new component changes.
abstract  void addTimerTask(java.lang.Runnable task, long milliseconds)
           
abstract  void addTimerTask(java.lang.Runnable task, long milliseconds, boolean repeat)
           
protected abstract  void captureThread()
           
static Application current()
           
abstract  java.lang.String getBaseFolder()
           
static Style getDefaultStyle(java.lang.Class<? extends Component> clazz)
           
protected  java.util.Map<java.lang.Class<? extends Component>,Style> getDefaultStyles()
           
protected abstract  FileChooser.FileInfo getFileInfo()
           
 Frame getFrame()
          Gets the Frame that represents the primary application window.
static java.util.Map<java.lang.String,java.lang.String> getPlatformVersionInfo()
          Returns the current version info details for the platform.
 Component getPriorFocus()
          Returns the Component that previously had focus in the Application.
protected abstract  java.lang.String getQualifiedURL(java.lang.String location)
           
 java.io.File getRelativeFile(java.lang.String pathname)
           
 java.io.File getRelativeFile(java.lang.String parent, java.lang.String child)
           
static java.io.InputStream getResourceAsStream(java.lang.String uri)
          Returns an InputStream representing the specified resource.
static byte[] getResourceBytes(java.lang.String uri)
           
protected  java.util.Map<java.lang.String,Color> getSystemColors()
           
protected  java.lang.String getSystemFile(java.lang.String value)
           
protected  java.util.Map<java.lang.String,java.lang.String> getSystemImages()
           
protected abstract  void hideWindow(Window w)
           
protected  void loadStyleSheet(java.lang.String styleSheet)
           
static void main(java.lang.String[] args)
          Displays a version detail dialog.
protected abstract  void releaseThread()
           
 void removeExceptionListener(ExceptionListener listener)
           
protected abstract  void removeFileFromMap(java.lang.String location)
           
 void removeGlobalActionListener(ActionListener listener)
          Unregister an ActionListener from all action event notifications from any component.
 void removeGlobalDropListener(DropListener listener)
           
 void removeGlobalItemChangeListener(ItemChangeListener listener)
           
 void removeGlobalKeyPressListener(KeyPressListener listener)
           
 void removeGlobalPropertyChangeListener(PropertyChangeListener listener)
          Removes the PropertyChangeListener from the list of global listeners that are added to all new Component's.
abstract  void removeTimerTask(java.lang.Runnable task)
           
 void reportException(java.lang.Object source, java.lang.Throwable exception)
           
abstract  void resetTimerTask(java.lang.Runnable task)
           
protected  java.lang.Object setPackagePrivateMember(java.lang.String memberName, Component comp, java.lang.Object value)
           
protected abstract  void showWindow(Window w)
           
static void writeResourceToStream(java.lang.String uri, java.io.OutputStream os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Application

protected Application()
Method Detail

getPlatformVersionInfo

public static java.util.Map<java.lang.String,java.lang.String> getPlatformVersionInfo()
Returns the current version info details for the platform. The returned Map is read-only and contains the following keys: companyName companyAddress1 companyAddress2 companyCity companyState companyZip companyPhone companyWebsite productDescription productVersion internalName legalCopyright originalFilename

Returns:
the current version info details for the platform.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Displays a version detail dialog.

Parameters:
args -
Throws:
java.lang.Exception

current

public static Application current()
Returns:
the current instance of the application, or null if called from a thread other than the UI thread.

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String uri)
Returns an InputStream representing the specified resource. The following URL's are supported:

Returns:
an InputStream representing the specified resource or null if the resource was not found.

getResourceBytes

public static byte[] getResourceBytes(java.lang.String uri)

writeResourceToStream

public static void writeResourceToStream(java.lang.String uri,
                                         java.io.OutputStream os)

getDefaultStyle

public static Style getDefaultStyle(java.lang.Class<? extends Component> clazz)

addGlobalPropertyChangeListener

public void addGlobalPropertyChangeListener(java.lang.String propertyName,
                                            PropertyChangeListener listener)
Adds a PropertyChangeListener that will be notified when the specified property of any new component changes. To further clarify, a global property change listener will receive an event notification for any component that is created after this global property change listener is added, for which the specified property changes. Therefore, establishing a global property change listener is the same as invoking the Component.addPropertyChangeListener(String, PropertyChangeListener) method on every component after it's creation.

As a general rule, you should avoid using this feature because it can cause a large volume of events to be generated. This is especially true if you listen to a frequently updated property, such as PROPERTY_TEXT. However, there are cases where this can be quite useful. One such case is when you use the 'userObject' property to store a boolean state that indicates whether a value is required for the component. In such a case, you can establish a global property change listener for 'userObject' and then based on the property being set to true you could update the background color so it is apparent to the user that a value is required.

Example:
 Component.addGlobalPropertyChangeListener(Component.PROPERTY_USER_OBJECT, new PropertyChangeListener() {
     public void propertyChange(PropertyChangeEvent pce) {
         Component comp = (Component) pce.getSource();
 
         if (comp.getUserObject() == Boolean.TRUE) {
             comp.getStyle().getBackground().setColor(Color.PALEGOLDENROD);
         } else {
             comp.getStyle().getBackground().setColor(null); //restore the default background color
         }
     }
 });
 
 TextField tf = new TextField();
 tf.setUserObject(Boolean.TRUE); //Causes background color to be set to Color.PALEGOLDENROD
 tf.setUserObject(Boolean.FALSE); //Causes background color to be set to the default.
 

Parameters:
propertyName - the name of the property that the listener will receive change events for.
listener - the listener that will receive PropertyChangeEvent objects upon the property of any new component changing.
Throws:
java.lang.IllegalArgumentException - if listener or propertyName is null or if propertyName is an empty string.
See Also:
Component.addPropertyChangeListener(String, PropertyChangeListener), PropertyChangeListener, PropertyChangeEvent

addGlobalPropertyChangeListener

public void addGlobalPropertyChangeListener(java.lang.String[] propertyNames,
                                            PropertyChangeListener listener)
Adds a PropertyChangeListener that will be notified when any of the specified properties of any new component changes. This method is equivalent to calling addGlobalPropertyChangeListener(String, PropertyChangeListener) once for each property you want to listen to.

Parameters:
propertyNames - a string array of property names that the listener will receive change events for.
listener - the listerner that will receive PropertyChangeEvent objects anytime one of the specified propertyNames of any new component change.
Throws:
java.lang.IllegalArgumentException - if listener, propertyNames or any property name is the array is null or if any property name is an empty string.
See Also:
addGlobalPropertyChangeListener(String, PropertyChangeListener), Component.addPropertyChangeListener(String[], PropertyChangeListener), PropertyChangeListener, PropertyChangeEvent

removeGlobalPropertyChangeListener

public void removeGlobalPropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener from the list of global listeners that are added to all new Component's. To further clarify, removing a global property change listener will NOT remove the listener from Component's that have already been created.

Parameters:
listener - the listener to remove from the notification list.
Throws:
java.lang.IllegalArgumentException - if listener is null.
See Also:
PropertyChangeListener

addGlobalActionListener

public void addGlobalActionListener(java.lang.String action,
                                    ActionListener listener)
Adds a ActionListener that will be notified when the specified action occurs on any new component. To further clarify, a global action listener will receive an event notification for any component that is created after this global action listener is added, on which the specified action occurs. Therefore, establishing a global action listener is the same as invoking the Component.addActionListener(String, ActionListener) method on every component after it's creation.

Parameters:
action - the action to specficially be notified of.
listener - the event listener that will receive notification.

addGlobalActionListener

public void addGlobalActionListener(java.lang.String[] actions,
                                    ActionListener listener)
Adds a ActionListener that will be notified when any of the specified actions occur on any new component. This method is equivalent to calling addGlobalActionListener(String, ActionListener) once for each action you want to receive notification for.

Parameters:
actions - the actions to specficially be notified of.
listener - the event listener that will receive notifications.

removeGlobalActionListener

public void removeGlobalActionListener(ActionListener listener)
Unregister an ActionListener from all action event notifications from any component.

Parameters:
listener - the listener that should no longer receive action event notifications.

addGlobalDropListener

public void addGlobalDropListener(Component dragSource,
                                  DropListener listener)

addGlobalDropListener

public void addGlobalDropListener(Component[] dragSources,
                                  DropListener listener)

removeGlobalDropListener

public void removeGlobalDropListener(DropListener listener)

addGlobalKeyPressListener

public void addGlobalKeyPressListener(java.lang.String keyPressCombo,
                                      KeyPressListener listener)

addGlobalKeyPressListener

public void addGlobalKeyPressListener(java.lang.String[] keyPressCombos,
                                      KeyPressListener listener)

removeGlobalKeyPressListener

public void removeGlobalKeyPressListener(KeyPressListener listener)

addGlobalItemChangeListener

public void addGlobalItemChangeListener(ItemChangeListener listener)

removeGlobalItemChangeListener

public void removeGlobalItemChangeListener(ItemChangeListener listener)

addExceptionListener

public void addExceptionListener(ExceptionListener listener)
Parameters:
listener -

removeExceptionListener

public void removeExceptionListener(ExceptionListener listener)
Parameters:
listener -

reportException

public void reportException(java.lang.Object source,
                            java.lang.Throwable exception)
Parameters:
source -
exception -

getFrame

public Frame getFrame()
Gets the Frame that represents the primary application window.

Returns:
the Frame that represents the primary application window.

getPriorFocus

public Component getPriorFocus()
Returns the Component that previously had focus in the Application. The Component that previously had focus is the last Component in ANY window that held the focus. This is different from the behavior of the focus property in which their is one Component with focus PER window.

Returns:
the Component that previously had focus in the Application, or null if no Component has had prior focus.
See Also:
Component.isFocus(), Component.setFocus(boolean)

loadStyleSheet

protected void loadStyleSheet(java.lang.String styleSheet)

getSystemFile

protected java.lang.String getSystemFile(java.lang.String value)

getDefaultStyles

protected java.util.Map<java.lang.Class<? extends Component>,Style> getDefaultStyles()

getSystemColors

protected java.util.Map<java.lang.String,Color> getSystemColors()

getSystemImages

protected java.util.Map<java.lang.String,java.lang.String> getSystemImages()

getBaseFolder

public abstract java.lang.String getBaseFolder()
Returns:
the base folder of the system

getRelativeFile

public java.io.File getRelativeFile(java.lang.String pathname)
Parameters:
pathname -
Returns:

getRelativeFile

public java.io.File getRelativeFile(java.lang.String parent,
                                    java.lang.String child)
Parameters:
parent -
child -
Returns:

setPackagePrivateMember

protected java.lang.Object setPackagePrivateMember(java.lang.String memberName,
                                                   Component comp,
                                                   java.lang.Object value)

captureThread

protected abstract void captureThread()

releaseThread

protected abstract void releaseThread()

showWindow

protected abstract void showWindow(Window w)

hideWindow

protected abstract void hideWindow(Window w)

getFileInfo

protected abstract FileChooser.FileInfo getFileInfo()

getQualifiedURL

protected abstract java.lang.String getQualifiedURL(java.lang.String location)

removeFileFromMap

protected abstract void removeFileFromMap(java.lang.String location)

addTimerTask

public abstract void addTimerTask(java.lang.Runnable task,
                                  long milliseconds)
Parameters:
task -
milliseconds -

addTimerTask

public abstract void addTimerTask(java.lang.Runnable task,
                                  long milliseconds,
                                  boolean repeat)
Parameters:
task -
milliseconds -
repeat -

resetTimerTask

public abstract void resetTimerTask(java.lang.Runnable task)
Parameters:
task -

removeTimerTask

public abstract void removeTimerTask(java.lang.Runnable task)
Parameters:
task -


ThinWire® is a registered of Custom Credit Systems  Copyright © 2007 All rights reserved.
ThinWire_is_Open_Source_under_the_terms_of_the_LGPLv2.1 SourceForge.net_Project_Page java.net_Member Support_ThinWire,_Digg_our_Story