Class GUIVariable

    • Field Detail

      • tooltip

        private java.lang.String tooltip
      • errorMsg

        private java.lang.String errorMsg
      • composite

        private org.eclipse.swt.widgets.Composite composite
      • parent

        private GUIVariable parent
        The parent holding this variable. Can be null in case of top level elements.
    • Constructor Detail

      • GUIVariable

        protected GUIVariable​(IDecisionVariable variable,
                              GUIConfiguration parentConfig,
                              GUIVariable parent,
                              org.eclipse.swt.widgets.Composite composite)
        Sole constructor for this class.
        Parameters:
        variable - The IDecisionVariable represented by this GUIVariable
        parentConfig - The GUIConfiguration holding this GUIVariable
        parent - The parent GUIVariable holding this variable. Can be null if and only if this variable is a top level variable stored inside the configuration.
        composite - The controlling composite, needed for the creation of editors.
    • Method Detail

      • getComposite

        public final org.eclipse.swt.widgets.Composite getComposite()
        Returns the GUI component where this variable and its editors are displayed.
        Returns:
        The holding GUI component.
      • getParent

        public GUIVariable getParent()
        Returns the parent Variable holding this variable.
        Returns:
        The parent or null if this variable is a top level variable nested directly inside the configuration.
      • getTopLevelParent

        public GUIVariable getTopLevelParent()
        Returns the TopLevelParent Variable holding this variable or the variable itself if it is a top level variable.
        Returns:
        The TopLevelParent or this if this variable is a top level variable.
      • getNestedDepth

        public final int getNestedDepth()
        Returns how many parent IDecisionVariables exist for this variable.
        Returns:
        0 if the Configuration is the direct parent of this IDecisionVariable, otherwise a number greater than 0 indicating how many IDecisionVariables between the Configuration and this variable exist.
      • getCellEditor

        public abstract org.eclipse.jface.viewers.CellEditor getCellEditor​(org.eclipse.swt.widgets.Composite parent)
        Returns a CellEditor for a table.
        Parameters:
        parent - The GUI component where this GUIVariable and, thus, its editor are displayed.
        Returns:
        CellEditor to configure the enclosed IDecisionVariable
      • getEditor

        public abstract GUIEditor getEditor()
        Returns the (non-cell) editor for this variable. The editor shall be ready to use, i.e., properly initialized.
        Returns:
        the editor, may be null if the variable shall not be displayed / being edited
      • getValue

        public abstract java.lang.Object getValue()
        Returns the value of the given IDecisionVariable so that it can be used as return value for the EditingSupport.getValue(Object) method.
        Returns:
        A value as needed by the Eclipse UI.
      • setValue

        public void setValue​(java.lang.Object value)
        Sets the value of the wrapped IDecisionVariable.
        Parameters:
        value - The value to be set.
      • isEditable

        public boolean isEditable()
        Returns whether the wrapped IDecisionVariable can be edited.
        Returns:
        true if the variable can be edited, otherwise false.
      • getValueText

        public abstract java.lang.String getValueText()
        Returns 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).
        Returns:
        A string representation of the current value or null.
      • isExpandable

        public boolean isExpandable()
        Returns whether is variable can be expanded. Subclasses may override this method.
        Returns:
        true if this variable is expandable, otherwise false.
      • isExtendable

        public boolean isExtendable()
        Returns whether is variable can be extended (insert new empty values). Subclasses may override this method.
        Returns:
        true if this variable is extendable, otherwise false.
        See Also:
        extend()
      • extend

        public GUIVariable extend()
        Creates a new empty nested value/variable if supported. This method shall only be called by the set and sequence variables.
        Returns:
        the new empty variable or null if nothing happened, e.g., not isExtendable().
      • remove

        public void remove​(GUIVariable nestedVariable)
        Deletes a nested GUIVariable from this variable. This is only supported in ContainerGUIVariable class.
        Parameters:
        nestedVariable - The nested variable which shall be removed.
      • replace

        protected GUIVariable replace​(GUIVariable nestedVariable,
                                      Value value)
                               throws ConfigurationException
        Replaces a variable to reflect the new value (of a more or less specific type).
        Parameters:
        nestedVariable - the variable to be replaced (may affect top-level GUI variables)
        value - the new value carrying the type
        Returns:
        the new variable or nestedVariable
        Throws:
        ConfigurationException - in case that configuring the variable is not possible
      • replaceValue

        static void replaceValue​(IDecisionVariable decVar,
                                 Value value)
                          throws ConfigurationException
        Replaces the value in decVar by value.
        Parameters:
        decVar - the decision variable to change
        value - the new value
        Throws:
        ConfigurationException - in case that the original value cannot be cleared or the new value cannot be set
      • getComment

        public java.lang.String getComment()
        Returns the comment of the model element.
        Returns:
        Comment of this model element.
      • getNestedElementsCount

        public int getNestedElementsCount()
        Returns the number of nested elements. The return value should be 0 unless this IDecisionVariable is an AbstractExpandableGUIVariable.
        Returns:
        An integer value greater or equal to 0.
      • getNestedElement

        public GUIVariable getNestedElement​(int index)
        Returns a nested element specified by the given index.
        Parameters:
        index - The 0-based index of the nested element.
        Returns:
        The specified nestedvariable.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if this variable has no nested elements, is not expanded, or if the index is out of range (index < 0 || index >= size())
      • isFrozen

        public boolean isFrozen()
        Returns whether the current variable is already frozen.
        Returns:
        true if the variable is frozen, otherwise false.
      • isFreezable

        public final boolean isFreezable()
        Returns whether this variable can be frozen. In case of some nested variables it is not possible to freeze only the nested variable (e.g. a nested set variable).
        Returns:
        true if the nested variable can be frozen, otherwise false.
      • freeze

        public void freeze()
        Causes to freeze the current value.
      • freezeNested

        private void freezeNested​(GUIVariable nestedVar)
        Recursive part of freeze() to freeze also all nested elements. This is especially needed to store nested states for the undo function.
        Parameters:
        nestedVar - The nested element to freeze.
      • getTooltip

        public final java.lang.String getTooltip()
        Returns a tooltip which can be displayed inside the GUI.
        Returns:
        The datatype of the variable (must not be null).
      • hasErrors

        public final boolean hasErrors()
        Checks whether error messages are stored to this GUIVariable.
        Returns:
        true if this variable has stored error messages, false otherwise.
        See Also:
        getErrorMessages()
      • getErrorMessages

        public final java.lang.String getErrorMessages()
        Returns the stored error messages as a string.
        Returns:
        The error messages stored at this variable or null if no errors are stored.
        See Also:
        hasErrors()
      • removeErrorMessages

        final void removeErrorMessages()
        Removes the stored error message.
      • addErrorMessage

        final void addErrorMessage​(ContainableModelElement conflictingElement,
                                   java.lang.String userMessage)
        Adds a new error message to this GUIVariable.
        Parameters:
        conflictingElement - A ContainableModelElement which lead to the conflict and where getVariable() is included.
        userMessage - Optional: A error message which can be ready by a normal user. If null, the constraint will be used for displaying an error message.
      • compareTo

        public final int compareTo​(GUIVariable other)
        Specified by:
        compareTo in interface java.lang.Comparable<GUIVariable>
      • isTopLevelDeclaration

        boolean isTopLevelDeclaration()
        Check for TopLevelDeclaration. Can be null in case of top level elements.
        Returns:
        true if Element is a TopLevelDeclaration.
      • getHistory

        public GUIHistory getHistory()
        Getter for the history of the variable.
        Returns:
        The history of the variable.
      • hasValue

        public boolean hasValue()
        Checks whether the variable has a configured Value.
        Returns:
        true if the variable has a value, false otherwise.
      • hasNullValue

        public boolean hasNullValue()
        Checks whether the variable has a NullValue. Note: this method does not check whether the variable has a value.
        Returns:
        true if the variable has a NullValue, false otherwise.
      • setEmptyValue

        public void setEmptyValue()
        Removes the current Value.
      • setNULLValue

        public void setNULLValue()
        Sets a NullValue.
      • getNullLabel

        public java.lang.String getNullLabel()
        Returns the label for an IVML null value to be used in this GUI variable.
        Returns:
        the label for an IVML null value
      • getType

        protected IDatatype getType()
        Returns the type of the underlying IVML variable. In case of derived variables, it returns the innermost type.
        Returns:
        the type
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isAnnotated

        public boolean isAnnotated()
        Returns whether the variable has any annotations.
        Returns:
        true The variable has at least one annotation, false the variable has no annotations.