|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.gui.GenericObjectEditor
A PropertyEditor for objects that themselves have been defined as editable in the GenericObjectEditor configuration file, which lists possible values that can be selected from, and themselves configured. The configuration file is called "GenericObjectEditor.props" and may live in either the location given by "user.home" or the current directory (this last will take precedence), and a default properties file is read from the weka distribution. For speed, the properties file is read only once when the class is first loaded -- this may need to be changed if we ever end up running in a Java OS ;-).
Nested Class Summary | |
class |
GenericObjectEditor.GOEPanel
Handles the GUI side of editing values. |
class |
GenericObjectEditor.JTreePopupMenu
Creates a popup menu containing a tree that is aware of the screen dimensions. |
Field Summary | |
protected static java.util.Properties |
EDITOR_PROPERTIES
Contains the editor properties |
protected java.lang.Object |
m_Backup
Holds a copy of the current object that can be reverted to if the user decides to cancel |
protected boolean |
m_canChangeClassInDialog
|
protected java.lang.Class |
m_ClassType
The Class of objects being edited |
protected GenericObjectEditor.GOEPanel |
m_EditorComponent
The GUI component for editing values, created when needed |
protected boolean |
m_Enabled
True if the GUI component is needed |
protected java.lang.Object |
m_Object
The object being configured |
protected HierarchyPropertyParser |
m_ObjectNames
The model containing the list of names to select from |
protected PropertyPanel |
m_ObjectPropertyPanel
The property panel created for the objects |
protected java.beans.PropertyChangeSupport |
m_Support
Handles property change notification |
protected javax.swing.tree.DefaultMutableTreeNode |
m_treeNodeOfCurrentObject
The tree node of the current object so we can re-select it for the user |
protected static java.lang.String |
PROPERTY_FILE
The name of the properties file |
Constructor Summary | |
GenericObjectEditor()
Default constructor. |
|
GenericObjectEditor(boolean canChangeClassInDialog)
Constructor that allows specifying whether it is possible to change the class within the editor dialog. |
Method Summary | |
protected void |
addChildrenToTree(javax.swing.tree.DefaultMutableTreeNode tree,
HierarchyPropertyParser hpp)
Recursively builds a JTree from an object heirarchy. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener who will be notified of value changes. |
protected void |
classSelected(java.lang.String className)
Called when the user selects an class type to change to. |
protected javax.swing.JButton |
createChooseClassButton()
Creates a button that when clicked will enable the user to change the class of the object being edited. |
protected javax.swing.JTree |
createTree(HierarchyPropertyParser hpp)
Creates a JTree from an object heirarchy. |
java.lang.String |
getAsText()
Returns null as we don't support getting/setting values as text. |
javax.swing.JPopupMenu |
getChooseClassPopupMenu()
Returns a popup menu that allows the user to change the class of object. |
protected HierarchyPropertyParser |
getClassesFromProperties()
Called when the class of object being edited changes. |
java.awt.Component |
getCustomEditor()
Returns the array editing component. |
javax.swing.JPanel |
getCustomPanel()
Gets the custom panel used for editing the object. |
java.lang.String |
getJavaInitializationString()
Supposedly returns an initialization string to create a Object identical to the current one, including it's state, but this doesn't appear possible given that the initialization string isn't supposed to contain multiple statements. |
java.lang.String[] |
getTags()
Returns null as we don't support getting values as tags. |
java.lang.Object |
getValue()
Gets the current Object. |
boolean |
isPaintable()
Returns true to indicate that we can paint a representation of the Object. |
static void |
main(java.lang.String[] args)
Tests out the Object editor from the command line. |
void |
paintValue(java.awt.Graphics gfx,
java.awt.Rectangle box)
Paints a representation of the current Object. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener. |
void |
setAsText(java.lang.String text)
Returns null as we don't support getting/setting values as text. |
void |
setClassType(java.lang.Class type)
Sets the class of values that can be edited. |
void |
setDefaultValue()
Sets the current object to be the default, taken as the first item in the chooser |
void |
setEnabled(boolean newVal)
Sets whether the editor is "enabled", meaning that the current values will be painted. |
protected void |
setObject(java.lang.Object c)
Sets the current Object. |
void |
setValue(java.lang.Object o)
Sets the current Object. |
boolean |
supportsCustomEditor()
Returns true because we do support a custom editor. |
protected void |
updateObjectNames()
Updates the list of selectable object names, adding any new names to the list. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.Object m_Object
protected java.lang.Object m_Backup
protected java.beans.PropertyChangeSupport m_Support
protected java.lang.Class m_ClassType
protected HierarchyPropertyParser m_ObjectNames
protected GenericObjectEditor.GOEPanel m_EditorComponent
protected boolean m_Enabled
protected static java.lang.String PROPERTY_FILE
protected static java.util.Properties EDITOR_PROPERTIES
protected javax.swing.tree.DefaultMutableTreeNode m_treeNodeOfCurrentObject
protected PropertyPanel m_ObjectPropertyPanel
protected boolean m_canChangeClassInDialog
Constructor Detail |
public GenericObjectEditor()
public GenericObjectEditor(boolean canChangeClassInDialog)
canChangeClassInDialog
- whether the user can change the classMethod Detail |
protected HierarchyPropertyParser getClassesFromProperties()
protected void updateObjectNames()
public void setEnabled(boolean newVal)
newVal
- a value of type 'boolean'public void setClassType(java.lang.Class type)
type
- a value of type 'Class'public void setDefaultValue()
public void setValue(java.lang.Object o)
setValue
in interface java.beans.PropertyEditor
o
- an object that must be a Object.protected void setObject(java.lang.Object c)
c
- a value of type 'Object'public java.lang.Object getValue()
getValue
in interface java.beans.PropertyEditor
public java.lang.String getJavaInitializationString()
getJavaInitializationString
in interface java.beans.PropertyEditor
public boolean isPaintable()
isPaintable
in interface java.beans.PropertyEditor
public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box)
paintValue
in interface java.beans.PropertyEditor
gfx
- the graphics context to usebox
- the area we are allowed to paint intopublic java.lang.String getAsText()
getAsText
in interface java.beans.PropertyEditor
public void setAsText(java.lang.String text)
setAsText
in interface java.beans.PropertyEditor
text
- the text value
java.lang.IllegalArgumentException
- as we don't support
getting/setting values as text.public java.lang.String[] getTags()
getTags
in interface java.beans.PropertyEditor
public boolean supportsCustomEditor()
supportsCustomEditor
in interface java.beans.PropertyEditor
public java.awt.Component getCustomEditor()
getCustomEditor
in interface java.beans.PropertyEditor
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
addPropertyChangeListener
in interface java.beans.PropertyEditor
l
- a value of type 'PropertyChangeListener'public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
removePropertyChangeListener
in interface java.beans.PropertyEditor
l
- a value of type 'PropertyChangeListener'public javax.swing.JPanel getCustomPanel()
getCustomPanel
in interface CustomPanelSupplier
protected javax.swing.JButton createChooseClassButton()
public javax.swing.JPopupMenu getChooseClassPopupMenu()
protected javax.swing.JTree createTree(HierarchyPropertyParser hpp)
hpp
- the hierarchy of objects to mirror in the tree
protected void addChildrenToTree(javax.swing.tree.DefaultMutableTreeNode tree, HierarchyPropertyParser hpp)
tree
- the root of the tree to add children tohpp
- the hierarchy of objects to mirror in the treeprotected void classSelected(java.lang.String className)
className
- the name of the class that was selectedpublic static void main(java.lang.String[] args)
args
- may contain the class name of a Object to edit
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |