|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--java.util.AbstractList | +--java.util.ArrayList | +--edu.kzoo.grid.gui.GeneratedButtonList
Grid GUI Support Package:
A GeneratedButtonList
object creates a group of
control buttons based on the methods of another class. When the
GeneratedButtonList
object is constructed, the
client code must specify a target object (the object whose methods
are to be associated with control buttons) and a set of arguments
to be passed to those methods. The GeneratedButtonList
object will generate control buttons for all of the target object's
methods that could be passed the given set of arguments and have a
void
return type.
Nested Class Summary | |
protected class |
GeneratedButtonList.GeneratedThreadedControlButton
GeneratedThreadedControlButton objects represent buttons whose button action is to reflectively invoke the appropriate method in the target object. |
Field Summary | |
protected java.util.Map |
buttonLabelToMethodObjMap
|
protected boolean |
displayGridAfterButtonActions
|
protected GridAppFrame |
gui
|
protected boolean |
includeOnButtonClickMethodsOnly
|
static java.util.regex.Pattern |
methNamePattern
|
static java.lang.String |
methNameRegExpr
|
protected java.lang.Object[] |
methodArguments
|
static java.lang.String |
prefix
|
static java.lang.String |
suffix
|
protected java.util.List |
targetMethods
|
protected java.lang.Object |
targetObj
|
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary | |
GeneratedButtonList(GridAppFrame gui,
java.lang.Object targetObj,
boolean displayAfterButtonPresses)
Constructs a list of control buttons based on methods associated with the given target object. |
|
GeneratedButtonList(GridAppFrame gui,
java.lang.Object targetObj,
boolean onButtonClickMethodsOnly,
boolean displayAfterButtonPresses)
Constructs a list of control buttons based on methods associated with the given target object. |
|
GeneratedButtonList(GridAppFrame gui,
java.lang.Object targetObj,
java.lang.Object[] arguments,
boolean displayAfterButtonPresses)
Constructs a list of control buttons based on methods associated with the given target object. |
|
GeneratedButtonList(GridAppFrame gui,
java.lang.Object targetObj,
java.lang.Object[] arguments,
boolean onClickButtonMethodsOnly,
boolean displayAfterButtonPresses)
Constructs a list of control buttons based on methods associated with the given target object. |
Method Summary | |
protected java.lang.String |
buttonLabelFor(java.lang.reflect.Method method)
Returns the appropriate button label for the given method. |
protected void |
createButtons()
Creates control buttons that, when pressed, will pass a message to the appropriate method in the target object. |
protected void |
identifyButtonMethods()
Identifies the target object's methods for which control buttons should be created. |
protected boolean |
meetsControlMethodCriteria(java.lang.reflect.Method methodToCheck,
java.lang.Class targetClass)
Returns true if the given method was declared in
the specified class (not in one of its superclasses) and has
the right return type and parameters to be turned into a
control button; false otherwise. |
protected boolean |
meetsMethodNameFormatCriteria(java.lang.String methodName)
Returns true if the given method was declared in
the specified class (not in one of its superclasses) and has
the right return type and parameters to be turned into a
control button; false otherwise. |
void |
resetButtonLabel(java.lang.String prevButtonLabel,
java.lang.String buttonLabel)
Resets the specified button label associated with a method in the target object. |
Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
Field Detail |
public static final java.lang.String prefix
public static final java.lang.String suffix
public static final java.lang.String methNameRegExpr
public static final java.util.regex.Pattern methNamePattern
protected GridAppFrame gui
protected java.lang.Object targetObj
protected boolean includeOnButtonClickMethodsOnly
protected java.util.List targetMethods
protected java.lang.Object[] methodArguments
protected java.util.Map buttonLabelToMethodObjMap
protected boolean displayGridAfterButtonActions
Constructor Detail |
public GeneratedButtonList(GridAppFrame gui, java.lang.Object targetObj, boolean displayAfterButtonPresses)
void
return type. The text on
each control button will be the associated method name or, if the
name matches the on...ButtonClick format, the middle part of the
method name. For example, the control button for a doX method
would have the label "doX", while the control button for an
onDoYButtonClick method would have the label "DoY". When each
resulting control button is pressed, it will send the associated
message to the target object. It may also display the contents
of the grid afterward, depending on the value of
displayAfterButtonPresses
.
gui
- graphical user interface that will contain these
buttonstargetObj
- an object of the class whose methods should become
control buttons; the buttons will forward
messages to targetObj in response to button pressesdisplayAfterButtonPresses
- true if the user interface should
display the contents of the grid after executing
the behaviors associated with control button
presses; false otherwisepublic GeneratedButtonList(GridAppFrame gui, java.lang.Object targetObj, boolean onButtonClickMethodsOnly, boolean displayAfterButtonPresses)
void
return type, and, if
onButtonClickMethodsOnly
is true, whose names match
the on...ButtonClick format (e.g., onXYZButtonClick). The text on
each control button will be the associated method name or, if the
name matches the on...ButtonClick format, the middle part of the
method name. For example, the control button for a doX method
would have the label "doX", while the control button for an
onDoYButtonClick method would have the label "DoY". When each
resulting control button is pressed, it will send the associated
message to the target object. It may also display the contents
of the grid afterward, depending on the value of
displayAfterButtonPresses
.
gui
- graphical user interface that will contain these
buttonstargetObj
- an object of the class whose methods should become
control buttons; the buttons will forward
messages to targetObj in response to button pressesonButtonClickMethodsOnly
- true if only on...ButtonClick
methods should be included; false otherwisedisplayAfterButtonPresses
- true if the user interface should
display the contents of the grid after executing
the behaviors associated with control button
presses; false otherwisepublic GeneratedButtonList(GridAppFrame gui, java.lang.Object targetObj, java.lang.Object[] arguments, boolean displayAfterButtonPresses)
void
return type. The text on each control button
will be the associated method name or, if the name matches the
on...ButtonClick format, the middle part of the method name. For
example, the control button for a doX method would have the label
"doX", while the control button for an onDoYButtonClick method
would have the label "DoY". When each resulting control button
is pressed, it will send the associated message to the target object,
passing as arguments the objects provided to this constructor.
It may also display the contents of the grid afterward, depending
on the value of displayAfterButtonPresses
.
gui
- graphical user interface that will contain these
buttonstargetObj
- an object of the class whose methods should become
control buttons; the buttons will forward
messages to targetObj in response to button pressesarguments
- the arguments to pass to methods associated with
control buttonsdisplayAfterButtonPresses
- true if the user interface should
display the contents of the grid after executing
the behaviors associated with control button
presses; false otherwisepublic GeneratedButtonList(GridAppFrame gui, java.lang.Object targetObj, java.lang.Object[] arguments, boolean onClickButtonMethodsOnly, boolean displayAfterButtonPresses)
void
return type, and, if
onButtonClickMethodsOnly
is true, whose names match
the on...ButtonClick format (e.g., onXYZButtonClick). The text on
each control button will be the associated method name or, if the
name matches the on...ButtonClick format, the middle part of the
method name. For example, the control button for a doX method
would have the label "doX", while the control button for an
onDoYButtonClick method would have the label "DoY". When each
resulting control button is pressed, it will send the associated
message to the target object, passing as arguments the objects
provided to this constructor. It may also display the contents
of the grid afterward, depending on the value of
displayAfterButtonPresses
.
gui
- graphical user interface that will contain these
buttonstargetObj
- an object of the class whose methods should become
control buttons; the buttons will forward
messages to targetObj in response to button pressesarguments
- the arguments to pass to methods associated with
control buttonsdisplayAfterButtonPresses
- true if the user interface should
display the contents of the grid after executing
the behaviors associated with control button
presses; false otherwiseMethod Detail |
protected void identifyButtonMethods()
protected boolean meetsControlMethodCriteria(java.lang.reflect.Method methodToCheck, java.lang.Class targetClass)
true
if the given method was declared in
the specified class (not in one of its superclasses) and has
the right return type and parameters to be turned into a
control button; false
otherwise.
protected boolean meetsMethodNameFormatCriteria(java.lang.String methodName)
true
if the given method was declared in
the specified class (not in one of its superclasses) and has
the right return type and parameters to be turned into a
control button; false
otherwise.
protected java.lang.String buttonLabelFor(java.lang.reflect.Method method)
protected void createButtons()
public void resetButtonLabel(java.lang.String prevButtonLabel, java.lang.String buttonLabel)
prevButtonLabel
parameter
should be the previous button label. (The default button label
is the name of the associated method or, if the method name
matches the onXYZButtonClick format, is the name of the method
without the on...ButtonClick prefix and suffix, e.g., XYZ). This
method should be called before the constructWindowContents
method of the graphical user interface. This method does nothing
if the list of generated control buttons does not include a button
whose current label is prevButtonLabel
.
prevButtonLabel
- previous button labelbuttonLabel
- label to place on button
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |