Class ComboboxGUIVariable
- java.lang.Object
-
- net.ssehub.easy.producer.ui.confModel.GUIVariable
-
- net.ssehub.easy.producer.ui.confModel.ComboboxGUIVariable
-
- All Implemented Interfaces:
java.lang.Comparable<GUIVariable>,IGUIConfigurableElement
class ComboboxGUIVariable extends GUIVariable
GUI representation ofIDecisionVariables which can be configured with a combo box (bounded range).- Author:
- El-Sharkawy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classComboboxGUIVariable.ComboItemElements of this combo box.
-
Field Summary
Fields Modifier and Type Field Description private IDatatypetypeprivate ComboboxGUIVariable.ComboItem[]values
-
Constructor Summary
Constructors Constructor Description ComboboxGUIVariable(IDecisionVariable variable, org.eclipse.swt.widgets.Composite parent, IDatatype type, ComboboxGUIVariable.ComboItem[] values, IGUIConfigurableElement confParent)Sole constructor for this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String[]createItems()Creates the items to be displayed in the resulting combobox.org.eclipse.jface.viewers.CellEditorgetCellEditor(org.eclipse.swt.widgets.Composite parent)Returns aCellEditorfor a table.GUIEditorgetEditor()Returns the (non-cell) editor for this variable.java.lang.ObjectgetValue()Returns the value of the givenIDecisionVariableso that it can be used as return value for theEditingSupport.getValue(Object)method.protected ValuegetValueAssignment(java.lang.Object value)Converts the given object into aValue.java.lang.StringgetValueText()Returns a string representation of the current value.private booleanisEqual(java.lang.Object currentValue, ComboboxGUIVariable.ComboItem possibleItem)Compares the current value of theIDecisionVariablewith an element of the possible value from the combo box.(package private) java.lang.String[]refreshContents()Refreshes the contents of this combobox variable.private java.lang.ObjecttoObjectValue(Value value)-
Methods inherited from class net.ssehub.easy.producer.ui.confModel.GUIVariable
addErrorMessage, compareTo, extend, freeze, getAssignmentState, getComment, getComposite, getConfiguration, getErrorMessages, getHistory, getName, getNestedDepth, getNestedElement, getNestedElementsCount, getNullLabel, getParent, getTooltip, getTopLevelParent, getType, getVariable, hasErrors, hasNullValue, hasValue, isAnnotated, isEditable, isExpandable, isExtendable, isFreezable, isFrozen, isTopLevelDeclaration, remove, removeErrorMessages, replace, replaceValue, setEmptyValue, setNULLValue, setValue, setVariable, toString, unfreeze
-
-
-
-
Field Detail
-
values
private ComboboxGUIVariable.ComboItem[] values
-
type
private IDatatype type
-
-
Constructor Detail
-
ComboboxGUIVariable
ComboboxGUIVariable(IDecisionVariable variable, org.eclipse.swt.widgets.Composite parent, IDatatype type, ComboboxGUIVariable.ComboItem[] values, IGUIConfigurableElement confParent)
Sole constructor for this class.- Parameters:
variable- TheIDecisionVariablerepresented by this GUIVariableparent- The controlling composite, needed for the creation of CellEditorstype- The type of this GUIVairable, cannot be set by this constructor since RefernceTypes need a special consideration.values- The list of possible values for this GUIVariable.confParent- The parent holding this variable. Can be theGUIConfigurationif and only if this variable is a top level variable stored inside the configuration.
-
-
Method Detail
-
createItems
private java.lang.String[] createItems()
Creates the items to be displayed in the resulting combobox.- Returns:
- the items
-
getCellEditor
public org.eclipse.jface.viewers.CellEditor getCellEditor(org.eclipse.swt.widgets.Composite parent)
Description copied from class:GUIVariableReturns aCellEditorfor a table.- Specified by:
getCellEditorin classGUIVariable- Parameters:
parent- The GUI component where thisGUIVariableand, thus, its editor are displayed.- Returns:
CellEditorto configure the enclosedIDecisionVariable
-
getEditor
public GUIEditor getEditor()
Description copied from class:GUIVariableReturns the (non-cell) editor for this variable. The editor shall be ready to use, i.e., properly initialized.- Specified by:
getEditorin classGUIVariable- Returns:
- the editor, may be null if the variable shall not be displayed / being edited
-
getValueText
public java.lang.String getValueText()
Description copied from class:GUIVariableReturns a string representation of the current value. This is used when no cursor is inside the cell (if the user is not editing the variable).- Specified by:
getValueTextin classGUIVariable- Returns:
- A string representation of the current value or null.
-
getValueAssignment
protected Value getValueAssignment(java.lang.Object value) throws ValueDoesNotMatchTypeException
Description copied from class:GUIVariableConverts the given object into aValue.- Specified by:
getValueAssignmentin classGUIVariable- Parameters:
value- An object given by the Eclipse GUI.- Returns:
- A
Valuerepresentation of the object, maybe null. - Throws:
ValueDoesNotMatchTypeException- in case ofvaluecannot be converted to the related data type of the wrappedIDecisionVariable.
-
getValue
public java.lang.Object getValue()
Description copied from class:GUIVariableReturns the value of the givenIDecisionVariableso that it can be used as return value for theEditingSupport.getValue(Object)method.- Specified by:
getValuein classGUIVariable- Returns:
- A value as needed by the Eclipse UI.
-
isEqual
private boolean isEqual(java.lang.Object currentValue, ComboboxGUIVariable.ComboItem possibleItem)Compares the current value of theIDecisionVariablewith an element of the possible value from the combo box.- Parameters:
currentValue- The current value of theIDecisionVariable, maybe null.possibleItem- An item ofvalues.- Returns:
- true if the currentValue matches the given possibleItem
-
toObjectValue
private java.lang.Object toObjectValue(Value value)
- Parameters:
value- A value from which the value should be extracted from.- Returns:
- The
Value.getValue()or maybe null if no value is set.
-
refreshContents
java.lang.String[] refreshContents()
Refreshes the contents of this combobox variable.- Returns:
- the new combobox elements (may be null if nothing needs to be refreshed)
-
-