Class AbstractEditorMap<T,V>
- java.lang.Object
-
- de.fraunhofer.iosb.ilt.configurable.editor.EditorDefault<T>
-
- de.fraunhofer.iosb.ilt.configurable.editor.AbstractEditorMap<T,V>
-
- Type Parameters:
T- The type of object returned by getValue.V- The type of object in the map.
- All Implemented Interfaces:
ConfigEditor<T>,Iterable<String>
- Direct Known Subclasses:
EditorMap
public abstract class AbstractEditorMap<T,V> extends EditorDefault<T> implements Iterable<String>
An editor for a list of editors, all of the same type.- Author:
- Hylke van der Schaaf
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractEditorMap.Item<V>
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,AbstractEditorMap.Item<V>>optionsAll optionsprotected Set<String>valueThe names of the selected options.-
Fields inherited from interface de.fraunhofer.iosb.ilt.configurable.ConfigEditor
DEFAULT_PROFILE_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEditorMap()protectedAbstractEditorMap(int columns)protectedAbstractEditorMap(int columns, String label, String description)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(String jsonName)voidaddOption(String name, ConfigEditor editor, boolean optional)Add an option (Field) to the Map.voidaddOption(String name, ConfigEditor editor, boolean optional, int width)Add an option (Field) to the Map.voidaddOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width)voidaddOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width, boolean merge)voidaddOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width, boolean merge, String profilesSave, String profilesGui)voidaddOption(String fieldName, String jsonName, ConfigEditor editor, ConfigurableField annotation)booleancanEdit()True if the component is editable in the current profile.voidfillComponent()intgetColumns()How many columns we want to have.com.google.gson.JsonElementgetConfig()Get the current (edited) state of the configuration.GuiFactoryFxgetGuiFactoryFx()Get a factory that can generate a JavaFX-based gui for this editor.GuiFactorySwinggetGuiFactorySwing()Get a factory that can generate a swing-based gui for this editor.SchemaItemgetJsonSchema(RootSchema rootSchema)Get the JSON Schema for this editor, using the given rootSchema for shared $defs.List<String>getOptionalOptions()The names of the optional options.Map<String,AbstractEditorMap.Item<V>>getOptions()StringgetProfile()Set<String>getRawValue()VgetValue(String name)booleanisOptionSet(String name)Checks if the given option is set.Iterator<String>iterator()voidremoveItem(String jsonName)voidsetConfig(com.google.gson.JsonElement config)Load the given configuration into this editor.voidsetContentsOn(Object target)For each of the keys in the map, tries set the value of the field on the target object.It first tries to set the field with the fieldName directly.voidsetProfile(String profile)Sets the currently active profile.voidsetProfilesEdit(String csv)-
Methods inherited from class de.fraunhofer.iosb.ilt.configurable.editor.EditorDefault
getDescription, getHelpButton, getHelpFrame, getLabel, initFor, popupDescription, setDescription, setLabel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.fraunhofer.iosb.ilt.configurable.ConfigEditor
getJsonRootSchema, getValue, initFor, isDefault, setValue
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
addOption
public void addOption(String name, ConfigEditor editor, boolean optional)
Add an option (Field) to the Map.- Parameters:
name- The name to use for the option in the JSON config.editor- The editor to use for editing the option.optional- Flag indicating the option is optional.
-
addOption
public void addOption(String name, ConfigEditor editor, boolean optional, int width)
Add an option (Field) to the Map.- Parameters:
name- The name to use for the option in the JSON config.editor- The editor to use for editing the option.optional- Flag indicating the option is optional.width- The number of columns the editor should take in the GUI.
-
addOption
public void addOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width)
-
addOption
public void addOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width, boolean merge)
-
addOption
public void addOption(String fieldName, String jsonName, ConfigEditor editor, boolean optional, int width, boolean merge, String profilesSave, String profilesGui)
-
addOption
public void addOption(String fieldName, String jsonName, ConfigEditor editor, ConfigurableField annotation)
-
setConfig
public void setConfig(com.google.gson.JsonElement config)
Description copied from interface:ConfigEditorLoad the given configuration into this editor.- Specified by:
setConfigin interfaceConfigEditor<T>- Parameters:
config- the configuration to load into this editor.
-
getConfig
public com.google.gson.JsonElement getConfig()
Description copied from interface:ConfigEditorGet the current (edited) state of the configuration.- Specified by:
getConfigin interfaceConfigEditor<T>- Returns:
- The current (edited) configuration.
-
getJsonSchema
public SchemaItem getJsonSchema(RootSchema rootSchema)
Description copied from interface:ConfigEditorGet the JSON Schema for this editor, using the given rootSchema for shared $defs.- Specified by:
getJsonSchemain interfaceConfigEditor<T>- Parameters:
rootSchema- the root schema to use for $defs. If null, the return value must be a root schema.- Returns:
- the schema for this editor.
-
getGuiFactorySwing
public GuiFactorySwing getGuiFactorySwing()
Description copied from interface:ConfigEditorGet a factory that can generate a swing-based gui for this editor.- Specified by:
getGuiFactorySwingin interfaceConfigEditor<T>- Returns:
- A factory that can generate a swing-based gui for this editor.
-
getGuiFactoryFx
public GuiFactoryFx getGuiFactoryFx()
Description copied from interface:ConfigEditorGet a factory that can generate a JavaFX-based gui for this editor.- Specified by:
getGuiFactoryFxin interfaceConfigEditor<T>- Returns:
- A factory that can generate a JavaFX-based gui for this editor.
-
fillComponent
public void fillComponent()
-
addItem
public void addItem(String jsonName)
-
removeItem
public void removeItem(String jsonName)
-
setContentsOn
public void setContentsOn(Object target) throws ConfigurationException
For each of the keys in the map, tries set the value of the field on the target object.It first tries to set the field with the fieldName directly. If that does not work, it tries to call the setter set{fieldName}(fieldValue) on the target.- Parameters:
target- The target to set the fields, or call the setters on.- Throws:
ConfigurationException- if any of the values could not be loaded.
-
getValue
public V getValue(String name) throws ConfigurationException
- Throws:
ConfigurationException
-
isOptionSet
public boolean isOptionSet(String name)
Checks if the given option is set.- Parameters:
name- The option to check.- Returns:
- true if the option is set, false otherwise.
-
getOptionalOptions
public final List<String> getOptionalOptions()
The names of the optional options.- Returns:
- the optionalOptions
-
getColumns
public final int getColumns()
How many columns we want to have. Defaults to 1.- Returns:
- How many columns we want to have.
-
getOptions
public Map<String,AbstractEditorMap.Item<V>> getOptions()
-
getProfile
public String getProfile()
-
setProfile
public void setProfile(String profile)
Description copied from interface:ConfigEditorSets the currently active profile.- Specified by:
setProfilein interfaceConfigEditor<T>- Parameters:
profile- the currently active profile.
-
setProfilesEdit
public void setProfilesEdit(String csv)
-
canEdit
public boolean canEdit()
Description copied from interface:ConfigEditorTrue if the component is editable in the current profile.- Specified by:
canEditin interfaceConfigEditor<T>- Returns:
- True if the component is editable in the current profile.
-
-