Class EditorSubclass<C,D,T>
- java.lang.Object
-
- de.fraunhofer.iosb.ilt.configurable.editor.EditorDefault<T>
-
- de.fraunhofer.iosb.ilt.configurable.editor.EditorSubclass<C,D,T>
-
- Type Parameters:
C- The class type that provides context at runtime.D- The class type that provides context while editing.T- The type of object returned by getValue.
- All Implemented Interfaces:
ConfigEditor<T>
public class EditorSubclass<C,D,T> extends EditorDefault<T>
An editor that offers a selection of a class that implements an interface or extends a class.- Author:
- Hylke van der Schaaf
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEditorSubclass.classItemstatic interfaceEditorSubclass.EdOptsSubclassstatic interfaceEditorSubclass.ExposeA simple annotation to use as requiredAnnotation.static interfaceEditorSubclass.NoFilterThe default requiredAnnotation that specifies that classes are not filtered.
-
Field Summary
Fields Modifier and Type Field Description Set<String>profilesEdit-
Fields inherited from interface de.fraunhofer.iosb.ilt.configurable.ConfigEditor
DEFAULT_PROFILE_NAME
-
-
Constructor Summary
Constructors Constructor Description EditorSubclass()EditorSubclass(C context, D edtCtx, Class<? extends T> iface, boolean merge, String nameField)EditorSubclass(C context, D edtCtx, Class<? extends T> iface, String label, String description)EditorSubclass(C context, D edtCtx, Class<? extends T> iface, String label, String description, boolean merge, String nameField)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanEdit()True if the component is editable in the current profile.EditorSubclass.classItemfindClassItem(String from)StringfindClassName(String from)List<Class<? extends Annotation>>getAllowList()An annotation that the presented classes must implement.com.google.gson.JsonElementgetClassConfig()Get the configuration of the selected class.ConfigEditorgetClassEditor()Map<String,EditorSubclass.classItem>getClassesByClassName()Map<String,EditorSubclass.classItem>getClassesByDisplayName()Map<String,EditorSubclass.classItem>getClassesByJsonName()com.google.gson.JsonElementgetConfig()Get the current (edited) state of the configuration.List<Class<? extends Annotation>>getDenyList()An annotation that the presented classes must not implement.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.Class<?>getIface()The interface or superclass that the selectable classes must implement/extend.StringgetJsonName()SchemaItemgetJsonSchema(RootSchema rootSchema)Get the JSON Schema for this editor, using the given rootSchema for shared $defs.StringgetNameField()The name of the json field that holds the name of the selected class.Class<? extends Annotation>getRequiredAnnotation()An annotation that the presented classes must implement.TgetValue()Get the value configured in the editor.voidinitFor(Field field)Initialise the editor for the given Field, using the Field name and type and any annotations present on the Field.booleanisMerge()The flag indicating the selected class name and the configuration of this class should be merged into one JSON object.booleanisRestrictedClasses()Are classes restricted to the ones found after applying the allow/deny lists, or is a user allowed to type in any class name.voidsetAllowList(List<Class<? extends Annotation>> allowList)An annotation that the presented classes must implement.voidsetClassConfig(com.google.gson.JsonElement classConfig)Set the configuration of the selected class.voidsetConfig(com.google.gson.JsonElement config)Load the given configuration into this editor.voidsetContexts(C context, D edtCtx)voidsetDenyList(List<Class<? extends Annotation>> denyList)An annotation that the presented classes must not implement.voidsetJsonName(String name)voidsetMerge(boolean merge)The flag indicating the selected class name and the configuration of this class should be merged into one JSON object.voidsetNameField(String nameField)The name of the json field that holds the name of the selected class.voidsetProfile(String profile)Sets the currently active profile.voidsetProfilesEdit(String csv)voidsetRequiredAnnotation(Class<? extends Annotation> requiredAnnotation)An annotation that the presented classes must implement.voidsetRestrictedClasses(boolean restrictedClasses)Are classes restricted to the ones found after applying the allow/deny lists, or is a user allowed to type in any class name.EditorSubclass<C,D,T>setSelectLabel(String selectLabel)voidsetValue(T value)Set the value in the editor.booleantestConfig(com.google.gson.JsonElement config)Helper method to test if the given config is a valid configuration for this EditorSubclass.-
Methods inherited from class de.fraunhofer.iosb.ilt.configurable.editor.EditorDefault
getDescription, getHelpButton, getHelpFrame, getLabel, 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, initFor, isDefault
-
-
-
-
Constructor Detail
-
EditorSubclass
public EditorSubclass()
-
EditorSubclass
public EditorSubclass(C context, D edtCtx, Class<? extends T> iface, boolean merge, String nameField)
-
EditorSubclass
public EditorSubclass(C context, D edtCtx, Class<? extends T> iface, String label, String description)
-
EditorSubclass
public EditorSubclass(C context, D edtCtx, Class<? extends T> iface, String label, String description, boolean merge, String nameField)
- Parameters:
iface- The interface or superclass the presented options should implement or extend.label- The label to use for this instance.description- The description describing this instance.merge- Should the class name be merged into the configuration.nameField- The name of the field to use for storing the className.context-edtCtx-
-
-
Method Detail
-
initFor
public void initFor(Field field)
Description copied from interface:ConfigEditorInitialise the editor for the given Field, using the Field name and type and any annotations present on the Field.- Specified by:
initForin interfaceConfigEditor<C>- Overrides:
initForin classEditorDefault<T>- Parameters:
field- the Field to initialise the editor for.
-
getConfig
public com.google.gson.JsonElement getConfig()
Description copied from interface:ConfigEditorGet the current (edited) state of the configuration.- Returns:
- The current (edited) configuration.
-
setConfig
public void setConfig(com.google.gson.JsonElement config)
Description copied from interface:ConfigEditorLoad the given configuration into this editor.- Parameters:
config- the configuration to load into this editor.
-
getClassConfig
public com.google.gson.JsonElement getClassConfig()
Get the configuration of the selected class.- Returns:
- the configuration of the selected class.
-
setClassConfig
public void setClassConfig(com.google.gson.JsonElement classConfig)
Set the configuration of the selected class.- Parameters:
classConfig- the configuration of the selected class.
-
getJsonSchema
public SchemaItem getJsonSchema(RootSchema rootSchema)
Description copied from interface:ConfigEditorGet the JSON Schema for this editor, using the given rootSchema for shared $defs.- 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.- 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.- Returns:
- A factory that can generate a JavaFX-based gui for this editor.
-
getJsonName
public String getJsonName()
-
getClassEditor
public ConfigEditor getClassEditor()
-
getClassesByClassName
public Map<String,EditorSubclass.classItem> getClassesByClassName()
-
getClassesByDisplayName
public Map<String,EditorSubclass.classItem> getClassesByDisplayName()
-
getClassesByJsonName
public Map<String,EditorSubclass.classItem> getClassesByJsonName()
-
setJsonName
public void setJsonName(String name)
-
findClassItem
public EditorSubclass.classItem findClassItem(String from)
-
getValue
public T getValue() throws ConfigurationException
Description copied from interface:ConfigEditorGet the value configured in the editor.- Returns:
- the value configured in the editor.
- Throws:
ConfigurationException- when the configuration can not be used to create a value.
-
setValue
public void setValue(T value)
Description copied from interface:ConfigEditorSet the value in the editor. Used for saving an (externally) updated configuration.- Parameters:
value- the value in the editor.
-
setSelectLabel
public EditorSubclass<C,D,T> setSelectLabel(String selectLabel)
-
testConfig
public boolean testConfig(com.google.gson.JsonElement config)
Helper method to test if the given config is a valid configuration for this EditorSubclass.- Parameters:
config- The configuration to test.- Returns:
- true if the configuration is valid.
-
getIface
public Class<?> getIface()
The interface or superclass that the selectable classes must implement/extend.- Returns:
- the interface class.
-
isMerge
public boolean isMerge()
The flag indicating the selected class name and the configuration of this class should be merged into one JSON object.- Returns:
- the merge setting
-
setMerge
public void setMerge(boolean merge)
The flag indicating the selected class name and the configuration of this class should be merged into one JSON object.- Parameters:
merge- the merge to set
-
getNameField
public String getNameField()
The name of the json field that holds the name of the selected class.- Returns:
- the nameField
-
setNameField
public void setNameField(String nameField)
The name of the json field that holds the name of the selected class.- Parameters:
nameField- the nameField to set
-
getRequiredAnnotation
public Class<? extends Annotation> getRequiredAnnotation()
An annotation that the presented classes must implement.- Returns:
- the required Annotation class
-
setRequiredAnnotation
public void setRequiredAnnotation(Class<? extends Annotation> requiredAnnotation)
An annotation that the presented classes must implement.- Parameters:
requiredAnnotation- the required Annotation class
-
getAllowList
public List<Class<? extends Annotation>> getAllowList()
An annotation that the presented classes must implement.- Returns:
- the allowList
-
setAllowList
public void setAllowList(List<Class<? extends Annotation>> allowList)
An annotation that the presented classes must implement.- Parameters:
allowList- the allowList to set
-
getDenyList
public List<Class<? extends Annotation>> getDenyList()
An annotation that the presented classes must not implement. These override the allowList and requiredAnnotation annotations.- Returns:
- the denyList
-
setDenyList
public void setDenyList(List<Class<? extends Annotation>> denyList)
An annotation that the presented classes must not implement. These override the allowList and requiredAnnotation annotations.- Parameters:
denyList- the denyList to set
-
isRestrictedClasses
public boolean isRestrictedClasses()
Are classes restricted to the ones found after applying the allow/deny lists, or is a user allowed to type in any class name.- Returns:
- the restrictedClasses
-
setRestrictedClasses
public void setRestrictedClasses(boolean restrictedClasses)
Are classes restricted to the ones found after applying the allow/deny lists, or is a user allowed to type in any class name.- Parameters:
restrictedClasses- the restrictedClasses to set
-
setProfilesEdit
public void setProfilesEdit(String csv)
-
setProfile
public void setProfile(String profile)
Description copied from interface:ConfigEditorSets the currently active profile.- Parameters:
profile- the currently active profile.
-
canEdit
public boolean canEdit()
Description copied from interface:ConfigEditorTrue if the component is editable in the current profile.- Returns:
- True if the component is editable in the current profile.
-
-