WebObjects 5.1

com.webobjects.eoapplication
Class EOApplication

java.lang.Object
  |
  +--com.webobjects.eoapplication.EOController
        |
        +--com.webobjects.eoapplication.EOApplication
All Implemented Interfaces:
EOAction.Enabling, NSDisposable, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions
Direct Known Subclasses:
EODynamicApplication

public class EOApplication
extends EOController

Java Client applications typically execute from the command line (often referred to as a "Java application") or as an applet running in a browser. EOApplication insulates the developer from this distinction by serving as an execution-mode-independent repository for application-level client-side logic. The provided JApplet subclass EOApplet simply invokes EOApplication with the HTML arguments as parameters.

Each application has a window observer which keeps track of all of the windows in the application, which window is active, and whether all windows have been closed. The window observer has two notifications: ActiveWindowChangedNotification and LastWindowClosedNotification, which the finishInitialization method binds to the activeWindowDidChange and lastWindowDidClose methods, respectively.

Each application also has a defaults manager, an EODefaults object, which maintains two dictionaries for application defaults: a transient dictionary whose values are forgotten when the application exits, and a persistent dictionary whose values are stored on the server. The defaults manager implements valueForKey to read the defaults and setPersistentValueForKey and setTransientValueForKey to store the defaults.


Inner classes inherited from class com.webobjects.eoapplication.EOController
EOController.Enumeration
 
Inner classes inherited from class com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor
 
Inner classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Field Summary
static String ApplicationDidStart
          The name of the notification sent when the application did finish the launch sequence.
static String ApplicationWillQuit
          The name of the notification sent when the application is about to quit.
 
Fields inherited from class com.webobjects.eoapplication.EOController
ControllerAndSubcontrollersEnumeration, SubcontrollersEnumeration, SupercontrollersEnumeration
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
KeyPathSeparator
 
Constructor Summary
EOApplication()
          Creates a new EOApplication object.
 
Method Summary
 void activatePreviousWindow()
          Activates the previously active window.
 void activeWindowDidChange(NSNotification notification)
          This method is invoked when the user changes the active window in the receiver (usually by clicking in an inactive window).
 NSDictionary arguments()
          Returns all of the application's arguments in a dictionary.
 boolean canPerformActionNamed(String actionName)
          Overridden to handle application specific action enabling and disabling.
 boolean canQuit()
          Returns whether or not the application can quit (shows a Quit menu item).
 void collectChangesFromServer()
          Updates the client application's enterprise objects to reflect the changes sent to the server from other client applications.
protected  NSArray defaultActions()
          Returns an NSArray containing the actions (EOAction objects) for the application.
 EODefaults defaults()
          Returns the receiver's defaults manager (an EODefaults object).
 void dispose()
          Prepares the receiver so it is disposed when Java performs garbage collection.
 NSArray documents()
          Returns an array containing the application's visible documents (EODocument objects).
 NSArray documentsForGlobalID(EOGlobalID globalID, String entityName)
          Returns an array containing the application's documents (EODocument objects) that edit enterprise objects with an entity name matching entityName and a global ID matching globalID.
 NSArray editedDocuments()
          Returns an NSArray containing the application's documents (EODocument objects) that are edited (and not saved).
protected  void finishInitialization()
          This method is invoked after the final event thread is guaranteed to be running.
 boolean hasEditedDocuments()
          Returns whether any of the application's documents are edited (and not saved).
 NSArray languages()
          Returns an array containing the language names (Strings) for which the application is localized.
 void lastWindowDidClose(NSNotification notification)
          This method is invoked when the user closes the last window in the application.
static void main(String[] argv)
           
 void quit()
          Causes the receiver to quit (provided canQuit is true).
 boolean quitsOnLastWindowClose()
          Returns whether or not the receiver quits when the user closes all of its windows.
 boolean saveAll()
          Attempts to save all of the receiver's edited documents.
 void sessionDidTimeOut()
          Invoked if the application receives a session time out error while trying to communicate with the server.
 void setCanQuit(boolean flag)
          Sets whether or not the application can quit (shows a Quit menu item).
 void setQuitsOnLastWindowClose(boolean flag)
          Sets whether or not the receiver quits when the user closes all of its windows.
 void setWindowObserver(EOWindowObserver windowObserver)
          Sets the application's window observer to EOWindowObserver.
static EOApplication sharedApplication()
          Returns the shared EOApplication instance initialized in the startApplication method.
static EOApplication startApplication(NSDictionary parameters, EOComponentController initialTopComponentController, boolean remoteRequestArguments)
          This method is the primary entry point for starting a Java Client application.
 String toString()
          Returns the receiver as a string describing the state of the application.
 EOWindowObserver windowObserver()
          Returns the application's window observer.
 
Methods inherited from class com.webobjects.eoapplication.EOController
actionNames, actions, actionWithName, addSubcontroller, breakConnection, breakConnectionToSubcontrollers, canAccessFieldsDirectly, canBeTransient, connectionWasBroken, connectionWasEstablished, controllerEnumeration, controllersInEnumeration, controllersWithKeyValuePair, controllersWithKeyValuePairs, controllerWithKeyValuePair, controllerWithKeyValuePairs, disableActionNamed, disposableRegistry, disposeIfTransient, enableActionNamed, enabledActions, establishConnection, establishConnectionToSupercontrollers, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hierarchicalControllerForKey, hierarchicalValueForKey, invokeMethod, isActionNamedEnabled, isAncestorOfController, isConnected, isSupercontrollerOfController, isTransientExplicitlyForbidden, prepareForNewTask, removeFromSupercontroller, removeSubcontroller, removeTransientSubcontroller, resetActions, setConnected, setSupercontroller, setTransientExplicitlyForbidden, setTypeName, subcontrollers, subcontrollerWasAdded, subcontrollerWasRemoved, supercontroller, supercontroller, takeValueForKey, takeValueForKeyPath, typeName, unableToSetNullForKey, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ApplicationDidStart

public static final String ApplicationDidStart
The name of the notification sent when the application did finish the launch sequence.

ApplicationWillQuit

public static final String ApplicationWillQuit
The name of the notification sent when the application is about to quit.
Constructor Detail

EOApplication

public EOApplication()
Creates a new EOApplication object.
Method Detail

activatePreviousWindow

public void activatePreviousWindow()
Activates the previously active window. The user can usually trigger this method from the Window menu.

activeWindowDidChange

public void activeWindowDidChange(NSNotification notification)
This method is invoked when the user changes the active window in the receiver (usually by clicking in an inactive window). It is invoked via a notification from the application's window observer.
Parameters:
notification - the window observer notification

arguments

public NSDictionary arguments()
Returns all of the application's arguments in a dictionary. If the application is a desktop application (and not an applet), the arguments can come from both the command line and the WOJavaClientApplet on the server side.
Returns:
the application's arguments

canPerformActionNamed

public boolean canPerformActionNamed(String actionName)
Overridden to handle application specific action enabling and disabling.
Overrides:
canPerformActionNamed in class EOController
Parameters:
actionName - the action method name
Returns:
true if the action should be enabled; false otherwise
See Also:
EOAction.Enabling

canQuit

public boolean canQuit()
Returns whether or not the application can quit (shows a Quit menu item). Defaults to true if the application is run as a desktop application and false if it runs as an applet.
Returns:
true if the application can quit; false otherwise

collectChangesFromServer

public void collectChangesFromServer()
Updates the client application's enterprise objects to reflect the changes sent to the server from other client applications. By default, the application does not automatically update its objects, however, the user can usually update the objects manually from the Document menu.

defaultActions

protected NSArray defaultActions()
Returns an NSArray containing the actions (EOAction objects) for the application. The application object's actions are displayed in the main menu of the Java Client application.
Overrides:
defaultActions in class EOController
Returns:
the array of actions

defaults

public EODefaults defaults()
Returns the receiver's defaults manager (an EODefaults object). If your application requires the user to log in, you may override this method so it returns null until the user has authenticated.
Returns:
the application's default manager

dispose

public void dispose()
Prepares the receiver so it is disposed when Java performs garbage collection.
Overrides:
dispose in class EOController

documents

public NSArray documents()
Returns an array containing the application's visible documents (EODocument objects).
Returns:
an array of the application's visible documents

documentsForGlobalID

public NSArray documentsForGlobalID(EOGlobalID globalID,
                                    String entityName)
Returns an array containing the application's documents (EODocument objects) that edit enterprise objects with an entity name matching entityName and a global ID matching globalID.
Parameters:
globalID - the global ID for the documents
entityName - the entity name for the documents
Returns:
an array of documents matching the entity name and global ID

editedDocuments

public NSArray editedDocuments()
Returns an NSArray containing the application's documents (EODocument objects) that are edited (and not saved).
Returns:
an array of the application's edited documents

finishInitialization

protected void finishInitialization()
This method is invoked after the final event thread is guaranteed to be running. If you subclass EOApplication, use this method to initialize anything relating to the user interface or event handling. Do not perform such initialization using EOApplication's constructor.

hasEditedDocuments

public boolean hasEditedDocuments()
Returns whether any of the application's documents are edited (and not saved). Otherwise returns false.
Returns:
true if the application has edited documents; false otherwise

languages

public NSArray languages()
Returns an array containing the language names (Strings) for which the application is localized. An example language is English.
Returns:
the application's languages

lastWindowDidClose

public void lastWindowDidClose(NSNotification notification)
This method is invoked when the user closes the last window in the application. It is invoked as a notification from the receiver's window observer. Usually causes the application to quit.
Parameters:
notification - the window observer notification
See Also:
quitsOnLastWindowClose()

main

public static void main(String[] argv)

quit

public void quit()
Causes the receiver to quit (provided canQuit is true).
See Also:
canQuit()

quitsOnLastWindowClose

public boolean quitsOnLastWindowClose()
Returns whether or not the receiver quits when the user closes all of its windows. Defaults to true.
Returns:
true if the application quits if the user closes all windows; false otherwise

saveAll

public boolean saveAll()
Attempts to save all of the receiver's edited documents.
Returns:
true if the save was successful; false otherwise

sessionDidTimeOut

public void sessionDidTimeOut()
Invoked if the application receives a session time out error while trying to communicate with the server. Causes an error dialog to be displayed and the application quits automatically afterwards.

setCanQuit

public void setCanQuit(boolean flag)
Sets whether or not the application can quit (shows a Quit menu item).
Parameters:
flag - true if the application can quit; false otherwise

setQuitsOnLastWindowClose

public void setQuitsOnLastWindowClose(boolean flag)
Sets whether or not the receiver quits when the user closes all of its windows.
Parameters:
flag - true if the application quits if the user closes all windows; false otherwise

setWindowObserver

public void setWindowObserver(EOWindowObserver windowObserver)
Sets the application's window observer to EOWindowObserver. The window observer manages the application's windows: Which window is active, how many there are, etc.
Parameters:
windowObserver - the window observer

sharedApplication

public static EOApplication sharedApplication()
Returns the shared EOApplication instance initialized in the startApplication method.
Returns:
the shared application object

startApplication

public static EOApplication startApplication(NSDictionary parameters,
                                             EOComponentController initialTopComponentController,
                                             boolean remoteRequestArguments)

This method is the primary entry point for starting a Java Client application. Together with the finishInitialization method it performs the complete startup sequence (connect to the server, warm up the user interface, determine languages, etc.)

The parameters dictionary contains all client parameters known at the time this method is invoked. For applets, these are all values of the WOJavaClientApplet bindings on the server side, passed in the HTML. For applications, these are all command line arguments.

The initialTopComponentController parameter can specify an EOComponentController in the controller hierarchy which becomes the parent controller for the intial EOInterfaceController if one is specified. For applets, this controller is an EOAppletController. For desktop applications, this is null, which causes a new EOFrameController to be instantiated and used as the top-most EOComponentController.

Parameters:
parameters - the parameters for the application
initialTopComponentController - the parent component controller for initial interface controllers
remoteRequestArguments - flag whether WOJavaClientApplet bindings should be requested explicitly
Returns:
the shared application object created while executing this method

toString

public String toString()
Returns the receiver as a string describing the state of the application.
Overrides:
toString in class EOController
Returns:
the String representation of the receiver

windowObserver

public EOWindowObserver windowObserver()
Returns the application's window observer.
Returns:
the application's window observer

Last updated Thu Jan 10 18:10:21 PST 2002.

Copyright © 2002 Apple Computer, Inc.