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

      • AbstractEditorMap

        protected AbstractEditorMap()
      • AbstractEditorMap

        protected AbstractEditorMap​(int columns)
      • AbstractEditorMap

        protected AbstractEditorMap​(int columns,
                                    String label,
                                    String description)
    • 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)
      • setConfig

        public void setConfig​(com.google.gson.JsonElement config)
        Description copied from interface: ConfigEditor
        Load the given configuration into this editor.
        Specified by:
        setConfig in interface ConfigEditor<T>
        Parameters:
        config - 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.
        Specified by:
        getConfig in interface ConfigEditor<T>
        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.
        Specified by:
        getJsonSchema in interface ConfigEditor<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: ConfigEditor
        Get a factory that can generate a swing-based gui for this editor.
        Specified by:
        getGuiFactorySwing in interface ConfigEditor<T>
        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.
        Specified by:
        getGuiFactoryFx in interface ConfigEditor<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.
      • getRawValue

        public Set<String> getRawValue()
      • 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.
      • getProfile

        public String getProfile()
      • setProfile

        public void setProfile​(String profile)
        Description copied from interface: ConfigEditor
        Sets the currently active profile.
        Specified by:
        setProfile in interface ConfigEditor<T>
        Parameters:
        profile - the currently active profile.
      • setProfilesEdit

        public void setProfilesEdit​(String csv)
      • canEdit

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