Class GUIConfiguration
- java.lang.Object
-
- net.ssehub.easy.producer.ui.confModel.GUIConfiguration
-
- All Implemented Interfaces:
IGUIConfigurableElement
public class GUIConfiguration extends java.lang.Object implements IGUIConfigurableElement
Wrapper class for this configuration as needed by the Eclipse GUI.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private Configurationconfigprivate java.util.List<IGUIConfigChangeListener>listenersprivate org.eclipse.swt.widgets.Compositeparentprivate GUIVariable[]topLevelVariables
-
Constructor Summary
Constructors Constructor Description GUIConfiguration(Configuration config, org.eclipse.swt.widgets.Composite parent)Sole constructor for this class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidchanged(GUIVariable var)Informs all listeners that this model contains unsaved data.voidclearErrorMessages()Removes the error messages of all storedGUIVariable.voidconfigurationChanged()Informs all listeners that this model contains unsaved data.private static voiddetermineVisible(AttributeAssignment block, java.util.Set<AbstractVariable> visible)Part ofdetermineVisible(IResolutionScope, Set, Set), which handlesAttributeAssignmentblocks recursively.private static voiddetermineVisible(IResolutionScope scope, java.util.Set<AbstractVariable> visible, java.util.Set<IResolutionScope> done)Determines the actually visible variables for the given resolutionscope.voidfreeze()Causes to freeze all values.ConfigurationgetConfig()Returns the variability configuration.GUIConfigurationgetConfiguration()Returns the relatedGUIConfigurationwhere this items belongs to.GUIVariable[]getElements()Returns the GUI Elements which should be shown inside the GUI as an array.intgetItemCount()Returns the number of items.voidinitMap()Resets the map and adds only all top level elements to this map.voidregister(IGUIConfigChangeListener listener)Adds a newIGUIConfigChangeListenerto this configuration.GUIVariablereplace(GUIVariable var, Value val)Replaces a variable to reflect the new value (of a more or less specific type).voidsetErrorMessages(Message[] warnings)Deletes all error messages for theGUIVariable's of this configuration and adds the given messages to variables affected variables.private java.util.Map<AbstractVariable,GUIVariable>toHashMap()Converts the nestedGUIVariable's into a temporaryMap.
-
-
-
Field Detail
-
config
private Configuration config
-
parent
private org.eclipse.swt.widgets.Composite parent
-
listeners
private java.util.List<IGUIConfigChangeListener> listeners
-
topLevelVariables
private GUIVariable[] topLevelVariables
-
-
Constructor Detail
-
GUIConfiguration
public GUIConfiguration(Configuration config, org.eclipse.swt.widgets.Composite parent)
Sole constructor for this class.- Parameters:
config- The origin configuration.parent- Should be a table for creating CellEditors
-
-
Method Detail
-
determineVisible
private static void determineVisible(IResolutionScope scope, java.util.Set<AbstractVariable> visible, java.util.Set<IResolutionScope> done)
Determines the actually visible variables for the given resolutionscope.- Parameters:
scope- the resolution scope (project or interface)visible- the visible variables (to be modified as a side effect)done- already processed scopes
-
determineVisible
private static void determineVisible(AttributeAssignment block, java.util.Set<AbstractVariable> visible)
Part ofdetermineVisible(IResolutionScope, Set, Set), which handlesAttributeAssignmentblocks recursively.- Parameters:
block- the current assignment blockvisible- the visible variables (to be modified as a side effect)
-
initMap
public void initMap()
Resets the map and adds only all top level elements to this map.
-
replace
public GUIVariable replace(GUIVariable var, Value val) throws ConfigurationException
Replaces a variable to reflect the new value (of a more or less specific type).- Parameters:
var- the variable to be replaced (may affect top-level GUI variables)val- the new value carrying the type- Returns:
- the new variable or
var - Throws:
ConfigurationException- in case that configuring the variable is not possibe
-
getElements
public GUIVariable[] getElements()
Returns the GUI Elements which should be shown inside the GUI as an array.- Returns:
- Not hidden configuration items.
-
changed
void changed(GUIVariable var)
Informs all listeners that this model contains unsaved data.- Parameters:
var- The variable which has been changed inside the GUI.
-
configurationChanged
public void configurationChanged()
Informs all listeners that this model contains unsaved data.
-
register
public void register(IGUIConfigChangeListener listener)
Adds a newIGUIConfigChangeListenerto this configuration.- Parameters:
listener- The listener, which shall be informed if any changes occur.
-
getItemCount
public int getItemCount()
Returns the number of items.- Returns:
- the number of items
-
getConfiguration
public GUIConfiguration getConfiguration()
Description copied from interface:IGUIConfigurableElementReturns the relatedGUIConfigurationwhere this items belongs to.- Specified by:
getConfigurationin interfaceIGUIConfigurableElement- Returns:
- The
GUIConfigurationwhich holds this element. In case this is theGUIConfigurationthis will be returned.
-
setErrorMessages
public void setErrorMessages(Message[] warnings)
Deletes all error messages for theGUIVariable's of this configuration and adds the given messages to variables affected variables.- Parameters:
warnings- A list of error/warning messages, produced by a reasoning step. warnings[i].getConflicts() must return a list containing only constraints.
-
clearErrorMessages
public void clearErrorMessages()
Removes the error messages of all storedGUIVariable. This method should be called after a reasoning was performed and no error was detected.
-
toHashMap
private java.util.Map<AbstractVariable,GUIVariable> toHashMap()
Converts the nestedGUIVariable's into a temporaryMap. This is used inside thesetErrorMessages(Message[])method to reduce the complexity (O(2n) instead of O(n^2)). This also removes all stored error messages.- Returns:
- A map in the form of (
AbstractVariable,GUIVariable).
-
freeze
public void freeze()
Causes to freeze all values.
-
getConfig
public Configuration getConfig()
Returns the variability configuration.- Returns:
- the variability configuration
-
-