![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
EOInterfaceController
Inherits From:
java.lang.Object
EOKeyValueCodingAdditions (EOControl)
EOObserving (EOControl)
java.awt.event.WindowListener
Inherits From:
com.apple.client.eointerface
Class Description
EOInterfaceController serves as a convenient base class for logic related to the interface of client-side applications. When the WebObjectsApplication wizard in Project Builder creates a new client-side interface, it adds to the client-side subproject an Interface Builder nib file representing this interface and a skeletal EOInterfaceController subclass defined as the nib file's root object or "owner."
In an application constructed in conformance to the Model-View-Controller paradigm, EOInterfaceController plays the role of controller. It has four special outlets: its editingContext
, its component
, its masterDisplayGroup
, and its controllerDisplayGroup
, all of which you can configure using Interface Builder. The object identified by component is an AWT Component that functions as the view, since it is the main entry point into the user interface. Because an enterprise objects must always inhabit an editing context, editingContext and its contents serve as the "model." The masterDisplayGroup is an EODisplayGroup containing the "master" enterprise objects manipulated by the controller's user interface (which may well involve many other display groups). The controllerDisplayGroup is a convenience instance containing nothing but the interface controller itself.
Constructors
public EOInterfaceController
()
public EOInterfaceController
(com.apple.client.eocontrol.EOEditingContext substitutionContext)
public EOInterfaceController
(com.apple.client.eocontrol.EOEditingContext substitutionContext, java.lang.String archiveName)
The two-argument constructor is EOInterfaceController's designated constructor. It initializes a new instance and then attempts to load the associated EOArchive indentified by archiveName, using substitutionContext as EOEditingContext's substitution editing context during the load. Archive loading results in the restoration of any controller outlets such as editingContext
and component
connected within InterfaceBuilder. The remaining constructors are convenience constructions that invoke the designated constructor with null
s substituted for the missing arguments. These null
values are passed along in the calls to loadArchive
and EOEditingContext's setSubstitutionEditingContext
.
Instance Methods
closeWindow
public void closeWindow
()
Puts any window created through the runInFrame
or runInModalDialog
methods offscreen and disposes of the window once the Component has been removed.
See also:
- component
collectChangesFromServer
public void collectChangesFromServer
()
Updates the receiver's editing context to reflect any changes to enterprise objects pending on the server.
component
public java.awt.Component component
()
Returns the main entry point into the receiver's user interface, which is always an AWT Component.
controllerDisplayGroup
public EODisplayGroup controllerDisplayGroup
()
Returns an EODisplayGroup containing nothing but the receiver (EOInterfaceController implements EOKeyValueCodingAdditions). You typically instantiate and connect this display group with Interface Builder. This display group facilitates the use of the receiver with EOAssociations, as any properties defined in a controller subclass may then be used as association aspect keys.
For example, to enable or disable the entire user interface, you could add a "uiEnabled" property to an EOInterfaceController subclass and bind the "enabled" aspect of any EOAssociation with display objects in its component to the key of the controller display group.
displayGroupDidChangeDataSource
public void displayGroupDidChangeDataSource
(EODisplayGroup aDisplayGroup)
Overriden by subclasses to respond to a change in aDisplayGroup's data source. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
displayGroupDidChangeSelection
public void displayGroupDidChangeSelection
(EODisplayGroup aDisplayGroup)
Overriden by subclasses to respond to a selection change in aDisplayGroup. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
displayGroupDidDeleteObject
public void displayGroupDidDeleteObject
(EODisplayGroup aDisplayGroup, java.lang.Object anObject)
Overriden by subclasses to respond to the deletion of anObject in aDisplayGroup. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
displayGroupDidFetchObjects
public void displayGroupDidFetchObjects
(EODisplayGroup aDisplayGroup, NSArray anArray)
Overriden by subclasses to respond to the fetch of objects in anArray by aDisplayGroup. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
displayGroupDidInsertObject
public void displayGroupDidInsertObject
(EODisplayGroup aDisplayGroup, java.lang.Object anObject)
Overriden by subclasses to respond to the insertion of object anObject into aDisplayGroup. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
displayGroupDidSetValueForObject
public void displayGroupDidSetValueForObject
(EODisplayGroup aDisplayGroup, java.lang.Object anObject, java.lang.Object anObject, java.lang.String aString)
Overriden by subclasses to aDisplayGroup. In the setMasterDisplayGroup
and setControllerDisplayGroup
methods EOInterfaceController sets itself as the delegate of its master and controller display groups if no other object has claimed delegate status. The default implementation of this delegation method simply invokes redisplayControllerDisplayGroup
.
editingContext
public com.apple.client.eocontrol.EOEditingContext editingContext
()
Returns the EOEditingContext established through setEditingContext
, which should also be that of the master display group's data source. All manipulation of enterprise objects must occur within an editing context.
See also:
- masterDisplayGroup
handleEditingContextChanges
public void handleEditingContextChanges
(NSNotification aNotification)
Implemented by observers of EOEditingContext's ObjectsChangedInEditingContext and EditingContextDidSaveChanges notifications; when setEditingContext
is invoked, the receiver is automatically registered as an observer. The default implementation simply invokes redisplayControllerDisplayGroup
and updateWindowTitle
.
handleWindowClosing
protected void handleWindowClosing
()
Invoked when the window containing the receiver's component is about to close. The default implementation invokes saveIfUserConfirmsAndCloseWindow
.
See also:
- component
insertIntoControllerDisplayGroup
protected void insertIntoControllerDisplayGroup
()
Makes the receiver the only object in the controller display group and selects it. This method is invoked whenever setControllerDisplayGroup
is invoked.
isEdited
public boolean isEdited
()
Returns whether the receiver's editing context has changes and thus whether the receiver is "dirty."
See also:
- editingContext
isRunning
public boolean isRunning
()
Returns whether component
currently has a parent.
isRunningInContainer
public boolean isRunningInContainer
()
Returns true
if no JFrame or JDialog has been instantiated by the receiver but component
still has a parent.
isRunningInFrame
public boolean isRunningInFrame
()
Returns true
if runInFrame
has previously been invoked but closeWindow
has not.
isRunningInModalDialog
public boolean isRunningInModalDialog
()
Returns true
if runInModalDialog
has previously been invoked but closeWindow
has not.
loadArchive
protected void loadArchive
()
Convenience method equivalent invoking the following form with a null parameter.
protected void loadArchive (java.lang.String archiveName)
Loads a new instance of the EOArchive named archiveName with the receiver as its owner and a null archive package name, throwing if the attempt fails (see EOArchive's loadArchiveNamed ). If archiveName is null the name of the receiver's class will be used instead.
locateWindow
protected void locateWindow
(java.awt.Window window)
Invoked within runInFrame
and runInModalDialog
, this method positions window at its appropriate initial location, center screen in the default implementation.
masterDisplayGroup
public EODisplayGroup masterDisplayGroup
()
Returns an EODisplayGroup containing the "master" enterprise objects primarily manipulated by the receiver's user interface (the EOArchive associated with the receiver may well contain additional display groups).
A component containing a display of Studios, for example, might contain additional displays of Movies the selected Studio has produced and Talent in its stable, but the Studio EODisplayGroup would drive these details and therefore be the "master."
masterObject
public com.apple.client.eocontrol.EOEnterpriseObject masterObject
()
Returns that single enterprise object currently selected in the receiver's masterDisplayGroup
.
masterObjectGlobalID
public com.apple.client.eocontrol.EOGlobalID masterObjectGlobalID
()
Returns the EOGlobalID of the masterObject
.
objectWillChange
public void objectWillChange
(java.lang.Object object)
Actually EOObserverCenter's notification hook, this method is implemented by EOInterfaceController in order to invoke redisplayControllerDisplayGroup
whenever object is the receiver.
redisplayControllerDisplayGroup
public void redisplayControllerDisplayGroup
()
Invoked whenever the contents or selection of controllerDisplayGroup
changes (see objectWillChange
), this method sends the display group a redisplay message.
A "presentation-neutral" form of the following three more specific editions, this method is intended to be invoked when the consumer is content to leave component
presentation details to the receiver. The default implementation invokes runInFrame
.
runInContainer
public void runInContainer
(java.awt.Container container)
Adds the receiver's component
to container.
runInFrame
public void runInFrame
()
Instantiates a JFrame containing the receiver's component
and makes it visible atop the window stack.
runInModalDialog
public void runInModalDialog
()
Instantiates a modal JDialog containing the receiver's component
and makes it visible atop the window stack.
Sends editingContext
a saveChanges message with the receiver as its sender and presents an error dialog containing any exception if this invocation fails. Returns true
if saveChanges succeeds, false
otherwise.
saveAndCloseWindow
public boolean saveAndCloseWindow
()
Invokes save
and, upon success, closeWindow
, returning save
's result.
saveIfUserConfirms
public boolean saveIfUserConfirms
()
Convenience method invoking the following two parameter form with a null dialogTitle and message.
public boolean saveIfUserConfirms
(java.lang.String dialogTitle, java.lang.String message)
Invokes save
once the user has confirmed this operation in a dialog titled dialogTitle containing message (both arguments take on default values if null). Returns true
if the operation is confirmed and succeeds, false
otherwise.
saveIfUserConfirmsAndCloseWindow
public boolean saveIfUserConfirmsAndCloseWindow
()
Invokes the two parameter form of saveIfUserConfirms
with the dialogTitle "Close" and a null message. If the operation is confirmed, closeWindow
is invoked. Returns the result of saveIfUserConfirms .
setComponent
public void setComponent
(java.awt.Component component)
Establishes component as the main entry point into the receiver's user interface. If component is a Window or RootPaneContainer, the receiver's component
will actually wind up being a new EOView containing its subcomponents rather than component, as the appropriate root container will be determined by which run... method is subsequently invoked. If component is not a Window it will be removed from any existing parent.
setControllerDisplayGroup
public void setControllerDisplayGroup
(EODisplayGroup displayGroup)
Typically invoked only by EOArchive in re-establishing a connection made in the receiver's corresponding InterfaceBuilder document, this method establishes displayGroup as the EODisplayGroup which will vend the receiver's keys (also see controllerDisplayGroup
). The default implementation invokes insertIntoControllerDisplayGroup
before making the receiver both an observer of displayGroup and its delegate in the absence of any other.
setEditingContext
public void setEditingContext
(com.apple.client.eocontrol.EOEditingContext editingContext)
Typically invoked only by EOArchive in re-establishing a connection made in the receiver's corresponding InterfaceBuilder document, this method establishes editingContext as the EOEditingContext for any manipulated enterprise objects (also see editingContext
). This should be the same as that of masterDisplayGroup
's dataSource . The default implementation adds the receiver as a recipient of ObjectsChangedInEditingContext and EditingContextDidSaveChanges notifications sent to handleEditingContextChanges
.
setMasterDisplayGroup
public void setMasterDisplayGroup
(EODisplayGroup displayGroup)
Establishes displayGroup as the EODisplayGroup containing the "master" enterprise objects manipulated in component
(also see masterDisplayGroup
).
setMasterWithGlobalID
public void setMasterWithGlobalID
(com.apple.client.eocontrol.EOGlobalID gid)
Attempts to retrieve that enterprise object with gid from the EOEditingContext of masterDisplayGroup
's dataSource . If successful, this object is set as masterDisplayGroup
's new contents and selection. If not, the masterDisplayGroup
will be emptied.
setMasterWithObject
public void setMasterWithObject
(com.apple.client.eocontrol.EOEnterpriseObject anEO)
Retrieves anEO's EOGlobalID from its editing context and invokes setMasterWithGlobalID
.
setTitle
public void setTitle
(java.lang.String title)
Sets the receiver's title to title. Note that this value will be used in constructing the receiver's windowTitle
. Invocations of this method will have no effect on window titles until changes occur in the receiver's editing context.
showWindow
public void showWindow
()
If the receiver's root container is a Window, this method makes it visible atop the window stack.
title
public java.lang.String title
()
Returns any title explicitly set for the receiver via setTitle
.
updateWindowTitle
public void updateWindowTitle
()
Sets the title of any Window created by the receiver to the current value of windowTitle
.
window
public java.awt.Window window
()
Returns the Window created to contain the receiver's component
, which will only be non-null if runInFrame
or runInModalDialog
have previously been invoked.
windowTitle
protected java.lang.String windowTitle
()
Returns title
if it has been explicitly set or an de-packaged, prettified edition of the receiver's class name. Both will be prefixed by an asterisk if isEdited
currently returns true
.
![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
Copyright © 1998, Apple Computer, Inc. All rights reserved.