public class GenericObjectEditor extends java.lang.Object implements java.beans.PropertyEditor, CustomPanelSupplier
USE_DYNAMIC is false) the
objects 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 ;-). UseDynamic property
of the GenericPropertiesCreator props file is set to true) then
the classes to list are discovered by the
GenericPropertiesCreator class (it checks the complete
classpath).| Modifier and Type | Class and Description |
|---|---|
class |
GenericObjectEditor.CapabilitiesFilterDialog
A dialog for selecting Capabilities to look for in the GOE tree.
|
class |
GenericObjectEditor.GOEPanel
Handles the GUI side of editing values.
|
class |
GenericObjectEditor.GOETreeNode
A specialized TreeNode for supporting filtering via Capabilities.
|
class |
GenericObjectEditor.JTreePopupMenu
Creates a popup menu containing a tree that is aware of the screen
dimensions.
|
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Properties |
EDITOR_PROPERTIES
Contains the editor properties.
|
static java.lang.String |
GUIEDITORS_PROPERTY_FILE
the properties files containing the class/editor mappings.
|
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_CancelWasPressed
True if the cancel button was pressed
|
protected boolean |
m_canChangeClassInDialog
whether the class can be changed.
|
protected Capabilities |
m_CapabilitiesFilter
for filtering the tree based on the Capabilities of the leaves.
|
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 static boolean |
m_EditorsRegistered
whether the Weka Editors were already registered.
|
protected boolean |
m_Enabled
True if the GUI component is needed.
|
protected GenericObjectEditorHistory |
m_History
the history of used setups.
|
protected java.lang.Object |
m_Object
The object being configured.
|
protected java.util.Hashtable<java.lang.String,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 static boolean |
m_ShowGlobalInfoToolTip
whether to display the global info tool tip in the tree.
|
protected java.beans.PropertyChangeSupport |
m_Support
Handles property change notification.
|
protected GenericObjectEditor.GOETreeNode |
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 and Description |
|---|
GenericObjectEditor()
Default constructor.
|
GenericObjectEditor(boolean canChangeClassInDialog)
Constructor that allows specifying whether it is possible to change the
class within the editor dialog.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addChildrenToTree(GenericObjectEditor.GOETreeNode 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(java.util.Hashtable<java.lang.String,HierarchyPropertyParser> hpps)
Creates a JTree from an object heirarchy.
|
static void |
determineClasses() |
java.lang.String |
getAsText()
Returns null as we don't support getting/setting values as text.
|
java.lang.Object |
getBackup()
Returns the backup object (may be null if there is no backup.
|
boolean |
getCanChangeClassInDialog()
Returns whether the user can change the class in the dialog.
|
Capabilities |
getCapabilitiesFilter()
Returns the current Capabilities filter, can be null.
|
javax.swing.JPopupMenu |
getChooseClassPopupMenu()
Returns a popup menu that allows the user to change the class of object.
|
protected java.util.Hashtable<java.lang.String,HierarchyPropertyParser> |
getClassesFromProperties()
Called when the class of object being edited changes.
|
protected java.lang.String |
getClassnameFromPath(javax.swing.tree.TreePath path)
creates a classname from the given path.
|
java.awt.Component |
getCustomEditor()
Returns the array editing component.
|
javax.swing.JPanel |
getCustomPanel()
Gets the custom panel used for editing the object.
|
GenericObjectEditorHistory |
getHistory()
Returns the history of the used setups.
|
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.
|
protected static java.lang.String |
getRootFromClass(java.lang.String clsname,
java.lang.String separator)
returns the name of the root element of the given class name,
null if it doesn't contain the separator. |
boolean |
getShowGlobalInfoToolTips() |
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.
|
static java.lang.Object |
makeCopy(java.lang.Object source)
Makes a copy of an object using serialization.
|
void |
paintValue(java.awt.Graphics gfx,
java.awt.Rectangle box)
Paints a representation of the current Object.
|
static void |
registerEditor(java.lang.String name,
java.lang.String value) |
static void |
registerEditors()
registers all the editors in Weka.
|
void |
removeCapabilitiesFilter()
Removes the current Capabilities filter.
|
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 |
setCanChangeClassInDialog(boolean value)
Sets whether the user can change the class in the dialog.
|
void |
setCapabilitiesFilter(Capabilities value)
Sets the capabilities to use for filtering.
|
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.
|
static void |
setShowGlobalInfoToolTips(boolean show) |
void |
setValue(java.lang.Object o)
Sets the current Object.
|
static java.util.Hashtable<java.lang.String,java.lang.String> |
sortClassesByRoot(java.lang.String classes)
parses the given string of classes separated by ", " and returns the a
hashtable with as many entries as there are different root elements in the
class names (the key is the root element).
|
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.
|
boolean |
wasCancelPressed()
True if the cancel button was used to close the editor.
|
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 java.util.Hashtable<java.lang.String,HierarchyPropertyParser> m_ObjectNames
protected GenericObjectEditor.GOEPanel m_EditorComponent
protected boolean m_CancelWasPressed
protected boolean m_Enabled
protected static java.lang.String PROPERTY_FILE
protected static java.util.Properties EDITOR_PROPERTIES
public static final java.lang.String GUIEDITORS_PROPERTY_FILE
protected GenericObjectEditor.GOETreeNode m_treeNodeOfCurrentObject
protected PropertyPanel m_ObjectPropertyPanel
protected boolean m_canChangeClassInDialog
protected GenericObjectEditorHistory m_History
protected static boolean m_EditorsRegistered
protected static boolean m_ShowGlobalInfoToolTip
protected Capabilities m_CapabilitiesFilter
public GenericObjectEditor()
public GenericObjectEditor(boolean canChangeClassInDialog)
canChangeClassInDialog - whether the user can change the classpublic static void setShowGlobalInfoToolTips(boolean show)
public boolean getShowGlobalInfoToolTips()
public static void determineClasses()
public static void registerEditors()
public static void registerEditor(java.lang.String name,
java.lang.String value)
public void setCanChangeClassInDialog(boolean value)
value - if true then the user can change the classpublic boolean getCanChangeClassInDialog()
public java.lang.Object getBackup()
protected static java.lang.String getRootFromClass(java.lang.String clsname,
java.lang.String separator)
null if it doesn't contain the separator.clsname - the full classnameseparator - the separatorpublic static java.util.Hashtable<java.lang.String,java.lang.String> sortClassesByRoot(java.lang.String classes)
classes - the classnames to work onprotected java.util.Hashtable<java.lang.String,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 boolean wasCancelPressed()
public void setValue(java.lang.Object o)
setValue in interface java.beans.PropertyEditoro - 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.PropertyEditorpublic java.lang.String getJavaInitializationString()
getJavaInitializationString in interface java.beans.PropertyEditorpublic boolean isPaintable()
isPaintable in interface java.beans.PropertyEditorpublic void paintValue(java.awt.Graphics gfx,
java.awt.Rectangle box)
paintValue in interface java.beans.PropertyEditorgfx - the graphics context to usebox - the area we are allowed to paint intopublic java.lang.String getAsText()
getAsText in interface java.beans.PropertyEditorpublic void setAsText(java.lang.String text)
setAsText in interface java.beans.PropertyEditortext - the text valuejava.lang.IllegalArgumentException - as we don't support getting/setting values
as text.public java.lang.String[] getTags()
getTags in interface java.beans.PropertyEditorpublic boolean supportsCustomEditor()
supportsCustomEditor in interface java.beans.PropertyEditorpublic java.awt.Component getCustomEditor()
getCustomEditor in interface java.beans.PropertyEditorpublic void addPropertyChangeListener(java.beans.PropertyChangeListener l)
addPropertyChangeListener in interface java.beans.PropertyEditorl - a value of type 'PropertyChangeListener'public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
removePropertyChangeListener in interface java.beans.PropertyEditorl - a value of type 'PropertyChangeListener'public javax.swing.JPanel getCustomPanel()
getCustomPanel in interface CustomPanelSupplierprotected javax.swing.JButton createChooseClassButton()
protected java.lang.String getClassnameFromPath(javax.swing.tree.TreePath path)
path - the path to generate the classname frompublic javax.swing.JPopupMenu getChooseClassPopupMenu()
protected javax.swing.JTree createTree(java.util.Hashtable<java.lang.String,HierarchyPropertyParser> hpps)
hpps - the hierarchy of objects to mirror in the treeprotected void addChildrenToTree(GenericObjectEditor.GOETreeNode 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 void setCapabilitiesFilter(Capabilities value)
value - the object to get the filter capabilities frompublic Capabilities getCapabilitiesFilter()
public void removeCapabilitiesFilter()
public static java.lang.Object makeCopy(java.lang.Object source)
throws java.lang.Exception
source - the object to copyjava.lang.Exception - if the copy failspublic GenericObjectEditorHistory getHistory()
public static void main(java.lang.String[] args)
args - may contain the class name of a Object to edit