edu.neu.ccs.gui
Class ArrayPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.ArrayPanel
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants, TypedView

public abstract class ArrayPanel
extends DisplayPanel
implements TypedView

Class ArrayPanel is an abstract class that is designed for the input of an array of a single type of Stringable object; this class must implement the TypedView interface in such a way that the data type associated with this view is constructed via the Stringable array in some fashion.

To implement TypedView, a derived class must implement at least the following 3 methods:

    public abstract Class getDataType()
    public abstract Stringable demandObject()
    public abstract Stringable requestObject()
         throws CancelledException

An ArrayPanel is an integrated component that contains a collection of TypedViews for input of the corresponding set of Stringable objects. The panel also provides for optional controls that permit the end user to dynamically modify the length of the TypedView array.

The developer can control the TypedView that is inserted into the array panel by overriding the protected method:

    protected TypedView createViewFor(int index)

The default implementation of this method returns a generic TextFieldView. It is very likely that the developer will want to override this default definition.

Experience with ArrayPanel has shown that although the class is powerful it is also complex to use. As of 2.4.0, we have introduced the SimpleArrayPanel class that takes a different approach and is significantly easier to use. The class SimpleArrayPanel is not abstract so it may be used directly without the need to make a derived class that implements TypedView.

For backward compatibility, the class ArrayPanel has been left basically as is.

Since:
1.0
Version:
2.4.0
See Also:
TypedView, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int align
          Alignment of the length controls relative to the view collection.
protected  DisplayPanel controlPanel
          Panel containing the length controls.
static String CONTROLS
          Bound property name for the visible controls property.
protected static int CONTROLS_MASK
          Bit mask for the valid controls options.
protected  int controlsValue
          Value specifying the visible length controls.
protected  Action decrement
          Action for decrementing the length of this array.
static String DECREMENT_BUTTON_TEXT
          Bound property name for the decrement button text.
static int DEFAULT_ALIGNMENT
          Default alignment of length controls relative to the view collection.
static int DEFAULT_CONTROLS
          Default value specifying the visible length controls.
static int DEFAULT_MAXIMUM_LENGTH
          Default maximum length for the array.
static int DEFAULT_MINIMUM_LENGTH
          Default minimum length for the array.
static int DEFAULT_ORIENTATION
          Default direction of the view collection.
protected  String defaultViewState
          Default view state for the elements of this array.
protected  Action increment
          Action for incrementing the length of this array.
static String INCREMENT_BUTTON_TEXT
          Bound property name for the increment button text.
static int INCREMENT_DECREMENT
          Value designating the increment and decrement controls.
static String LENGTH
          Bound property name for the length of the array.
static String LENGTH_PROMPT
          Bound property name for the length prompt.
static int LENGTH_TEXT_FIELD
          Value designating the length field and set button controls.
protected  ActionsPanel lengthActions
          Actions panel containing the increment and decrement array length actions.
protected  Display lengthControls
          Display containing the length field and its prompt.
protected  TextFieldView lengthField
          Text field for input of the array length.
protected  RangeFilter.Long lengthFilter
          Filter used by array length field to enforce minimum and maximum array length.
static String MAXIMUM_LENGTH
          Bound property name for the maximum length of the array.
protected  int maxLength
          Maximum length of this array.
static String MINIMUM_LENGTH
          Bound property name for the minimum length of the array.
protected  int minLength
          Minimum length of this array.
static int NO_CONTROLS
          Value designating no desired length controls.
protected  InputProperties properties
          Property list for this view object.
protected  ScrollableDisplay scroller
          The view collection scrolling display.
protected  Action set
          Button for setting the length of this array to the value held in the field contained in the length controls.
static String SET_BUTTON_TEXT
          Bound property name for the set button text.
protected  ActionsPanel setActions
          Actions panel containing the set array length action.
protected  int userMaxLength
          Maximum length of this array in user coordinates.
protected  int userMinLength
          Minimum length of this array in user coordinates.
protected  DisplayCollection views
          The view collection used by this array.
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface edu.neu.ccs.gui.TypedView
DATA_TYPE
 
Fields inherited from interface edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ArrayPanel()
          Constructs an array panel of length 0 with the default orientation, controls, and alignment.
ArrayPanel(Stringable[] obj)
          Constructs an array panel displaying the given array of model objects with the default direction, controls, and alignment.
ArrayPanel(Stringable[] obj, int orientation)
          Constructs an array panel displaying the given array of model objects with the given orientation, and the default controls and alignment.
ArrayPanel(Stringable[] obj, int orientation, int controls, int alignment)
          Constructs an array panel displaying the given array of model objects with the given orientation, controls and alignment.
 
Method Summary
protected  void applyLengthFromControls()
          Sets the length of the array, that is, the number of views in the collection, to the raw array length represented by the view state of the length field.
protected  DisplayPanel createControlPanel()
          Creates a length control panel with the appropriate controls.
private  Display createDisplayFor(int index)
          Creates an appropriate display for an element at the given index by combining an appropriate view object with the appropriate prompt text, using a display object with the appropriate settings.
protected  Display.Settings createDisplaySettingsFor(int index)
          Returns a display settings object appropriate for the element at the given index.
 String createLengthSetOutOfBoundsMessage(FilterException exception)
          Returns an error message indicating that the user attempted to set the array length to a value that is less than the minimum array length or greater than the maximum array length.
protected  String createPromptTextFor(int index)
          Returns prompt text suitable for the element at the given index in this array.
protected  TypedView createViewFor(int index)
          Returns an input component suitable for the element at the given index in this array.
protected  TypedView decrement()
          Removes the last input component from the end of the view collection.
abstract  Stringable demandObject()
          Returns a Stringable object based on the view state of the view using the mandatory model.
 Stringable[] demandObjectArray()
          Returns an array of model objects of the appropriate type initialized from the view states for the elements of this array panel, using the mandatory model of IO.
 int getAlignment()
          Returns the alignment value of the length controls relative to the view collection.
 int getControls()
          Returns the controls value corresponding with the current length controls.
abstract  Class getDataType()
          Returns the current class of objects returned when a model object is demanded or requested.
 String getDecrementButtonText()
          Returns the current label for the length decrement button.
 String getDefaultViewState()
          Returns the default view state for this array panel as an encoded String.
 String getIncrementButtonText()
          Returns the current label for the length increment button.
 InputProperties getInputProperties()
          Returns the input properties for this view.
 int getLength()
          Returns the current length of this array, that is, the number of views in this collection.
 String getLengthPrompt()
          Returns the prompt text for the length field.
 int getMaximumLength()
          Returns the maximum length for this array.
 int getMinimumLength()
          Returns the minimum length of this array.
 int getOrientation()
          Returns the current orientation value of the view collection.
 String getSetButtonText()
          Returns the current label text for the length set button.
 TypedView getView(int index)
          Returns the view element at the given index.
 String getViewState()
          Returns the view states for objects in the collection as an encoded String.
protected  void increment(String data)
          Appends an appropriate input component to the end of the view collection whose view state is initialized from the given data String.
protected  int requestArrayLength()
          Returns the value contained in the length field after applying the filter that polices the minimum and maximum array length and transforming the value from the user length perspective to the raw length perspective.
abstract  Stringable requestObject()
          Returns a Stringable object based on the view state of the view using the optional model; throws an exception if the input operation is cancelled by the user.
 Stringable[] requestObjectArray()
          Returns an array of model objects of the appropriate type initialized from the view states for the elements of this array panel, using the optional model of IO.
 void reset()
          Sets the view state for this array panel to the default view state for this array panel.
protected  void revalidateDisplay()
          Updates the contents and layout of the control panel based on the current parameters.
 void setAlignment(int alignment)
          Sets the alignment of the length controls relative to the view collection to the given alignment value.
 void setControls(int controls)
          Sets the length controls for this array panel to those designated by the given value.
 void setDecrementButtonText(String text)
          Sets the label for the length decrement button to the given String.
 void setDefaultViewState(String data)
          Sets the default view state for the elements of this array panel to the data encoded in the given String.
 void setIncrementButtonText(String s)
          Sets the label for the length increment button to the given String.
 void setInputProperties(InputProperties p)
          Sets the input properties for this view to the provided input properties.
 void setLength(int length)
          Sets the length of the array, that is, the number of views in the collection, to the provided value.
 void setLengthPrompt(String prompt)
          Sets the prompt for the length field to the given String.
 void setMaximumLength(int length)
          Sets the maximum length of this array to the given value.
 void setMinimumLength(int length)
          Sets the minimum length of this array to the given value.
 void setOrientation(int orientation)
          Sets the orientation of this view collection to the given orientation value.
 void setSetButtonText(String text)
          Sets the label for the length set button to the given String.
 void setViewState(String data)
          Sets the view states for Displayable objects in this collection to the data encoded in the given String.
protected  int transformRawLengthToUserLength(int rawLength)
          Returns the array length from the user perspective corresponding to the given raw array length.
protected  int transformUserLengthToRawLength(int userLength)
          Returns the raw array length corresponding to the given array length from the user perspective.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewStates, getDisplayables, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewStates, setEnabled, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.neu.ccs.gui.Displayable
setEnabled
 

Field Detail

CONTROLS

public static final String CONTROLS
Bound property name for the visible controls property.

See Also:
Constant Field Values

INCREMENT_BUTTON_TEXT

public static final String INCREMENT_BUTTON_TEXT
Bound property name for the increment button text.

See Also:
Constant Field Values

DECREMENT_BUTTON_TEXT

public static final String DECREMENT_BUTTON_TEXT
Bound property name for the decrement button text.

See Also:
Constant Field Values

LENGTH_PROMPT

public static final String LENGTH_PROMPT
Bound property name for the length prompt.

See Also:
Constant Field Values

SET_BUTTON_TEXT

public static final String SET_BUTTON_TEXT
Bound property name for the set button text.

See Also:
Constant Field Values

LENGTH

public static final String LENGTH
Bound property name for the length of the array.

See Also:
Constant Field Values

MINIMUM_LENGTH

public static final String MINIMUM_LENGTH
Bound property name for the minimum length of the array.

See Also:
Constant Field Values

MAXIMUM_LENGTH

public static final String MAXIMUM_LENGTH
Bound property name for the maximum length of the array.

See Also:
Constant Field Values

NO_CONTROLS

public static final int NO_CONTROLS
Value designating no desired length controls.

See Also:
Constant Field Values

INCREMENT_DECREMENT

public static final int INCREMENT_DECREMENT
Value designating the increment and decrement controls.

See Also:
Constant Field Values

LENGTH_TEXT_FIELD

public static final int LENGTH_TEXT_FIELD
Value designating the length field and set button controls.

See Also:
Constant Field Values

CONTROLS_MASK

protected static final int CONTROLS_MASK
Bit mask for the valid controls options.

See Also:
Constant Field Values

DEFAULT_CONTROLS

public static final int DEFAULT_CONTROLS
Default value specifying the visible length controls.

See Also:
Constant Field Values

DEFAULT_ALIGNMENT

public static final int DEFAULT_ALIGNMENT
Default alignment of length controls relative to the view collection.

See Also:
Constant Field Values

DEFAULT_ORIENTATION

public static final int DEFAULT_ORIENTATION
Default direction of the view collection.

See Also:
Constant Field Values

DEFAULT_MINIMUM_LENGTH

public static final int DEFAULT_MINIMUM_LENGTH
Default minimum length for the array.

See Also:
Constant Field Values

DEFAULT_MAXIMUM_LENGTH

public static final int DEFAULT_MAXIMUM_LENGTH
Default maximum length for the array.

See Also:
Constant Field Values

align

protected int align
Alignment of the length controls relative to the view collection.


controlsValue

protected int controlsValue
Value specifying the visible length controls.


minLength

protected int minLength
Minimum length of this array.


maxLength

protected int maxLength
Maximum length of this array.


userMinLength

protected int userMinLength
Minimum length of this array in user coordinates.


userMaxLength

protected int userMaxLength
Maximum length of this array in user coordinates.


views

protected DisplayCollection views
The view collection used by this array.


scroller

protected ScrollableDisplay scroller
The view collection scrolling display.


controlPanel

protected DisplayPanel controlPanel
Panel containing the length controls.


increment

protected Action increment
Action for incrementing the length of this array.


decrement

protected Action decrement
Action for decrementing the length of this array.


lengthActions

protected ActionsPanel lengthActions
Actions panel containing the increment and decrement array length actions.


lengthField

protected TextFieldView lengthField
Text field for input of the array length.


lengthFilter

protected RangeFilter.Long lengthFilter
Filter used by array length field to enforce minimum and maximum array length.


set

protected Action set
Button for setting the length of this array to the value held in the field contained in the length controls.


setActions

protected ActionsPanel setActions
Actions panel containing the set array length action.


lengthControls

protected Display lengthControls
Display containing the length field and its prompt.


properties

protected InputProperties properties
Property list for this view object.


defaultViewState

protected String defaultViewState
Default view state for the elements of this array.

Constructor Detail

ArrayPanel

public ArrayPanel()
Constructs an array panel of length 0 with the default orientation, controls, and alignment.

See Also:
ArrayPanel(Stringable[]), ArrayPanel(Stringable[], int), ArrayPanel(Stringable[], int, int, int)

ArrayPanel

public ArrayPanel(Stringable[] obj)
Constructs an array panel displaying the given array of model objects with the default direction, controls, and alignment. If the given array is null, the array is set to length 0.

Parameters:
obj - an array of data models for the elements of the collection
See Also:
ArrayPanel(), ArrayPanel(Stringable[], int), ArrayPanel(Stringable[], int, int, int)

ArrayPanel

public ArrayPanel(Stringable[] obj,
                  int orientation)
Constructs an array panel displaying the given array of model objects with the given orientation, and the default controls and alignment. If the given array is null, the array is set to length 0. If the given orientation is not valid, the default orientation is used.

Parameters:
obj - an array of data models for the elements of the collection
orientation - the orientation for the view collection
See Also:
ArrayPanel(), ArrayPanel(Stringable[]), ArrayPanel(Stringable[], int, int, int)

ArrayPanel

public ArrayPanel(Stringable[] obj,
                  int orientation,
                  int controls,
                  int alignment)
Constructs an array panel displaying the given array of model objects with the given orientation, controls and alignment. If the given array is null, the array is set to length 0. If the given orientation is not valid, the default orientation is used. If the given controls value is not valid, the default controls are included. If the given alignment value is not valid, the default alignment is used.

Parameters:
obj - an array of data models for the elements of the collection
orientation - the orientation for the view collection
controls - the length controls for the component
alignment - the alignment of length controls relative to the view collection
See Also:
ArrayPanel(), ArrayPanel(Stringable[]), ArrayPanel(Stringable[], int)
Method Detail

getDataType

public abstract Class getDataType()
Description copied from interface: TypedView
Returns the current class of objects returned when a model object is demanded or requested.

Specified by:
getDataType in interface TypedView
Returns:
the current class of a model object

demandObject

public abstract Stringable demandObject()
Description copied from interface: TypedView
Returns a Stringable object based on the view state of the view using the mandatory model.

Specified by:
demandObject in interface TypedView
Returns:
a Stringable model object
See Also:
TypedView.requestObject()

requestObject

public abstract Stringable requestObject()
                                  throws CancelledException
Description copied from interface: TypedView
Returns a Stringable object based on the view state of the view using the optional model; throws an exception if the input operation is cancelled by the user.

Specified by:
requestObject in interface TypedView
Returns:
a Stringable model object
Throws:
CancelledException
See Also:
TypedView.demandObject()

setInputProperties

public void setInputProperties(InputProperties p)
Description copied from interface: TypedView

Sets the input properties for this view to the provided input properties.

If the given input properties list is null, the property list for this view is set to the base property list containing default property values.

Specified by:
setInputProperties in interface TypedView
Parameters:
p - the new input properties for the view
See Also:
TypedView.getInputProperties()

getInputProperties

public InputProperties getInputProperties()
Description copied from interface: TypedView
Returns the input properties for this view.

Specified by:
getInputProperties in interface TypedView
Returns:
the input properties
See Also:
TypedView.setInputProperties(InputProperties)

setViewState

public void setViewState(String data)

Sets the view states for Displayable objects in this collection to the data encoded in the given String. The length of this array is set to the number of view states contained in the given encoded String before the view states for the views in this collecion are set. Each object in the collection has its view state set from the encoded String data in the manner described in the API documentation for the DisplayPanel class.

If the given encoded data is null, the view state is not changed. If the given data is an encoding for null, the view state is not changed.

Implementation change: As of 2.4.0 decodes the data parameter using Strings.decode.

Specified by:
setViewState in interface Displayable
Overrides:
setViewState in class DisplayPanel
Parameters:
data - the encoded String data
See Also:
getViewState(), Displayable

getViewState

public String getViewState()
Returns the view states for objects in the collection as an encoded String. The view state for the collection is encoded in the manner described in the API documentation for the DisplayPanel class.

Specified by:
getViewState in interface Displayable
Overrides:
getViewState in class DisplayPanel
See Also:
setViewState(String), Displayable

setDefaultViewState

public void setDefaultViewState(String data)
Sets the default view state for the elements of this array panel to the data encoded in the given String. If null, the default view state for the collection is encoded in the manner described in the API documentation for the DisplayPanel class.

Specified by:
setDefaultViewState in interface Displayable
Overrides:
setDefaultViewState in class DisplayPanel
Parameters:
data - the desired default String data
See Also:
reset(), Displayable

getDefaultViewState

public String getDefaultViewState()
Returns the default view state for this array panel as an encoded String. If the default view state for this array panel has been set to null, or has not been set, the default view state for the collection is encoded in the manner described in the API documentation for the DisplayPanel class.

Specified by:
getDefaultViewState in interface Displayable
Overrides:
getDefaultViewState in class DisplayPanel
See Also:
setDefaultViewState(String), reset()

reset

public void reset()
Sets the view state for this array panel to the default view state for this array panel.

Specified by:
reset in interface Displayable
Overrides:
reset in class DisplayPanel
See Also:
setDefaultViewState(String), Displayable

demandObjectArray

public Stringable[] demandObjectArray()
Returns an array of model objects of the appropriate type initialized from the view states for the elements of this array panel, using the mandatory model of IO. This method relies on the individual element views to provide their own error strategy.

See Also:
requestObjectArray(), demandObject()

requestObjectArray

public Stringable[] requestObjectArray()
                                throws CancelledException
Returns an array of model objects of the appropriate type initialized from the view states for the elements of this array panel, using the optional model of IO. This method relies on the individual element views to provide their own error strategy.

Throws:
CancelledException - if the user cancels the input operation
See Also:
demandObjectArray(), requestObject()

getView

public TypedView getView(int index)
Returns the view element at the given index.

Parameters:
index - the index of the view to be returned

setOrientation

public void setOrientation(int orientation)
Sets the orientation of this view collection to the given orientation value. If the orientation value is not valid, the current orientation is not changed.

Parameters:
orientation - the new orientation for this collection
See Also:
getOrientation(), SwingConstants.HORIZONTAL, SwingConstants.VERTICAL, JPTConstants.DEFAULT

getOrientation

public int getOrientation()
Returns the current orientation value of the view collection.

See Also:
setOrientation(int)

setAlignment

public void setAlignment(int alignment)
Sets the alignment of the length controls relative to the view collection to the given alignment value. If the alignment value is not valid, the current alignment is not changed.

Parameters:
alignment - the new alignment of length controls relative to the view collection
See Also:
getAlignment(), JPTConstants.ABOVE, JPTConstants.BELOW, SwingConstants.LEFT, SwingConstants.RIGHT, JPTConstants.DEFAULT

getAlignment

public int getAlignment()
Returns the alignment value of the length controls relative to the view collection.

See Also:
setAlignment(int), JPTConstants.ABOVE, JPTConstants.BELOW, SwingConstants.LEFT, SwingConstants.RIGHT

setControls

public void setControls(int controls)
Sets the length controls for this array panel to those designated by the given value. If the given controls value is not valid, only the appropriate controls information contained in the value is used.

Parameters:
controls - the sum of the values corresponding to each of the desired controls
See Also:
getControls(), NO_CONTROLS, INCREMENT_DECREMENT, LENGTH_TEXT_FIELD, JPTConstants.DEFAULT

getControls

public int getControls()
Returns the controls value corresponding with the current length controls.

See Also:
setControls(int), NO_CONTROLS, INCREMENT_DECREMENT, LENGTH_TEXT_FIELD

setIncrementButtonText

public void setIncrementButtonText(String s)
Sets the label for the length increment button to the given String. If the given String is null, the button label is not changed.

Parameters:
s - the new label text for the length increment button
See Also:
getIncrementButtonText()

getIncrementButtonText

public String getIncrementButtonText()
Returns the current label for the length increment button.

See Also:
setIncrementButtonText(String)

setDecrementButtonText

public void setDecrementButtonText(String text)
Sets the label for the length decrement button to the given String. If the given String is null, the button label is not changed.

Parameters:
text - the new label text for the length decrement button
See Also:
getDecrementButtonText()

getDecrementButtonText

public String getDecrementButtonText()
Returns the current label for the length decrement button.

See Also:
setDecrementButtonText(String)

setLengthPrompt

public void setLengthPrompt(String prompt)
Sets the prompt for the length field to the given String. If the given String is null, the prompt text is not changed.

Parameters:
prompt - the new length field prompt text
See Also:
getLengthPrompt()

getLengthPrompt

public String getLengthPrompt()
Returns the prompt text for the length field.

See Also:
setLengthPrompt(String)

setSetButtonText

public void setSetButtonText(String text)
Sets the label for the length set button to the given String. If the given String is null, the button label is not changed.

Parameters:
text - the new label text for the length set button
See Also:
getSetButtonText()

getSetButtonText

public String getSetButtonText()
Returns the current label text for the length set button.

See Also:
setSetButtonText(String)

setLength

public void setLength(int length)
Sets the length of the array, that is, the number of views in the collection, to the provided value. The given array length is assumed to be a raw length and not a length provided from the user's perspective. This method ensures that the length is in the range specified by the current minimum and maximum length by increasing the given length to the minimum length or decreasing the given length to the maximum length as necessary.

Parameters:
length - the desired length of the array

getLength

public int getLength()
Returns the current length of this array, that is, the number of views in this collection.


setMinimumLength

public void setMinimumLength(int length)
Sets the minimum length of this array to the given value. The given minimum length is assumed to be a raw length and not a length provided from the user's perspective. If the given minimum length is less than zero, the minimum length is set to zero. If the given minimum length is greater than the maximum length the minimum length is set to the maximum length.

Parameters:
length - the minimum length
See Also:
getMinimumLength(), setMaximumLength(int), getMaximumLength()

getMinimumLength

public int getMinimumLength()
Returns the minimum length of this array.

See Also:
setMinimumLength(int), getMaximumLength(), setMaximumLength(int)

setMaximumLength

public void setMaximumLength(int length)
Sets the maximum length of this array to the given value. The given maximum length is assumed to be a raw length and not a length provided from the user's perspective. If the given maximum length is less than the minimum length, the minimum length is set to the maximum length.

Parameters:
length - the maximum length
See Also:
getMaximumLength(), setMinimumLength(int), getMinimumLength()

getMaximumLength

public int getMaximumLength()
Returns the maximum length for this array.

See Also:
setMaximumLength(int), getMinimumLength(), setMinimumLength(int)

createDisplaySettingsFor

protected Display.Settings createDisplaySettingsFor(int index)
Returns a display settings object appropriate for the element at the given index. By default this method returns a settings object encapsulating prompt text created by the createPromptTextFor method, the default prompt alignment, and no title. Derived classes may override this method and produce display settings appropriate for input of elements of a specific type.

Parameters:
index - the index of the element
See Also:
createViewFor(int), createPromptTextFor(int), "Building a custom ArrayPanel"

createViewFor

protected TypedView createViewFor(int index)
Returns an input component suitable for the element at the given index in this array. By default this method returns a TextFieldView with the empty string as its default view state. Derived classes may override this method and produce views appropriate for input of elements of a specific type.

Parameters:
index - the index of the element
See Also:
createDisplaySettingsFor(int), createPromptTextFor(int), "Building a custom ArrayPanel"

createPromptTextFor

protected String createPromptTextFor(int index)
Returns prompt text suitable for the element at the given index in this array. By default, this method returns a String containing the index of the element followed by a colon. Derived classes should override this method and produce prompt text appropriate for input of elements of a specific type.

Parameters:
index - the index of the element
See Also:
createDisplaySettingsFor(int), createViewFor(int), "Building a custom ArrayPanel"

createLengthSetOutOfBoundsMessage

public String createLengthSetOutOfBoundsMessage(FilterException exception)

Returns an error message indicating that the user attempted to set the array length to a value that is less than the minimum array length or greater than the maximum array length.

By default this method returns a String with an appropriate error message using the text returned by getLengthPrompt() to make the message more specific.

Parameters:
exception - the filter exception that was generated by the filter policing the array length bounds

increment

protected void increment(String data)
Appends an appropriate input component to the end of the view collection whose view state is initialized from the given data String. If null, the provided data is ignored and the default view state for the created view is used. This method assumes that the current array length is less than the maximum length of the array.

Parameters:
data - the desired data state for the element

decrement

protected TypedView decrement()
Removes the last input component from the end of the view collection. This method assumes that the current array length is greater than the minimum length of the array.

Returns:
the removed input component

applyLengthFromControls

protected void applyLengthFromControls()
Sets the length of the array, that is, the number of views in the collection, to the raw array length represented by the view state of the length field. If the view state of the length field is malformed and the user cancels error handling for the malformed data, the current array length will not be changed.


requestArrayLength

protected int requestArrayLength()
                          throws CancelledException
Returns the value contained in the length field after applying the filter that polices the minimum and maximum array length and transforming the value from the user length perspective to the raw length perspective.

Throws:
CancelledException - if the user cancels the set length operation

transformUserLengthToRawLength

protected int transformUserLengthToRawLength(int userLength)
Returns the raw array length corresponding to the given array length from the user perspective. By default, this method returns the given value. Derived classes may override this method in order to allow the user to have a mental model of the array length that differs from the raw length of this array.

Parameters:
userLength - a length of this array from the user perspective

transformRawLengthToUserLength

protected int transformRawLengthToUserLength(int rawLength)
Returns the array length from the user perspective corresponding to the given raw array length. By default, this method returns the given value. Derived classes may override this method in order to allow the raw length of the array to differ from the user's mental model of the array length.

Parameters:
rawLength - a raw length of this array

revalidateDisplay

protected void revalidateDisplay()
Updates the contents and layout of the control panel based on the current parameters.


createControlPanel

protected DisplayPanel createControlPanel()
Creates a length control panel with the appropriate controls.


createDisplayFor

private final Display createDisplayFor(int index)
Creates an appropriate display for an element at the given index by combining an appropriate view object with the appropriate prompt text, using a display object with the appropriate settings.

Parameters:
index - the index of the desired element