Class AbstractComboBox<Value>

  • Type Parameters:
    Value - The kind of model elements, which shall be selected by this combo box.
    Direct Known Subclasses:
    InterfaceDropDown

    public abstract class AbstractComboBox<Value>
    extends java.lang.Object
    Super class for combox box working with information of a PLPInfo object.
    Author:
    Sascha El-Sharkawy
    • Field Detail

      • NO_SELECTION_VALUE

        public static final java.lang.String NO_SELECTION_VALUE
        See Also:
        Constant Field Values
      • values

        private java.util.List<Value> values
      • displayNames

        private java.lang.String[] displayNames
      • combobox

        private org.eclipse.swt.widgets.Combo combobox
      • lastSelection

        private Value lastSelection
      • informListeners

        private boolean informListeners
    • Constructor Detail

      • AbstractComboBox

        protected AbstractComboBox​(PLPInfo plp,
                                   org.eclipse.swt.widgets.Composite parent)
        Default constructor for this class.
        Parameters:
        plp - The PLPInfo which will be configured by this combo box, will also be used for creating the displayed information.
        parent - The parent container holding this combo box
      • AbstractComboBox

        protected AbstractComboBox​(PLPInfo plp,
                                   org.eclipse.swt.widgets.Composite parent,
                                   AbstractComboBox.ComboBoxListener<Value>... initialListeners)
        Constructor for this class if listeners should already be called during start up.
        Parameters:
        plp - The PLPInfo which will be configured by this combo box, will also be used for creating the displayed information.
        parent - The parent container holding this combo box
        initialListeners - Listeners which should already be informed while this combo box is created. Useful if onInit() is overwritten
    • Method Detail

      • onInit

        protected void onInit()
        Method if something additional should be at the end of the constructor call.
      • update

        public void update()
        Updates its information.
        Recalculates the data displayed (and selectable) by this combo box.
      • select

        public void select​(int index)
        Selects the item at the given zero-relative index in the receiver's list. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.
        Parameters:
        index - the index of the item to select, based on 0.
      • size

        public int size()
        The number of elements which can be selected / are displayed by this combo box.
        Returns:
        A value greater or equal to 0.
      • addListener

        public void addListener​(AbstractComboBox.ComboBoxListener<Value> listener)
        Adds an action listener to this drop down menu.
        Parameters:
        listener - The listener which should react on state changes.
      • calculateValues

        protected abstract java.util.List<Value> calculateValues()
        Part of the individual sub class: Calculates elements which may be selected by this combo box.
        Returns:
        A list of items which may be selected by this combo box, must not be null.
      • getDisplayName

        protected abstract java.lang.String getDisplayName​(Value element)
        Returns a String representing a selectable element.
        Parameters:
        element - a selectable element of this combo box.
        Returns:
        A name which is sufficient for the user.
      • equals

        protected abstract boolean equals​(Value value1,
                                          Value value2)
        Compare method to check whether the old selection is equal to one of the new elements calculated inside the update() method, e.q. return value1.equals(value2).
        Sometimes the exiting equals method are not sufficient for this combo box.
        Parameters:
        value1 - On value to compare with the other, maybe null.
        value2 - On value to compare with the other, maybe null.
        Returns:
        true if value1 and value2 are equal in the context of this combo box.
      • getProductLineProject

        public PLPInfo getProductLineProject()
        Returns the PLPInfo which will be configured by this combo box and which is used for data generation.
        Returns:
        The PLPInfo which will be configured by this combo box and which is used for data generation