|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
wt.clients.replication.unit.PartAttributesPanel
PartAttributesPanel
is Java Bean component for manipulating
wt.clients.replication.unit.PartItem objects.
It contains methods to specify the class of the object being manipulated and the
attributes to be displayed. A label, maximum length, and edit/view may be specified
for each attribute.
The PartAttributesPanel dynamically constructs a user interface based on the
contained class and the specified information about the attributes. Boolean
attributes are represented as checkboxes, Enumerated types as choice lists,
string and integer values are shown in text fields.
The following code demonstrates a possible use of this class:
Frame f = new Frame("AttributesPanel test"); PartAttributesPanel attributeBean = new PartAttributesPanel(); f.setSize(700,600); f.setLayout(new BorderLayout()); try { attributeBean.setObjectClassName("wt.clients.replication.unit.PartItem"); { java.lang.String[] tempString = new java.lang.String[4]; tempString[0] = new java.lang.String("Number"); tempString[1] = new java.lang.String("Name"); tempString[2] = new java.lang.String("Source"); tempString[3] = new java.lang.String("Type"); attributeBean.setAttributes(tempString); } { java.lang.String[] tempString = new java.lang.String[4]; tempString[0] = new java.lang.String("Number:"); tempString[1] = new java.lang.String("Name:"); tempString[2] = new java.lang.String("Source:"); tempString[3] = new java.lang.String("Type:"); attributeBean.setLabels(tempString); } { java.lang.String[] tempString = new java.lang.String[4]; tempString[0] = "true"; tempString[1] = "true"; tempString[2] = "true"; tempString[3] = "true"; attributeBean.setEdits(tempString); } } catch ( WTPropertyVetoException wte) { wte.printStackTrace(); } f.add("Center",attributeBean); f.pack(); f.show();
wt.clients.replication.unit.PartItem
class,
Serialized FormNested Class Summary |
Nested classes inherited from class java.awt.Panel |
Panel.AccessibleAWTPanel |
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 | |
private String[] |
attributes
|
private Color |
background
|
private Font |
crossLocaleFont
|
private boolean[] |
edits
|
static String |
FALSE
|
private Color |
foregound
|
protected Vector |
getterMethods
|
protected HelpContext |
helpContext
|
protected HelpSystem |
helpSystem
|
private String[] |
labels
|
protected int |
MAX_TEXT_FIELD_LENGTH
|
private String[] |
maxLen
|
private Object |
object
|
private String |
objectClassName
|
private int[] |
separators
|
protected Vector |
setterMethods
|
private int[] |
spaces
|
protected int |
TEXT_AREA_ROWS
|
static String |
TRUE
|
protected Vector |
types
|
protected Vector |
uiAttributes
|
protected Vector |
uiLabels
|
Fields inherited from class java.awt.Panel |
|
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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
PartAttributesPanel()
Construct an empty PartAttributesPanel |
Method Summary | |
void |
addHelpListener(PropertyChangeListener listener)
Add a help listener for this component. |
protected Component |
createCheckbox(int i)
Create a checkbox component for boolean attributes. |
protected int |
createComponents(Component comp,
int x,
int y,
int width)
|
protected Component |
createEnumeratedChoice(int i)
Create a UI component for an EnumeratedType attribute. |
protected Component |
createHorizontalLine()
Create a horizontal line to separate groups of attributes. |
protected void |
createLabels(int x,
int y,
int i)
Create a label component at the specified grid position. |
protected Component |
createTextArea(int i)
Create a text area component. |
protected Component |
createTextField(int i)
Create a text field component. |
protected void |
createUI()
Create the user interface by creating the components for each attribute. |
String[] |
getAttributes()
Return the array of attribute names |
protected Object |
getAttrValue(Object obj,
Method getter)
Invoke the specified getter method on the specified object. |
Color |
getBackground()
|
protected Class |
getClassContained()
Get a Class object for the contained object or classname |
boolean[] |
getEditable()
Return the array of booleans specifying if an attribute is editable. |
String[] |
getEdits()
Return the array of strings specifying if an attribute is editable. |
boolean |
getEdits(int index)
Get the edits value for the specified index. |
Font |
getFont()
|
Color |
getForeground()
|
protected Method |
getGetterMethod(String attribute)
Get the getter method for the specified attribute. |
HelpContext |
getHelpContext()
Return the help context. |
String[] |
getLabels()
Return the labels used for the attributes. |
String[] |
getMaxLen()
Return the maximum lengths for each attribute. |
Object |
getObject()
Return the contained object. |
String |
getObjectClassName()
Get the fully qualified class name of the contained object. |
String[] |
getSeparators()
Get the position values of any separators. |
protected Method |
getSetterMethod(String attribute,
Class returnType)
Get the setter method for the specified attribute. |
String[] |
getSpaces()
Get the array of spacer locations. |
void |
initializeHelp()
Initialize the help system for this component. |
protected boolean |
isLargeString(int i)
Determine if the string attribute is large ( longer than MAX_TEXT_FIELD_LENGTH). |
protected boolean |
isReadyForUI()
Check if enough information is known to construct the user interface. |
static void |
main(String[] args)
A main method that demonstrates how to use this class and allows testing |
protected boolean |
needSeparatorNow(int i)
Determine if a separator should placed at the specified position. |
protected boolean |
needSpaceNow(int i)
Determine if a spacer should placed at the specified position. |
void |
setAttributes(String[] attributes)
Set the attributes to be displayed for the contained object. |
protected void |
setAttrValue(Object obj,
Method setter,
Object value)
Invoke the specified setter method on the object. |
void |
setBackground(Color color)
|
void |
setEditable(boolean[] editValues)
Set the editable values for each attribute. |
void |
setEdits(int index,
boolean editValue)
Set the edits value for the specified index. |
void |
setEdits(String[] editValues)
Set the edits values for each attribute. |
void |
setFont(Font font)
|
void |
setForeground(Color color)
|
void |
setHelpContext(HelpContext helpContext)
Set the help context. |
void |
setLabels(String[] labels)
Set the labels for the attributes. |
void |
setMaxLen(String[] max_len)
Set the maximum length for each attribute. |
void |
setObject(Object object)
Set the contained object. |
Object |
setObjectAttributeValues()
Transfers any user-modified values to the contained object. |
void |
setObjectClassName(String objectClassName)
Set the fully qualified class name of the contained object. |
void |
setSeparators(int[] separators)
Specify where any separators should be placed. |
void |
setSeparators(String[] separatorStrings)
Specify where any separators should be placed. |
void |
setSpaces(int[] spaces)
Set the location for any spacer elements |
void |
setSpaces(String[] spacerStrings)
Set the location for any spacer elements |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private String[] attributes
private String[] labels
private String[] maxLen
private boolean[] edits
private int[] separators
private int[] spaces
private Color foregound
private Color background
private Object object
private String objectClassName
protected Vector getterMethods
protected Vector setterMethods
protected Vector types
protected Vector uiLabels
protected Vector uiAttributes
protected HelpSystem helpSystem
protected HelpContext helpContext
protected int MAX_TEXT_FIELD_LENGTH
protected int TEXT_AREA_ROWS
public static final String TRUE
public static final String FALSE
private Font crossLocaleFont
Constructor Detail |
public PartAttributesPanel()
Method Detail |
public Object getObject()
public void setObject(Object object)
object
- the object to refreshpublic Object setObjectAttributeValues() throws WTPropertyVetoException
WTPropertyVetoException
- if an exception was thrown
when invoking the setter on the object.protected Object getAttrValue(Object obj, Method getter)
obj
- the object to invoke the method ongetter
- the getter method to invoke
protected void setAttrValue(Object obj, Method setter, Object value) throws WTPropertyVetoException
obj
- the object to invoke the setter method onsetter
- the method to invokevalue
- the value to use in the setter method
WTPropertyVetoException
- if invoking the setter threw an exceptionpublic String getObjectClassName()
public void setObjectClassName(String objectClassName) throws WTPropertyVetoException
objectClassName
- the fully qualified class name of the contained object
WTPropertyVetoException
- if the class name is not valid.public void setAttributes(String[] attributes) throws WTPropertyVetoException
attributes
- an array of attribute names
WTPropertyVetoException
- if any of the attributes are not valid for the contained class.protected void createLabels(int x, int y, int i)
x
- the x positiony
- the y positioni
- the index in the labels arrayprotected int createComponents(Component comp, int x, int y, int width)
protected Component createEnumeratedChoice(int i) throws PropertyVetoException
i
- index into components array
PropertyVetoException
protected Component createTextField(int i)
i
- index into the attribute arrays
protected Component createTextArea(int i)
i
- the index of the attribute
protected Component createHorizontalLine()
protected Component createCheckbox(int i)
i
- the index of the attribute
protected boolean isLargeString(int i)
i
- the index of the attribute
protected boolean needSpaceNow(int i)
i
- the index of the attribute
protected boolean needSeparatorNow(int i)
i
- the index of the attribute
protected void createUI()
public String[] getAttributes()
public boolean[] getEditable()
public void setEditable(boolean[] editValues) throws WTPropertyVetoException
editValues
- array of booleans indicating if the corresponding attribute
is editable.
WTPropertyVetoException
public boolean getEdits(int index)
index
- the index for the attribute
public void setEdits(int index, boolean editValue) throws WTPropertyVetoException
index
- the index for the attributeeditValue
- true if the attribute should be editable
WTPropertyVetoException
public void setEdits(String[] editValues) throws WTPropertyVetoException
editValues
- array of strings indicating if the corresponding attribute
is editable.
WTPropertyVetoException
public String[] getEdits()
public void setLabels(String[] labels) throws WTPropertyVetoException
labels
- an array of strings, each string is the label for the
corresponding attribute.
WTPropertyVetoException
protected boolean isReadyForUI()
public String[] getLabels()
public void setMaxLen(String[] max_len) throws WTPropertyVetoException
max_len
- an array of strings, each string representing the maximum length
or value for the corresponding attribute.
WTPropertyVetoException
public String[] getMaxLen()
public void setSeparators(String[] separatorStrings) throws WTPropertyVetoException
WTPropertyVetoException
- if the value is not numericpublic void setSeparators(int[] separators) throws WTPropertyVetoException
WTPropertyVetoException
- if the value is not numericpublic String[] getSeparators()
public void setSpaces(String[] spacerStrings) throws WTPropertyVetoException
spacerStrings
- array of spacer locations
WTPropertyVetoException
- is a location is not numericpublic void setSpaces(int[] spaces) throws WTPropertyVetoException
WTPropertyVetoException
- is a location is not numericpublic String[] getSpaces()
public void setForeground(Color color)
public Color getForeground()
public void setBackground(Color color)
public Color getBackground()
public void setFont(Font font)
public Font getFont()
protected Class getClassContained()
protected Method getGetterMethod(String attribute)
attribute
- the name of the attribute
protected Method getSetterMethod(String attribute, Class returnType)
attribute
- the name of the attributereturnType
- the parameter type for the setter
public void setHelpContext(HelpContext helpContext) throws WTPropertyVetoException
helpContext
- the HelpContext to use
WTPropertyVetoException
- if the helpContext is invalidpublic HelpContext getHelpContext()
public void initializeHelp()
public void addHelpListener(PropertyChangeListener listener)
listener
- a new help listenerpublic static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |