|
Email Answering System Version 1.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--test.ConfigurationDialog
Create a configuration file for a bean.
| Field Summary | |
protected JTable |
mConfiguration
|
protected PropertyDescriptor[] |
mDescriptors
Cached list of property descriptors introspected from the bean. |
protected String |
mFile
The file to store the configuration in. |
protected ArrayList |
mListeners
The array of TableModelListeners. |
protected Object |
mObject
The bean we're going to configure. |
protected Boolean |
mResult
The user action causing the dialog to exit: Boolean.TRUE - user clicked the OK button Boolean.FALSE - user clicked the Cancel button null - user closed window without choosing either button |
| 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.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 | |
ConfigurationDialog(Object bean,
String file)
Creates a new configuration dialog. |
|
| Method Summary | |
void |
actionPerformed(ActionEvent event)
Invoked when an action occurs. |
void |
addTableModelListener(TableModelListener listener)
Adds a listener to the list that is notified each time a change to the data model occurs. |
static void |
applyConfiguration(Properties properties)
Apply the configuration to the system properties. |
protected void |
conditionObject(PropertyDescriptor[] descriptors)
Apply the configuration stored in the system properties to the object. |
static Boolean |
configure(String cls,
String file)
Perform the configuration. |
Object |
deStringize(Class cls,
String string)
Convert the given string into an acceptable object for the property setter. |
Class |
getColumnClass(int index)
Returns the most specific superclass for all the cell values in the column. |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int index)
Returns the name of the column at columnIndex. |
protected PropertyDescriptor[] |
getDescriptors()
Get the bean properties we can understand by introspecting the object. |
int |
getRowCount()
Returns the number of rows in the model. |
Object |
getValueAt(int rowIndex,
int index)
Returns the value for the cell at index and
rowIndex. |
boolean |
isCellEditable(int rowIndex,
int index)
Returns true if the cell at rowIndex and
index is editable. |
static boolean |
loadConfiguration(String cls,
String file)
Load the configuration. |
static void |
main(String[] args)
The main line for the configuration dialog. |
String |
propertyName(PropertyDescriptor descriptor)
Create the configuration property name from the property descriptor. |
protected static Properties |
readProperties(String file)
Read the properties file. |
void |
removeTableModelListener(TableModelListener listener)
Removes a listener from the list that is notified each time a change to the data model occurs. |
protected void |
save()
Save the contents of the object. |
void |
setValueAt(Object string,
int rowIndex,
int index)
Sets the value in the cell at index and
rowIndex to aValue. |
void |
windowActivated(WindowEvent event)
Invoked when the Window is set to be the active Window. |
void |
windowClosed(WindowEvent event)
Invoked when a window has been closed as the result of calling dispose on the window. |
void |
windowClosing(WindowEvent event)
Invoked when the user attempts to close the window from the window's system menu. |
void |
windowDeactivated(WindowEvent event)
Invoked when a Window is no longer the active Window. |
void |
windowDeiconified(WindowEvent event)
Invoked when a window is changed from a minimized to a normal state. |
void |
windowIconified(WindowEvent event)
Invoked when a window is changed from a normal to a minimized state. |
void |
windowOpened(WindowEvent event)
Invoked the first time a window is made visible. |
protected static void |
writeProperties(String file,
Properties properties)
Write the properties file. |
| 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 |
| Field Detail |
protected Object mObject
protected String mFile
protected PropertyDescriptor[] mDescriptors
protected ArrayList mListeners
protected Boolean mResult
protected JTable mConfiguration
| Constructor Detail |
public ConfigurationDialog(Object bean,
String file)
bean - The object to get the configuration data for.file - The name of a file to write the configuration to, or null if the
configuration is to be sent to System.out.| Method Detail |
public Object deStringize(Class cls,
String string)
cls - The class determined from the bean information.string - The value to be assigned to the property (as a String).
null if no conversion was possible.protected void conditionObject(PropertyDescriptor[] descriptors)
descriptors - The list of bean properties that can be set.protected PropertyDescriptor[] getDescriptors()
String or primitive types.protected static Properties readProperties(String file)
file - The properties file to read.
protected static void writeProperties(String file,
Properties properties)
file - The name of the file to write.properties - The property set to store in the file.public String propertyName(PropertyDescriptor descriptor)
descriptor - The property descriptor (with the name of the property).
protected void save()
public void addTableModelListener(TableModelListener listener)
addTableModelListener in interface TableModellistener - The TableModelListener.public Class getColumnClass(int index)
JTable to set up a
default renderer and editor for the column.
getColumnClass in interface TableModelindex - The index of the column.
public int getColumnCount()
JTable uses this method to determine how many columns it
should create and display by default.
getColumnCount in interface TableModelgetRowCount()public String getColumnName(int index)
columnIndex. This is used
to initialize the table's column header name. Note: this name does
not need to be unique; two columns in a table can have the same name.
getColumnName in interface TableModelindex - The index of the column.
public int getRowCount()
JTable uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.
getRowCount in interface TableModelgetColumnCount()
public Object getValueAt(int rowIndex,
int index)
index and
rowIndex.
getValueAt in interface TableModelrowIndex - The row whose value is to be queried.index - The column whose value is to be queried.
public boolean isCellEditable(int rowIndex,
int index)
rowIndex and
index is editable.
Otherwise, setValueAt on the cell will not
change the value of that cell.
isCellEditable in interface TableModelrowIndex - The row whose value to be queried.index - The column whose value to be queried.
true if the cell is editable.setValueAt(java.lang.Object, int, int)public void removeTableModelListener(TableModelListener listener)
removeTableModelListener in interface TableModellistener - The TableModelListener
public void setValueAt(Object string,
int rowIndex,
int index)
index and
rowIndex to aValue.
setValueAt in interface TableModelstring - The new value (as a string).rowIndex - The row whose value is to be changed.index - The column whose value is to be changed.getValueAt(int, int),
isCellEditable(int, int)public void actionPerformed(ActionEvent event)
actionPerformed in interface ActionListenerevent - The event triggering the action.public void windowActivated(WindowEvent event)
windowActivated in interface WindowListenerevent - The event on the window.public void windowClosed(WindowEvent event)
windowClosed in interface WindowListenerevent - The event on the window.public void windowClosing(WindowEvent event)
windowClosing in interface WindowListenerevent - The event on the window.public void windowDeactivated(WindowEvent event)
windowDeactivated in interface WindowListenerevent - The event on the window.public void windowDeiconified(WindowEvent event)
windowDeiconified in interface WindowListenerevent - The event on the window.public void windowIconified(WindowEvent event)
windowIconified in interface WindowListenerevent - The event on the window.Frame.setIconImage(java.awt.Image)public void windowOpened(WindowEvent event)
windowOpened in interface WindowListenerevent - The event on the window.
public static Boolean configure(String cls,
String file)
cls - The class name of the bean to configure.file - The name of the file to read/write.
public static void applyConfiguration(Properties properties)
properties - The properties file containing configuration parameters.
public static boolean loadConfiguration(String cls,
String file)
throws IllegalStateException
cls - The class name of the bean to configure. This is only
used if the file specified is not found, otherwise all the properties from
that file are loaded.file - The name of the file to load from.
true if the file was successfully loaded,
false otherwise.
IllegalArgumentException - If the file name is null or cannot be loaded.
IllegalStateExceptionpublic static void main(String[] args)
args - Command line arguments. args[0] is the class name
of a bean to edit, while args[1] is an optional file name to save the
configuration in.
|
Email Answering System Version 1.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||