Class 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
    • Field Detail

      • profilesEdit

        public Set<String> profilesEdit
    • 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: ConfigEditor
        Initialise the editor for the given Field, using the Field name and type and any annotations present on the Field.
        Specified by:
        initFor in interface ConfigEditor<C>
        Overrides:
        initFor in class EditorDefault<T>
        Parameters:
        field - the Field to initialise the editor for.
      • setContexts

        public final void setContexts​(C context,
                                      D edtCtx)
      • getConfig

        public com.google.gson.JsonElement getConfig()
        Description copied from interface: ConfigEditor
        Get 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: ConfigEditor
        Load 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: ConfigEditor
        Get 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: ConfigEditor
        Get 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: ConfigEditor
        Get 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()
      • setJsonName

        public void setJsonName​(String name)
      • findClassName

        public String findClassName​(String from)
      • getValue

        public T getValue()
                   throws ConfigurationException
        Description copied from interface: ConfigEditor
        Get 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: ConfigEditor
        Set the value in the editor. Used for saving an (externally) updated configuration.
        Parameters:
        value - the value in the editor.
      • 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: ConfigEditor
        Sets the currently active profile.
        Parameters:
        profile - the currently active profile.
      • canEdit

        public boolean canEdit()
        Description copied from interface: ConfigEditor
        True if the component is editable in the current profile.
        Returns:
        True if the component is editable in the current profile.