|
|||||||||||
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.beans.AttributesForm
AttributesForm
is Java Bean component for manipulating
modeled Windchill business objects, such as Parts, Documents, etc.
It contains methods to specify the class of the object being manipulated and the
attributes to be displayed. A label and edit/view may be specified
for each attribute.
The AttributesForm 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 attribute types are currently supported:
wt.clients.beans.selectors.ComponentDelegate
for an attribute type and placing an entry
in the service.properties
file in the section for use by the
wt.clients.beans.selectors.ComponentDelegateFactory
.
The bean uses Windchill Introspection mechanisms to determine if an attribute
is required. If the attribute is required, the label will contain a leading asterisk(*),
or other suitable localized character.
The bean uses Windchill Introspection mechanisms to determine the maximum length of String
attributes. By default, string attributes with a maximum length of more than 80 characters are
displayed in TextAreas, while strings 80 characters or less are displayed in TextFields.
The transition point value of 80 characters may be overridden by specifying another value for
the "MaxTextFieldLength" property for the bean.
The bean will also use Windchill Introspection mechanisms to obtain a display value to use as
the label for property.
The following code demonstrates a possible use of this class:
Frame f = new Frame("AttributesPanel test"); AttributesForm attributeBean = new AttributesForm(); f.setSize(700,600); f.setLayout(new BorderLayout()); try { attributeBean.setObjectClassName("wt.part.WTPart"); { 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("partType"); attributeBean.setAttributes(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.part.WTPart part = wt.part.WTPart.newWTPart(); attributeBean.setObject(part);
Nested 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 |
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 | |
AttributesForm()
Construct an empty AttributesForm |
Method Summary | |
protected String[] |
_getEdits()
Method for use internally by the bean itself. |
protected boolean |
_getEdits(int index)
Method for use internally by the bean itself. |
String |
_getObjectClassName()
Method for use internally by the bean itself. |
protected void |
_setAttributes(String[] attributes)
Method for use internally by the bean itself. |
void |
_setEdits(int index,
boolean editValue)
Set the edits value for the specified index. |
protected void |
_setEdits(String[] editValues)
Method for use internally by the bean itself. |
protected void |
_setLabels(String[] labels)
Method for use internally by the bean itself. |
protected void |
_setMaxLen(String[] max_len)
Method for use internally by the bean itself. |
protected void |
_setObjectClassName(String objectClassName)
Method for use internally by the bean itself. |
void |
addHelpListener(PropertyChangeListener listener)
Add a help listener for this component. |
protected void |
addHelpListenerToComponent(Component c,
PropertyChangeListener l)
Add a help listener for components which use their own HelpSystem. |
void |
addObjectPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to be notified of changes to attributes in the contained business object. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
add a change listener for changes to bean properties. |
protected boolean |
compareArrays(Object[] array1,
Object[] array2)
Compare two arrays of objects. |
protected int |
createComponents(Component comp,
int x,
int y,
int width)
Add the specified component at the specified location |
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 Object |
createNewObject()
Internal method to create a new instance of the specified persistable business class if the setObjectAttributeValues method is invoked before setObject . |
protected void |
createUI()
Create the user interface by creating the components for each attribute. |
protected void |
fireObjectPropertyChangeEvent(String propertyName,
Object oldValue,
Object newValue)
|
String[] |
getAttributes()
Return the array of attribute names |
protected Object |
getAttrValue(Object obj,
Method getter)
Internal method to invoke the specified getter method on the specified object. |
Color |
getBackground()
|
protected Class |
getClassContained()
Get a Class object for the contained object or classname |
protected ClassInfo |
getClassInfo()
Get the ClassInfo for the current object class name. |
protected Component |
getComponent(String attributeName)
Return the component currently used for the specified attribute |
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. |
String |
getFocusAttributeName()
Set the attribute name of the component to have focus. |
Font |
getFont()
|
Color |
getForeground()
|
protected Method |
getGetterMethod(PropertyDescriptor attributeDescriptor)
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. |
int |
getMaxTextFieldLength()
Get the maximum text field size in characters. |
int |
getMode()
Return the current mode (CREATE_MODE, UPDATE_MODE, VIEW_MODE). |
Object |
getObject()
Return the contained object. |
protected Class |
getObjectClass()
Return the class of the contained object |
String |
getObjectClassName()
Get the fully qualified class name of the contained object. |
protected PropertyDescriptor[] |
getPropertyDescriptors()
Get the property descriptors for the current attribute list. |
Schema |
getSchema()
Return the current Schema object specifying the object class name and a list of attributes. |
String[] |
getSeparators()
Get the position values of any separators. |
protected Method |
getSetterMethod(PropertyDescriptor attributeDescriptor)
Get the setter method for the specified attribute. |
protected String |
getSimpleName(String fullClassName)
Helper method to get the name of the class without the package qualification. |
String[] |
getSpaces()
Get the array of spacer locations. |
void |
initializeHelp()
Initialize the help system for this component. |
protected boolean |
isReadyForUI()
Check if enough information is known to construct the user interface. |
boolean |
isUICreationAllowed()
|
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. |
protected static ClassInfo |
obtainClassInfo(String className)
Obtain a ClassInfo object for the specified class name |
protected Method |
obtainComponentHelpMethod(Component c)
Return the method "addHelpListener" for the component if it exists. |
protected static PropertyDescriptor |
obtainPropertyDescriptor(ClassInfo a_class_info,
String attribute_constant)
Obtain a property descriptor for the specified attribute using the specified ClassInfo |
void |
propertyChange(PropertyChangeEvent event)
|
void |
readExternal(ObjectInput stream)
Externalization routine used for serialization. |
private static void |
recursiveRemoveAll(Container con)
Added 10/02/99 tcd Use this as a workaround to a problem where the AttributesForm bean would lock up during the createUI() method during the call to this.removeAll(). |
void |
removeObjectPropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener to be notified of changes to attributes in the contained business object. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
remove a change listener for changes to bean properties. |
void |
setAttributes(String[] attributes)
Set the attributes to be displayed for the contained object. |
protected void |
setAttrValue(Object obj,
Method setter,
Object value)
Internal method to invoke the specified setter method on the object. |
void |
setBackground(Color color)
|
protected void |
setClassInfo(ClassInfo classInfo)
Set the ClassInfo for the current object class. |
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 |
setFocus(String attributeName)
Set focus to the component associated with the specified attribute name. |
void |
setFocusAttributeName(String attributeName)
Set the attribute name of the component to have focus. |
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)
Deprecated. The values specified in the String array for this method are ignored by the bean. The bean will use the maximum values specified in the Rose models and returned via Windchill Introspection mechanisms. |
void |
setMaxTextFieldLength(int size)
Set the maximum text field size in characters. |
void |
setMode(int mode)
Set the current mode (CREATE_MODE, UPDATE_MODE, VIEW_MODE). |
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. |
protected void |
setPropertyDescriptors(PropertyDescriptor[] descriptors)
Set the property descriptors for the current attributes |
protected void |
setPropertyDescriptors(String[] attributes)
Set the property descriptors for the specified attribute names |
void |
setSchema(Schema schema)
Set the current Schema. |
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 The spacer elements are simply blank spaces. |
void |
setSpaces(String[] spacerStrings)
Set the location for any spacer elements. |
void |
setUICreationAllowed(boolean value)
This method can be used to control the creation of User Interface elements by the bean. |
protected void |
TRACE(String message)
|
void |
writeExternal(ObjectOutput stream)
Externalization routine used for serialization. |
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 |
protected final int DEFAULT_MAX_TEXT_FIELD_LENGTH
private String[] attributes
private String[] labels
private String[] maxLen
private boolean[] edits
private String objectClassName
private Class objectClass
private String[] attributesProperty
private String[] labelsProperty
private String[] maxLenProperty
private boolean[] editsProperty
private String objectClassNameProperty
private Class objectClassProperty
private String[] editValuesProperty
private String[] editValues
private int[] separators
private int[] spaces
private String focusAttributeName
private ContainerColorUtility colorUtility
private Color background
private Color foreground
private Font font
private int maxTextFieldLength
private Object object
private int mode
private Schema schema
protected Vector getterMethods
protected Vector setterMethods
protected Vector types
protected Vector uiLabels
protected Vector uiAttributes
protected PropertyDescriptor[] propertyDescriptors
protected PropertyItem[] propertyItems
protected ClassInfo classInfo
protected ComponentDelegate[] componentSelectors
protected HelpSystem helpSystem
protected HelpContext helpContext
protected static boolean VERBOSE
protected boolean uiCreationAllowed
protected boolean listenForPropChange
public static final String TRUE
public static final String FALSE
protected PropertyChangeSupport propertyChangeSupport
protected transient Vector objectPropertyChangeListeners
public static int VIEW_MODE
public static int CREATE_MODE
public static int UPDATE_MODE
Constructor Detail |
public AttributesForm()
Method Detail |
public void writeExternal(ObjectOutput stream) throws IOException
writeExternal
in interface Externalizable
stream
- the object output stream
IOException
public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
stream
- the input object stream
IOException
ClassNotFoundException
public void addObjectPropertyChangeListener(PropertyChangeListener listener)
setObject
method,
not for changes in the properties to the bean itself.
listener
- the listener to addpublic void removeObjectPropertyChangeListener(PropertyChangeListener listener)
listener
- public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- public int getMode()
public void setMode(int mode) throws WTPropertyVetoException
setEdits()
method
to individually specify if each attribute is editable or not.
mode
- the new mode (CREATE_MODE, UPDATE_MODE, VIEW_MODE)
WTPropertyVetoException
public Object getObject()
public void setObject(Object object) throws WTException
object
- the object to refresh and display in the form
WTException
public Object setObjectAttributeValues() throws WTPropertyVetoException, WTException
WTPropertyVetoException
- if an exception was thrown
when invoking the setter on the object.
WTException
protected Class getObjectClass() throws ClassNotFoundException
ClassNotFoundException
protected Object createNewObject() throws WTException
setObjectAttributeValues
method is invoked before setObject
.
The method will attempt to instantiate an object using a Windchill style factory method
( ClassName.newClassName()
). If no factory method is available, a default Java
constructor will be used ( new ClassName()
).
WTException
protected String getSimpleName(String fullClassName)
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 exception
WTPropertyVetoException
public String getObjectClassName()
public 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.protected void _setObjectClassName(String objectClassName) throws WTPropertyVetoException
objectClassName
-
WTPropertyVetoException
protected void _setAttributes(String[] attributes) throws WTPropertyVetoException
attributes
-
WTPropertyVetoException
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.public void setMaxTextFieldLength(int size) throws WTPropertyVetoException
size
- the maximum text field size
WTPropertyVetoException
- if the size is not valid.public int getMaxTextFieldLength()
public void setFocusAttributeName(String attributeName) throws WTPropertyVetoException
attributeName
- the attribute name of the component with focus
WTPropertyVetoException
- if the attribute name is not valid.public String getFocusAttributeName()
WTPropertyVetoException
- if the attribute name is not valid.protected Component getComponent(String attributeName)
attributeName
- the name of the attribute
public void setFocus(String attributeName) throws WTPropertyVetoException
attributeName
- the name of attribute
WTPropertyVetoException
protected ClassInfo getClassInfo()
protected void setClassInfo(ClassInfo classInfo)
classInfo
- the ClassInfo for the current object classprotected PropertyDescriptor[] getPropertyDescriptors()
protected void setPropertyDescriptors(PropertyDescriptor[] descriptors) throws WTPropertyVetoException
descriptors
- the property descriptors for the current attributes
WTPropertyVetoException
protected void setPropertyDescriptors(String[] attributes) throws WTPropertyVetoException
attributes
- the names of each attribute
WTPropertyVetoException
protected static PropertyDescriptor obtainPropertyDescriptor(ClassInfo a_class_info, String attribute_constant) throws WTIntrospectionException
a_class_info
- attribute_constant
-
WTIntrospectionException
protected static ClassInfo obtainClassInfo(String className) throws WTIntrospectionException, ClassNotFoundException
className
- the fully qualified class name
WTIntrospectionException
ClassNotFoundException
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)
comp
- x
- y
- width
- protected Component createHorizontalLine()
protected boolean needSpaceNow(int i)
i
- the index of the attribute
protected boolean needSeparatorNow(int i)
i
- the index of the attribute
private static void recursiveRemoveAll(Container con)
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
protected boolean _getEdits(int index)
index
- 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(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
protected void _setEdits(String[] editValues) throws WTPropertyVetoException
editValues
-
WTPropertyVetoException
public String[] getEdits()
protected String[] _getEdits()
protected void _setLabels(String[] labels) throws WTPropertyVetoException
labels
-
WTPropertyVetoException
public void setLabels(String[] labels) throws WTPropertyVetoException
labels
- an array of strings, each string is the label for the
corresponding attribute.
WTPropertyVetoException
WTPropertyVetoException
protected boolean isReadyForUI()
public String[] getLabels()
protected void _setMaxLen(String[] max_len) throws WTPropertyVetoException
max_len
-
WTPropertyVetoException
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
- if value is not numeric and not empty
WTPropertyVetoException
public String[] getMaxLen()
public void setSeparators(String[] separatorStrings) throws WTPropertyVetoException
separatorStrings
- the list of separator positions
WTPropertyVetoException
- if the value is not numeric
WTPropertyVetoException
public void setSeparators(int[] separators) throws WTPropertyVetoException
separators
- the list of separator positions
WTPropertyVetoException
- if the value is not numeric
WTPropertyVetoException
public String[] getSeparators()
public void setSpaces(String[] spacerStrings) throws WTPropertyVetoException
spacerStrings
- array of spacer locations
WTPropertyVetoException
- is a location is not numeric
WTPropertyVetoException
public void setSpaces(int[] spaces) throws WTPropertyVetoException
spaces
- the list of spacer positions
WTPropertyVetoException
- is a location is not numeric
WTPropertyVetoException
public String[] getSpaces()
public void setSchema(Schema schema) throws PropertyVetoException
setObjectClassName()
and setAttributes()
methods. It is used by the SchemaEditor
to allow the class name and attributes to be selected graphically at dev time in an IDE
such as Visual Cafe.
schema
- the schema specifing the object class name and a list of attribute names
PropertyVetoException
Schema
public Schema getSchema()
public void setForeground(Color color)
public Color getForeground()
public void setBackground(Color color)
public Color getBackground()
public void setFont(Font font)
public Font getFont()
getFont
in interface MenuContainer
protected Class getClassContained()
protected Method getGetterMethod(PropertyDescriptor attributeDescriptor)
protected Method getSetterMethod(PropertyDescriptor attributeDescriptor)
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 listenerprotected Method obtainComponentHelpMethod(Component c)
c
- potential component with addHelpListener method
protected void addHelpListenerToComponent(Component c, PropertyChangeListener l)
c
- the componentl
- a new help listenerpublic void setUICreationAllowed(boolean value)
value
- if true, the AttributesForm will construct a user interface if relavent properties have been changed.
if false, the AttributesForm will not allow the user interface to be constructed even if relevant properties
have changed.public boolean isUICreationAllowed()
public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
protected void fireObjectPropertyChangeEvent(String propertyName, Object oldValue, Object newValue)
protected boolean compareArrays(Object[] array1, Object[] array2)
public static void main(String[] args)
protected void TRACE(String message)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |