public class GenericObjectEditor extends Object implements 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).GenericPropertiesCreator
,
GenericPropertiesCreator.useDynamic()
,
GenericPropertiesCreator.CREATOR_FILE
,
ClassDiscovery
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 |
---|---|
static String |
GUIEDITORS_PROPERTY_FILE
the properties files containing the class/editor mappings.
|
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 |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds a PropertyChangeListener who will be notified of value changes.
|
String |
getAsText()
Returns null as we don't support getting/setting values as text.
|
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.
|
JPopupMenu |
getChooseClassPopupMenu()
Returns a popup menu that allows the user to change
the class of object.
|
static Vector<String> |
getClassnames(String property)
Returns the available classnames for a certain property in the
props file.
|
Component |
getCustomEditor()
Returns the array editing component.
|
JPanel |
getCustomPanel()
Gets the custom panel used for editing the object.
|
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.
|
String[] |
getTags()
Returns null as we don't support getting values as tags.
|
Object |
getValue()
Gets the current Object.
|
boolean |
isPaintable()
Returns true to indicate that we can paint a representation of the
Object.
|
static void |
main(String[] args)
Tests out the Object editor from the command line.
|
static Object |
makeCopy(Object source)
Makes a copy of an object using serialization.
|
void |
paintValue(Graphics gfx,
Rectangle box)
Paints a representation of the current Object.
|
static void |
registerEditors()
registers all the editors in Weka.
|
void |
removeCapabilitiesFilter()
Removes the current Capabilities filter.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes a PropertyChangeListener.
|
void |
setAsText(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(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.
|
void |
setValue(Object o)
Sets the current Object.
|
static Hashtable |
sortClassesByRoot(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.
|
public static final String GUIEDITORS_PROPERTY_FILE
public GenericObjectEditor()
public GenericObjectEditor(boolean canChangeClassInDialog)
canChangeClassInDialog
- whether the user can change the classpublic static void registerEditors()
public void setCanChangeClassInDialog(boolean value)
value
- if true then the user can change the classpublic boolean getCanChangeClassInDialog()
public Object getBackup()
public static Hashtable sortClassesByRoot(String classes)
classes
- the classnames to work onpublic void setEnabled(boolean newVal)
newVal
- a value of type 'boolean'public void setClassType(Class type)
type
- a value of type 'Class'public void setDefaultValue()
public void setValue(Object o)
setValue
in interface PropertyEditor
o
- an object that must be a Object.public Object getValue()
getValue
in interface PropertyEditor
public String getJavaInitializationString()
getJavaInitializationString
in interface PropertyEditor
public boolean isPaintable()
isPaintable
in interface PropertyEditor
public void paintValue(Graphics gfx, Rectangle box)
paintValue
in interface PropertyEditor
gfx
- the graphics context to usebox
- the area we are allowed to paint intopublic String getAsText()
getAsText
in interface PropertyEditor
public void setAsText(String text)
setAsText
in interface PropertyEditor
text
- the text valueIllegalArgumentException
- as we don't support
getting/setting values as text.public String[] getTags()
getTags
in interface PropertyEditor
public boolean supportsCustomEditor()
supportsCustomEditor
in interface PropertyEditor
public Component getCustomEditor()
getCustomEditor
in interface PropertyEditor
public void addPropertyChangeListener(PropertyChangeListener l)
addPropertyChangeListener
in interface PropertyEditor
l
- a value of type 'PropertyChangeListener'public void removePropertyChangeListener(PropertyChangeListener l)
removePropertyChangeListener
in interface PropertyEditor
l
- a value of type 'PropertyChangeListener'public JPanel getCustomPanel()
getCustomPanel
in interface CustomPanelSupplier
public JPopupMenu getChooseClassPopupMenu()
public void setCapabilitiesFilter(Capabilities value)
value
- the object to get the filter capabilities frompublic Capabilities getCapabilitiesFilter()
public void removeCapabilitiesFilter()
public static Object makeCopy(Object source) throws Exception
source
- the object to copyException
- if the copy failspublic static Vector<String> getClassnames(String property)
property
- the property to get the classnames forpublic static void main(String[] args)
args
- may contain the class name of a Object to editCopyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.