Class AbstractComboBox<Value>
- java.lang.Object
-
- net.ssehub.easy.producer.ui.productline_editor.components.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.ObjectSuper class for combox box working with information of aPLPInfoobject.- Author:
- Sascha El-Sharkawy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractComboBox.ComboBoxListener<Value>A listener to react on state changes ofAbstractComboBox.
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.swt.widgets.Combocomboboxprivate java.lang.String[]displayNamesprivate booleaninformListenersprivate ValuelastSelectionprivate java.util.List<AbstractComboBox.ComboBoxListener<Value>>listenersstatic java.lang.StringNO_SELECTION_VALUEprivate PLPInfoplpprivate java.util.List<Value>values
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractComboBox(PLPInfo plp, org.eclipse.swt.widgets.Composite parent)Default constructor for this class.protectedAbstractComboBox(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.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(AbstractComboBox.ComboBoxListener<Value> listener)Adds an action listener to this drop down menu.protected abstract java.util.List<Value>calculateValues()Part of the individual sub class: Calculates elements which may be selected by this combo box.protected abstract booleanequals(Value value1, Value value2)Compare method to check whether the old selection is equal to one of the new elements calculated inside theupdate()method, e.q.protected abstract java.lang.StringgetDisplayName(Value element)Returns a String representing a selectable element.PLPInfogetProductLineProject()Returns thePLPInfowhich will be configured by this combo box and which is used for data generation.protected ProjectgetProject()Returns the main IVML varmodelProjectof the relatedgetProductLineProject().ValuegetSelectedValue()Returns the selected value or null ifNO_SELECTION_VALUEwas selected.protected voidonInit()Method if something additional should be at the end of the constructor call.voidselect(int index)Selects the item at the given zero-relative index in the receiver's list.intsize()The number of elements which can be selected / are displayed by this combo box.voidupdate()Updates its information.
-
-
-
Field Detail
-
NO_SELECTION_VALUE
public static final java.lang.String NO_SELECTION_VALUE
- See Also:
- Constant Field Values
-
plp
private PLPInfo plp
-
values
private java.util.List<Value> values
-
displayNames
private java.lang.String[] displayNames
-
listeners
private java.util.List<AbstractComboBox.ComboBoxListener<Value>> listeners
-
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- ThePLPInfowhich 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- ThePLPInfowhich will be configured by this combo box, will also be used for creating the displayed information.parent- The parent container holding this combo boxinitialListeners- Listeners which should already be informed while this combo box is created. Useful ifonInit()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.
-
getSelectedValue
public Value getSelectedValue()
Returns the selected value or null ifNO_SELECTION_VALUEwas selected.- Returns:
- The selected value or null if
NO_SELECTION_VALUEwas selected
-
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 theupdate()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 thePLPInfowhich will be configured by this combo box and which is used for data generation.- Returns:
- The
PLPInfowhich will be configured by this combo box and which is used for data generation
-
getProject
protected Project getProject()
Returns the main IVML varmodelProjectof the relatedgetProductLineProject().- Returns:
getProductLineProject().getProject().
-
-