Interface EditableComboBoxModel


  • public interface EditableComboBoxModel

    Definition of a specialized ListModel extension interface to be used by editable combo boxes.

    A ListModel per default contains a mapping from display objects (to be presented on the UI) to value objects (the application uses internally) and vice versa. This is fine as long the user can only select an element from a given set of available options.

    For an editable combo box situation is different. Here the user can enter arbitrary values, and therefore it is possible that there is no mapping from the display object to a value object in the model. This extended interface addresses this problem. It defines explicit methods for mapping from display objects to value objects or vice versa. These methods are called if no match in the current ListModel is found. A concrete implementation can then perform a transformation as it pleases.

    Version:
    $Id: $
    Author:
    Oliver Heger
    • Method Detail

      • toDisplay

        Object toDisplay​(Object value)
        Transforms a value object to a display object. This method is called at initialization of a component if the object obtained from the data model cannot be matched in the list model. An implementation is then responsible for mapping it to a correct object that can be displayed by the combo box.
        Parameters:
        value - the value object to be transformed
        Returns:
        the corresponding display object for this value
      • toValue

        Object toValue​(Object displ)
        Transforms a display object to a value object. This method is called when data entered by the user is to be written back into the data model and the selected object of the combo box cannot be matched in the list model. An implementation then has to create a value object to be passed to the data model.
        Parameters:
        displ - the display object to be transformed
        Returns:
        the corresponding value object