Package adams.gui.goe

Class GenericObjectEditor

    • Field Detail

      • LOGGER

        protected static Logger LOGGER
        for logging.
      • m_Object

        protected Object m_Object
        The object being configured.
      • m_Backup

        protected Object m_Backup
        Holds a copy of the current object that can be reverted to if the user decides to cancel.
      • m_DefaultValue

        protected Object m_DefaultValue
        the default value.
      • m_DefaultValueDetermined

        protected Boolean m_DefaultValueDetermined
        whether a default value has been determined.
      • m_ClassType

        protected Class m_ClassType
        The Class of objects being edited.
      • m_ObjectNames

        protected List<String> m_ObjectNames
        The model containing the list of names to select from.
      • m_Enabled

        protected boolean m_Enabled
        True if the GUI component is needed.
      • m_CustomPanel

        protected JPanel m_CustomPanel
        the custom panel provided by this editor.
      • m_CustomPanelChooseButton

        protected BaseButton m_CustomPanelChooseButton
        the button for choosing a different class in the custom panel.
      • m_ObjectPropertyPanel

        protected PropertyPanel m_ObjectPropertyPanel
        The property panel created for the objects.
      • m_canChangeClassInDialog

        protected boolean m_canChangeClassInDialog
        whether the class can be changed.
      • m_MinimumChars

        protected int m_MinimumChars
        the minimum number of characters before triggering search events.
      • m_ProposedClasses

        protected Class[] m_ProposedClasses
        the proposed classes.
      • m_UserMode

        protected UserMode m_UserMode
        the user mode to use.
    • Constructor Detail

      • GenericObjectEditor

        public GenericObjectEditor()
        Default constructor.
      • GenericObjectEditor

        public GenericObjectEditor​(boolean canChangeClassInDialog)
        Constructor that allows specifying whether it is possible to change the class within the editor dialog.
        Parameters:
        canChangeClassInDialog - whether the user can change the class
    • Method Detail

      • setCanChangeClassInDialog

        public void setCanChangeClassInDialog​(boolean value)
        Sets whether the user can change the class in the dialog.
        Parameters:
        value - if true then the user can change the class
      • getCanChangeClassInDialog

        public boolean getCanChangeClassInDialog()
        Returns whether the user can change the class in the dialog.
        Returns:
        true if the user can change the class
      • setReadOnly

        public void setReadOnly​(boolean value)
        Sets whether the dialog is read-only.
        Parameters:
        value - if true then the dialog is read-only
      • isReadOnly

        public boolean isReadOnly()
        Returns whether the dialog is read-only.
        Returns:
        true if the dialog is read-only
      • setFilter

        public void setFilter​(AbstractItemFilter value)
        Sets the filter to use for filtering the display.
        Parameters:
        value - the filter, null if to disable filtering
      • getFilter

        public AbstractItemFilter getFilter()
        Returns the current filter.
        Returns:
        the filter, null if none set
      • getBackup

        public Object getBackup()
        Returns the backup object (may be null if there is no backup.
        Returns:
        the backup object
      • getClasses

        protected List<String> getClasses()
        Called when the class of object being edited changes.
        Returns:
        the vector containing all the (sorted) classnames
      • updateObjectNames

        protected void updateObjectNames()
        Updates the list of selectable object names, adding any new names to the list.
      • setEnabled

        public void setEnabled​(boolean newVal)
        Sets whether the editor is "enabled", meaning that the current values will be painted.
        Parameters:
        newVal - a value of type 'boolean'
      • setClassType

        public void setClassType​(Class type)
        Sets the class of values that can be edited.
        Parameters:
        type - a value of type 'Class'
      • getClassType

        public Class getClassType()
        Returns the currently set class.
        Returns:
        the current class
      • determineDefaultValue

        protected Object determineDefaultValue()
        Determines the default value.
        Returns:
        the default value, null if none found or not possible to instantiate
      • checkClassType

        protected boolean checkClassType​(Object obj)
        Checks and, if possible, sets the class type for the given object. If a class type is determined successfully, m_canChangeClassInDialog is enabled as well.

        It is assumed that a missing class type is due to the fact that the GOE is called from another framework which doesn't know that setClassType(Class) needs to called in order to make it work properly.
        Parameters:
        obj - the object to (potentially) set the class type for
      • setDefaultValue

        public void setDefaultValue()
        Sets the current object to be the default, taken as the first item in the chooser.
      • setValue

        public void setValue​(Object o)
        Sets the current Object. If the Object is in the Object chooser, this becomes the selected item (and added to the chooser if necessary).
        Specified by:
        setValue in interface PropertyEditor
        Parameters:
        o - an object that must be a Object.
      • setObject

        protected void setObject​(Object obj)
        Sets the current Object.
        Parameters:
        obj - a value of type 'Object'
      • getValue

        public Object getValue()
        Gets the current Object.
        Specified by:
        getValue in interface PropertyEditor
        Returns:
        the current Object
      • setUserMode

        public void setUserMode​(UserMode value)
        Sets the user mode to use for displaying the properties.
        Specified by:
        setUserMode in interface UserModeSupporter
        Parameters:
        value - the mode
      • getUserMode

        public UserMode getUserMode()
        Returns the user mode to use for displaying the properties.
        Specified by:
        getUserMode in interface UserModeSupporter
        Returns:
        the mode
      • getJavaInitializationString

        public 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.
        Specified by:
        getJavaInitializationString in interface PropertyEditor
        Returns:
        the java source code initialisation string
      • isPaintable

        public boolean isPaintable()
        Returns true to indicate that we can paint a representation of the Object.
        Specified by:
        isPaintable in interface PropertyEditor
        Returns:
        always true
      • paintValue

        public void paintValue​(Graphics gfx,
                               Rectangle box)
        Paints a representation of the current Object.
        Specified by:
        paintValue in interface PropertyEditor
        Parameters:
        gfx - the graphics context to use
        box - the area we are allowed to paint into
      • getAsText

        public String getAsText()
        Returns null as we don't support getting/setting values as text.
        Specified by:
        getAsText in interface PropertyEditor
        Returns:
        always null
      • setAsText

        public void setAsText​(String text)
        Returns null as we don't support getting/setting values as text.
        Specified by:
        setAsText in interface PropertyEditor
        Parameters:
        text - the text value
        Throws:
        IllegalArgumentException - as we don't support getting/setting values as text.
      • getTags

        public String[] getTags()
        Returns null as we don't support getting values as tags.
        Specified by:
        getTags in interface PropertyEditor
        Returns:
        always null
      • supportsCustomEditor

        public boolean supportsCustomEditor()
        Returns true because we do support a custom editor.
        Specified by:
        supportsCustomEditor in interface PropertyEditor
        Returns:
        always true
      • setMinimumChars

        public void setMinimumChars​(int value)
        Sets the minimum number of characters that the user needs to enter before triggering a search event.
        Parameters:
        value - the minimum number of characters (>= 1)
      • getMinimumChars

        public int getMinimumChars()
        Returns the minimum number of characters that the user needs to enter before triggering a search event.
        Returns:
        the minimum number of characters (>= 1)
      • createChooseClassButton

        protected BaseButton createChooseClassButton()
        Creates a button that when clicked will enable the user to change the class of the object being edited.
        Returns:
        the choose button
      • getChooseClassPopupMenu

        public BasePopupMenu getChooseClassPopupMenu()
        Returns a popup menu that allows the user to change the class of object.
        Returns:
        a JPopupMenu that when shown will let the user choose the class
      • classSelected

        protected void classSelected​(String className)
        Called when the user selects an class type to change to.
        Parameters:
        className - the name of the class that was selected
      • setProposedClasses

        public void setProposedClasses​(Object[] value)
        Sets the proposed classes based on the provided objects. This call needs to happen before calling setValue(Object).
        Parameters:
        value - the proposed objects
        See Also:
        setProposedClasses(Class[])
      • setProposedClasses

        public void setProposedClasses​(Class[] value)
        Sets the proposed classes. This call needs to happen before calling setValue(Object).
        Parameters:
        value - the proposed classes
      • getProposedClasses

        public Class[] getProposedClasses()
        Returns the proposed classes.
        Returns:
        the proposed classes
      • firePropertyChange

        public void firePropertyChange()
        Fires a property change event.
        See Also:
        m_Support
      • setPostProcessObjectHandler

        public void setPostProcessObjectHandler​(GenericObjectEditor.PostProcessObjectHandler value)
        Sets the handler for post-processing objects after they have been selected but before updating the UI.
        Parameters:
        value - the handler, null to remove
      • getPostProcessObjectHandler

        public GenericObjectEditor.PostProcessObjectHandler getPostProcessObjectHandler()
        Returns the handler for post-processing objects after they have been selected but before updating the UI.
        Returns:
        the handler, null if none set
      • setUpdateSize

        public void setUpdateSize​(boolean value)
        Sets whether to update the size.
        Parameters:
        value - true if to update
      • getUpdateSize

        public boolean getUpdateSize()
        Returns whether to update the size.
        Returns:
        true if to update
      • setButtonsVisible

        public void setButtonsVisible​(boolean value)
        Sets whether to display the buttons.
        Parameters:
        value - true if to display
      • getButtonsVisible

        public boolean getButtonsVisible()
        Returns whether the buttons are visible.
        Returns:
        true if displayed
      • log

        public void log​(Level level,
                        String msg)
        For logging messages.
        Parameters:
        level - the logging level
        msg - the message
      • log

        public void log​(Level level,
                        String msg,
                        Throwable t)
        For logging messages.
        Parameters:
        level - the logging level
        msg - the message
        t - the optional exception (if one occurred), can be null
      • clearLogMessage

        public void clearLogMessage()
        Removes the message and hides the panel.
      • copyLogMessage

        public void copyLogMessage()
        Copies the message to the clipboard.
      • hasLogMessage

        public boolean hasLogMessage()
        Returns whether a message is currently being displayed.
        Returns:
        true if message displayed
      • getLogMessage

        public String getLogMessage()
        Returns the current log message.
        Returns:
        the log message, null if none displayed