rolodex
Class RolodexTextEditor

java.lang.Object
  |
  +--mvp.View
        |
        +--rolodex.RolodexTextEditor
All Implemented Interfaces:
java.util.Observer, java.io.Serializable

public class RolodexTextEditor
extends mvp.View

Class RolodexTextEditor is a purely textual view of the Rolodex model class. It presents a UNIX-like (Notepad-like) plain text editor in which the textual version of the complete rolodex is displayed and may be edited in a restricted fashion. The RolodexTextEditor window is a java JTextArea.

It is noteworthy this textual rolodex view uses exactly the same Rolodex model API as the GUI rolodex view in RolodexMenuUI.

It is also noteworthy that this view is an observer of its companion Rolodex model. This means that this' update method will be called whenever the Rolodex has changed. The determination of when the model object has actually changed is made by the model itself, when it calls the setChanged method. In the Rolodex Model, setChanged is called in Rolodex.add , Rolodex.delete , and Rolodex.change, q.q.v. The determination of when to notify observers is made in View objects that call Model objects that may (potentially) change the model. In the Rolodex Tool, notifying View classes are the button listeners that confirm one of the Rolodex changing operations, viz., OKAddButtonListener.actionPerformed, OKDeleteButtonListener.actionPerformed, and OKChangeButtonListener.actionPerformed, q.q.v.

See Also:
Serialized Form

Field Summary
protected  javax.swing.JTextArea jta
          The representation of this is a JTextArea.
protected  RolodexMultiViewMenuUI rmui
          The grandparent view.
 
Fields inherited from class mvp.View
closeAdapter, editable, model, screen, shown, widget, window
 
Constructor Summary
RolodexTextEditor(mvp.Screen s, RolodexMultiViewMenuUI rmui, Rolodex r)
          Construct this with the given Screen, RolodexMultiViewMenuUI grandparent view, and Rolodex model.
 
Method Summary
 java.awt.Component compose()
          Compose the window of this by adding the JTextArea and commit button.
 void update(java.util.Observable o, java.lang.Object arg)
          Respond to a change in the companion model.
 
Methods inherited from class mvp.View
getModel, getWidget, getWindow, hide, isEditable, isShown, run, setEditable, setExitOnClose, setModel, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jta

protected javax.swing.JTextArea jta
The representation of this is a JTextArea.


rmui

protected RolodexMultiViewMenuUI rmui
The grandparent view.

Constructor Detail

RolodexTextEditor

public RolodexTextEditor(mvp.Screen s,
                         RolodexMultiViewMenuUI rmui,
                         Rolodex r)
Construct this with the given Screen, RolodexMultiViewMenuUI grandparent view, and Rolodex model.

Method Detail

compose

public java.awt.Component compose()
Compose the window of this by adding the JTextArea and commit button.

Overrides:
compose in class mvp.View

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Respond to a change in the companion model. The current implementation is simply a stub. The complete implementation would display the updated Rolodex in the text area. This could be accomplished brute force by completely erasing and redisplaying the text area with a full enumeration of the Rolodex cards. Alternatively, a more sophisticated form of incremental update could be performed that only changes the affected card. In the latter case, callers of this update method could oblige by passing in the card that was affected, plus an indication of the operation performed. Since the current specification of the Rolodex Model only provides single-card updating operations (i.e., add, delete, change), incremental update can be guaranteed only to affect only one card.

Specified by:
update in interface java.util.Observer
Overrides:
update in class mvp.View