|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.ArrayPanel
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.
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 javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| 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 |
public static final String CONTROLS
public static final String INCREMENT_BUTTON_TEXT
public static final String DECREMENT_BUTTON_TEXT
public static final String LENGTH_PROMPT
public static final String SET_BUTTON_TEXT
public static final String LENGTH
public static final String MINIMUM_LENGTH
public static final String MAXIMUM_LENGTH
public static final int NO_CONTROLS
public static final int INCREMENT_DECREMENT
public static final int LENGTH_TEXT_FIELD
protected static final int CONTROLS_MASK
public static final int DEFAULT_CONTROLS
public static final int DEFAULT_ALIGNMENT
public static final int DEFAULT_ORIENTATION
public static final int DEFAULT_MINIMUM_LENGTH
public static final int DEFAULT_MAXIMUM_LENGTH
protected int align
protected int controlsValue
protected int minLength
protected int maxLength
protected int userMinLength
protected int userMaxLength
protected DisplayCollection views
protected ScrollableDisplay scroller
protected DisplayPanel controlPanel
protected Action increment
protected Action decrement
protected ActionsPanel lengthActions
protected TextFieldView lengthField
protected RangeFilter.Long lengthFilter
protected Action set
protected ActionsPanel setActions
protected Display lengthControls
protected InputProperties properties
protected String defaultViewState
| Constructor Detail |
public ArrayPanel()
ArrayPanel(Stringable[]),
ArrayPanel(Stringable[], int),
ArrayPanel(Stringable[], int, int, int)public ArrayPanel(Stringable[] obj)
null,
the array is set to length 0.
obj - an array of data models
for the elements of the collectionArrayPanel(),
ArrayPanel(Stringable[], int),
ArrayPanel(Stringable[], int, int, int)
public ArrayPanel(Stringable[] obj,
int orientation)
null,
the array is set to length 0.
If the given orientation is not valid,
the default orientation is used.
obj - an array of data models
for the elements of the collectionorientation - the orientation for the view collectionArrayPanel(),
ArrayPanel(Stringable[]),
ArrayPanel(Stringable[], int, int, int)
public ArrayPanel(Stringable[] obj,
int orientation,
int controls,
int alignment)
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.
obj - an array of data models
for the elements of the collectionorientation - the orientation for the view collectioncontrols - the length controls for the componentalignment - the alignment of length controls
relative to the view collectionArrayPanel(),
ArrayPanel(Stringable[]),
ArrayPanel(Stringable[], int)| Method Detail |
public abstract Class getDataType()
TypedView
getDataType in interface TypedViewpublic abstract Stringable demandObject()
TypedViewStringable object based on the view state
of the view using the mandatory model.
demandObject in interface TypedViewStringable model objectTypedView.requestObject()
public abstract Stringable requestObject()
throws CancelledException
TypedViewStringable 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.
requestObject in interface TypedViewStringable model object
CancelledExceptionTypedView.demandObject()public void setInputProperties(InputProperties p)
TypedViewSets 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.
setInputProperties in interface TypedViewp - the new input properties for the viewTypedView.getInputProperties()public InputProperties getInputProperties()
TypedView
getInputProperties in interface TypedViewTypedView.setInputProperties(InputProperties)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
class.DisplayPanel
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.
setViewState in interface DisplayablesetViewState in class DisplayPaneldata - the encoded String datagetViewState(),
Displayablepublic String getViewState()
String.
The view state for the collection is encoded
in the manner described in the API documentation for the
DisplayPanel class.
getViewState in interface DisplayablegetViewState in class DisplayPanelsetViewState(String),
Displayablepublic void setDefaultViewState(String data)
String.
If null, the default view state
for the collection is encoded in the manner described
in the API documentation for the
DisplayPanel class.
setDefaultViewState in interface DisplayablesetDefaultViewState in class DisplayPaneldata - the desired default String datareset(),
Displayablepublic String getDefaultViewState()
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.
getDefaultViewState in interface DisplayablegetDefaultViewState in class DisplayPanelsetDefaultViewState(String),
reset()public void reset()
reset in interface Displayablereset in class DisplayPanelsetDefaultViewState(String),
Displayablepublic Stringable[] demandObjectArray()
requestObjectArray(),
demandObject()
public Stringable[] requestObjectArray()
throws CancelledException
CancelledException - if the user cancels the input operationdemandObjectArray(),
requestObject()public TypedView getView(int index)
index - the index of the view to be returnedpublic void setOrientation(int orientation)
orientation - the new orientation for this collectiongetOrientation(),
SwingConstants.HORIZONTAL,
SwingConstants.VERTICAL,
JPTConstants.DEFAULTpublic int getOrientation()
setOrientation(int)public void setAlignment(int alignment)
alignment - the new alignment of length controls
relative to the view collectiongetAlignment(),
JPTConstants.ABOVE,
JPTConstants.BELOW,
SwingConstants.LEFT,
SwingConstants.RIGHT,
JPTConstants.DEFAULTpublic int getAlignment()
setAlignment(int),
JPTConstants.ABOVE,
JPTConstants.BELOW,
SwingConstants.LEFT,
SwingConstants.RIGHTpublic void setControls(int controls)
controls - the sum of the values corresponding to
each of the desired controlsgetControls(),
NO_CONTROLS,
INCREMENT_DECREMENT,
LENGTH_TEXT_FIELD,
JPTConstants.DEFAULTpublic int getControls()
setControls(int),
NO_CONTROLS,
INCREMENT_DECREMENT,
LENGTH_TEXT_FIELDpublic void setIncrementButtonText(String s)
String.
If the given String is null,
the button label is not changed.
s - the new label text for the length increment buttongetIncrementButtonText()public String getIncrementButtonText()
setIncrementButtonText(String)public void setDecrementButtonText(String text)
String.
If the given String is null,
the button label is not changed.
text - the new label text
for the length decrement buttongetDecrementButtonText()public String getDecrementButtonText()
setDecrementButtonText(String)public void setLengthPrompt(String prompt)
String.
If the given String is null,
the prompt text is not changed.
prompt - the new length field prompt textgetLengthPrompt()public String getLengthPrompt()
setLengthPrompt(String)public void setSetButtonText(String text)
String.
If the given String is null,
the button label is not changed.
text - the new label text for the length set buttongetSetButtonText()public String getSetButtonText()
setSetButtonText(String)public void setLength(int length)
length - the desired length of the arraypublic int getLength()
public void setMinimumLength(int length)
length - the minimum lengthgetMinimumLength(),
setMaximumLength(int),
getMaximumLength()public int getMinimumLength()
setMinimumLength(int),
getMaximumLength(),
setMaximumLength(int)public void setMaximumLength(int length)
length - the maximum lengthgetMaximumLength(),
setMinimumLength(int),
getMinimumLength()public int getMaximumLength()
setMaximumLength(int),
getMinimumLength(),
setMinimumLength(int)protected Display.Settings createDisplaySettingsFor(int index)
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.
index - the index of the elementcreateViewFor(int),
createPromptTextFor(int),
"Building a custom ArrayPanel"protected TypedView createViewFor(int index)
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.
index - the index of the elementcreateDisplaySettingsFor(int),
createPromptTextFor(int),
"Building a custom ArrayPanel"protected String createPromptTextFor(int index)
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.
index - the index of the elementcreateDisplaySettingsFor(int),
createViewFor(int),
"Building a custom ArrayPanel"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.
exception - the filter exception that was generated
by the filter policing the array length boundsprotected void increment(String 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.
data - the desired data state for the elementprotected TypedView decrement()
protected void applyLengthFromControls()
protected int requestArrayLength()
throws CancelledException
CancelledException - if the user cancels the set length operationprotected int transformUserLengthToRawLength(int userLength)
userLength - a length of this array
from the user perspectiveprotected int transformRawLengthToUserLength(int rawLength)
rawLength - a raw length of this arrayprotected void revalidateDisplay()
protected DisplayPanel createControlPanel()
private final Display createDisplayFor(int index)
index - the index of the desired element
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||