Class EditorClass<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 final class EditorClass<C,​D,​T>
    extends EditorDefault<T>
    An editor that wraps a single class. This is like an editorSubclass with only a single implementing class. Useful in EditorList where you need an editor that can create instances of the class it edits.
    Author:
    Hylke van der Schaaf
    • Constructor Detail

      • EditorClass

        public EditorClass()
      • EditorClass

        public EditorClass​(C context,
                           D edtCtx,
                           Class<T> clazz)
        Parameters:
        context - The Object that provides context at runtime.
        edtCtx - The Object that provides context while editing.
        clazz - The class to wrap.
      • EditorClass

        public EditorClass​(C context,
                           D edtCtx,
                           Class<T> clazz,
                           String label,
                           String description)
        Parameters:
        context - The Object that provides context at runtime.
        edtCtx - The Object that provides context while editing.
        clazz - The class to wrap.
        label - The label to use when showing this editor in a GUI.
        description - The description of the editor.
    • 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)
      • setConfig

        public void setConfig​(com.google.gson.JsonElement classConfig)
        Description copied from interface: ConfigEditor
        Load the given configuration into this editor.
        Parameters:
        classConfig - the configuration to load into this editor.
      • 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.
      • 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.
      • initClass

        public void initClass()
        Set the name of the class selected in this editor.
      • setClassConfig

        public void setClassConfig​(com.google.gson.JsonElement classConfig)
        Set the configuration of the selected class.
        Parameters:
        classConfig - the configuration of the selected class.
      • getClassConfig

        public com.google.gson.JsonElement getClassConfig()
      • 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.
      • setProfile

        public void setProfile​(String profile)
        Description copied from interface: ConfigEditor
        Sets the currently active profile.
        Parameters:
        profile - the currently active profile.